aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/devinet.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/ipv4/devinet.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/ipv4/devinet.c')
-rw-r--r--net/ipv4/devinet.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index c5eb1a29a5cf..721b89b60963 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -420,7 +420,7 @@ struct in_device *inetdev_by_index(int ifindex)
420 struct net_device *dev; 420 struct net_device *dev;
421 struct in_device *in_dev = NULL; 421 struct in_device *in_dev = NULL;
422 read_lock(&dev_base_lock); 422 read_lock(&dev_base_lock);
423 dev = __dev_get_by_index(ifindex); 423 dev = __dev_get_by_index(&init_net, ifindex);
424 if (dev) 424 if (dev)
425 in_dev = in_dev_get(dev); 425 in_dev = in_dev_get(dev);
426 read_unlock(&dev_base_lock); 426 read_unlock(&dev_base_lock);
@@ -506,7 +506,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
506 goto errout; 506 goto errout;
507 } 507 }
508 508
509 dev = __dev_get_by_index(ifm->ifa_index); 509 dev = __dev_get_by_index(&init_net, ifm->ifa_index);
510 if (dev == NULL) { 510 if (dev == NULL) {
511 err = -ENODEV; 511 err = -ENODEV;
512 goto errout; 512 goto errout;
@@ -628,7 +628,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
628 *colon = 0; 628 *colon = 0;
629 629
630#ifdef CONFIG_KMOD 630#ifdef CONFIG_KMOD
631 dev_load(ifr.ifr_name); 631 dev_load(&init_net, ifr.ifr_name);
632#endif 632#endif
633 633
634 switch (cmd) { 634 switch (cmd) {
@@ -669,7 +669,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
669 rtnl_lock(); 669 rtnl_lock();
670 670
671 ret = -ENODEV; 671 ret = -ENODEV;
672 if ((dev = __dev_get_by_name(ifr.ifr_name)) == NULL) 672 if ((dev = __dev_get_by_name(&init_net, ifr.ifr_name)) == NULL)
673 goto done; 673 goto done;
674 674
675 if (colon) 675 if (colon)
@@ -909,7 +909,7 @@ no_in_dev:
909 */ 909 */
910 read_lock(&dev_base_lock); 910 read_lock(&dev_base_lock);
911 rcu_read_lock(); 911 rcu_read_lock();
912 for_each_netdev(dev) { 912 for_each_netdev(&init_net, dev) {
913 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) 913 if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
914 continue; 914 continue;
915 915
@@ -988,7 +988,7 @@ __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local,
988 988
989 read_lock(&dev_base_lock); 989 read_lock(&dev_base_lock);
990 rcu_read_lock(); 990 rcu_read_lock();
991 for_each_netdev(dev) { 991 for_each_netdev(&init_net, dev) {
992 if ((in_dev = __in_dev_get_rcu(dev))) { 992 if ((in_dev = __in_dev_get_rcu(dev))) {
993 addr = confirm_addr_indev(in_dev, dst, local, scope); 993 addr = confirm_addr_indev(in_dev, dst, local, scope);
994 if (addr) 994 if (addr)
@@ -1185,7 +1185,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
1185 1185
1186 s_ip_idx = ip_idx = cb->args[1]; 1186 s_ip_idx = ip_idx = cb->args[1];
1187 idx = 0; 1187 idx = 0;
1188 for_each_netdev(dev) { 1188 for_each_netdev(&init_net, dev) {
1189 if (idx < s_idx) 1189 if (idx < s_idx)
1190 goto cont; 1190 goto cont;
1191 if (idx > s_idx) 1191 if (idx > s_idx)
@@ -1244,7 +1244,7 @@ static void devinet_copy_dflt_conf(int i)
1244 struct net_device *dev; 1244 struct net_device *dev;
1245 1245
1246 read_lock(&dev_base_lock); 1246 read_lock(&dev_base_lock);
1247 for_each_netdev(dev) { 1247 for_each_netdev(&init_net, dev) {
1248 struct in_device *in_dev; 1248 struct in_device *in_dev;
1249 rcu_read_lock(); 1249 rcu_read_lock();
1250 in_dev = __in_dev_get_rcu(dev); 1250 in_dev = __in_dev_get_rcu(dev);
@@ -1333,7 +1333,7 @@ void inet_forward_change(void)
1333 IPV4_DEVCONF_DFLT(FORWARDING) = on; 1333 IPV4_DEVCONF_DFLT(FORWARDING) = on;
1334 1334
1335 read_lock(&dev_base_lock); 1335 read_lock(&dev_base_lock);
1336 for_each_netdev(dev) { 1336 for_each_netdev(&init_net, dev) {
1337 struct in_device *in_dev; 1337 struct in_device *in_dev;
1338 rcu_read_lock(); 1338 rcu_read_lock();
1339 in_dev = __in_dev_get_rcu(dev); 1339 in_dev = __in_dev_get_rcu(dev);