aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.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/ipv6/addrconf.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/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1a6783646520..ee55be975407 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -450,7 +450,7 @@ static void addrconf_forward_change(void)
450 struct inet6_dev *idev; 450 struct inet6_dev *idev;
451 451
452 read_lock(&dev_base_lock); 452 read_lock(&dev_base_lock);
453 for_each_netdev(dev) { 453 for_each_netdev(&init_net, dev) {
454 rcu_read_lock(); 454 rcu_read_lock();
455 idev = __in6_dev_get(dev); 455 idev = __in6_dev_get(dev);
456 if (idev) { 456 if (idev) {
@@ -912,7 +912,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
912 read_lock(&dev_base_lock); 912 read_lock(&dev_base_lock);
913 rcu_read_lock(); 913 rcu_read_lock();
914 914
915 for_each_netdev(dev) { 915 for_each_netdev(&init_net, dev) {
916 struct inet6_dev *idev; 916 struct inet6_dev *idev;
917 struct inet6_ifaddr *ifa; 917 struct inet6_ifaddr *ifa;
918 918
@@ -1858,7 +1858,7 @@ int addrconf_set_dstaddr(void __user *arg)
1858 if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq))) 1858 if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
1859 goto err_exit; 1859 goto err_exit;
1860 1860
1861 dev = __dev_get_by_index(ireq.ifr6_ifindex); 1861 dev = __dev_get_by_index(&init_net, ireq.ifr6_ifindex);
1862 1862
1863 err = -ENODEV; 1863 err = -ENODEV;
1864 if (dev == NULL) 1864 if (dev == NULL)
@@ -1889,7 +1889,7 @@ int addrconf_set_dstaddr(void __user *arg)
1889 1889
1890 if (err == 0) { 1890 if (err == 0) {
1891 err = -ENOBUFS; 1891 err = -ENOBUFS;
1892 if ((dev = __dev_get_by_name(p.name)) == NULL) 1892 if ((dev = __dev_get_by_name(&init_net, p.name)) == NULL)
1893 goto err_exit; 1893 goto err_exit;
1894 err = dev_open(dev); 1894 err = dev_open(dev);
1895 } 1895 }
@@ -1919,7 +1919,7 @@ static int inet6_addr_add(int ifindex, struct in6_addr *pfx, int plen,
1919 if (!valid_lft || prefered_lft > valid_lft) 1919 if (!valid_lft || prefered_lft > valid_lft)
1920 return -EINVAL; 1920 return -EINVAL;
1921 1921
1922 if ((dev = __dev_get_by_index(ifindex)) == NULL) 1922 if ((dev = __dev_get_by_index(&init_net, ifindex)) == NULL)
1923 return -ENODEV; 1923 return -ENODEV;
1924 1924
1925 if ((idev = addrconf_add_dev(dev)) == NULL) 1925 if ((idev = addrconf_add_dev(dev)) == NULL)
@@ -1970,7 +1970,7 @@ static int inet6_addr_del(int ifindex, struct in6_addr *pfx, int plen)
1970 struct inet6_dev *idev; 1970 struct inet6_dev *idev;
1971 struct net_device *dev; 1971 struct net_device *dev;
1972 1972
1973 if ((dev = __dev_get_by_index(ifindex)) == NULL) 1973 if ((dev = __dev_get_by_index(&init_net, ifindex)) == NULL)
1974 return -ENODEV; 1974 return -ENODEV;
1975 1975
1976 if ((idev = __in6_dev_get(dev)) == NULL) 1976 if ((idev = __in6_dev_get(dev)) == NULL)
@@ -2065,7 +2065,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
2065 return; 2065 return;
2066 } 2066 }
2067 2067
2068 for_each_netdev(dev) { 2068 for_each_netdev(&init_net, dev) {
2069 struct in_device * in_dev = __in_dev_get_rtnl(dev); 2069 struct in_device * in_dev = __in_dev_get_rtnl(dev);
2070 if (in_dev && (dev->flags & IFF_UP)) { 2070 if (in_dev && (dev->flags & IFF_UP)) {
2071 struct in_ifaddr * ifa; 2071 struct in_ifaddr * ifa;
@@ -2221,12 +2221,12 @@ static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
2221 2221
2222 /* first try to inherit the link-local address from the link device */ 2222 /* first try to inherit the link-local address from the link device */
2223 if (idev->dev->iflink && 2223 if (idev->dev->iflink &&
2224 (link_dev = __dev_get_by_index(idev->dev->iflink))) { 2224 (link_dev = __dev_get_by_index(&init_net, idev->dev->iflink))) {
2225 if (!ipv6_inherit_linklocal(idev, link_dev)) 2225 if (!ipv6_inherit_linklocal(idev, link_dev))
2226 return; 2226 return;
2227 } 2227 }
2228 /* then try to inherit it from any device */ 2228 /* then try to inherit it from any device */
2229 for_each_netdev(link_dev) { 2229 for_each_netdev(&init_net, link_dev) {
2230 if (!ipv6_inherit_linklocal(idev, link_dev)) 2230 if (!ipv6_inherit_linklocal(idev, link_dev))
2231 return; 2231 return;
2232 } 2232 }
@@ -3084,7 +3084,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
3084 valid_lft = INFINITY_LIFE_TIME; 3084 valid_lft = INFINITY_LIFE_TIME;
3085 } 3085 }
3086 3086
3087 dev = __dev_get_by_index(ifm->ifa_index); 3087 dev = __dev_get_by_index(&init_net, ifm->ifa_index);
3088 if (dev == NULL) 3088 if (dev == NULL)
3089 return -ENODEV; 3089 return -ENODEV;
3090 3090
@@ -3268,7 +3268,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
3268 s_ip_idx = ip_idx = cb->args[1]; 3268 s_ip_idx = ip_idx = cb->args[1];
3269 3269
3270 idx = 0; 3270 idx = 0;
3271 for_each_netdev(dev) { 3271 for_each_netdev(&init_net, dev) {
3272 if (idx < s_idx) 3272 if (idx < s_idx)
3273 goto cont; 3273 goto cont;
3274 if (idx > s_idx) 3274 if (idx > s_idx)
@@ -3377,7 +3377,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
3377 3377
3378 ifm = nlmsg_data(nlh); 3378 ifm = nlmsg_data(nlh);
3379 if (ifm->ifa_index) 3379 if (ifm->ifa_index)
3380 dev = __dev_get_by_index(ifm->ifa_index); 3380 dev = __dev_get_by_index(&init_net, ifm->ifa_index);
3381 3381
3382 if ((ifa = ipv6_get_ifaddr(addr, dev, 1)) == NULL) { 3382 if ((ifa = ipv6_get_ifaddr(addr, dev, 1)) == NULL) {
3383 err = -EADDRNOTAVAIL; 3383 err = -EADDRNOTAVAIL;
@@ -3589,7 +3589,7 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
3589 3589
3590 read_lock(&dev_base_lock); 3590 read_lock(&dev_base_lock);
3591 idx = 0; 3591 idx = 0;
3592 for_each_netdev(dev) { 3592 for_each_netdev(&init_net, dev) {
3593 if (idx < s_idx) 3593 if (idx < s_idx)
3594 goto cont; 3594 goto cont;
3595 if ((idev = in6_dev_get(dev)) == NULL) 3595 if ((idev = in6_dev_get(dev)) == NULL)
@@ -4266,7 +4266,7 @@ void __exit addrconf_cleanup(void)
4266 * clean dev list. 4266 * clean dev list.
4267 */ 4267 */
4268 4268
4269 for_each_netdev(dev) { 4269 for_each_netdev(&init_net, dev) {
4270 if (__in6_dev_get(dev) == NULL) 4270 if (__in6_dev_get(dev) == NULL)
4271 continue; 4271 continue;
4272 addrconf_ifdown(dev, 1); 4272 addrconf_ifdown(dev, 1);