net: core: dev: Add extack argument to dev_change_flags()
authorPetr Machata <petrm@mellanox.com>
Thu, 6 Dec 2018 17:05:42 +0000 (17:05 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Dec 2018 21:26:07 +0000 (13:26 -0800)
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: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
15 files changed:
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/ipvlan/ipvlan_main.c
drivers/net/vrf.c
include/linux/netdevice.h
net/8021q/vlan.c
net/core/dev.c
net/core/dev_ioctl.c
net/core/net-sysfs.c
net/core/rtnetlink.c
net/ipv4/devinet.c
net/ipv4/ipconfig.c
net/openvswitch/vport-geneve.c
net/openvswitch/vport-gre.c
net/openvswitch/vport-vxlan.c

index 8710214594d80521db211d4a2bac312685e4f2ed..6214d8c0d5468666c21f285381bd214b2690d032 100644 (file)
@@ -167,7 +167,7 @@ int ipoib_open(struct net_device *dev)
                        if (flags & IFF_UP)
                                continue;
 
-                       dev_change_flags(cpriv->dev, flags | IFF_UP);
+                       dev_change_flags(cpriv->dev, flags | IFF_UP, NULL);
                }
                up_read(&priv->vlan_rwsem);
        }
@@ -207,7 +207,7 @@ static int ipoib_stop(struct net_device *dev)
                        if (!(flags & IFF_UP))
                                continue;
 
-                       dev_change_flags(cpriv->dev, flags & ~IFF_UP);
+                       dev_change_flags(cpriv->dev, flags & ~IFF_UP, NULL);
                }
                up_read(&priv->vlan_rwsem);
        }
@@ -1823,7 +1823,7 @@ static void ipoib_parent_unregister_pre(struct net_device *ndev)
         * running ensures the it will not add more work.
         */
        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();
 
        /* ipoib_event() cannot be running once this returns */
index c65620adab522049514784200a5083f132dbc7d2..18b5584d63779f54306cb65341307c3bd00bf237 100644 (file)
@@ -1993,7 +1993,7 @@ static void __netvsc_vf_setup(struct net_device *ndev,
                            "unable to change mtu to %u\n", ndev->mtu);
 
        /* 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 */
        netif_addr_lock_bh(ndev);
index 14f1cbd3b96faf5876427a6189f5e28eac31556a..c3d3e458f541017e726cd7bf786cd34e5db41148 100644 (file)
@@ -85,10 +85,12 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval,
                        flags = ipvlan->dev->flags;
                        if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
                                err = dev_change_flags(ipvlan->dev,
-                                                      flags | IFF_NOARP);
+                                                      flags | IFF_NOARP,
+                                                      extack);
                        } else {
                                err = dev_change_flags(ipvlan->dev,
-                                                      flags & ~IFF_NOARP);
+                                                      flags & ~IFF_NOARP,
+                                                      extack);
                        }
                        if (unlikely(err))
                                goto fail;
@@ -117,9 +119,11 @@ fail:
                flags = ipvlan->dev->flags;
                if (port->mode == IPVLAN_MODE_L3 ||
                    port->mode == IPVLAN_MODE_L3S)
-                       dev_change_flags(ipvlan->dev, flags | IFF_NOARP);
+                       dev_change_flags(ipvlan->dev, flags | IFF_NOARP,
+                                        NULL);
                else
-                       dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP);
+                       dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP,
+                                        NULL);
        }
 
        return err;
index 1e9f2dc0de07a48513204bc3c49e04ec3b7f3397..95909e262ba4369fa853acf24c62bf271670d4ad 100644 (file)
@@ -756,9 +756,9 @@ static void cycle_netdev(struct net_device *dev,
        if (!netif_running(dev))
                return;
 
-       ret = dev_change_flags(dev, flags & ~IFF_UP);
+       ret = dev_change_flags(dev, flags & ~IFF_UP, extack);
        if (ret >= 0)
-               ret = dev_change_flags(dev, flags);
+               ret = dev_change_flags(dev, flags, extack);
 
        if (ret < 0) {
                netdev_err(dev,
index d79be3055f5f10dfafb1948e29248eb801db6b9a..18cf464450ee0f2f51379bfd42b7712e58cf8ae2 100644 (file)
@@ -3612,7 +3612,8 @@ int dev_ifconf(struct net *net, struct ifconf *, int);
 int dev_ethtool(struct net *net, struct ifreq *);
 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);
+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,
                        unsigned int gchanges);
 int dev_change_name(struct net_device *, const char *);
index aef1a977279c6cd402cf1388bac7926b1f6c756d..dc4411165e437a2f6e962d7466612eec9706631d 100644 (file)
@@ -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,
                             void *ptr)
 {
+       struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
        struct net_device *dev = netdev_notifier_info_to_dev(ptr);
        struct vlan_group *grp;
        struct vlan_info *vlan_info;
@@ -460,7 +461,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
 
                        vlan = vlan_dev_priv(vlandev);
                        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);
                }
                break;
