Skip to content

Commit 32d5eaa

Browse files
q2venkuba-moo
authored andcommitted
neighbour: Drop read_lock_bh(&tbl->lock) in pneigh_dump_table().
Now pneigh_entry is guaranteed to be alive during the RCU critical section even without holding tbl->lock. Let's drop read_lock_bh(&tbl->lock) and use rcu_dereference() to iterate tbl->phash_buckets[] in pneigh_dump_table() Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ed6e380 commit 32d5eaa

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

net/core/neighbour.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,14 +2808,12 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
28082808
if (filter->dev_idx || filter->master_idx)
28092809
flags |= NLM_F_DUMP_FILTERED;
28102810

2811-
read_lock_bh(&tbl->lock);
2812-
28132811
for (h = s_h; h <= PNEIGH_HASHMASK; h++) {
28142812
if (h > s_h)
28152813
s_idx = 0;
2816-
for (n = rcu_dereference_protected(tbl->phash_buckets[h], 1), idx = 0;
2814+
for (n = rcu_dereference(tbl->phash_buckets[h]), idx = 0;
28172815
n;
2818-
n = rcu_dereference_protected(n->next, 1)) {
2816+
n = rcu_dereference(n->next)) {
28192817
if (idx < s_idx || pneigh_net(n) != net)
28202818
goto next;
28212819
if (neigh_ifindex_filtered(n->dev, filter->dev_idx) ||
@@ -2824,16 +2822,13 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
28242822
err = pneigh_fill_info(skb, n, NETLINK_CB(cb->skb).portid,
28252823
cb->nlh->nlmsg_seq,
28262824
RTM_NEWNEIGH, flags, tbl);
2827-
if (err < 0) {
2828-
read_unlock_bh(&tbl->lock);
2825+
if (err < 0)
28292826
goto out;
2830-
}
28312827
next:
28322828
idx++;
28332829
}
28342830
}
28352831

2836-
read_unlock_bh(&tbl->lock);
28372832
out:
28382833
cb->args[3] = h;
28392834
cb->args[4] = idx;

0 commit comments

Comments
 (0)