aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-04-16 03:55:06 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-16 03:56:37 -0400
commit65d292a2ef2df66fd1ab83447afee71ef3720ded (patch)
treed3ac632109448ab07f0fef3fe767dca66d183149
parent7a17a2f79f54a988d08ffa33ec9e1038bffec42b (diff)
[VLAN]: Allow vlan devices registration in net namespaces.
This one is similar to what I've done for TUN - set the proper net after device allocation and clean VLANs on net exit (use the rtnl_kill_links helper finally). Plus, drop explicit init_net usage and net != &init_net checks. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/8021q/vlan.c7
-rw-r--r--net/8021q/vlan_dev.c3
-rw-r--r--net/8021q/vlan_netlink.c2
3 files changed, 4 insertions, 8 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 5cacad0671db..7e9d22ec7d45 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -340,6 +340,7 @@ static int register_vlan_device(struct net_device *real_dev,
340 if (new_dev == NULL) 340 if (new_dev == NULL)
341 return -ENOBUFS; 341 return -ENOBUFS;
342 342
343 dev_net_set(new_dev, net);
343 /* need 4 bytes for extra VLAN header info, 344 /* need 4 bytes for extra VLAN header info,
344 * hope the underlying device can handle it. 345 * hope the underlying device can handle it.
345 */ 346 */
@@ -406,9 +407,6 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
406 int i, flgs; 407 int i, flgs;
407 struct net_device *vlandev; 408 struct net_device *vlandev;
408 409
409 if (dev_net(dev) != &init_net)
410 return NOTIFY_DONE;
411
412 if (is_vlan_dev(dev)) { 410 if (is_vlan_dev(dev)) {
413 __vlan_device_event(dev, event); 411 __vlan_device_event(dev, event);
414 goto out; 412 goto out;
@@ -534,7 +532,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
534 case GET_VLAN_REALDEV_NAME_CMD: 532 case GET_VLAN_REALDEV_NAME_CMD:
535 case GET_VLAN_VID_CMD: 533 case GET_VLAN_VID_CMD:
536 err = -ENODEV; 534 err = -ENODEV;
537 dev = __dev_get_by_name(&init_net, args.device1); 535 dev = __dev_get_by_name(net, args.device1);
538 if (!dev) 536 if (!dev)
539 goto out; 537 goto out;
540 538
@@ -665,6 +663,7 @@ static void vlan_exit_net(struct net *net)
665 struct vlan_net *vn; 663 struct vlan_net *vn;
666 664
667 vn = net_generic(net, vlan_net_id); 665 vn = net_generic(net, vlan_net_id);
666 rtnl_kill_links(net, &vlan_link_ops);
668 vlan_proc_cleanup(net); 667 vlan_proc_cleanup(net);
669 kfree(vn); 668 kfree(vn);
670} 669}
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4ae0d7ef62c1..c961f0826005 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -153,9 +153,6 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
153 struct net_device_stats *stats; 153 struct net_device_stats *stats;
154 unsigned short vlan_TCI; 154 unsigned short vlan_TCI;
155 155
156 if (dev_net(dev) != &init_net)
157 goto err_free;
158
159 skb = skb_share_check(skb, GFP_ATOMIC); 156 skb = skb_share_check(skb, GFP_ATOMIC);
160 if (skb == NULL) 157 if (skb == NULL)
161 goto err_free; 158 goto err_free;
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
index e32eeb37987e..c93e69ec28ed 100644
--- a/net/8021q/vlan_netlink.c
+++ b/net/8021q/vlan_netlink.c
@@ -113,7 +113,7 @@ static int vlan_newlink(struct net_device *dev,
113 113
114 if (!tb[IFLA_LINK]) 114 if (!tb[IFLA_LINK])
115 return -EINVAL; 115 return -EINVAL;
116 real_dev = __dev_get_by_index(&init_net, nla_get_u32(tb[IFLA_LINK])); 116 real_dev = __dev_get_by_index(dev_net(dev), nla_get_u32(tb[IFLA_LINK]));
117 if (!real_dev) 117 if (!real_dev)
118 return -ENODEV; 118 return -ENODEV;
119 119