Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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>

authored by

Petr Machata and committed by
David S. Miller
567c5e13 cf7686a0

+33 -23
+3 -3
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 167 167 if (flags & IFF_UP) 168 168 continue; 169 169 170 - dev_change_flags(cpriv->dev, flags | IFF_UP); 170 + dev_change_flags(cpriv->dev, flags | IFF_UP, NULL); 171 171 } 172 172 up_read(&priv->vlan_rwsem); 173 173 } ··· 207 207 if (!(flags & IFF_UP)) 208 208 continue; 209 209 210 - dev_change_flags(cpriv->dev, flags & ~IFF_UP); 210 + dev_change_flags(cpriv->dev, flags & ~IFF_UP, NULL); 211 211 } 212 212 up_read(&priv->vlan_rwsem); 213 213 } ··· 1823 1823 * running ensures the it will not add more work. 1824 1824 */ 1825 1825 rtnl_lock(); 1826 - dev_change_flags(priv->dev, priv->dev->flags & ~IFF_UP); 1826 + dev_change_flags(priv->dev, priv->dev->flags & ~IFF_UP, NULL); 1827 1827 rtnl_unlock(); 1828 1828 1829 1829 /* ipoib_event() cannot be running once this returns */
+1 -1
drivers/net/hyperv/netvsc_drv.c
··· 1993 1993 "unable to change mtu to %u\n", ndev->mtu); 1994 1994 1995 1995 /* set multicast etc flags on VF */ 1996 - dev_change_flags(vf_netdev, ndev->flags | IFF_SLAVE); 1996 + dev_change_flags(vf_netdev, ndev->flags | IFF_SLAVE, NULL); 1997 1997 1998 1998 /* sync address list from ndev to VF */ 1999 1999 netif_addr_lock_bh(ndev);
+8 -4
drivers/net/ipvlan/ipvlan_main.c
··· 85 85 flags = ipvlan->dev->flags; 86 86 if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) { 87 87 err = dev_change_flags(ipvlan->dev, 88 - flags | IFF_NOARP); 88 + flags | IFF_NOARP, 89 + extack); 89 90 } else { 90 91 err = dev_change_flags(ipvlan->dev, 91 - flags & ~IFF_NOARP); 92 + flags & ~IFF_NOARP, 93 + extack); 92 94 } 93 95 if (unlikely(err)) 94 96 goto fail; ··· 119 117 flags = ipvlan->dev->flags; 120 118 if (port->mode == IPVLAN_MODE_L3 || 121 119 port->mode == IPVLAN_MODE_L3S) 122 - dev_change_flags(ipvlan->dev, flags | IFF_NOARP); 120 + dev_change_flags(ipvlan->dev, flags | IFF_NOARP, 121 + NULL); 123 122 else 124 - dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP); 123 + dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP, 124 + NULL); 125 125 } 126 126 127 127 return err;
+2 -2
drivers/net/vrf.c
··· 756 756 if (!netif_running(dev)) 757 757 return; 758 758 759 - ret = dev_change_flags(dev, flags & ~IFF_UP); 759 + ret = dev_change_flags(dev, flags & ~IFF_UP, extack); 760 760 if (ret >= 0) 761 - ret = dev_change_flags(dev, flags); 761 + ret = dev_change_flags(dev, flags, extack); 762 762 763 763 if (ret < 0) { 764 764 netdev_err(dev,
+2 -1
include/linux/netdevice.h
··· 3612 3612 int dev_ethtool(struct net *net, struct ifreq *); 3613 3613 unsigned int dev_get_flags(const struct net_device *); 3614 3614 int __dev_change_flags(struct net_device *, unsigned int flags); 3615 - int dev_change_flags(struct net_device *, unsigned int); 3615 + int dev_change_flags(struct net_device *dev, unsigned int flags, 3616 + struct netlink_ext_ack *extack); 3616 3617 void __dev_notify_flags(struct net_device *, unsigned int old_flags, 3617 3618 unsigned int gchanges); 3618 3619 int dev_change_name(struct net_device *, const char *);
+3 -1
net/8021q/vlan.c
··· 358 358 static int vlan_device_event(struct notifier_block *unused, unsigned long event, 359 359 void *ptr) 360 360 { 361 + struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr); 361 362 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 362 363 struct vlan_group *grp; 363 364 struct vlan_info *vlan_info; ··· 461 460 462 461 vlan = vlan_dev_priv(vlandev); 463 462 if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING)) 464 - dev_change_flags(vlandev, flgs | IFF_UP); 463 + dev_change_flags(vlandev, flgs | IFF_UP, 464 + extack); 465 465 netif_stacked_transfer_operstate(dev, vlandev); 466 466 } 467 467 break;
+3 -1
net/core/dev.c
··· 7595 7595 * dev_change_flags - change device settings 7596 7596 * @dev: device 7597 7597 * @flags: device state flags 7598 + * @extack: netlink extended ack 7598 7599 * 7599 7600 * Change settings on device based state flags. The flags are 7600 7601 * in the userspace exported format. 7601 7602 */ 7602 - int dev_change_flags(struct net_device *dev, unsigned int flags) 7603 + int dev_change_flags(struct net_device *dev, unsigned int flags, 7604 + struct netlink_ext_ack *extack) 7603 7605 { 7604 7606 int ret; 7605 7607 unsigned int changes, old_flags = dev->flags, old_gflags = dev->gflags;
+1 -1
net/core/dev_ioctl.c
··· 234 234 235 235 switch (cmd) { 236 236 case SIOCSIFFLAGS: /* Set interface flags */ 237 - return dev_change_flags(dev, ifr->ifr_flags); 237 + return dev_change_flags(dev, ifr->ifr_flags, NULL); 238 238 239 239 case SIOCSIFMETRIC: /* Set the metric on the interface 240 240 (currently unused) */
+1 -1
net/core/net-sysfs.c
··· 337 337 338 338 static int change_flags(struct net_device *dev, unsigned long new_flags) 339 339 { 340 - return dev_change_flags(dev, (unsigned int)new_flags); 340 + return dev_change_flags(dev, (unsigned int)new_flags, NULL); 341 341 } 342 342 343 343 static ssize_t flags_store(struct device *dev, struct device_attribute *attr,
+2 -1
net/core/rtnetlink.c
··· 2489 2489 } 2490 2490 2491 2491 if (ifm->ifi_flags || ifm->ifi_change) { 2492 - err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm)); 2492 + err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm), 2493 + extack); 2493 2494 if (err < 0) 2494 2495 goto errout; 2495 2496 }
+1 -1
net/ipv4/devinet.c
··· 1100 1100 inet_del_ifa(in_dev, ifap, 1); 1101 1101 break; 1102 1102 } 1103 - ret = dev_change_flags(dev, ifr->ifr_flags); 1103 + ret = dev_change_flags(dev, ifr->ifr_flags, NULL); 1104 1104 break; 1105 1105 1106 1106 case SIOCSIFADDR: /* Set interface address (and family) */
+3 -3
net/ipv4/ipconfig.c
··· 220 220 for_each_netdev(&init_net, dev) { 221 221 if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev)) 222 222 continue; 223 - if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) 223 + if (dev_change_flags(dev, dev->flags | IFF_UP, NULL) < 0) 224 224 pr_err("IP-Config: Failed to open %s\n", dev->name); 225 225 } 226 226 ··· 238 238 if (ic_proto_enabled && !able) 239 239 continue; 240 240 oflags = dev->flags; 241 - if (dev_change_flags(dev, oflags | IFF_UP) < 0) { 241 + if (dev_change_flags(dev, oflags | IFF_UP, NULL) < 0) { 242 242 pr_err("IP-Config: Failed to open %s\n", 243 243 dev->name); 244 244 continue; ··· 315 315 dev = d->dev; 316 316 if (d != ic_dev && !netdev_uses_dsa(dev)) { 317 317 pr_debug("IP-Config: Downing %s\n", dev->name); 318 - dev_change_flags(dev, d->flags); 318 + dev_change_flags(dev, d->flags, NULL); 319 319 } 320 320 kfree(d); 321 321 }
+1 -1
net/openvswitch/vport-geneve.c
··· 93 93 return ERR_CAST(dev); 94 94 } 95 95 96 - err = dev_change_flags(dev, dev->flags | IFF_UP); 96 + err = dev_change_flags(dev, dev->flags | IFF_UP, NULL); 97 97 if (err < 0) { 98 98 rtnl_delete_link(dev); 99 99 rtnl_unlock();
+1 -1
net/openvswitch/vport-gre.c
··· 68 68 return ERR_CAST(dev); 69 69 } 70 70 71 - err = dev_change_flags(dev, dev->flags | IFF_UP); 71 + err = dev_change_flags(dev, dev->flags | IFF_UP, NULL); 72 72 if (err < 0) { 73 73 rtnl_delete_link(dev); 74 74 rtnl_unlock();
+1 -1
net/openvswitch/vport-vxlan.c
··· 131 131 return ERR_CAST(dev); 132 132 } 133 133 134 - err = dev_change_flags(dev, dev->flags | IFF_UP); 134 + err = dev_change_flags(dev, dev->flags | IFF_UP, NULL); 135 135 if (err < 0) { 136 136 rtnl_delete_link(dev); 137 137 rtnl_unlock();