diff options
author | Veaceslav Falico <vfalico@redhat.com> | 2013-08-28 17:25:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-29 16:19:42 -0400 |
commit | 48311f46853c0361f9fba7e0e6bb1652d633c049 (patch) | |
tree | 75d08bc2b59876668f50a293eae746755b2cc075 /net/core/dev.c | |
parent | 620f3186caa8124e0efaf329751cf51c5d55c731 (diff) |
net: add netdev_upper_get_next_dev_rcu(dev, iter)
This function returns the next dev in the dev->upper_dev_list after the
struct list_head **iter position, and updates *iter accordingly. Returns
NULL if there are no devices left.
Caller must hold RCU read lock.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
CC: Cong Wang <amwang@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 749925a040a4..6fbb0c90849b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4468,6 +4468,31 @@ struct net_device *netdev_master_upper_dev_get(struct net_device *dev) | |||
4468 | } | 4468 | } |
4469 | EXPORT_SYMBOL(netdev_master_upper_dev_get); | 4469 | EXPORT_SYMBOL(netdev_master_upper_dev_get); |
4470 | 4470 | ||
4471 | /* netdev_upper_get_next_dev_rcu - Get the next dev from upper list | ||
4472 | * @dev: device | ||
4473 | * @iter: list_head ** of the current position | ||
4474 | * | ||
4475 | * Gets the next device from the dev's upper list, starting from iter | ||
4476 | * position. The caller must hold RCU read lock. | ||
4477 | */ | ||
4478 | struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev, | ||
4479 | struct list_head **iter) | ||
4480 | { | ||
4481 | struct netdev_adjacent *upper; | ||
4482 | |||
4483 | WARN_ON_ONCE(!rcu_read_lock_held()); | ||
4484 | |||
4485 | upper = list_entry_rcu((*iter)->next, struct netdev_adjacent, list); | ||
4486 | |||
4487 | if (&upper->list == &dev->upper_dev_list) | ||
4488 | return NULL; | ||
4489 | |||
4490 | *iter = &upper->list; | ||
4491 | |||
4492 | return upper->dev; | ||
4493 | } | ||
4494 | EXPORT_SYMBOL(netdev_upper_get_next_dev_rcu); | ||
4495 | |||
4471 | /** | 4496 | /** |
4472 | * netdev_master_upper_dev_get_rcu - Get master upper device | 4497 | * netdev_master_upper_dev_get_rcu - Get master upper device |
4473 | * @dev: device | 4498 | * @dev: device |