summaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorVeaceslav Falico <vfalico@redhat.com>2013-09-25 09:20:31 +0200
committerDavid S. Miller <davem@davemloft.net>2013-09-26 16:02:08 -0400
commit842d67a7b34ea735155812ecf0671a481284f358 (patch)
tree71b2de5b2ffda2fa7e41c1d9e9023eef51006394 /net/core/dev.c
parent47701a36a3ed6d97e5bbe7ad72cceb49ca329d00 (diff)
downloadop-kernel-dev-842d67a7b34ea735155812ecf0671a481284f358.zip
op-kernel-dev-842d67a7b34ea735155812ecf0671a481284f358.tar.gz
net: expose the master link to sysfs, and remove it from bond
Currently, we can have only one master upper neighbour, so it would be useful to create a symlink to it in the sysfs device directory, the way that bonding now does it, for every device. Lower devices from bridge/team/etc will automagically get it, so we could rely on it. Also, remove the same functionality from bonding. CC: Jay Vosburgh <fubar@us.ibm.com> CC: Andy Gospodarek <andy@greyhouse.net> CC: "David S. Miller" <davem@davemloft.net> CC: Eric Dumazet <edumazet@google.com> CC: Jiri Pirko <jiri@resnulli.us> CC: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index acc1181..de443ee 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4584,6 +4584,7 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
void *private, bool master)
{
struct netdev_adjacent *adj;
+ int ret;
adj = __netdev_find_adj(dev, adj_dev, dev_list);
@@ -4606,12 +4607,23 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
adj_dev->name, dev->name, adj_dev->name);
/* Ensure that master link is always the first item in list. */
- if (master)
+ if (master) {
+ ret = sysfs_create_link(&(dev->dev.kobj),
+ &(adj_dev->dev.kobj), "master");
+ if (ret)
+ goto free_adj;
+
list_add_rcu(&adj->list, dev_list);
- else
+ } else {
list_add_tail_rcu(&adj->list, dev_list);
+ }
return 0;
+
+free_adj:
+ kfree(adj);
+
+ return ret;
}
void __netdev_adjacent_dev_remove(struct net_device *dev,
@@ -4635,6 +4647,9 @@ void __netdev_adjacent_dev_remove(struct net_device *dev,
return;
}
+ if (adj->master)
+ sysfs_remove_link(&(dev->dev.kobj), "master");
+
list_del_rcu(&adj->list);
pr_debug("dev_put for %s, because link removed from %s to %s\n",
adj_dev->name, dev->name, adj_dev->name);
OpenPOWER on IntegriCloud