]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vrf: Use dst_dev_put() instead of using loopback device
authorIdo Schimmel <idosch@nvidia.com>
Thu, 26 Mar 2026 20:32:32 +0000 (22:32 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 28 Mar 2026 04:07:24 +0000 (21:07 -0700)
Use dst_dev_put() to clean up the device referenced by the dst entry
instead of partially open coding it. Internally, the helper uses the
blackhole device instead of the loopback device.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260326203233.1128554-3-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vrf.c

index 0952ab6a25712f6425b905d541176c3a3ec3d969..bfc9ea91ac20c2b9173ccab8ec17685232672a3e 100644 (file)
@@ -751,21 +751,13 @@ static struct sk_buff *vrf_ip6_out(struct net_device *vrf_dev,
 static void vrf_rt6_release(struct net_device *dev, struct net_vrf *vrf)
 {
        struct rt6_info *rt6 = rtnl_dereference(vrf->rt6);
-       struct net *net = dev_net(dev);
-       struct dst_entry *dst;
 
        RCU_INIT_POINTER(vrf->rt6, NULL);
        synchronize_rcu();
 
-       /* move dev in dst's to loopback so this VRF device can be deleted
-        * - based on dst_ifdown
-        */
        if (rt6) {
-               dst = &rt6->dst;
-               netdev_ref_replace(dst->dev, net->loopback_dev,
-                                  &dst->dev_tracker, GFP_KERNEL);
-               dst->dev = net->loopback_dev;
-               dst_release(dst);
+               dst_dev_put(&rt6->dst);
+               dst_release(&rt6->dst);
        }
 }
 
@@ -998,20 +990,12 @@ static struct sk_buff *vrf_l3_out(struct net_device *vrf_dev,
 static void vrf_rtable_release(struct net_device *dev, struct net_vrf *vrf)
 {
        struct rtable *rth = rtnl_dereference(vrf->rth);
-       struct net *net = dev_net(dev);
-       struct dst_entry *dst;
 
        RCU_INIT_POINTER(vrf->rth, NULL);
        synchronize_rcu();
 
-       /* move dev in dst's to loopback so this VRF device can be deleted
-        * - based on dst_ifdown
-        */
-       dst = &rth->dst;
-       netdev_ref_replace(dst->dev, net->loopback_dev,
-                          &dst->dev_tracker, GFP_KERNEL);
-       dst->dev = net->loopback_dev;
-       dst_release(dst);
+       dst_dev_put(&rth->dst);
+       dst_release(&rth->dst);
 }
 
 static int vrf_rtable_create(struct net_device *dev)