aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/dn_dev.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2007-09-17 14:56:21 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:49:10 -0400
commit881d966b48b035ab3f3aeaae0f3d3f9b584f45b2 (patch)
treec579d59a4107cbbe9e2b85939bc0d496b815c887 /net/decnet/dn_dev.c
parentb4b510290b056b86611757ce1175a230f1080f53 (diff)
[NET]: Make the device list and device lookups per namespace.
This patch makes most of the generic device layer network namespace safe. This patch makes dev_base_head a network namespace variable, and then it picks up a few associated variables. The functions: dev_getbyhwaddr dev_getfirsthwbytype dev_get_by_flags dev_get_by_name __dev_get_by_name dev_get_by_index __dev_get_by_index dev_ioctl dev_ethtool dev_load wireless_process_ioctl were modified to take a network namespace argument, and deal with it. vlan_ioctl_set and brioctl_set were modified so their hooks will receive a network namespace argument. So basically anthing in the core of the network stack that was affected to by the change of dev_base was modified to handle multiple network namespaces. The rest of the network stack was simply modified to explicitly use &init_net the initial network namespace. This can be fixed when those components of the network stack are modified to handle multiple network namespaces. For now the ifindex generator is left global. Fundametally ifindex numbers are per namespace, or else we will have corner case problems with migration when we get that far. At the same time there are assumptions in the network stack that the ifindex of a network device won't change. Making the ifindex number global seems a good compromise until the network stack can cope with ifindex changes when you change namespaces, and the like. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/decnet/dn_dev.c')
-rw-r--r--net/decnet/dn_dev.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 83cb0761336a..ddfd2aff44d8 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -513,7 +513,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
513 ifr->ifr_name[IFNAMSIZ-1] = 0; 513 ifr->ifr_name[IFNAMSIZ-1] = 0;
514 514
515#ifdef CONFIG_KMOD 515#ifdef CONFIG_KMOD
516 dev_load(ifr->ifr_name); 516 dev_load(&init_net, ifr->ifr_name);
517#endif 517#endif
518 518
519 switch(cmd) { 519 switch(cmd) {
@@ -531,7 +531,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
531 531
532 rtnl_lock(); 532 rtnl_lock();
533 533
534 if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL) { 534 if ((dev = __dev_get_by_name(&init_net, ifr->ifr_name)) == NULL) {
535 ret = -ENODEV; 535 ret = -ENODEV;
536 goto done; 536 goto done;
537 } 537 }
@@ -629,7 +629,7 @@ static struct dn_dev *dn_dev_by_index(int ifindex)
629{ 629{
630 struct net_device *dev; 630 struct net_device *dev;
631 struct dn_dev *dn_dev = NULL; 631 struct dn_dev *dn_dev = NULL;
632 dev = dev_get_by_index(ifindex); 632 dev = dev_get_by_index(&init_net, ifindex);
633 if (dev) { 633 if (dev) {
634 dn_dev = dev->dn_ptr; 634 dn_dev = dev->dn_ptr;
635 dev_put(dev); 635 dev_put(dev);
@@ -694,7 +694,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
694 return -EINVAL; 694 return -EINVAL;
695 695
696 ifm = nlmsg_data(nlh); 696 ifm = nlmsg_data(nlh);
697 if ((dev = __dev_get_by_index(ifm->ifa_index)) == NULL) 697 if ((dev = __dev_get_by_index(&init_net, ifm->ifa_index)) == NULL)
698 return -ENODEV; 698 return -ENODEV;
699 699
700 if ((dn_db = dev->dn_ptr) == NULL) { 700 if ((dn_db = dev->dn_ptr) == NULL) {
@@ -800,7 +800,7 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
800 skip_naddr = cb->args[1]; 800 skip_naddr = cb->args[1];
801 801
802 idx = 0; 802 idx = 0;
803 for_each_netdev(dev) { 803 for_each_netdev(&init_net, dev) {
804 if (idx < skip_ndevs) 804 if (idx < skip_ndevs)
805 goto cont; 805 goto cont;
806 else if (idx > skip_ndevs) { 806 else if (idx > skip_ndevs) {
@@ -1297,7 +1297,7 @@ void dn_dev_devices_off(void)
1297 struct net_device *dev; 1297 struct net_device *dev;
1298 1298
1299 rtnl_lock(); 1299 rtnl_lock();
1300 for_each_netdev(dev) 1300 for_each_netdev(&init_net, dev)
1301 dn_dev_down(dev); 1301 dn_dev_down(dev);
1302 rtnl_unlock(); 1302 rtnl_unlock();
1303 1303
@@ -1308,7 +1308,7 @@ void dn_dev_devices_on(void)
1308 struct net_device *dev; 1308 struct net_device *dev;
1309 1309
1310 rtnl_lock(); 1310 rtnl_lock();
1311 for_each_netdev(dev) { 1311 for_each_netdev(&init_net, dev) {
1312 if (dev->flags & IFF_UP) 1312 if (dev->flags & IFF_UP)
1313 dn_dev_up(dev); 1313 dn_dev_up(dev);
1314 } 1314 }
@@ -1342,7 +1342,7 @@ static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
1342 return SEQ_START_TOKEN; 1342 return SEQ_START_TOKEN;
1343 1343
1344 i = 1; 1344 i = 1;
1345 for_each_netdev(dev) { 1345 for_each_netdev(&init_net, dev) {
1346 if (!is_dn_dev(dev)) 1346 if (!is_dn_dev(dev))
1347 continue; 1347 continue;
1348 1348
@@ -1361,9 +1361,9 @@ static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1361 1361
1362 dev = (struct net_device *)v; 1362 dev = (struct net_device *)v;
1363 if (v == SEQ_START_TOKEN) 1363 if (v == SEQ_START_TOKEN)
1364 dev = net_device_entry(&dev_base_head); 1364 dev = net_device_entry(&init_net.dev_base_head);
1365 1365
1366 for_each_netdev_continue(dev) { 1366 for_each_netdev_continue(&init_net, dev) {
1367 if (!is_dn_dev(dev)) 1367 if (!is_dn_dev(dev))
1368 continue; 1368 continue;
1369 1369