diff options
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 3 | ||||
-rw-r--r-- | drivers/net/bonding/bond_ipv6.c | 7 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 111 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 19 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 14 |
6 files changed, 99 insertions, 58 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 3cd8153b906c..1d0581923287 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -2445,9 +2445,6 @@ int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct pac | |||
2445 | struct slave *slave = NULL; | 2445 | struct slave *slave = NULL; |
2446 | int ret = NET_RX_DROP; | 2446 | int ret = NET_RX_DROP; |
2447 | 2447 | ||
2448 | if (dev_net(dev) != &init_net) | ||
2449 | goto out; | ||
2450 | |||
2451 | if (!(dev->flags & IFF_MASTER)) | 2448 | if (!(dev->flags & IFF_MASTER)) |
2452 | goto out; | 2449 | goto out; |
2453 | 2450 | ||
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 9b5936f072dc..0d30d1e5e53f 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -355,9 +355,6 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct | |||
355 | struct arp_pkt *arp = (struct arp_pkt *)skb->data; | 355 | struct arp_pkt *arp = (struct arp_pkt *)skb->data; |
356 | int res = NET_RX_DROP; | 356 | int res = NET_RX_DROP; |
357 | 357 | ||
358 | if (dev_net(bond_dev) != &init_net) | ||
359 | goto out; | ||
360 | |||
361 | while (bond_dev->priv_flags & IFF_802_1Q_VLAN) | 358 | while (bond_dev->priv_flags & IFF_802_1Q_VLAN) |
362 | bond_dev = vlan_dev_real_dev(bond_dev); | 359 | bond_dev = vlan_dev_real_dev(bond_dev); |
363 | 360 | ||
diff --git a/drivers/net/bonding/bond_ipv6.c b/drivers/net/bonding/bond_ipv6.c index 83921abae12d..b72e1dc8cf8f 100644 --- a/drivers/net/bonding/bond_ipv6.c +++ b/drivers/net/bonding/bond_ipv6.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <net/ipv6.h> | 25 | #include <net/ipv6.h> |
26 | #include <net/ndisc.h> | 26 | #include <net/ndisc.h> |
27 | #include <net/addrconf.h> | 27 | #include <net/addrconf.h> |
28 | #include <net/netns/generic.h> | ||
28 | #include "bonding.h" | 29 | #include "bonding.h" |
29 | 30 | ||
30 | /* | 31 | /* |
@@ -152,11 +153,9 @@ static int bond_inet6addr_event(struct notifier_block *this, | |||
152 | struct net_device *vlan_dev, *event_dev = ifa->idev->dev; | 153 | struct net_device *vlan_dev, *event_dev = ifa->idev->dev; |
153 | struct bonding *bond; | 154 | struct bonding *bond; |
154 | struct vlan_entry *vlan; | 155 | struct vlan_entry *vlan; |
156 | struct bond_net *bn = net_generic(dev_net(event_dev), bond_net_id); | ||
155 | 157 | ||
156 | if (dev_net(event_dev) != &init_net) | 158 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
157 | return NOTIFY_DONE; | ||
158 | |||
159 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | ||
160 | if (bond->dev == event_dev) { | 159 | if (bond->dev == event_dev) { |
161 | switch (event) { | 160 | switch (event) { |
162 | case NETDEV_UP: | 161 | case NETDEV_UP: |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 405971374fe2..208d2c4ef068 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -75,6 +75,7 @@ | |||
75 | #include <linux/jiffies.h> | 75 | #include <linux/jiffies.h> |
76 | #include <net/route.h> | 76 | #include <net/route.h> |
77 | #include <net/net_namespace.h> | 77 | #include <net/net_namespace.h> |
78 | #include <net/netns/generic.h> | ||
78 | #include "bonding.h" | 79 | #include "bonding.h" |
79 | #include "bond_3ad.h" | 80 | #include "bond_3ad.h" |
80 | #include "bond_alb.h" | 81 | #include "bond_alb.h" |
@@ -157,11 +158,7 @@ MODULE_PARM_DESC(fail_over_mac, "For active-backup, do not set all slaves to the | |||
157 | static const char * const version = | 158 | static const char * const version = |
158 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; | 159 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; |
159 | 160 | ||
160 | LIST_HEAD(bond_dev_list); | 161 | int bond_net_id; |
161 | |||
162 | #ifdef CONFIG_PROC_FS | ||
163 | static struct proc_dir_entry *bond_proc_dir; | ||
164 | #endif | ||
165 | 162 | ||
166 | static __be32 arp_target[BOND_MAX_ARP_TARGETS]; | 163 | static __be32 arp_target[BOND_MAX_ARP_TARGETS]; |
167 | static int arp_ip_count; | 164 | static int arp_ip_count; |
@@ -2586,7 +2583,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave) | |||
2586 | fl.fl4_dst = targets[i]; | 2583 | fl.fl4_dst = targets[i]; |
2587 | fl.fl4_tos = RTO_ONLINK; | 2584 | fl.fl4_tos = RTO_ONLINK; |
2588 | 2585 | ||
2589 | rv = ip_route_output_key(&init_net, &rt, &fl); | 2586 | rv = ip_route_output_key(dev_net(bond->dev), &rt, &fl); |
2590 | if (rv) { | 2587 | if (rv) { |
2591 | if (net_ratelimit()) { | 2588 | if (net_ratelimit()) { |
2592 | pr_warning(DRV_NAME | 2589 | pr_warning(DRV_NAME |
@@ -2694,9 +2691,6 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack | |||
2694 | unsigned char *arp_ptr; | 2691 | unsigned char *arp_ptr; |
2695 | __be32 sip, tip; | 2692 | __be32 sip, tip; |
2696 | 2693 | ||
2697 | if (dev_net(dev) != &init_net) | ||
2698 | goto out; | ||
2699 | |||
2700 | if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER)) | 2694 | if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER)) |
2701 | goto out; | 2695 | goto out; |
2702 | 2696 | ||
@@ -3359,10 +3353,11 @@ static const struct file_operations bond_info_fops = { | |||
3359 | static void bond_create_proc_entry(struct bonding *bond) | 3353 | static void bond_create_proc_entry(struct bonding *bond) |
3360 | { | 3354 | { |
3361 | struct net_device *bond_dev = bond->dev; | 3355 | struct net_device *bond_dev = bond->dev; |
3356 | struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id); | ||
3362 | 3357 | ||
3363 | if (bond_proc_dir) { | 3358 | if (bn->proc_dir) { |
3364 | bond->proc_entry = proc_create_data(bond_dev->name, | 3359 | bond->proc_entry = proc_create_data(bond_dev->name, |
3365 | S_IRUGO, bond_proc_dir, | 3360 | S_IRUGO, bn->proc_dir, |
3366 | &bond_info_fops, bond); | 3361 | &bond_info_fops, bond); |
3367 | if (bond->proc_entry == NULL) | 3362 | if (bond->proc_entry == NULL) |
3368 | pr_warning(DRV_NAME | 3363 | pr_warning(DRV_NAME |
@@ -3375,8 +3370,11 @@ static void bond_create_proc_entry(struct bonding *bond) | |||
3375 | 3370 | ||
3376 | static void bond_remove_proc_entry(struct bonding *bond) | 3371 | static void bond_remove_proc_entry(struct bonding *bond) |
3377 | { | 3372 | { |
3378 | if (bond_proc_dir && bond->proc_entry) { | 3373 | struct net_device *bond_dev = bond->dev; |
3379 | remove_proc_entry(bond->proc_file_name, bond_proc_dir); | 3374 | struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id); |
3375 | |||
3376 | if (bn->proc_dir && bond->proc_entry) { | ||
3377 | remove_proc_entry(bond->proc_file_name, bn->proc_dir); | ||
3380 | memset(bond->proc_file_name, 0, IFNAMSIZ); | 3378 | memset(bond->proc_file_name, 0, IFNAMSIZ); |
3381 | bond->proc_entry = NULL; | 3379 | bond->proc_entry = NULL; |
3382 | } | 3380 | } |
@@ -3385,11 +3383,11 @@ static void bond_remove_proc_entry(struct bonding *bond) | |||
3385 | /* Create the bonding directory under /proc/net, if doesn't exist yet. | 3383 | /* Create the bonding directory under /proc/net, if doesn't exist yet. |
3386 | * Caller must hold rtnl_lock. | 3384 | * Caller must hold rtnl_lock. |
3387 | */ | 3385 | */ |
3388 | static void bond_create_proc_dir(void) | 3386 | static void bond_create_proc_dir(struct bond_net *bn) |
3389 | { | 3387 | { |
3390 | if (!bond_proc_dir) { | 3388 | if (!bn->proc_dir) { |
3391 | bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net); | 3389 | bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net); |
3392 | if (!bond_proc_dir) | 3390 | if (!bn->proc_dir) |
3393 | pr_warning(DRV_NAME | 3391 | pr_warning(DRV_NAME |
3394 | ": Warning: cannot create /proc/net/%s\n", | 3392 | ": Warning: cannot create /proc/net/%s\n", |
3395 | DRV_NAME); | 3393 | DRV_NAME); |
@@ -3399,11 +3397,11 @@ static void bond_create_proc_dir(void) | |||
3399 | /* Destroy the bonding directory under /proc/net, if empty. | 3397 | /* Destroy the bonding directory under /proc/net, if empty. |
3400 | * Caller must hold rtnl_lock. | 3398 | * Caller must hold rtnl_lock. |
3401 | */ | 3399 | */ |
3402 | static void bond_destroy_proc_dir(void) | 3400 | static void bond_destroy_proc_dir(struct bond_net *bn) |
3403 | { | 3401 | { |
3404 | if (bond_proc_dir) { | 3402 | if (bn->proc_dir) { |
3405 | remove_proc_entry(DRV_NAME, init_net.proc_net); | 3403 | remove_proc_entry(DRV_NAME, bn->net->proc_net); |
3406 | bond_proc_dir = NULL; | 3404 | bn->proc_dir = NULL; |
3407 | } | 3405 | } |
3408 | } | 3406 | } |
3409 | 3407 | ||
@@ -3417,11 +3415,11 @@ static void bond_remove_proc_entry(struct bonding *bond) | |||
3417 | { | 3415 | { |
3418 | } | 3416 | } |
3419 | 3417 | ||
3420 | static void bond_create_proc_dir(void) | 3418 | static void bond_create_proc_dir(struct bond_net *bn) |
3421 | { | 3419 | { |
3422 | } | 3420 | } |
3423 | 3421 | ||
3424 | static void bond_destroy_proc_dir(void) | 3422 | static void bond_destroy_proc_dir(struct bond_net *bn) |
3425 | { | 3423 | { |
3426 | } | 3424 | } |
3427 | 3425 | ||
@@ -3540,9 +3538,6 @@ static int bond_netdev_event(struct notifier_block *this, | |||
3540 | { | 3538 | { |
3541 | struct net_device *event_dev = (struct net_device *)ptr; | 3539 | struct net_device *event_dev = (struct net_device *)ptr; |
3542 | 3540 | ||
3543 | if (dev_net(event_dev) != &init_net) | ||
3544 | return NOTIFY_DONE; | ||
3545 | |||
3546 | pr_debug("event_dev: %s, event: %lx\n", | 3541 | pr_debug("event_dev: %s, event: %lx\n", |
3547 | (event_dev ? event_dev->name : "None"), | 3542 | (event_dev ? event_dev->name : "None"), |
3548 | event); | 3543 | event); |
@@ -3575,13 +3570,11 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event, | |||
3575 | { | 3570 | { |
3576 | struct in_ifaddr *ifa = ptr; | 3571 | struct in_ifaddr *ifa = ptr; |
3577 | struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev; | 3572 | struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev; |
3573 | struct bond_net *bn = net_generic(dev_net(event_dev), bond_net_id); | ||
3578 | struct bonding *bond; | 3574 | struct bonding *bond; |
3579 | struct vlan_entry *vlan; | 3575 | struct vlan_entry *vlan; |
3580 | 3576 | ||
3581 | if (dev_net(ifa->ifa_dev->dev) != &init_net) | 3577 | list_for_each_entry(bond, &bn->dev_list, bond_list) { |
3582 | return NOTIFY_DONE; | ||
3583 | |||
3584 | list_for_each_entry(bond, &bond_dev_list, bond_list) { | ||
3585 | if (bond->dev == event_dev) { | 3578 | if (bond->dev == event_dev) { |
3586 | switch (event) { | 3579 | switch (event) { |
3587 | case NETDEV_UP: | 3580 | case NETDEV_UP: |
@@ -3950,7 +3943,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3950 | if (!capable(CAP_NET_ADMIN)) | 3943 | if (!capable(CAP_NET_ADMIN)) |
3951 | return -EPERM; | 3944 | return -EPERM; |
3952 | 3945 | ||
3953 | slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave); | 3946 | slave_dev = dev_get_by_name(dev_net(bond_dev), ifr->ifr_slave); |
3954 | 3947 | ||
3955 | pr_debug("slave_dev=%p: \n", slave_dev); | 3948 | pr_debug("slave_dev=%p: \n", slave_dev); |
3956 | 3949 | ||
@@ -5031,6 +5024,7 @@ static void bond_set_lockdep_class(struct net_device *dev) | |||
5031 | static int bond_init(struct net_device *bond_dev) | 5024 | static int bond_init(struct net_device *bond_dev) |
5032 | { | 5025 | { |
5033 | struct bonding *bond = netdev_priv(bond_dev); | 5026 | struct bonding *bond = netdev_priv(bond_dev); |
5027 | struct bond_net *bn = net_generic(dev_net(bond_dev), bond_net_id); | ||
5034 | 5028 | ||
5035 | pr_debug("Begin bond_init for %s\n", bond_dev->name); | 5029 | pr_debug("Begin bond_init for %s\n", bond_dev->name); |
5036 | 5030 | ||
@@ -5043,7 +5037,7 @@ static int bond_init(struct net_device *bond_dev) | |||
5043 | netif_carrier_off(bond_dev); | 5037 | netif_carrier_off(bond_dev); |
5044 | 5038 | ||
5045 | bond_create_proc_entry(bond); | 5039 | bond_create_proc_entry(bond); |
5046 | list_add_tail(&bond->bond_list, &bond_dev_list); | 5040 | list_add_tail(&bond->bond_list, &bn->dev_list); |
5047 | 5041 | ||
5048 | bond_prepare_sysfs_group(bond); | 5042 | bond_prepare_sysfs_group(bond); |
5049 | return 0; | 5043 | return 0; |
@@ -5071,7 +5065,7 @@ static struct rtnl_link_ops bond_link_ops __read_mostly = { | |||
5071 | * Caller must NOT hold rtnl_lock; we need to release it here before we | 5065 | * Caller must NOT hold rtnl_lock; we need to release it here before we |
5072 | * set up our sysfs entries. | 5066 | * set up our sysfs entries. |
5073 | */ | 5067 | */ |
5074 | int bond_create(const char *name) | 5068 | int bond_create(struct net *net, const char *name) |
5075 | { | 5069 | { |
5076 | struct net_device *bond_dev; | 5070 | struct net_device *bond_dev; |
5077 | int res; | 5071 | int res; |
@@ -5087,6 +5081,7 @@ int bond_create(const char *name) | |||
5087 | goto out; | 5081 | goto out; |
5088 | } | 5082 | } |
5089 | 5083 | ||
5084 | dev_net_set(bond_dev, net); | ||
5090 | bond_dev->rtnl_link_ops = &bond_link_ops; | 5085 | bond_dev->rtnl_link_ops = &bond_link_ops; |
5091 | 5086 | ||
5092 | if (!name) { | 5087 | if (!name) { |
@@ -5105,6 +5100,46 @@ out_netdev: | |||
5105 | goto out; | 5100 | goto out; |
5106 | } | 5101 | } |
5107 | 5102 | ||
5103 | static int bond_net_init(struct net *net) | ||
5104 | { | ||
5105 | struct bond_net *bn; | ||
5106 | int err; | ||
5107 | |||
5108 | err = -ENOMEM; | ||
5109 | bn = kzalloc(sizeof(struct bond_net), GFP_KERNEL); | ||
5110 | if (bn == NULL) | ||
5111 | goto out; | ||
5112 | |||
5113 | bn->net = net; | ||
5114 | INIT_LIST_HEAD(&bn->dev_list); | ||
5115 | |||
5116 | err = net_assign_generic(net, bond_net_id, bn); | ||
5117 | if (err) | ||
5118 | goto out_free; | ||
5119 | |||
5120 | bond_create_proc_dir(bn); | ||
5121 | out: | ||
5122 | return err; | ||
5123 | out_free: | ||
5124 | kfree(bn); | ||
5125 | goto out; | ||
5126 | } | ||
5127 | |||
5128 | static void bond_net_exit(struct net *net) | ||
5129 | { | ||
5130 | struct bond_net *bn; | ||
5131 | |||
5132 | bn = net_generic(net, bond_net_id); | ||
5133 | |||
5134 | bond_destroy_proc_dir(bn); | ||
5135 | kfree(bn); | ||
5136 | } | ||
5137 | |||
5138 | static struct pernet_operations bond_net_ops = { | ||
5139 | .init = bond_net_init, | ||
5140 | .exit = bond_net_exit, | ||
5141 | }; | ||
5142 | |||
5108 | static int __init bonding_init(void) | 5143 | static int __init bonding_init(void) |
5109 | { | 5144 | { |
5110 | int i; | 5145 | int i; |
@@ -5116,14 +5151,16 @@ static int __init bonding_init(void) | |||
5116 | if (res) | 5151 | if (res) |
5117 | goto out; | 5152 | goto out; |
5118 | 5153 | ||
5119 | bond_create_proc_dir(); | 5154 | res = register_pernet_gen_subsys(&bond_net_id, &bond_net_ops); |
5155 | if (res) | ||
5156 | goto out; | ||
5120 | 5157 | ||
5121 | res = rtnl_link_register(&bond_link_ops); | 5158 | res = rtnl_link_register(&bond_link_ops); |
5122 | if (res) | 5159 | if (res) |
5123 | goto err; | 5160 | goto err; |
5124 | 5161 | ||
5125 | for (i = 0; i < max_bonds; i++) { | 5162 | for (i = 0; i < max_bonds; i++) { |
5126 | res = bond_create(NULL); | 5163 | res = bond_create(&init_net, NULL); |
5127 | if (res) | 5164 | if (res) |
5128 | goto err; | 5165 | goto err; |
5129 | } | 5166 | } |
@@ -5139,7 +5176,7 @@ out: | |||
5139 | return res; | 5176 | return res; |
5140 | err: | 5177 | err: |
5141 | rtnl_link_unregister(&bond_link_ops); | 5178 | rtnl_link_unregister(&bond_link_ops); |
5142 | bond_destroy_proc_dir(); | 5179 | unregister_pernet_gen_subsys(bond_net_id, &bond_net_ops); |
5143 | goto out; | 5180 | goto out; |
5144 | 5181 | ||
5145 | } | 5182 | } |
@@ -5153,7 +5190,7 @@ static void __exit bonding_exit(void) | |||
5153 | bond_destroy_sysfs(); | 5190 | bond_destroy_sysfs(); |
5154 | 5191 | ||
5155 | rtnl_link_unregister(&bond_link_ops); | 5192 | rtnl_link_unregister(&bond_link_ops); |
5156 | bond_destroy_proc_dir(); | 5193 | unregister_pernet_gen_subsys(bond_net_id, &bond_net_ops); |
5157 | } | 5194 | } |
5158 | 5195 | ||
5159 | module_init(bonding_init); | 5196 | module_init(bonding_init); |
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", |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 013be296f0da..a51ae7dc8d51 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -30,8 +30,6 @@ | |||
30 | 30 | ||
31 | #define BOND_MAX_ARP_TARGETS 16 | 31 | #define BOND_MAX_ARP_TARGETS 16 |
32 | 32 | ||
33 | extern struct list_head bond_dev_list; | ||
34 | |||
35 | #define IS_UP(dev) \ | 33 | #define IS_UP(dev) \ |
36 | ((((dev)->flags & IFF_UP) == IFF_UP) && \ | 34 | ((((dev)->flags & IFF_UP) == IFF_UP) && \ |
37 | netif_running(dev) && \ | 35 | netif_running(dev) && \ |
@@ -327,7 +325,7 @@ static inline void bond_unset_master_alb_flags(struct bonding *bond) | |||
327 | 325 | ||
328 | struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); | 326 | struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); |
329 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); | 327 | int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); |
330 | int bond_create(const char *name); | 328 | int bond_create(struct net *net, const char *name); |
331 | int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); | 329 | int bond_release_and_destroy(struct net_device *bond_dev, struct net_device *slave_dev); |
332 | int bond_create_sysfs(void); | 330 | int bond_create_sysfs(void); |
333 | void bond_destroy_sysfs(void); | 331 | void bond_destroy_sysfs(void); |
@@ -346,8 +344,16 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active); | |||
346 | void bond_register_arp(struct bonding *); | 344 | void bond_register_arp(struct bonding *); |
347 | void bond_unregister_arp(struct bonding *); | 345 | void bond_unregister_arp(struct bonding *); |
348 | 346 | ||
347 | struct bond_net { | ||
348 | struct net * net; /* Associated network namespace */ | ||
349 | struct list_head dev_list; | ||
350 | #ifdef CONFIG_PROC_FS | ||
351 | struct proc_dir_entry * proc_dir; | ||
352 | #endif | ||
353 | }; | ||
354 | |||
349 | /* exported from bond_main.c */ | 355 | /* exported from bond_main.c */ |
350 | extern struct list_head bond_dev_list; | 356 | extern int bond_net_id; |
351 | extern const struct bond_parm_tbl bond_lacp_tbl[]; | 357 | extern const struct bond_parm_tbl bond_lacp_tbl[]; |
352 | extern const struct bond_parm_tbl bond_mode_tbl[]; | 358 | extern const struct bond_parm_tbl bond_mode_tbl[]; |
353 | extern const struct bond_parm_tbl xmit_hashtype_tbl[]; | 359 | extern const struct bond_parm_tbl xmit_hashtype_tbl[]; |