Skip to content

Commit 5249dec

Browse files
Veaceslav Falicodavem330
authored andcommitted
net: add RCU variant to search for netdev_adjacent link
Currently we have only the RTNL flavour, however we can traverse it while holding only RCU, so add the RCU search. Add an RCU variant that uses list_head * as an argument, so that it can be universally used afterwards. CC: "David S. Miller" <[email protected]> CC: Eric Dumazet <[email protected]> CC: Jiri Pirko <[email protected]> CC: Alexander Duyck <[email protected]> CC: Cong Wang <[email protected]> Signed-off-by: Veaceslav Falico <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2f268f1 commit 5249dec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/core/dev.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,6 +4380,19 @@ struct netdev_adjacent {
43804380
struct rcu_head rcu;
43814381
};
43824382

4383+
static struct netdev_adjacent *__netdev_find_adj_rcu(struct net_device *dev,
4384+
struct net_device *adj_dev,
4385+
struct list_head *adj_list)
4386+
{
4387+
struct netdev_adjacent *adj;
4388+
4389+
list_for_each_entry_rcu(adj, adj_list, list) {
4390+
if (adj->dev == adj_dev)
4391+
return adj;
4392+
}
4393+
return NULL;
4394+
}
4395+
43834396
static struct netdev_adjacent *__netdev_find_adj(struct net_device *dev,
43844397
struct net_device *adj_dev,
43854398
struct list_head *adj_list)

0 commit comments

Comments
 (0)