Skip to content

Commit

Permalink
net: Add info for NETDEV_CHANGEUPPER event
Browse files Browse the repository at this point in the history
Some consumers of NETDEV_CHANGEUPPER event would like to know which
upper device was linked/unlinked and what operation was carried.

Add information in the notifier info block for that purpose.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Matan Barak authored and Doug Ledford committed Aug 30, 2015
1 parent 399e6f9 commit 816dd19
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,20 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
netdev_features_t features);

enum netdev_changeupper_event {
NETDEV_CHANGEUPPER_LINK,
NETDEV_CHANGEUPPER_UNLINK,
};

struct netdev_changeupper_info {
struct netdev_notifier_info info; /* must be first */
enum netdev_changeupper_event event;
struct net_device *upper;
};

void netdev_changeupper_info_change(struct net_device *dev,
struct netdev_changeupper_info *info);

struct netdev_bonding_info {
ifslave slave;
ifbond master;
Expand Down
12 changes: 10 additions & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5302,6 +5302,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
void *private)
{
struct netdev_adjacent *i, *j, *to_i, *to_j;
struct netdev_changeupper_info changeupper_info;
int ret = 0;

ASSERT_RTNL();
Expand Down Expand Up @@ -5357,7 +5358,10 @@ static int __netdev_upper_dev_link(struct net_device *dev,
goto rollback_lower_mesh;
}

call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev);
changeupper_info.event = NETDEV_CHANGEUPPER_LINK;
changeupper_info.upper = upper_dev;
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
&changeupper_info.info);
return 0;

rollback_lower_mesh:
Expand Down Expand Up @@ -5453,6 +5457,7 @@ void netdev_upper_dev_unlink(struct net_device *dev,
struct net_device *upper_dev)
{
struct netdev_adjacent *i, *j;
struct netdev_changeupper_info changeupper_info;
ASSERT_RTNL();

__netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
Expand All @@ -5474,7 +5479,10 @@ void netdev_upper_dev_unlink(struct net_device *dev,
list_for_each_entry(i, &upper_dev->all_adj_list.upper, list)
__netdev_adjacent_dev_unlink(dev, i->dev);

call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev);
changeupper_info.event = NETDEV_CHANGEUPPER_UNLINK;
changeupper_info.upper = upper_dev;
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
&changeupper_info.info);
}
EXPORT_SYMBOL(netdev_upper_dev_unlink);

Expand Down

0 comments on commit 816dd19

Please sign in to comment.