/* when the ip_tunnel_info is availble, the tos used for lookup is
         * packet independent, so we can use the cache
         */
-       if (dst_cache && !skb->mark && (!tos || info)) {
+       if (!skb->mark && (!tos || info)) {
                use_cache = true;
                rt = dst_cache_get_ip4(dst_cache, saddr);
                if (rt)
                                          struct in6_addr *saddr,
                                          struct dst_cache *dst_cache)
 {
-       bool use_cache = false;
        struct dst_entry *ndst;
        struct flowi6 fl6;
        int err;
 
-       if (dst_cache && !skb->mark) {
-               use_cache = true;
+       if (!skb->mark) {
                ndst = dst_cache_get_ip6(dst_cache, saddr);
                if (ndst)
                        return ndst;
                return ERR_PTR(err);
 
        *saddr = fl6.saddr;
-       if (use_cache)
+       if (!skb->mark)
                dst_cache_set_ip6(dst_cache, ndst, saddr);
        return ndst;
 }
 static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
                           struct vxlan_rdst *rdst, bool did_rsc)
 {
+       struct dst_cache *dst_cache;
        struct ip_tunnel_info *info;
        struct vxlan_dev *vxlan = netdev_priv(dev);
        struct sock *sk;
                dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port;
                vni = rdst->remote_vni;
                dst = &rdst->remote_ip;
+               dst_cache = &rdst->dst_cache;
        } else {
                if (!info) {
                        WARN_ONCE(1, "%s: Missing encapsulation instructions\n",
                else
                        remote_ip.sin6.sin6_addr = info->key.u.ipv6.dst;
                dst = &remote_ip;
+               dst_cache = &info->dst_cache;
        }
 
        if (vxlan_addr_any(dst)) {
                rt = vxlan_get_route(vxlan, skb,
                                     rdst ? rdst->remote_ifindex : 0, tos,
                                     dst->sin.sin_addr.s_addr, &saddr,
-                                    rdst ? &rdst->dst_cache : NULL, info);
+                                    dst_cache, info);
                if (IS_ERR(rt)) {
                        netdev_dbg(dev, "no route to %pI4\n",
                                   &dst->sin.sin_addr.s_addr);
                ndst = vxlan6_get_route(vxlan, skb,
                                        rdst ? rdst->remote_ifindex : 0,
                                        &dst->sin6.sin6_addr, &saddr,
-                                       rdst ? &rdst->dst_cache : NULL);
+                                       dst_cache);
                if (IS_ERR(ndst)) {
                        netdev_dbg(dev, "no route to %pI6\n",
                                   &dst->sin6.sin6_addr);
 
        lwtstate_put(dst->lwtstate);
 
        if (dst->flags & DST_METADATA)
-               kfree(dst);
+               metadata_dst_free((struct metadata_dst *)dst);
        else
                kmem_cache_free(dst->ops->kmem_cachep, dst);
 
 }
 EXPORT_SYMBOL_GPL(metadata_dst_alloc);
 
+void metadata_dst_free(struct metadata_dst *md_dst)
+{
+#ifdef CONFIG_DST_CACHE
+       dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
+#endif
+       kfree(md_dst);
+}
+
 struct metadata_dst __percpu *metadata_dst_alloc_percpu(u8 optslen, gfp_t flags)
 {
        int cpu;