Skip to content

Commit e353ea9

Browse files
edumazetdavem330
authored andcommitted
rtnetlink: prepare nla_put_iflink() to run under RCU
We want to be able to run rtnl_fill_ifinfo() under RCU protection instead of RTNL in the future. This patch prepares dev_get_iflink() and nla_put_iflink() to run either with RTNL or RCU held. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5f6000a commit e353ea9

16 files changed

Lines changed: 20 additions & 20 deletions

File tree

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,10 +1272,10 @@ static int ipoib_get_iflink(const struct net_device *dev)
12721272

12731273
/* parent interface */
12741274
if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags))
1275-
return dev->ifindex;
1275+
return READ_ONCE(dev->ifindex);
12761276

12771277
/* child/vlan interface */
1278-
return priv->parent->ifindex;
1278+
return READ_ONCE(priv->parent->ifindex);
12791279
}
12801280

12811281
static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, u8 *daddr)

drivers/net/can/vxcan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static int vxcan_get_iflink(const struct net_device *dev)
119119

120120
rcu_read_lock();
121121
peer = rcu_dereference(priv->peer);
122-
iflink = peer ? peer->ifindex : 0;
122+
iflink = peer ? READ_ONCE(peer->ifindex) : 0;
123123
rcu_read_unlock();
124124

125125
return iflink;

drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int rmnet_vnd_get_iflink(const struct net_device *dev)
9898
{
9999
struct rmnet_priv *priv = netdev_priv(dev);
100100

101-
return priv->real_dev->ifindex;
101+
return READ_ONCE(priv->real_dev->ifindex);
102102
}
103103

104104
static int rmnet_vnd_init(struct net_device *dev)

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static int ipvlan_get_iflink(const struct net_device *dev)
349349
{
350350
struct ipvl_dev *ipvlan = netdev_priv(dev);
351351

352-
return ipvlan->phy_dev->ifindex;
352+
return READ_ONCE(ipvlan->phy_dev->ifindex);
353353
}
354354

355355
static const struct net_device_ops ipvlan_netdev_ops = {

drivers/net/macsec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3753,7 +3753,7 @@ static void macsec_get_stats64(struct net_device *dev,
37533753

37543754
static int macsec_get_iflink(const struct net_device *dev)
37553755
{
3756-
return macsec_priv(dev)->real_dev->ifindex;
3756+
return READ_ONCE(macsec_priv(dev)->real_dev->ifindex);
37573757
}
37583758

37593759
static const struct net_device_ops macsec_netdev_ops = {

drivers/net/macvlan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ static int macvlan_dev_get_iflink(const struct net_device *dev)
11581158
{
11591159
struct macvlan_dev *vlan = netdev_priv(dev);
11601160

1161-
return vlan->lowerdev->ifindex;
1161+
return READ_ONCE(vlan->lowerdev->ifindex);
11621162
}
11631163

11641164
static const struct ethtool_ops macvlan_ethtool_ops = {

drivers/net/netkit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static int netkit_get_iflink(const struct net_device *dev)
145145
rcu_read_lock();
146146
peer = rcu_dereference(nk->peer);
147147
if (peer)
148-
iflink = peer->ifindex;
148+
iflink = READ_ONCE(peer->ifindex);
149149
rcu_read_unlock();
150150
return iflink;
151151
}

drivers/net/veth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ static int veth_get_iflink(const struct net_device *dev)
14611461

14621462
rcu_read_lock();
14631463
peer = rcu_dereference(priv->peer);
1464-
iflink = peer ? peer->ifindex : 0;
1464+
iflink = peer ? READ_ONCE(peer->ifindex) : 0;
14651465
rcu_read_unlock();
14661466

14671467
return iflink;

drivers/net/wireless/virtual/virt_wifi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static int virt_wifi_net_device_get_iflink(const struct net_device *dev)
453453
{
454454
struct virt_wifi_netdev_priv *priv = netdev_priv(dev);
455455

456-
return priv->lowerdev->ifindex;
456+
return READ_ONCE(priv->lowerdev->ifindex);
457457
}
458458

459459
static const struct net_device_ops virt_wifi_ops = {

net/8021q/vlan_dev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,9 @@ static void vlan_dev_netpoll_cleanup(struct net_device *dev)
762762

763763
static int vlan_dev_get_iflink(const struct net_device *dev)
764764
{
765-
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
765+
const struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
766766

767-
return real_dev->ifindex;
767+
return READ_ONCE(real_dev->ifindex);
768768
}
769769

770770
static int vlan_dev_fill_forward_path(struct net_device_path_ctx *ctx,

0 commit comments

Comments
 (0)