Skip to content

Commit ba0f780

Browse files
Eric Dumazetdavem330
Eric Dumazet
authored andcommittedApr 19, 2024
neighbour: no longer hold RTNL in neigh_dump_info()
neigh_dump_table() is already relying on RCU protection. pneigh_dump_table() is using its own protection (tbl->lock) Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7e4975f commit ba0f780

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎net/core/neighbour.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,6 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
27232723
if (filter->dev_idx || filter->master_idx)
27242724
flags |= NLM_F_DUMP_FILTERED;
27252725

2726-
rcu_read_lock();
27272726
nht = rcu_dereference(tbl->nht);
27282727

27292728
for (h = s_h; h < (1 << nht->hash_shift); h++) {
@@ -2747,7 +2746,6 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
27472746
}
27482747
}
27492748
out:
2750-
rcu_read_unlock();
27512749
cb->args[1] = h;
27522750
cb->args[2] = idx;
27532751
return err;
@@ -2881,8 +2879,9 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
28812879

28822880
s_t = cb->args[0];
28832881

2882+
rcu_read_lock();
28842883
for (t = 0; t < NEIGH_NR_TABLES; t++) {
2885-
tbl = rcu_dereference_rtnl(neigh_tables[t]);
2884+
tbl = rcu_dereference(neigh_tables[t]);
28862885

28872886
if (!tbl)
28882887
continue;
@@ -2898,6 +2897,7 @@ static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
28982897
if (err < 0)
28992898
break;
29002899
}
2900+
rcu_read_unlock();
29012901

29022902
cb->args[0] = t;
29032903
return err;
@@ -3894,7 +3894,8 @@ static int __init neigh_init(void)
38943894
{
38953895
rtnl_register(PF_UNSPEC, RTM_NEWNEIGH, neigh_add, NULL, 0);
38963896
rtnl_register(PF_UNSPEC, RTM_DELNEIGH, neigh_delete, NULL, 0);
3897-
rtnl_register(PF_UNSPEC, RTM_GETNEIGH, neigh_get, neigh_dump_info, 0);
3897+
rtnl_register(PF_UNSPEC, RTM_GETNEIGH, neigh_get, neigh_dump_info,
3898+
RTNL_FLAG_DUMP_UNLOCKED);
38983899

38993900
rtnl_register(PF_UNSPEC, RTM_GETNEIGHTBL, NULL, neightbl_dump_info,
39003901
0);

0 commit comments

Comments
 (0)