Skip to content

Commit c92eb77

Browse files
roopa-prabhudavem330
authored andcommitted
net-sysfs: trigger netlink notification on ifalias change via sysfs
This patch adds netlink notifications on iflias changes via sysfs. makes it consistent with the netlink path which also calls netdev_state_change. Also makes it consistent with other sysfs netdev_store operations. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6dc14dc commit c92eb77

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

net/core/net-sysfs.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
382382
struct net_device *netdev = to_net_dev(dev);
383383
struct net *net = dev_net(netdev);
384384
size_t count = len;
385-
ssize_t ret;
385+
ssize_t ret = 0;
386386

387387
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
388388
return -EPERM;
@@ -391,9 +391,20 @@ static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
391391
if (len > 0 && buf[len - 1] == '\n')
392392
--count;
393393

394-
ret = dev_set_alias(netdev, buf, count);
394+
if (!rtnl_trylock())
395+
return restart_syscall();
396+
397+
if (dev_isalive(netdev)) {
398+
ret = dev_set_alias(netdev, buf, count);
399+
if (ret < 0)
400+
goto err;
401+
ret = len;
402+
netdev_state_change(netdev);
403+
}
404+
err:
405+
rtnl_unlock();
395406

396-
return ret < 0 ? ret : len;
407+
return ret;
397408
}
398409

399410
static ssize_t ifalias_show(struct device *dev,

0 commit comments

Comments
 (0)