Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mpls: Pass net to mpls_dev_get().

We will replace RTNL with a per-netns mutex to protect dev->mpls_ptr.

Then, we will use rcu_dereference_protected() with the lockdep_is_held()
annotation, which requires net to access the per-netns mutex.

However, dev_net(dev) is not safe without RTNL.

Let's pass net to mpls_dev_get().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Link: https://patch.msgid.link/20251029173344.2934622-8-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
1fb462de ab061f33

+8 -6
+6 -5
net/mpls/af_mpls.c
··· 708 708 709 709 /* Ensure this is a supported device */ 710 710 err = -EINVAL; 711 - if (!mpls_dev_get(dev)) 711 + if (!mpls_dev_get(net, dev)) 712 712 goto errout_put; 713 713 714 714 if ((nh->nh_via_table == NEIGH_LINK_TABLE) && ··· 1288 1288 if (!dev) 1289 1289 goto errout; 1290 1290 1291 - mdev = mpls_dev_get(dev); 1291 + mdev = mpls_dev_get(net, dev); 1292 1292 if (!mdev) 1293 1293 goto errout; 1294 1294 ··· 1611 1611 void *ptr) 1612 1612 { 1613 1613 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 1614 + struct net *net = dev_net(dev); 1614 1615 struct mpls_dev *mdev; 1615 1616 unsigned int flags; 1616 1617 int err; ··· 1626 1625 goto out; 1627 1626 } 1628 1627 1629 - mdev = mpls_dev_get(dev); 1628 + mdev = mpls_dev_get(net, dev); 1630 1629 if (!mdev) 1631 1630 goto out; 1632 1631 ··· 1659 1658 if (err) 1660 1659 goto err; 1661 1660 1662 - mdev = mpls_dev_get(dev); 1661 + mdev = mpls_dev_get(net, dev); 1663 1662 if (mdev) { 1664 1663 mpls_dev_sysctl_unregister(dev, mdev); 1665 1664 RCU_INIT_POINTER(dev->mpls_ptr, NULL); ··· 1667 1666 } 1668 1667 break; 1669 1668 case NETDEV_CHANGENAME: 1670 - mdev = mpls_dev_get(dev); 1669 + mdev = mpls_dev_get(net, dev); 1671 1670 if (mdev) { 1672 1671 mpls_dev_sysctl_unregister(dev, mdev); 1673 1672 err = mpls_dev_sysctl_register(dev, mdev);
+2 -1
net/mpls/internal.h
··· 190 190 return rcu_dereference(dev->mpls_ptr); 191 191 } 192 192 193 - static inline struct mpls_dev *mpls_dev_get(const struct net_device *dev) 193 + static inline struct mpls_dev *mpls_dev_get(const struct net *net, 194 + const struct net_device *dev) 194 195 { 195 196 return rcu_dereference_rtnl(dev->mpls_ptr); 196 197 }