diff options
| author | David Ahern <dsa@cumulusnetworks.com> | 2016-10-17 22:15:44 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-10-18 11:44:58 -0400 |
| commit | 1a3f060c1a47dba4e12ac21ce62b57666b9c4e95 (patch) | |
| tree | e0293fad952087cce74a7d4badac11e3ce3ee4b6 /include/linux/netdevice.h | |
| parent | 790510d99f39cee7f275d001aa5024032ed9bb48 (diff) | |
net: Introduce new api for walking upper and lower devices
This patch introduces netdev_walk_all_upper_dev_rcu,
netdev_walk_all_lower_dev and netdev_walk_all_lower_dev_rcu. These
functions recursively walk the adj_list of devices to determine all upper
and lower devices.
The functions take a callback function that is invoked for each device
in the list. If the callback returns non-0, the walk is terminated and
the functions return that code back to callers.
v3
- simplified netdev_has_upper_dev_all_rcu and __netdev_has_upper_dev and
removed typecast as suggested by Stephen
v2
- fixed definition of netdev_next_lower_dev_rcu to mirror the upper_dev
version.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index bf341b65ca5e..a5902d995907 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -3778,6 +3778,14 @@ struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev, | |||
| 3778 | updev; \ | 3778 | updev; \ |
| 3779 | updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter))) | 3779 | updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter))) |
| 3780 | 3780 | ||
| 3781 | int netdev_walk_all_upper_dev_rcu(struct net_device *dev, | ||
| 3782 | int (*fn)(struct net_device *upper_dev, | ||
| 3783 | void *data), | ||
| 3784 | void *data); | ||
| 3785 | |||
| 3786 | bool netdev_has_upper_dev_all_rcu(struct net_device *dev, | ||
| 3787 | struct net_device *upper_dev); | ||
| 3788 | |||
| 3781 | void *netdev_lower_get_next_private(struct net_device *dev, | 3789 | void *netdev_lower_get_next_private(struct net_device *dev, |
| 3782 | struct list_head **iter); | 3790 | struct list_head **iter); |
| 3783 | void *netdev_lower_get_next_private_rcu(struct net_device *dev, | 3791 | void *netdev_lower_get_next_private_rcu(struct net_device *dev, |
| @@ -3821,6 +3829,15 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev, | |||
| 3821 | ldev; \ | 3829 | ldev; \ |
| 3822 | ldev = netdev_all_lower_get_next_rcu(dev, &(iter))) | 3830 | ldev = netdev_all_lower_get_next_rcu(dev, &(iter))) |
| 3823 | 3831 | ||
| 3832 | int netdev_walk_all_lower_dev(struct net_device *dev, | ||
| 3833 | int (*fn)(struct net_device *lower_dev, | ||
| 3834 | void *data), | ||
| 3835 | void *data); | ||
| 3836 | int netdev_walk_all_lower_dev_rcu(struct net_device *dev, | ||
| 3837 | int (*fn)(struct net_device *lower_dev, | ||
| 3838 | void *data), | ||
| 3839 | void *data); | ||
| 3840 | |||
| 3824 | void *netdev_adjacent_get_private(struct list_head *adj_list); | 3841 | void *netdev_adjacent_get_private(struct list_head *adj_list); |
| 3825 | void *netdev_lower_get_first_private_rcu(struct net_device *dev); | 3842 | void *netdev_lower_get_first_private_rcu(struct net_device *dev); |
| 3826 | struct net_device *netdev_master_upper_dev_get(struct net_device *dev); | 3843 | struct net_device *netdev_master_upper_dev_get(struct net_device *dev); |
