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

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>

authored by

Roopa Prabhu and committed by
David S. Miller
c92eb77a 6dc14dc4

+14 -3
+14 -3
net/core/net-sysfs.c
··· 382 382 struct net_device *netdev = to_net_dev(dev); 383 383 struct net *net = dev_net(netdev); 384 384 size_t count = len; 385 - ssize_t ret; 385 + ssize_t ret = 0; 386 386 387 387 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 388 388 return -EPERM; ··· 391 391 if (len > 0 && buf[len - 1] == '\n') 392 392 --count; 393 393 394 - ret = dev_set_alias(netdev, buf, count); 394 + if (!rtnl_trylock()) 395 + return restart_syscall(); 395 396 396 - return ret < 0 ? ret : len; 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(); 406 + 407 + return ret; 397 408 } 398 409 399 410 static ssize_t ifalias_show(struct device *dev,