aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipvs
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/ipvs
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/ipvs')
-rw-r--r--net/ipv4/ipvs/ip_vs_sync.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
index 356f067484e3..1960747f354c 100644
--- a/net/ipv4/ipvs/ip_vs_sync.c
+++ b/net/ipv4/ipvs/ip_vs_sync.c
@@ -387,7 +387,7 @@ static int set_mcast_if(struct sock *sk, char *ifname)
387 struct net_device *dev; 387 struct net_device *dev;
388 struct inet_sock *inet = inet_sk(sk); 388 struct inet_sock *inet = inet_sk(sk);
389 389
390 if ((dev = __dev_get_by_name(ifname)) == NULL) 390 if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
391 return -ENODEV; 391 return -ENODEV;
392 392
393 if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if) 393 if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
@@ -412,7 +412,7 @@ static int set_sync_mesg_maxlen(int sync_state)
412 int num; 412 int num;
413 413
414 if (sync_state == IP_VS_STATE_MASTER) { 414 if (sync_state == IP_VS_STATE_MASTER) {
415 if ((dev = __dev_get_by_name(ip_vs_master_mcast_ifn)) == NULL) 415 if ((dev = __dev_get_by_name(&init_net, ip_vs_master_mcast_ifn)) == NULL)
416 return -ENODEV; 416 return -ENODEV;
417 417
418 num = (dev->mtu - sizeof(struct iphdr) - 418 num = (dev->mtu - sizeof(struct iphdr) -
@@ -423,7 +423,7 @@ static int set_sync_mesg_maxlen(int sync_state)
423 IP_VS_DBG(7, "setting the maximum length of sync sending " 423 IP_VS_DBG(7, "setting the maximum length of sync sending "
424 "message %d.\n", sync_send_mesg_maxlen); 424 "message %d.\n", sync_send_mesg_maxlen);
425 } else if (sync_state == IP_VS_STATE_BACKUP) { 425 } else if (sync_state == IP_VS_STATE_BACKUP) {
426 if ((dev = __dev_get_by_name(ip_vs_backup_mcast_ifn)) == NULL) 426 if ((dev = __dev_get_by_name(&init_net, ip_vs_backup_mcast_ifn)) == NULL)
427 return -ENODEV; 427 return -ENODEV;
428 428
429 sync_recv_mesg_maxlen = dev->mtu - 429 sync_recv_mesg_maxlen = dev->mtu -
@@ -451,7 +451,7 @@ join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
451 memset(&mreq, 0, sizeof(mreq)); 451 memset(&mreq, 0, sizeof(mreq));
452 memcpy(&mreq.imr_multiaddr, addr, sizeof(struct in_addr)); 452 memcpy(&mreq.imr_multiaddr, addr, sizeof(struct in_addr));
453 453
454 if ((dev = __dev_get_by_name(ifname)) == NULL) 454 if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
455 return -ENODEV; 455 return -ENODEV;
456 if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if) 456 if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
457 return -EINVAL; 457 return -EINVAL;
@@ -472,7 +472,7 @@ static int bind_mcastif_addr(struct socket *sock, char *ifname)
472 __be32 addr; 472 __be32 addr;
473 struct sockaddr_in sin; 473 struct sockaddr_in sin;
474 474
475 if ((dev = __dev_get_by_name(ifname)) == NULL) 475 if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
476 return -ENODEV; 476 return -ENODEV;
477 477
478 addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE); 478 addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);