Commit 51d0c047 authored by David Ahern's avatar David Ahern Committed by David S. Miller

net: Add extack to netdev_notifier_info

Add netlink_ext_ack to netdev_notifier_info to allow notifier
handlers to return errors to userspace.

Clean up the initialization in dev.c such that extack is easily
added in subsequent patches where relevant. Specifically, remove
the init call in call_netdevice_notifiers_info and have callers
initalize on stack when info is declared.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6621dd29
...@@ -2309,7 +2309,8 @@ int register_netdevice_notifier(struct notifier_block *nb); ...@@ -2309,7 +2309,8 @@ int register_netdevice_notifier(struct notifier_block *nb);
int unregister_netdevice_notifier(struct notifier_block *nb); int unregister_netdevice_notifier(struct notifier_block *nb);
struct netdev_notifier_info { struct netdev_notifier_info {
struct net_device *dev; struct net_device *dev;
struct netlink_ext_ack *extack;
}; };
struct netdev_notifier_change_info { struct netdev_notifier_change_info {
...@@ -2334,6 +2335,7 @@ static inline void netdev_notifier_info_init(struct netdev_notifier_info *info, ...@@ -2334,6 +2335,7 @@ static inline void netdev_notifier_info_init(struct netdev_notifier_info *info,
struct net_device *dev) struct net_device *dev)
{ {
info->dev = dev; info->dev = dev;
info->extack = NULL;
} }
static inline struct net_device * static inline struct net_device *
...@@ -2342,6 +2344,12 @@ netdev_notifier_info_to_dev(const struct netdev_notifier_info *info) ...@@ -2342,6 +2344,12 @@ netdev_notifier_info_to_dev(const struct netdev_notifier_info *info)
return info->dev; return info->dev;
} }
static inline struct netlink_ext_ack *
netdev_notifier_info_to_extack(const struct netdev_notifier_info *info)
{
return info->extack;
}
int call_netdevice_notifiers(unsigned long val, struct net_device *dev); int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
......
...@@ -163,7 +163,6 @@ static struct list_head offload_base __read_mostly; ...@@ -163,7 +163,6 @@ static struct list_head offload_base __read_mostly;
static int netif_rx_internal(struct sk_buff *skb); static int netif_rx_internal(struct sk_buff *skb);
static int call_netdevice_notifiers_info(unsigned long val, static int call_netdevice_notifiers_info(unsigned long val,
struct net_device *dev,
struct netdev_notifier_info *info); struct netdev_notifier_info *info);
static struct napi_struct *napi_by_id(unsigned int napi_id); static struct napi_struct *napi_by_id(unsigned int napi_id);
...@@ -1339,10 +1338,11 @@ EXPORT_SYMBOL(netdev_features_change); ...@@ -1339,10 +1338,11 @@ EXPORT_SYMBOL(netdev_features_change);
void netdev_state_change(struct net_device *dev) void netdev_state_change(struct net_device *dev)
{ {
if (dev->flags & IFF_UP) { if (dev->flags & IFF_UP) {
struct netdev_notifier_change_info change_info; struct netdev_notifier_change_info change_info = {
.info.dev = dev,
};
change_info.flags_changed = 0; call_netdevice_notifiers_info(NETDEV_CHANGE,
call_netdevice_notifiers_info(NETDEV_CHANGE, dev,
&change_info.info); &change_info.info);
rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL); rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL);
} }
...@@ -1563,9 +1563,10 @@ EXPORT_SYMBOL(dev_disable_lro); ...@@ -1563,9 +1563,10 @@ EXPORT_SYMBOL(dev_disable_lro);
static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val, static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val,
struct net_device *dev) struct net_device *dev)
{ {
struct netdev_notifier_info info; struct netdev_notifier_info info = {
.dev = dev,
};
netdev_notifier_info_init(&info, dev);
return nb->notifier_call(nb, val, &info); return nb->notifier_call(nb, val, &info);
} }
...@@ -1690,11 +1691,9 @@ EXPORT_SYMBOL(unregister_netdevice_notifier); ...@@ -1690,11 +1691,9 @@ EXPORT_SYMBOL(unregister_netdevice_notifier);
*/ */
static int call_netdevice_notifiers_info(unsigned long val, static int call_netdevice_notifiers_info(unsigned long val,
struct net_device *dev,
struct netdev_notifier_info *info) struct netdev_notifier_info *info)
{ {
ASSERT_RTNL(); ASSERT_RTNL();
netdev_notifier_info_init(info, dev);
return raw_notifier_call_chain(&netdev_chain, val, info); return raw_notifier_call_chain(&netdev_chain, val, info);
} }
...@@ -1709,9 +1708,11 @@ static int call_netdevice_notifiers_info(unsigned long val, ...@@ -1709,9 +1708,11 @@ static int call_netdevice_notifiers_info(unsigned long val,
int call_netdevice_notifiers(unsigned long val, struct net_device *dev) int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
{ {
struct netdev_notifier_info info; struct netdev_notifier_info info = {
.dev = dev,
};
return call_netdevice_notifiers_info(val, dev, &info); return call_netdevice_notifiers_info(val, &info);
} }
EXPORT_SYMBOL(call_netdevice_notifiers); EXPORT_SYMBOL(call_netdevice_notifiers);
...@@ -6278,7 +6279,15 @@ static int __netdev_upper_dev_link(struct net_device *dev, ...@@ -6278,7 +6279,15 @@ 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 *upper_priv, void *upper_info) void *upper_priv, void *upper_info)
{ {
struct netdev_notifier_changeupper_info changeupper_info; struct netdev_notifier_changeupper_info changeupper_info = {
.info = {
.dev = dev,
},
.upper_dev = upper_dev,
.master = master,
.linking = true,
.upper_info = upper_info,
};
int ret = 0; int ret = 0;
ASSERT_RTNL(); ASSERT_RTNL();
...@@ -6296,12 +6305,7 @@ static int __netdev_upper_dev_link(struct net_device *dev, ...@@ -6296,12 +6305,7 @@ 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; ret = call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER,
changeupper_info.master = master;
changeupper_info.linking = true;
changeupper_info.upper_info = upper_info;
ret = call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER, dev,
&changeupper_info.info); &changeupper_info.info);
ret = notifier_to_errno(ret); ret = notifier_to_errno(ret);
if (ret) if (ret)
...@@ -6312,7 +6316,7 @@ static int __netdev_upper_dev_link(struct net_device *dev, ...@@ -6312,7 +6316,7 @@ static int __netdev_upper_dev_link(struct net_device *dev,
if (ret) if (ret)
return ret; return ret;
ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev, ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
&changeupper_info.info); &changeupper_info.info);
ret = notifier_to_errno(ret); ret = notifier_to_errno(ret);
if (ret) if (ret)
...@@ -6376,20 +6380,24 @@ EXPORT_SYMBOL(netdev_master_upper_dev_link); ...@@ -6376,20 +6380,24 @@ EXPORT_SYMBOL(netdev_master_upper_dev_link);
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_notifier_changeupper_info changeupper_info = {
.info = {
.dev = dev,
},
.upper_dev = upper_dev,
.linking = false,
};
ASSERT_RTNL(); ASSERT_RTNL();
changeupper_info.upper_dev = upper_dev;
changeupper_info.master = netdev_master_upper_dev_get(dev) == upper_dev; changeupper_info.master = netdev_master_upper_dev_get(dev) == upper_dev;
changeupper_info.linking = false;
call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER, dev, call_netdevice_notifiers_info(NETDEV_PRECHANGEUPPER,
&changeupper_info.info); &changeupper_info.info);
__netdev_adjacent_dev_unlink_neighbour(dev, upper_dev); __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev, call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
&changeupper_info.info); &changeupper_info.info);
} }
EXPORT_SYMBOL(netdev_upper_dev_unlink); EXPORT_SYMBOL(netdev_upper_dev_unlink);
...@@ -6405,11 +6413,13 @@ EXPORT_SYMBOL(netdev_upper_dev_unlink); ...@@ -6405,11 +6413,13 @@ EXPORT_SYMBOL(netdev_upper_dev_unlink);
void netdev_bonding_info_change(struct net_device *dev, void netdev_bonding_info_change(struct net_device *dev,
struct netdev_bonding_info *bonding_info) struct netdev_bonding_info *bonding_info)
{ {
struct netdev_notifier_bonding_info info; struct netdev_notifier_bonding_info info = {
.info.dev = dev,
};
memcpy(&info.bonding_info, bonding_info, memcpy(&info.bonding_info, bonding_info,
sizeof(struct netdev_bonding_info)); sizeof(struct netdev_bonding_info));
call_netdevice_notifiers_info(NETDEV_BONDING_INFO, dev, call_netdevice_notifiers_info(NETDEV_BONDING_INFO,
&info.info); &info.info);
} }
EXPORT_SYMBOL(netdev_bonding_info_change); EXPORT_SYMBOL(netdev_bonding_info_change);
...@@ -6535,11 +6545,13 @@ EXPORT_SYMBOL(dev_get_nest_level); ...@@ -6535,11 +6545,13 @@ EXPORT_SYMBOL(dev_get_nest_level);
void netdev_lower_state_changed(struct net_device *lower_dev, void netdev_lower_state_changed(struct net_device *lower_dev,
void *lower_state_info) void *lower_state_info)
{ {
struct netdev_notifier_changelowerstate_info changelowerstate_info; struct netdev_notifier_changelowerstate_info changelowerstate_info = {
.info.dev = lower_dev,
};
ASSERT_RTNL(); ASSERT_RTNL();
changelowerstate_info.lower_state_info = lower_state_info; changelowerstate_info.lower_state_info = lower_state_info;
call_netdevice_notifiers_info(NETDEV_CHANGELOWERSTATE, lower_dev, call_netdevice_notifiers_info(NETDEV_CHANGELOWERSTATE,
&changelowerstate_info.info); &changelowerstate_info.info);
} }
EXPORT_SYMBOL(netdev_lower_state_changed); EXPORT_SYMBOL(netdev_lower_state_changed);
...@@ -6830,11 +6842,14 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags, ...@@ -6830,11 +6842,14 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
if (dev->flags & IFF_UP && if (dev->flags & IFF_UP &&
(changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) { (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) {
struct netdev_notifier_change_info change_info; struct netdev_notifier_change_info change_info = {
.info = {
change_info.flags_changed = changes; .dev = dev,
call_netdevice_notifiers_info(NETDEV_CHANGE, dev, },
&change_info.info); .flags_changed = changes,
};
call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment