Skip to content

Commit 567c5e1

Browse files
pmachatadavem330
authored andcommitted
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>
1 parent cf7686a commit 567c5e1

File tree

15 files changed

+33
-23
lines changed

15 files changed

+33
-23
lines changed

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int ipoib_open(struct net_device *dev)
167167
if (flags & IFF_UP)
168168
continue;
169169

170-
dev_change_flags(cpriv->dev, flags | IFF_UP);
170+
dev_change_flags(cpriv->dev, flags | IFF_UP, NULL);
171171
}
172172
up_read(&priv->vlan_rwsem);
173173
}
@@ -207,7 +207,7 @@ static int ipoib_stop(struct net_device *dev)
207207
if (!(flags & IFF_UP))
208208
continue;
209209

210-
dev_change_flags(cpriv->dev, flags & ~IFF_UP);
210+
dev_change_flags(cpriv->dev, flags & ~IFF_UP, NULL);
211211
}
212212
up_read(&priv->vlan_rwsem);
213213
}
@@ -1823,7 +1823,7 @@ static void ipoib_parent_unregister_pre(struct net_device *ndev)
18231823
* running ensures the it will not add more work.
18241824
*/
18251825
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);
18271827
rtnl_unlock();
18281828

18291829
/* ipoib_event() cannot be running once this returns */

drivers/net/hyperv/netvsc_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ static void __netvsc_vf_setup(struct net_device *ndev,
19931993
"unable to change mtu to %u\n", ndev->mtu);
19941994

19951995
/* 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);
19971997

19981998
/* sync address list from ndev to VF */
19991999
netif_addr_lock_bh(ndev);

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval,
8585
flags = ipvlan->dev->flags;
8686
if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S) {
8787
err = dev_change_flags(ipvlan->dev,
88-
flags | IFF_NOARP);
88+
flags | IFF_NOARP,
89+
extack);
8990
} else {
9091
err = dev_change_flags(ipvlan->dev,
91-
flags & ~IFF_NOARP);
92+
flags & ~IFF_NOARP,
93+
extack);
9294
}
9395
if (unlikely(err))
9496
goto fail;
@@ -117,9 +119,11 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval,
117119
flags = ipvlan->dev->flags;
118120
if (port->mode == IPVLAN_MODE_L3 ||
119121
port->mode == IPVLAN_MODE_L3S)
120-
dev_change_flags(ipvlan->dev, flags | IFF_NOARP);
122+
dev_change_flags(ipvlan->dev, flags | IFF_NOARP,
123+
NULL);
121124
else
122-
dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP);
125+
dev_change_flags(ipvlan->dev, flags & ~IFF_NOARP,
126+
NULL);
123127
}
124128

125129
return err;

drivers/net/vrf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ static void cycle_netdev(struct net_device *dev,
756756
if (!netif_running(dev))
757757
return;
758758

759-
ret = dev_change_flags(dev, flags & ~IFF_UP);
759+
ret = dev_change_flags(dev, flags & ~IFF_UP, extack);
760760
if (ret >= 0)
761-
ret = dev_change_flags(dev, flags);
761+
ret = dev_change_flags(dev, flags, extack);
762762

763763
if (ret < 0) {
764764
netdev_err(dev,

include/linux/netdevice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3612,7 +3612,8 @@ int dev_ifconf(struct net *net, struct ifconf *, int);
36123612
int dev_ethtool(struct net *net, struct ifreq *);
36133613
unsigned int dev_get_flags(const struct net_device *);
36143614
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);
36163617
void __dev_notify_flags(struct net_device *, unsigned int old_flags,
36173618
unsigned int gchanges);
36183619
int dev_change_name(struct net_device *, const char *);

net/8021q/vlan.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ static int __vlan_device_event(struct net_device *dev, unsigned long event)
358358
static int vlan_device_event(struct notifier_block *unused, unsigned long event,
359359
void *ptr)
360360
{
361+
struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(ptr);
361362
struct net_device *dev = netdev_notifier_info_to_dev(ptr);
362363
struct vlan_group *grp;
363364
struct vlan_info *vlan_info;
@@ -460,7 +461,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
460461

461462
vlan = vlan_dev_priv(vlandev);
462463
if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
463-
dev_change_flags(vlandev, flgs | IFF_UP);
464+
dev_change_flags(vlandev, flgs | IFF_UP,
465+
extack);
464466
netif_stacked_transfer_operstate(dev, vlandev);
465467
}
466468
break;

net/core/dev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7595,11 +7595,13 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
75957595
* dev_change_flags - change device settings
75967596
* @dev: device
75977597
* @flags: device state flags
7598+
* @extack: netlink extended ack
75987599
*
75997600
* Change settings on device based state flags. The flags are
76007601
* in the userspace exported format.
76017602
*/
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)
76037605
{
76047606
int ret;
76057607
unsigned int changes, old_flags = dev->flags, old_gflags = dev->gflags;

net/core/dev_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
234234

235235
switch (cmd) {
236236
case SIOCSIFFLAGS: /* Set interface flags */
237-
return dev_change_flags(dev, ifr->ifr_flags);
237+
return dev_change_flags(dev, ifr->ifr_flags, NULL);
238238

239239
case SIOCSIFMETRIC: /* Set the metric on the interface
240240
(currently unused) */

net/core/net-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ NETDEVICE_SHOW_RW(mtu, fmt_dec);
337337

338338
static int change_flags(struct net_device *dev, unsigned long new_flags)
339339
{
340-
return dev_change_flags(dev, (unsigned int)new_flags);
340+
return dev_change_flags(dev, (unsigned int)new_flags, NULL);
341341
}
342342

343343
static ssize_t flags_store(struct device *dev, struct device_attribute *attr,

net/core/rtnetlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,8 @@ static int do_setlink(const struct sk_buff *skb,
24892489
}
24902490

24912491
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);
24932494
if (err < 0)
24942495
goto errout;
24952496
}

net/ipv4/devinet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ int devinet_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr)
11001100
inet_del_ifa(in_dev, ifap, 1);
11011101
break;
11021102
}
1103-
ret = dev_change_flags(dev, ifr->ifr_flags);
1103+
ret = dev_change_flags(dev, ifr->ifr_flags, NULL);
11041104
break;
11051105

11061106
case SIOCSIFADDR: /* Set interface address (and family) */

net/ipv4/ipconfig.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static int __init ic_open_devs(void)
220220
for_each_netdev(&init_net, dev) {
221221
if (!(dev->flags & IFF_LOOPBACK) && !netdev_uses_dsa(dev))
222222
continue;
223-
if (dev_change_flags(dev, dev->flags | IFF_UP) < 0)
223+
if (dev_change_flags(dev, dev->flags | IFF_UP, NULL) < 0)
224224
pr_err("IP-Config: Failed to open %s\n", dev->name);
225225
}
226226

@@ -238,7 +238,7 @@ static int __init ic_open_devs(void)
238238
if (ic_proto_enabled && !able)
239239
continue;
240240
oflags = dev->flags;
241-
if (dev_change_flags(dev, oflags | IFF_UP) < 0) {
241+
if (dev_change_flags(dev, oflags | IFF_UP, NULL) < 0) {
242242
pr_err("IP-Config: Failed to open %s\n",
243243
dev->name);
244244
continue;
@@ -315,7 +315,7 @@ static void __init ic_close_devs(void)
315315
dev = d->dev;
316316
if (d != ic_dev && !netdev_uses_dsa(dev)) {
317317
pr_debug("IP-Config: Downing %s\n", dev->name);
318-
dev_change_flags(dev, d->flags);
318+
dev_change_flags(dev, d->flags, NULL);
319319
}
320320
kfree(d);
321321
}

net/openvswitch/vport-geneve.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static struct vport *geneve_tnl_create(const struct vport_parms *parms)
9393
return ERR_CAST(dev);
9494
}
9595

96-
err = dev_change_flags(dev, dev->flags | IFF_UP);
96+
err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
9797
if (err < 0) {
9898
rtnl_delete_link(dev);
9999
rtnl_unlock();

net/openvswitch/vport-gre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static struct vport *gre_tnl_create(const struct vport_parms *parms)
6868
return ERR_CAST(dev);
6969
}
7070

71-
err = dev_change_flags(dev, dev->flags | IFF_UP);
71+
err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
7272
if (err < 0) {
7373
rtnl_delete_link(dev);
7474
rtnl_unlock();

net/openvswitch/vport-vxlan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
131131
return ERR_CAST(dev);
132132
}
133133

134-
err = dev_change_flags(dev, dev->flags | IFF_UP);
134+
err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
135135
if (err < 0) {
136136
rtnl_delete_link(dev);
137137
rtnl_unlock();

0 commit comments

Comments
 (0)