aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet
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
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')
-rw-r--r--net/decnet/af_decnet.c2
-rw-r--r--net/decnet/dn_dev.c20
-rw-r--r--net/decnet/dn_fib.c8
-rw-r--r--net/decnet/dn_route.c6
-rw-r--r--net/decnet/sysctl_net_decnet.c4
5 files changed, 20 insertions, 20 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 83398da5d763..aabe98d9402f 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -751,7 +751,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
751 if (dn_ntohs(saddr->sdn_nodeaddrl)) { 751 if (dn_ntohs(saddr->sdn_nodeaddrl)) {
752 read_lock(&dev_base_lock); 752 read_lock(&dev_base_lock);
753 ldev = NULL; 753 ldev = NULL;
754 for_each_netdev(dev) { 754 for_each_netdev(&init_net, dev) {
755 if (!dev->dn_ptr) 755 if (!dev->dn_ptr)
756 continue; 756 continue;
757 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) { 757 if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) {
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
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index d2bc19d47950..3760a20d10d0 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -212,7 +212,7 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct
212 return -EINVAL; 212 return -EINVAL;
213 if (dnet_addr_type(nh->nh_gw) != RTN_UNICAST) 213 if (dnet_addr_type(nh->nh_gw) != RTN_UNICAST)
214 return -EINVAL; 214 return -EINVAL;
215 if ((dev = __dev_get_by_index(nh->nh_oif)) == NULL) 215 if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL)
216 return -ENODEV; 216 return -ENODEV;
217 if (!(dev->flags&IFF_UP)) 217 if (!(dev->flags&IFF_UP))
218 return -ENETDOWN; 218 return -ENETDOWN;
@@ -255,7 +255,7 @@ out:
255 if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK)) 255 if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK))
256 return -EINVAL; 256 return -EINVAL;
257 257
258 dev = __dev_get_by_index(nh->nh_oif); 258 dev = __dev_get_by_index(&init_net, nh->nh_oif);
259 if (dev == NULL || dev->dn_ptr == NULL) 259 if (dev == NULL || dev->dn_ptr == NULL)
260 return -ENODEV; 260 return -ENODEV;
261 if (!(dev->flags&IFF_UP)) 261 if (!(dev->flags&IFF_UP))
@@ -355,7 +355,7 @@ struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, struct dn_kern_rta
355 if (nhs != 1 || nh->nh_gw) 355 if (nhs != 1 || nh->nh_gw)
356 goto err_inval; 356 goto err_inval;
357 nh->nh_scope = RT_SCOPE_NOWHERE; 357 nh->nh_scope = RT_SCOPE_NOWHERE;
358 nh->nh_dev = dev_get_by_index(fi->fib_nh->nh_oif); 358 nh->nh_dev = dev_get_by_index(&init_net, fi->fib_nh->nh_oif);
359 err = -ENODEV; 359 err = -ENODEV;
360 if (nh->nh_dev == NULL) 360 if (nh->nh_dev == NULL)
361 goto failure; 361 goto failure;
@@ -602,7 +602,7 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
602 602
603 /* Scan device list */ 603 /* Scan device list */
604 read_lock(&dev_base_lock); 604 read_lock(&dev_base_lock);
605 for_each_netdev(dev) { 605 for_each_netdev(&init_net, dev) {
606 dn_db = dev->dn_ptr; 606 dn_db = dev->dn_ptr;
607 if (dn_db == NULL) 607 if (dn_db == NULL)
608 continue; 608 continue;
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 580e786d0c38..70b1c3fa00f3 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -908,7 +908,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
908 908
909 /* If we have an output interface, verify its a DECnet device */ 909 /* If we have an output interface, verify its a DECnet device */
910 if (oldflp->oif) { 910 if (oldflp->oif) {
911 dev_out = dev_get_by_index(oldflp->oif); 911 dev_out = dev_get_by_index(&init_net, oldflp->oif);
912 err = -ENODEV; 912 err = -ENODEV;
913 if (dev_out && dev_out->dn_ptr == NULL) { 913 if (dev_out && dev_out->dn_ptr == NULL) {
914 dev_put(dev_out); 914 dev_put(dev_out);
@@ -929,7 +929,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
929 goto out; 929 goto out;
930 } 930 }
931 read_lock(&dev_base_lock); 931 read_lock(&dev_base_lock);
932 for_each_netdev(dev) { 932 for_each_netdev(&init_net, dev) {
933 if (!dev->dn_ptr) 933 if (!dev->dn_ptr)
934 continue; 934 continue;
935 if (!dn_dev_islocal(dev, oldflp->fld_src)) 935 if (!dn_dev_islocal(dev, oldflp->fld_src))
@@ -1556,7 +1556,7 @@ static int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
1556 1556
1557 if (fl.iif) { 1557 if (fl.iif) {
1558 struct net_device *dev; 1558 struct net_device *dev;
1559 if ((dev = dev_get_by_index(fl.iif)) == NULL) { 1559 if ((dev = dev_get_by_index(&init_net, fl.iif)) == NULL) {
1560 kfree_skb(skb); 1560 kfree_skb(skb);
1561 return -ENODEV; 1561 return -ENODEV;
1562 } 1562 }
diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
index 52e40d7eb22d..ae354a43fb97 100644
--- a/net/decnet/sysctl_net_decnet.c
+++ b/net/decnet/sysctl_net_decnet.c
@@ -259,7 +259,7 @@ static int dn_def_dev_strategy(ctl_table *table, int __user *name, int nlen,
259 259
260 devname[newlen] = 0; 260 devname[newlen] = 0;
261 261
262 dev = dev_get_by_name(devname); 262 dev = dev_get_by_name(&init_net, devname);
263 if (dev == NULL) 263 if (dev == NULL)
264 return -ENODEV; 264 return -ENODEV;
265 265
@@ -299,7 +299,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
299 devname[*lenp] = 0; 299 devname[*lenp] = 0;
300 strip_it(devname); 300 strip_it(devname);
301 301
302 dev = dev_get_by_name(devname); 302 dev = dev_get_by_name(&init_net, devname);
303 if (dev == NULL) 303 if (dev == NULL)
304 return -ENODEV; 304 return -ENODEV;
305 305