mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 14:31:46 +00:00
net: introduce change upper device notifier change info
Add info that is passed along with NETDEV_CHANGEUPPER event. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
547c890cfd
commit
0e4ead9d7b
2 changed files with 21 additions and 2 deletions
|
@ -2127,6 +2127,13 @@ struct netdev_notifier_change_info {
|
||||||
unsigned int flags_changed;
|
unsigned int flags_changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct netdev_notifier_changeupper_info {
|
||||||
|
struct netdev_notifier_info info; /* must be first */
|
||||||
|
struct net_device *upper_dev; /* new upper dev */
|
||||||
|
bool master; /* is upper dev master */
|
||||||
|
bool linking; /* is the nofication for link or unlink */
|
||||||
|
};
|
||||||
|
|
||||||
static inline void netdev_notifier_info_init(struct netdev_notifier_info *info,
|
static inline void netdev_notifier_info_init(struct netdev_notifier_info *info,
|
||||||
struct net_device *dev)
|
struct net_device *dev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5311,6 +5311,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
|
||||||
struct net_device *upper_dev, bool master,
|
struct net_device *upper_dev, bool master,
|
||||||
void *private)
|
void *private)
|
||||||
{
|
{
|
||||||
|
struct netdev_notifier_changeupper_info changeupper_info;
|
||||||
struct netdev_adjacent *i, *j, *to_i, *to_j;
|
struct netdev_adjacent *i, *j, *to_i, *to_j;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -5329,6 +5330,10 @@ static int __netdev_upper_dev_link(struct net_device *dev,
|
||||||
if (master && netdev_master_upper_dev_get(dev))
|
if (master && netdev_master_upper_dev_get(dev))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
|
changeupper_info.upper_dev = upper_dev;
|
||||||
|
changeupper_info.master = master;
|
||||||
|
changeupper_info.linking = true;
|
||||||
|
|
||||||
ret = __netdev_adjacent_dev_link_neighbour(dev, upper_dev, private,
|
ret = __netdev_adjacent_dev_link_neighbour(dev, upper_dev, private,
|
||||||
master);
|
master);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -5367,7 +5372,8 @@ static int __netdev_upper_dev_link(struct net_device *dev,
|
||||||
goto rollback_lower_mesh;
|
goto rollback_lower_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev);
|
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
|
||||||
|
&changeupper_info.info);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rollback_lower_mesh:
|
rollback_lower_mesh:
|
||||||
|
@ -5462,9 +5468,14 @@ EXPORT_SYMBOL(netdev_master_upper_dev_link_private);
|
||||||
void netdev_upper_dev_unlink(struct net_device *dev,
|
void netdev_upper_dev_unlink(struct net_device *dev,
|
||||||
struct net_device *upper_dev)
|
struct net_device *upper_dev)
|
||||||
{
|
{
|
||||||
|
struct netdev_notifier_changeupper_info changeupper_info;
|
||||||
struct netdev_adjacent *i, *j;
|
struct netdev_adjacent *i, *j;
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
|
||||||
|
changeupper_info.upper_dev = upper_dev;
|
||||||
|
changeupper_info.master = netdev_master_upper_dev_get(dev) == upper_dev;
|
||||||
|
changeupper_info.linking = false;
|
||||||
|
|
||||||
__netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
|
__netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
|
||||||
|
|
||||||
/* Here is the tricky part. We must remove all dev's lower
|
/* Here is the tricky part. We must remove all dev's lower
|
||||||
|
@ -5484,7 +5495,8 @@ void netdev_upper_dev_unlink(struct net_device *dev,
|
||||||
list_for_each_entry(i, &upper_dev->all_adj_list.upper, list)
|
list_for_each_entry(i, &upper_dev->all_adj_list.upper, list)
|
||||||
__netdev_adjacent_dev_unlink(dev, i->dev);
|
__netdev_adjacent_dev_unlink(dev, i->dev);
|
||||||
|
|
||||||
call_netdevice_notifiers(NETDEV_CHANGEUPPER, dev);
|
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
|
||||||
|
&changeupper_info.info);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(netdev_upper_dev_unlink);
|
EXPORT_SYMBOL(netdev_upper_dev_unlink);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue