Commit 567c5e13 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

net: core: dev: Add extack argument to dev_change_flags()

In order to pass extack together with NETDEV_PRE_UP notifications, it's
necessary to route the extack to __dev_open() from diverse (possibly
indirect) callers. One prominent API through which the notification is
invoked is dev_change_flags().

Therefore extend dev_change_flags() with and extra extack argument and
update all users. Most of the calls end up just encoding NULL, but
several sites (VLAN, ipvlan, VRF, rtnetlink) do have extack available.

Since the function declaration line is changed anyway, name the other
function arguments to placate checkpatch.
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cf7686a0
...@@ -167,7 +167,7 @@ int ipoib_open(struct net_device *dev) ...@@ -167,7 +167,7 @@ int ipoib_open(struct net_device *dev)
if (flags & IFF_UP) if (flags & IFF_UP)
continue; continue;
dev_change_flags(cpriv->dev, flags | IFF_UP); dev_change_flags(cpriv->dev, flags | IFF_UP, NULL);
} }
up_read(&priv->vlan_rwsem); up_read(&priv->vlan_rwsem);
} }
...@@ -207,7 +207,7 @@ static int ipoib_stop(struct net_device *dev) ...@@ -207,7 +207,7 @@ static int ipoib_stop(struct net_device *dev)
if (!(flags & IFF_UP)) if (!(flags & IFF_UP))
continue; continue;
dev_change_flags(cpriv->dev, flags & ~IFF_UP); dev_change_flags(cpriv->dev, flags & ~IFF_UP, NULL);
} }
up_read(&priv->vlan_rwsem); up_read(&priv->vlan_rwsem);
} }
...@@ -1823,7 +1823,7 @@ static void ipoib_parent_unregister_pre(struct net_device *ndev) ...@@ -1823,7 +1823,7 @@ static void ipoib_parent_unregister_pre(struct net_device *ndev)
* running ensures the it will not add more work. * running ensures the it will not add more work.
*/ */
rtnl_lock(); rtnl_lock();
dev_change_flags(priv->dev, priv->dev->flags & ~IFF_UP); dev_change_flags(priv->dev, priv->dev->flags & ~IFF_UP, NULL);
rtnl_unlock(); rtnl_unlock();
/* ipoib_event() cannot be running once this returns */ /* ipoib_event() cannot be running once this returns */
......
...@@ -1993,7 +1993,7 @@ static void __netvsc_vf_setup(struct net_device *ndev, ...@@ -1993,7 +1993,7 @@ static void __netvsc_vf_setup(struct net_device *ndev,
"unable to change mtu to %u\n", ndev->mtu); "unable to change mtu to %u\n", ndev->mtu);
/* set multicast etc flags on VF */ /* set multicast etc flags on VF */
dev_change_flags(vf_netdev, ndev->flags | IFF_SLAVE); dev_change_flags(vf_netdev, ndev->flags | IFF_SLAVE, NULL);
/* sync address list from ndev to VF */ /* sync address list from ndev to VF */
netif_addr_lock_bh(ndev); netif_addr_lock_bh(ndev);
......
...@@ -85,10 +85,12 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, ...@@ -85,10 +85,12 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval,
flags = ipvlan->dev->flags; flags = ipvlan->dev->flags;
if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) { if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
err = dev_change_flags(ipvlan->dev, err = dev_change_flags(ipvlan->dev,
flags | IFF_NOARP); flags | IFF_NOARP,
extack);
} else { } else {
err = dev_change_flags(ipvlan->dev, err = dev_change_flags(ipvlan->dev,
flags & ~IFF_NOARP); flags & ~IFF_NOARP,
extack);
} }
if (unlikely(err)) if (unlikely(err))
goto fail; goto fail;
...@@ -117,9 +119,11 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, ...@@ -117,9 +119,11 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval,
flags = ipvlan->dev->flags; flags = ipvlan->dev->flags;
if (port->mode == IPVLAN_MODE_L3 || if (port->mode == IPVLAN_MODE_L3 ||
port->mode == IPVLAN_MODE_L3S) port->mode == IPVLAN_MODE_L3S)
dev_change_flags(ipvlan->dev, flags | IFF_NOARP); dev_change_flags(ipvlan->dev, flags | IFF_NOARP,
NULL);
else else
dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP); dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP,
NULL);
} }
return err; return err;
......
...@@ -756,9 +756,9 @@ static void cycle_netdev(struct net_device *dev, ...@@ -756,9 +756,9 @@ static void cycle_netdev(struct net_device *dev,
if (!netif_running(dev)) if (!netif_running(dev))
return; return;
ret = dev_change_flags(dev, flags & ~IFF_UP); ret = dev_change_flags(dev, flags & ~IFF_UP, extack);
if (ret >= 0) if (ret >= 0)
ret = dev_change_flags(dev, flags); ret = dev_change_flags(dev, flags, extack);
if (ret < 0) { if (ret < 0) {
netdev_err(dev, netdev_err(dev,
......
...@@ -3612,7 +3612,8 @@ int dev_ifconf(struct net *net, struct ifconf *, int); ...@@ -3612,7 +3612,8 @@ int dev_ifconf(struct net *net, struct ifconf *, int);
int dev_ethtool(struct net *net, struct ifreq *); int dev_ethtool(struct net *net, struct ifreq *);
unsigned int dev_get_flags(const struct net_device *); unsigned int dev_get_flags(const struct net_device *);
int __dev_change_flags(struct net_device *, unsigned int flags); int __dev_change_flags(struct net_device *, unsigned int flags);
int dev_change_flags(struct net_device *, unsigned int); int dev_change_flags(struct net_device *dev, unsigned int flags,
struct netlink_ext_ack *extack);
void __dev_notify_flags(struct net_device *, unsigned int old_flags, void __dev_notify_flags(struct net_device *, unsigned int old_flags,
unsigned int gchanges); unsigned int gchanges);
int dev_change_name(struct net_device *, const char *); int dev_change_name(struct net_device *, const char *);
......
...@@ -358,6 +358,7 @@ static int __vlan_device_event(struct net_device *dev, unsigned long event) ...@@ -358,6 +358,7 @@ static int __vlan_device_event(struct net_device *dev, unsigned long event)
static int vlan_device_event(struct notifier_block *unused, unsigned long event, static int vlan_device_event(struct notifier_block *unused, unsigned long event,
void *ptr) void *ptr)
{ {
struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct vlan_group *grp; struct vlan_group *grp;
struct vlan_info *vlan_info; struct vlan_info *vlan_info;
...@@ -460,7 +461,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, ...@@ -460,7 +461,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
vlan = vlan_dev_priv(vlandev); vlan = vlan_dev_priv(vlandev);
if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
dev_change_flags(vlandev, flgs | IFF_UP); dev_change_flags(vlandev, flgs | IFF_UP,
extack);
netif_stacked_transfer_operstate(dev, vlandev); netif_stacked_transfer_operstate(dev, vlandev);
} }
break; break;
......
...@@ -7595,11 +7595,13 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags, ...@@ -7595,11 +7595,13 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
* dev_change_flags - change device settings * dev_change_flags - change device settings
* @dev: device * @dev: device
* @flags: device state flags * @flags: device state flags
* @extack: netlink extended ack
* *
* Change settings on device based state flags. The flags are * Change settings on device based state flags. The flags are
* in the userspace exported format. * in the userspace exported format.
*/ */
int dev_change_flags(struct net_device *dev, unsigned int flags) int dev_change_flags(struct net_device *dev, unsigned int flags,
struct netlink_ext_ack *extack)
{ {
int ret; int ret;
unsigned int changes, old_flags = dev->flags, old_gflags = dev->gflags; unsigned int changes, old_flags = dev->flags, old_gflags = dev->gflags;
......
...@@ -234,7 +234,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) ...@@ -234,7 +234,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
switch (cmd) { switch (cmd) {
case SIOCSIFFLAGS: /* Set interface flags */ case SIOCSIFFLAGS: /* Set interface flags */
return dev_change_flags(dev, ifr->ifr_flags); return dev_change_flags(dev, ifr->ifr_flags, NULL);
case SIOCSIFMETRIC: /* Set the metric on the interface case SIOCSIFMETRIC: /* Set the metric on the interface
(currently unused) */ (currently unused) */
......
...@@ -337,7 +337,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec); ...@@ -337,7 +337,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec);
static int change_flags(struct net_device *dev, unsigned long new_flags) static int change_flags(struct net_device *dev, unsigned long new_flags)
{ {
return dev_change_flags(dev, (unsigned int)new_flags); return dev_change_flags(dev, (unsigned int)new_flags, NULL);
} }
static ssize_t flags_store(struct device *dev, struct device_attribute *attr, static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
......
...@@ -2489,7 +2489,8 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -2489,7 +2489,8 @@ static int do_setlink(const struct sk_buff *skb,
} }
if (ifm->ifi_flags || ifm->ifi_change) { if (ifm->ifi_flags || ifm->ifi_change) {
err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm)); err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm),
extack);
if (err < 0) if (err < 0)
goto errout; goto errout;
} }
......
...@@ -1100,7 +1100,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr) ...@@ -1100,7 +1100,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
inet_del_ifa(in_dev, ifap, 1); inet_del_ifa(in_dev, ifap, 1);
break; break;
} }
ret = dev_change_flags(dev, ifr->ifr_flags); ret = dev_change_flags(dev, ifr->ifr_flags, NULL);
break; break;
case SIOCSIFADDR: /* Set interface address (and family) */ case SIOCSIFADDR: /* Set interface address (and family) */
......
...@@ -220,7 +220,7 @@ static int __init ic_open_devs(void) ...@@ -220,7 +220,7 @@ static int __init ic_open_devs(void)
for_each_netdev(&init_net, dev) { for_each_netdev(&init_net, dev) {
if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev)) if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
continue; continue;
if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) if (dev_change_flags(dev, dev->flags | IFF_UP, NULL) < 0)
pr_err("IP-Config: Failed to open %s\n", dev->name); pr_err("IP-Config: Failed to open %s\n", dev->name);
} }
...@@ -238,7 +238,7 @@ static int __init ic_open_devs(void) ...@@ -238,7 +238,7 @@ static int __init ic_open_devs(void)
if (ic_proto_enabled && !able) if (ic_proto_enabled && !able)
continue; continue;
oflags = dev->flags; oflags = dev->flags;
if (dev_change_flags(dev, oflags | IFF_UP) < 0) { if (dev_change_flags(dev, oflags | IFF_UP, NULL) < 0) {
pr_err("IP-Config: Failed to open %s\n", pr_err("IP-Config: Failed to open %s\n",
dev->name); dev->name);
continue; continue;
...@@ -315,7 +315,7 @@ static void __init ic_close_devs(void) ...@@ -315,7 +315,7 @@ static void __init ic_close_devs(void)
dev = d->dev; dev = d->dev;
if (d != ic_dev && !netdev_uses_dsa(dev)) { if (d != ic_dev && !netdev_uses_dsa(dev)) {
pr_debug("IP-Config: Downing %s\n", dev->name); pr_debug("IP-Config: Downing %s\n", dev->name);
dev_change_flags(dev, d->flags); dev_change_flags(dev, d->flags, NULL);
} }
kfree(d); kfree(d);
} }
......
...@@ -93,7 +93,7 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms) ...@@ -93,7 +93,7 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev); return ERR_CAST(dev);
} }
err = dev_change_flags(dev, dev->flags | IFF_UP); err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
if (err < 0) { if (err < 0) {
rtnl_delete_link(dev); rtnl_delete_link(dev);
rtnl_unlock(); rtnl_unlock();
......
...@@ -68,7 +68,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms) ...@@ -68,7 +68,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev); return ERR_CAST(dev);
} }
err = dev_change_flags(dev, dev->flags | IFF_UP); err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
if (err < 0) { if (err < 0) {
rtnl_delete_link(dev); rtnl_delete_link(dev);
rtnl_unlock(); rtnl_unlock();
......
...@@ -131,7 +131,7 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms) ...@@ -131,7 +131,7 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
return ERR_CAST(dev); return ERR_CAST(dev);
} }
err = dev_change_flags(dev, dev->flags | IFF_UP); err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
if (err < 0) { if (err < 0) {
rtnl_delete_link(dev); rtnl_delete_link(dev);
rtnl_unlock(); rtnl_unlock();
......
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