Skip to content

Commit

Permalink
net-sysfs: trigger netlink notification on ifalias change via sysfs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roopa Prabhu authored and David S. Miller committed Nov 14, 2017
1 parent 6dc14dc commit c92eb77
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr,
struct net_device *netdev = to_net_dev(dev);
struct net *net = dev_net(netdev);
size_t count = len;
ssize_t ret;
ssize_t ret = 0;

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

ret = dev_set_alias(netdev, buf, count);
if (!rtnl_trylock())
return restart_syscall();

if (dev_isalive(netdev)) {
ret = dev_set_alias(netdev, buf, count);
if (ret < 0)
goto err;
ret = len;
netdev_state_change(netdev);
}
err:
rtnl_unlock();

return ret < 0 ? ret : len;
return ret;
}

static ssize_t ifalias_show(struct device *dev,
Expand Down

0 comments on commit c92eb77

Please sign in to comment.