index b801c1aafd709f9b627e06a4f333d04a0f35dbc8..8bba6f98b545eb497c2584706b53c68566959f6d 100644 (file)
@@ -7595,11 +7595,13 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
  *     dev_change_flags - change device settings
  *     @dev: device
  *     @flags: device state flags
+ *     @extack: netlink extended ack
  *
  *     Change settings on device based state flags. The flags are
  *     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;
        unsigned int changes, old_flags = dev->flags, old_gflags = dev->gflags;
index 90e8aa36881e1563fb6870384316a1d025979cdd..da273ec3cc571d09dc2998bb12b7f12c384e0120 100644 (file)
@@ -234,7 +234,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
 
        switch (cmd) {
        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
                                   (currently unused) */
index bd67c4d0fcfdf6522ce16143523169d506e09d82..ff9fd2bb4ce438119b6fac982aa47c626bd43d7d 100644 (file)
@@ -337,7 +337,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec);
 
 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,
index 98876cd1e36c2d8f366c8ff253a0cce14549758a..4c9e4e187600cc472c9e876b962b3d16eeff04f4 100644 (file)
@@ -2489,7 +2489,8 @@ static int do_setlink(const struct sk_buff *skb,
        }
 
        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)
                        goto errout;
        }
index a34602ae27dee2d3ff5d579172910c5f9f004292..5b9b6d497f7144428544c2f8a881bd6a29efe393 100644 (file)
@@ -1100,7 +1100,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
                                inet_del_ifa(in_dev, ifap, 1);
                        break;
                }
-               ret = dev_change_flags(dev, ifr->ifr_flags);
+               ret = dev_change_flags(dev, ifr->ifr_flags, NULL);
                break;
 
        case SIOCSIFADDR:       /* Set interface address (and family) */
index 88212615bf4ce75f5e840297b1be70f4e4e0b83b..55757764c38115f56a04d1f89e2dc57153ea3953 100644 (file)
@@ -220,7 +220,7 @@ static int __init ic_open_devs(void)
        for_each_netdev(&init_net, dev) {
                if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
                        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);
        }
 
@@ -238,7 +238,7 @@ static int __init ic_open_devs(void)
                        if (ic_proto_enabled && !able)
                                continue;
                        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",
                                       dev->name);
                                continue;
@@ -315,7 +315,7 @@ static void __init ic_close_devs(void)
                dev = d->dev;
                if (d != ic_dev && !netdev_uses_dsa(dev)) {
                        pr_debug("IP-Config: Downing %s\n", dev->name);
-                       dev_change_flags(dev, d->flags);
+                       dev_change_flags(dev, d->flags, NULL);
                }
                kfree(d);
        }
index 5aaf3babfc3fa0bf70b8a72ebd95c40962dd6ea2..acb6077b7478674f7356fca4aee5ad0b0e72e556 100644 (file)
@@ -93,7 +93,7 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms)
                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) {
                rtnl_delete_link(dev);
                rtnl_unlock();
index 0e72d95b0e8f1fcd2e6d1446fc0944b519c0500e..c38a62464b85a7b7163f1c6278285faf88162b50 100644 (file)
@@ -68,7 +68,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
                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) {
                rtnl_delete_link(dev);
                rtnl_unlock();
index 7e6301b2ec4d06abc605e5ddb48a686e3257e8f6..8f16f11f7ad3e004b39eba94d269fc0f67c96143 100644 (file)
@@ -131,7 +131,7 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
                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) {
                rtnl_delete_link(dev);
                rtnl_unlock();