diff options
author | Eric W. Biederman <ebiederm@aristanetworks.com> | 2009-10-29 10:18:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-30 15:41:21 -0400 |
commit | ec87fd3b4e111e8bc367d247a963e27e5b86df26 (patch) | |
tree | 8c33611b3e0afb37bcad232c2ad8d8f52d469634 /drivers/net/bonding/bond_sysfs.c | |
parent | 88ead977109da926a03068e277869ea8fedd170d (diff) |
bond: Add support for multiple network namespaces
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_sysfs.c')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index f924a0bcf8da..a59094f8bb6b 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -35,6 +35,8 @@ | |||
35 | #include <linux/rtnetlink.h> | 35 | #include <linux/rtnetlink.h> |
36 | #include <linux/etherdevice.h> | 36 | #include <linux/etherdevice.h> |
37 | #include <net/net_namespace.h> | 37 | #include <net/net_namespace.h> |
38 | #include <net/netns/generic.h> | ||
39 | #include <linux/nsproxy.h> | ||
38 | 40 | ||
39 | #include "bonding.h" | 41 | #include "bonding.h" |
40 | 42 | ||
@@ -47,12 +49,14 @@ | |||
47 | */ | 49 | */ |
48 | static ssize_t bonding_show_bonds(struct class *cls, char *buf) | 50 | static ssize_t bonding_show_bonds(struct class *cls, char *buf) |
49 | { | 51 | { |
52 | struct net *net = current->nsproxy->net_ns; | ||
53 | struct bond_net *bn = net_generic(net, bond_net_id); | ||
50 | int res = 0; | 54 | int res = 0; |
51 | struct bonding *bond; | 55 | struct bonding *bond; |
52 | 56 | ||
53 | rtnl_lock(); | 57 | rtnl_lock(); |
54 | 58 | ||
55 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | 59 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
56 | if (res > (PAGE_SIZE - IFNAMSIZ)) { | 60 | if (res > (PAGE_SIZE - IFNAMSIZ)) { |
57 | /* not enough space for another interface name */ | 61 | /* not enough space for another interface name */ |
58 | if ((PAGE_SIZE - res) > 10) | 62 | if ((PAGE_SIZE - res) > 10) |
@@ -69,11 +73,12 @@ static ssize_t bonding_show_bonds(struct class *cls, char *buf) | |||
69 | return res; | 73 | return res; |
70 | } | 74 | } |
71 | 75 | ||
72 | static struct net_device *bond_get_by_name(const char *ifname) | 76 | static struct net_device *bond_get_by_name(struct net *net, const char *ifname) |
73 | { | 77 | { |
78 | struct bond_net *bn = net_generic(net, bond_net_id); | ||
74 | struct bonding *bond; | 79 | struct bonding *bond; |
75 | 80 | ||
76 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | 81 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
77 | if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0) | 82 | if (strncmp(bond->dev->name, ifname, IFNAMSIZ) == 0) |
78 | return bond->dev; | 83 | return bond->dev; |
79 | } | 84 | } |
@@ -91,6 +96,7 @@ static struct net_device *bond_get_by_name(const char *ifname) | |||
91 | static ssize_t bonding_store_bonds(struct class *cls, | 96 | static ssize_t bonding_store_bonds(struct class *cls, |
92 | const char *buffer, size_t count) | 97 | const char *buffer, size_t count) |
93 | { | 98 | { |
99 | struct net *net = current->nsproxy->net_ns; | ||
94 | char command[IFNAMSIZ + 1] = {0, }; | 100 | char command[IFNAMSIZ + 1] = {0, }; |
95 | char *ifname; | 101 | char *ifname; |
96 | int rv, res = count; | 102 | int rv, res = count; |
@@ -104,7 +110,7 @@ static ssize_t bonding_store_bonds(struct class *cls, | |||
104 | if (command[0] == '+') { | 110 | if (command[0] == '+') { |
105 | pr_info(DRV_NAME | 111 | pr_info(DRV_NAME |
106 | ": %s is being created...\n", ifname); | 112 | ": %s is being created...\n", ifname); |
107 | rv = bond_create(ifname); | 113 | rv = bond_create(net, ifname); |
108 | if (rv) { | 114 | if (rv) { |
109 | pr_info(DRV_NAME ": Bond creation failed.\n"); | 115 | pr_info(DRV_NAME ": Bond creation failed.\n"); |
110 | res = rv; | 116 | res = rv; |
@@ -113,7 +119,7 @@ static ssize_t bonding_store_bonds(struct class *cls, | |||
113 | struct net_device *bond_dev; | 119 | struct net_device *bond_dev; |
114 | 120 | ||
115 | rtnl_lock(); | 121 | rtnl_lock(); |
116 | bond_dev = bond_get_by_name(ifname); | 122 | bond_dev = bond_get_by_name(net, ifname); |
117 | if (bond_dev) { | 123 | if (bond_dev) { |
118 | pr_info(DRV_NAME ": %s is being deleted...\n", | 124 | pr_info(DRV_NAME ": %s is being deleted...\n", |
119 | ifname); | 125 | ifname); |
@@ -238,8 +244,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
238 | /* Got a slave name in ifname. Is it already in the list? */ | 244 | /* Got a slave name in ifname. Is it already in the list? */ |
239 | found = 0; | 245 | found = 0; |
240 | 246 | ||
241 | /* FIXME: get netns from sysfs object */ | 247 | dev = __dev_get_by_name(dev_net(bond->dev), ifname); |
242 | dev = __dev_get_by_name(&init_net, ifname); | ||
243 | if (!dev) { | 248 | if (!dev) { |
244 | pr_info(DRV_NAME | 249 | pr_info(DRV_NAME |
245 | ": %s: Interface %s does not exist!\n", | 250 | ": %s: Interface %s does not exist!\n", |