diff options
99 files changed, 555 insertions, 362 deletions
diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c index 2180ac105b05..6c1815a47714 100644 --- a/arch/s390/appldata/appldata_net_sum.c +++ b/arch/s390/appldata/appldata_net_sum.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/kernel_stat.h> | 17 | #include <linux/kernel_stat.h> |
18 | #include <linux/netdevice.h> | 18 | #include <linux/netdevice.h> |
19 | #include <net/net_namespace.h> | ||
19 | 20 | ||
20 | #include "appldata.h" | 21 | #include "appldata.h" |
21 | 22 | ||
@@ -107,7 +108,7 @@ static void appldata_get_net_sum_data(void *data) | |||
107 | tx_dropped = 0; | 108 | tx_dropped = 0; |
108 | collisions = 0; | 109 | collisions = 0; |
109 | read_lock(&dev_base_lock); | 110 | read_lock(&dev_base_lock); |
110 | for_each_netdev(dev) { | 111 | for_each_netdev(&init_net, dev) { |
111 | stats = dev->get_stats(dev); | 112 | stats = dev->get_stats(dev); |
112 | rx_packets += stats->rx_packets; | 113 | rx_packets += stats->rx_packets; |
113 | tx_packets += stats->tx_packets; | 114 | tx_packets += stats->tx_packets; |
diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c index 18352a498628..8ad10a6d993b 100644 --- a/arch/sparc64/solaris/ioctl.c +++ b/arch/sparc64/solaris/ioctl.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/compat.h> | 28 | #include <linux/compat.h> |
29 | 29 | ||
30 | #include <net/sock.h> | 30 | #include <net/sock.h> |
31 | #include <net/net_namespace.h> | ||
31 | 32 | ||
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
33 | #include <asm/termios.h> | 34 | #include <asm/termios.h> |
@@ -686,7 +687,7 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg) | |||
686 | int i = 0; | 687 | int i = 0; |
687 | 688 | ||
688 | read_lock_bh(&dev_base_lock); | 689 | read_lock_bh(&dev_base_lock); |
689 | for_each_netdev(d) | 690 | for_each_netdev(&init_net, d) |
690 | i++; | 691 | i++; |
691 | read_unlock_bh(&dev_base_lock); | 692 | read_unlock_bh(&dev_base_lock); |
692 | 693 | ||
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c index f8b1700f4c16..eee54c0cde68 100644 --- a/drivers/atm/idt77252.c +++ b/drivers/atm/idt77252.c | |||
@@ -3576,7 +3576,7 @@ init_card(struct atm_dev *dev) | |||
3576 | * XXX: <hack> | 3576 | * XXX: <hack> |
3577 | */ | 3577 | */ |
3578 | sprintf(tname, "eth%d", card->index); | 3578 | sprintf(tname, "eth%d", card->index); |
3579 | tmp = dev_get_by_name(tname); /* jhs: was "tmp = dev_get(tname);" */ | 3579 | tmp = dev_get_by_name(&init_net, tname); /* jhs: was "tmp = dev_get(tname);" */ |
3580 | if (tmp) { | 3580 | if (tmp) { |
3581 | memcpy(card->atmdev->esi, tmp->dev_addr, 6); | 3581 | memcpy(card->atmdev->esi, tmp->dev_addr, 6); |
3582 | 3582 | ||
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 01fbdd38e3be..30394f78cac2 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/skbuff.h> | 9 | #include <linux/skbuff.h> |
10 | #include <linux/netdevice.h> | 10 | #include <linux/netdevice.h> |
11 | #include <linux/genhd.h> | 11 | #include <linux/genhd.h> |
12 | #include <net/net_namespace.h> | ||
12 | #include <asm/unaligned.h> | 13 | #include <asm/unaligned.h> |
13 | #include "aoe.h" | 14 | #include "aoe.h" |
14 | 15 | ||
@@ -194,7 +195,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail) | |||
194 | sl = sl_tail = NULL; | 195 | sl = sl_tail = NULL; |
195 | 196 | ||
196 | read_lock(&dev_base_lock); | 197 | read_lock(&dev_base_lock); |
197 | for_each_netdev(ifp) { | 198 | for_each_netdev(&init_net, ifp) { |
198 | dev_hold(ifp); | 199 | dev_hold(ifp); |
199 | if (!is_aoe_netif(ifp)) | 200 | if (!is_aoe_netif(ifp)) |
200 | goto cont; | 201 | goto cont; |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c index beb2a381467f..eec6a30840ca 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.c +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/spinlock.h> | 37 | #include <linux/spinlock.h> |
38 | #include <linux/pci.h> | 38 | #include <linux/pci.h> |
39 | #include <linux/dma-mapping.h> | 39 | #include <linux/dma-mapping.h> |
40 | #include <net/net_namespace.h> | ||
40 | 41 | ||
41 | #include "cxio_resource.h" | 42 | #include "cxio_resource.h" |
42 | #include "cxio_hal.h" | 43 | #include "cxio_hal.h" |
@@ -894,7 +895,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p) | |||
894 | if (cxio_hal_find_rdev_by_name(rdev_p->dev_name)) { | 895 | if (cxio_hal_find_rdev_by_name(rdev_p->dev_name)) { |
895 | return -EBUSY; | 896 | return -EBUSY; |
896 | } | 897 | } |
897 | netdev_p = dev_get_by_name(rdev_p->dev_name); | 898 | netdev_p = dev_get_by_name(&init_net, rdev_p->dev_name); |
898 | if (!netdev_p) { | 899 | if (!netdev_p) { |
899 | return -EINVAL; | 900 | return -EINVAL; |
900 | } | 901 | } |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index cf97d8a6326e..559fe9437e0b 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -3719,7 +3719,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3719 | } | 3719 | } |
3720 | 3720 | ||
3721 | down_write(&(bonding_rwsem)); | 3721 | down_write(&(bonding_rwsem)); |
3722 | slave_dev = dev_get_by_name(ifr->ifr_slave); | 3722 | slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave); |
3723 | 3723 | ||
3724 | dprintk("slave_dev=%p: \n", slave_dev); | 3724 | dprintk("slave_dev=%p: \n", slave_dev); |
3725 | 3725 | ||
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 60cccf2aa959..8289e27a360a 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/ctype.h> | 35 | #include <linux/ctype.h> |
36 | #include <linux/inet.h> | 36 | #include <linux/inet.h> |
37 | #include <linux/rtnetlink.h> | 37 | #include <linux/rtnetlink.h> |
38 | #include <net/net_namespace.h> | ||
38 | 39 | ||
39 | /* #define BONDING_DEBUG 1 */ | 40 | /* #define BONDING_DEBUG 1 */ |
40 | #include "bonding.h" | 41 | #include "bonding.h" |
@@ -299,7 +300,7 @@ static ssize_t bonding_store_slaves(struct device *d, | |||
299 | read_unlock_bh(&bond->lock); | 300 | read_unlock_bh(&bond->lock); |
300 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", | 301 | printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", |
301 | bond->dev->name, ifname); | 302 | bond->dev->name, ifname); |
302 | dev = dev_get_by_name(ifname); | 303 | dev = dev_get_by_name(&init_net, ifname); |
303 | if (!dev) { | 304 | if (!dev) { |
304 | printk(KERN_INFO DRV_NAME | 305 | printk(KERN_INFO DRV_NAME |
305 | ": %s: Interface %s does not exist!\n", | 306 | ": %s: Interface %s does not exist!\n", |
diff --git a/drivers/net/eql.c b/drivers/net/eql.c index 102218c4a907..f1cc66dcbdfd 100644 --- a/drivers/net/eql.c +++ b/drivers/net/eql.c | |||
@@ -116,6 +116,7 @@ | |||
116 | #include <linux/init.h> | 116 | #include <linux/init.h> |
117 | #include <linux/timer.h> | 117 | #include <linux/timer.h> |
118 | #include <linux/netdevice.h> | 118 | #include <linux/netdevice.h> |
119 | #include <net/net_namespace.h> | ||
119 | 120 | ||
120 | #include <linux/if.h> | 121 | #include <linux/if.h> |
121 | #include <linux/if_arp.h> | 122 | #include <linux/if_arp.h> |
@@ -412,7 +413,7 @@ static int eql_enslave(struct net_device *master_dev, slaving_request_t __user * | |||
412 | if (copy_from_user(&srq, srqp, sizeof (slaving_request_t))) | 413 | if (copy_from_user(&srq, srqp, sizeof (slaving_request_t))) |
413 | return -EFAULT; | 414 | return -EFAULT; |
414 | 415 | ||
415 | slave_dev = dev_get_by_name(srq.slave_name); | 416 | slave_dev = dev_get_by_name(&init_net, srq.slave_name); |
416 | if (slave_dev) { | 417 | if (slave_dev) { |
417 | if ((master_dev->flags & IFF_UP) == IFF_UP) { | 418 | if ((master_dev->flags & IFF_UP) == IFF_UP) { |
418 | /* slave is not a master & not already a slave: */ | 419 | /* slave is not a master & not already a slave: */ |
@@ -460,7 +461,7 @@ static int eql_emancipate(struct net_device *master_dev, slaving_request_t __use | |||
460 | if (copy_from_user(&srq, srqp, sizeof (slaving_request_t))) | 461 | if (copy_from_user(&srq, srqp, sizeof (slaving_request_t))) |
461 | return -EFAULT; | 462 | return -EFAULT; |
462 | 463 | ||
463 | slave_dev = dev_get_by_name(srq.slave_name); | 464 | slave_dev = dev_get_by_name(&init_net, srq.slave_name); |
464 | ret = -EINVAL; | 465 | ret = -EINVAL; |
465 | if (slave_dev) { | 466 | if (slave_dev) { |
466 | spin_lock_bh(&eql->queue.lock); | 467 | spin_lock_bh(&eql->queue.lock); |
@@ -493,7 +494,7 @@ static int eql_g_slave_cfg(struct net_device *dev, slave_config_t __user *scp) | |||
493 | if (copy_from_user(&sc, scp, sizeof (slave_config_t))) | 494 | if (copy_from_user(&sc, scp, sizeof (slave_config_t))) |
494 | return -EFAULT; | 495 | return -EFAULT; |
495 | 496 | ||
496 | slave_dev = dev_get_by_name(sc.slave_name); | 497 | slave_dev = dev_get_by_name(&init_net, sc.slave_name); |
497 | if (!slave_dev) | 498 | if (!slave_dev) |
498 | return -ENODEV; | 499 | return -ENODEV; |
499 | 500 | ||
@@ -528,7 +529,7 @@ static int eql_s_slave_cfg(struct net_device *dev, slave_config_t __user *scp) | |||
528 | if (copy_from_user(&sc, scp, sizeof (slave_config_t))) | 529 | if (copy_from_user(&sc, scp, sizeof (slave_config_t))) |
529 | return -EFAULT; | 530 | return -EFAULT; |
530 | 531 | ||
531 | slave_dev = dev_get_by_name(sc.slave_name); | 532 | slave_dev = dev_get_by_name(&init_net, sc.slave_name); |
532 | if (!slave_dev) | 533 | if (!slave_dev) |
533 | return -ENODEV; | 534 | return -ENODEV; |
534 | 535 | ||
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index f5c3598e59af..b06c6db4383a 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <net/pkt_sched.h> | 36 | #include <net/pkt_sched.h> |
37 | #include <net/net_namespace.h> | ||
37 | 38 | ||
38 | #define TX_TIMEOUT (2*HZ) | 39 | #define TX_TIMEOUT (2*HZ) |
39 | 40 | ||
@@ -97,7 +98,7 @@ static void ri_tasklet(unsigned long dev) | |||
97 | stats->tx_packets++; | 98 | stats->tx_packets++; |
98 | stats->tx_bytes +=skb->len; | 99 | stats->tx_bytes +=skb->len; |
99 | 100 | ||
100 | skb->dev = __dev_get_by_index(skb->iif); | 101 | skb->dev = __dev_get_by_index(&init_net, skb->iif); |
101 | if (!skb->dev) { | 102 | if (!skb->dev) { |
102 | dev_kfree_skb(skb); | 103 | dev_kfree_skb(skb); |
103 | stats->tx_dropped++; | 104 | stats->tx_dropped++; |
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index dc74d006e01f..2de073da182c 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -376,7 +376,7 @@ static int macvlan_newlink(struct net_device *dev, | |||
376 | if (!tb[IFLA_LINK]) | 376 | if (!tb[IFLA_LINK]) |
377 | return -EINVAL; | 377 | return -EINVAL; |
378 | 378 | ||
379 | lowerdev = __dev_get_by_index(nla_get_u32(tb[IFLA_LINK])); | 379 | lowerdev = __dev_get_by_index(dev->nd_net, nla_get_u32(tb[IFLA_LINK])); |
380 | if (lowerdev == NULL) | 380 | if (lowerdev == NULL) |
381 | return -ENODEV; | 381 | return -ENODEV; |
382 | 382 | ||
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index c5c70e4b1d36..2f130e06b6dc 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -216,7 +216,7 @@ static inline struct pppox_sock *get_item_by_addr(struct sockaddr_pppox *sp) | |||
216 | struct net_device *dev; | 216 | struct net_device *dev; |
217 | int ifindex; | 217 | int ifindex; |
218 | 218 | ||
219 | dev = dev_get_by_name(sp->sa_addr.pppoe.dev); | 219 | dev = dev_get_by_name(&init_net, sp->sa_addr.pppoe.dev); |
220 | if(!dev) | 220 | if(!dev) |
221 | return NULL; | 221 | return NULL; |
222 | ifindex = dev->ifindex; | 222 | ifindex = dev->ifindex; |
@@ -603,7 +603,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
603 | 603 | ||
604 | /* Don't re-bind if sid==0 */ | 604 | /* Don't re-bind if sid==0 */ |
605 | if (sp->sa_addr.pppoe.sid != 0) { | 605 | if (sp->sa_addr.pppoe.sid != 0) { |
606 | dev = dev_get_by_name(sp->sa_addr.pppoe.dev); | 606 | dev = dev_get_by_name(&init_net, sp->sa_addr.pppoe.dev); |
607 | 607 | ||
608 | error = -ENODEV; | 608 | error = -ENODEV; |
609 | if (!dev) | 609 | if (!dev) |
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c index 4c3d98ff4cd4..3773b3858bd4 100644 --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c | |||
@@ -86,6 +86,7 @@ | |||
86 | 86 | ||
87 | #include <net/dst.h> | 87 | #include <net/dst.h> |
88 | #include <net/arp.h> | 88 | #include <net/arp.h> |
89 | #include <net/net_namespace.h> | ||
89 | 90 | ||
90 | struct shaper_cb { | 91 | struct shaper_cb { |
91 | unsigned long shapeclock; /* Time it should go out */ | 92 | unsigned long shapeclock; /* Time it should go out */ |
@@ -488,7 +489,7 @@ static int shaper_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
488 | { | 489 | { |
489 | case SHAPER_SET_DEV: | 490 | case SHAPER_SET_DEV: |
490 | { | 491 | { |
491 | struct net_device *them=__dev_get_by_name(ss->ss_name); | 492 | struct net_device *them=__dev_get_by_name(&init_net, ss->ss_name); |
492 | if(them==NULL) | 493 | if(them==NULL) |
493 | return -ENODEV; | 494 | return -ENODEV; |
494 | if(sh->dev) | 495 | if(sh->dev) |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 62b2b3005019..691d264fbb6f 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <linux/if_ether.h> | 62 | #include <linux/if_ether.h> |
63 | #include <linux/if_tun.h> | 63 | #include <linux/if_tun.h> |
64 | #include <linux/crc32.h> | 64 | #include <linux/crc32.h> |
65 | #include <net/net_namespace.h> | ||
65 | 66 | ||
66 | #include <asm/system.h> | 67 | #include <asm/system.h> |
67 | #include <asm/uaccess.h> | 68 | #include <asm/uaccess.h> |
@@ -475,7 +476,7 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr) | |||
475 | !capable(CAP_NET_ADMIN)) | 476 | !capable(CAP_NET_ADMIN)) |
476 | return -EPERM; | 477 | return -EPERM; |
477 | } | 478 | } |
478 | else if (__dev_get_by_name(ifr->ifr_name)) | 479 | else if (__dev_get_by_name(&init_net, ifr->ifr_name)) |
479 | return -EINVAL; | 480 | return -EINVAL; |
480 | else { | 481 | else { |
481 | char *name; | 482 | char *name; |
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index ca1c6893b809..2c86a4459d8a 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -345,7 +345,7 @@ static int veth_newlink(struct net_device *dev, | |||
345 | else | 345 | else |
346 | snprintf(ifname, IFNAMSIZ, DRV_NAME "%%d"); | 346 | snprintf(ifname, IFNAMSIZ, DRV_NAME "%%d"); |
347 | 347 | ||
348 | peer = rtnl_create_link(ifname, &veth_link_ops, tbp); | 348 | peer = rtnl_create_link(dev->nd_net, ifname, &veth_link_ops, tbp); |
349 | if (IS_ERR(peer)) | 349 | if (IS_ERR(peer)) |
350 | return PTR_ERR(peer); | 350 | return PTR_ERR(peer); |
351 | 351 | ||
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c index 61041d5186ac..bc12810157e0 100644 --- a/drivers/net/wan/dlci.c +++ b/drivers/net/wan/dlci.c | |||
@@ -361,7 +361,7 @@ static int dlci_add(struct dlci_add *dlci) | |||
361 | 361 | ||
362 | 362 | ||
363 | /* validate slave device */ | 363 | /* validate slave device */ |
364 | slave = dev_get_by_name(dlci->devname); | 364 | slave = dev_get_by_name(&init_net, dlci->devname); |
365 | if (!slave) | 365 | if (!slave) |
366 | return -ENODEV; | 366 | return -ENODEV; |
367 | 367 | ||
@@ -427,7 +427,7 @@ static int dlci_del(struct dlci_add *dlci) | |||
427 | int err; | 427 | int err; |
428 | 428 | ||
429 | /* validate slave device */ | 429 | /* validate slave device */ |
430 | master = __dev_get_by_name(dlci->devname); | 430 | master = __dev_get_by_name(&init_net, dlci->devname); |
431 | if (!master) | 431 | if (!master) |
432 | return(-ENODEV); | 432 | return(-ENODEV); |
433 | 433 | ||
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c index 1cc18e787a65..8d7e01e8f56f 100644 --- a/drivers/net/wan/sbni.c +++ b/drivers/net/wan/sbni.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/init.h> | 54 | #include <linux/init.h> |
55 | #include <linux/delay.h> | 55 | #include <linux/delay.h> |
56 | 56 | ||
57 | #include <net/net_namespace.h> | ||
57 | #include <net/arp.h> | 58 | #include <net/arp.h> |
58 | 59 | ||
59 | #include <asm/io.h> | 60 | #include <asm/io.h> |
@@ -1361,7 +1362,7 @@ sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) | |||
1361 | 1362 | ||
1362 | if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name )) | 1363 | if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name )) |
1363 | return -EFAULT; | 1364 | return -EFAULT; |
1364 | slave_dev = dev_get_by_name( slave_name ); | 1365 | slave_dev = dev_get_by_name(&init_net, slave_name ); |
1365 | if( !slave_dev || !(slave_dev->flags & IFF_UP) ) { | 1366 | if( !slave_dev || !(slave_dev->flags & IFF_UP) ) { |
1366 | printk( KERN_ERR "%s: trying to enslave non-active " | 1367 | printk( KERN_ERR "%s: trying to enslave non-active " |
1367 | "device %s\n", dev->name, slave_name ); | 1368 | "device %s\n", dev->name, slave_name ); |
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c index edb214e8c744..904e548e6795 100644 --- a/drivers/net/wireless/strip.c +++ b/drivers/net/wireless/strip.c | |||
@@ -1972,7 +1972,7 @@ static struct net_device *get_strip_dev(struct strip *strip_info) | |||
1972 | sizeof(zero_address))) { | 1972 | sizeof(zero_address))) { |
1973 | struct net_device *dev; | 1973 | struct net_device *dev; |
1974 | read_lock_bh(&dev_base_lock); | 1974 | read_lock_bh(&dev_base_lock); |
1975 | for_each_netdev(dev) { | 1975 | for_each_netdev(&init_net, dev) { |
1976 | if (dev->type == strip_info->dev->type && | 1976 | if (dev->type == strip_info->dev->type && |
1977 | !memcmp(dev->dev_addr, | 1977 | !memcmp(dev->dev_addr, |
1978 | &strip_info->true_dev_addr, | 1978 | &strip_info->true_dev_addr, |
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index e5d7ed92d6f7..a6d6b2488ffc 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -359,7 +359,7 @@ static __inline__ int led_get_net_activity(void) | |||
359 | * for reading should be OK */ | 359 | * for reading should be OK */ |
360 | read_lock(&dev_base_lock); | 360 | read_lock(&dev_base_lock); |
361 | rcu_read_lock(); | 361 | rcu_read_lock(); |
362 | for_each_netdev(dev) { | 362 | for_each_netdev(&init_net, dev) { |
363 | struct net_device_stats *stats; | 363 | struct net_device_stats *stats; |
364 | struct in_device *in_dev = __in_dev_get_rcu(dev); | 364 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
365 | if (!in_dev || !in_dev->ifa_list) | 365 | if (!in_dev || !in_dev->ifa_list) |
diff --git a/fs/afs/netdevices.c b/fs/afs/netdevices.c index fc27d4b52e5f..49f189423063 100644 --- a/fs/afs/netdevices.c +++ b/fs/afs/netdevices.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/inetdevice.h> | 8 | #include <linux/inetdevice.h> |
9 | #include <linux/netdevice.h> | 9 | #include <linux/netdevice.h> |
10 | #include <linux/if_arp.h> | 10 | #include <linux/if_arp.h> |
11 | #include <net/net_namespace.h> | ||
11 | #include "internal.h" | 12 | #include "internal.h" |
12 | 13 | ||
13 | /* | 14 | /* |
@@ -23,7 +24,7 @@ int afs_get_MAC_address(u8 *mac, size_t maclen) | |||
23 | BUG(); | 24 | BUG(); |
24 | 25 | ||
25 | rtnl_lock(); | 26 | rtnl_lock(); |
26 | dev = __dev_getfirstbyhwtype(ARPHRD_ETHER); | 27 | dev = __dev_getfirstbyhwtype(&init_net, ARPHRD_ETHER); |
27 | if (dev) { | 28 | if (dev) { |
28 | memcpy(mac, dev->dev_addr, maclen); | 29 | memcpy(mac, dev->dev_addr, maclen); |
29 | ret = 0; | 30 | ret = 0; |
@@ -47,7 +48,7 @@ int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs, | |||
47 | ASSERT(maxbufs > 0); | 48 | ASSERT(maxbufs > 0); |
48 | 49 | ||
49 | rtnl_lock(); | 50 | rtnl_lock(); |
50 | for_each_netdev(dev) { | 51 | for_each_netdev(&init_net, dev) { |
51 | if (dev->type == ARPHRD_LOOPBACK && !wantloopback) | 52 | if (dev->type == ARPHRD_LOOPBACK && !wantloopback) |
52 | continue; | 53 | continue; |
53 | idev = __in_dev_get_rtnl(dev); | 54 | idev = __in_dev_get_rtnl(dev); |
diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h index 4ff211d98769..99e3a1a00099 100644 --- a/include/linux/if_bridge.h +++ b/include/linux/if_bridge.h | |||
@@ -104,7 +104,7 @@ struct __fdb_entry | |||
104 | 104 | ||
105 | #include <linux/netdevice.h> | 105 | #include <linux/netdevice.h> |
106 | 106 | ||
107 | extern void brioctl_set(int (*ioctl_hook)(unsigned int, void __user *)); | 107 | extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *)); |
108 | extern struct sk_buff *(*br_handle_frame_hook)(struct net_bridge_port *p, | 108 | extern struct sk_buff *(*br_handle_frame_hook)(struct net_bridge_port *p, |
109 | struct sk_buff *skb); | 109 | struct sk_buff *skb); |
110 | extern int (*br_should_route_hook)(struct sk_buff **pskb); | 110 | extern int (*br_should_route_hook)(struct sk_buff **pskb); |
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index f8443fdb124a..976d4b1067d1 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h | |||
@@ -62,7 +62,7 @@ struct vlan_hdr { | |||
62 | #define VLAN_VID_MASK 0xfff | 62 | #define VLAN_VID_MASK 0xfff |
63 | 63 | ||
64 | /* found in socket.c */ | 64 | /* found in socket.c */ |
65 | extern void vlan_ioctl_set(int (*hook)(void __user *)); | 65 | extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); |
66 | 66 | ||
67 | #define VLAN_NAME "vlan" | 67 | #define VLAN_NAME "vlan" |
68 | 68 | ||
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index dc3c15b726bc..7353b3e1f4fc 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -741,44 +741,48 @@ struct packet_type { | |||
741 | #include <linux/notifier.h> | 741 | #include <linux/notifier.h> |
742 | 742 | ||
743 | extern struct net_device loopback_dev; /* The loopback */ | 743 | extern struct net_device loopback_dev; /* The loopback */ |
744 | extern struct list_head dev_base_head; /* All devices */ | ||
745 | extern rwlock_t dev_base_lock; /* Device list lock */ | 744 | extern rwlock_t dev_base_lock; /* Device list lock */ |
746 | 745 | ||
747 | #define for_each_netdev(d) \ | ||
748 | list_for_each_entry(d, &dev_base_head, dev_list) | ||
749 | #define for_each_netdev_safe(d, n) \ | ||
750 | list_for_each_entry_safe(d, n, &dev_base_head, dev_list) | ||
751 | #define for_each_netdev_continue(d) \ | ||
752 | list_for_each_entry_continue(d, &dev_base_head, dev_list) | ||
753 | #define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) | ||
754 | |||
755 | static inline struct net_device *next_net_device(struct net_device *dev) | ||
756 | { | ||
757 | struct list_head *lh; | ||
758 | 746 | ||
759 | lh = dev->dev_list.next; | 747 | #define for_each_netdev(net, d) \ |
760 | return lh == &dev_base_head ? NULL : net_device_entry(lh); | 748 | list_for_each_entry(d, &(net)->dev_base_head, dev_list) |
761 | } | 749 | #define for_each_netdev_safe(net, d, n) \ |
750 | list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list) | ||
751 | #define for_each_netdev_continue(net, d) \ | ||
752 | list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list) | ||
753 | #define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) | ||
762 | 754 | ||
763 | static inline struct net_device *first_net_device(void) | 755 | #define next_net_device(d) \ |
764 | { | 756 | ({ \ |
765 | return list_empty(&dev_base_head) ? NULL : | 757 | struct net_device *dev = d; \ |
766 | net_device_entry(dev_base_head.next); | 758 | struct list_head *lh; \ |
767 | } | 759 | struct net *net; \ |
760 | \ | ||
761 | net = dev->nd_net; \ | ||
762 | lh = dev->dev_list.next; \ | ||
763 | lh == &net->dev_base_head ? NULL : net_device_entry(lh); \ | ||
764 | }) | ||
765 | |||
766 | #define first_net_device(N) \ | ||
767 | ({ \ | ||
768 | struct net *NET = (N); \ | ||
769 | list_empty(&NET->dev_base_head) ? NULL : \ | ||
770 | net_device_entry(NET->dev_base_head.next); \ | ||
771 | }) | ||
768 | 772 | ||
769 | extern int netdev_boot_setup_check(struct net_device *dev); | 773 | extern int netdev_boot_setup_check(struct net_device *dev); |
770 | extern unsigned long netdev_boot_base(const char *prefix, int unit); | 774 | extern unsigned long netdev_boot_base(const char *prefix, int unit); |
771 | extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr); | 775 | extern struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr); |
772 | extern struct net_device *dev_getfirstbyhwtype(unsigned short type); | 776 | extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type); |
773 | extern struct net_device *__dev_getfirstbyhwtype(unsigned short type); | 777 | extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type); |
774 | extern void dev_add_pack(struct packet_type *pt); | 778 | extern void dev_add_pack(struct packet_type *pt); |
775 | extern void dev_remove_pack(struct packet_type *pt); | 779 | extern void dev_remove_pack(struct packet_type *pt); |
776 | extern void __dev_remove_pack(struct packet_type *pt); | 780 | extern void __dev_remove_pack(struct packet_type *pt); |
777 | 781 | ||
778 | extern struct net_device *dev_get_by_flags(unsigned short flags, | 782 | extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags, |
779 | unsigned short mask); | 783 | unsigned short mask); |
780 | extern struct net_device *dev_get_by_name(const char *name); | 784 | extern struct net_device *dev_get_by_name(struct net *net, const char *name); |
781 | extern struct net_device *__dev_get_by_name(const char *name); | 785 | extern struct net_device *__dev_get_by_name(struct net *net, const char *name); |
782 | extern int dev_alloc_name(struct net_device *dev, const char *name); | 786 | extern int dev_alloc_name(struct net_device *dev, const char *name); |
783 | extern int dev_open(struct net_device *dev); | 787 | extern int dev_open(struct net_device *dev); |
784 | extern int dev_close(struct net_device *dev); | 788 | extern int dev_close(struct net_device *dev); |
@@ -790,8 +794,8 @@ extern void synchronize_net(void); | |||
790 | extern int register_netdevice_notifier(struct notifier_block *nb); | 794 | extern int register_netdevice_notifier(struct notifier_block *nb); |
791 | extern int unregister_netdevice_notifier(struct notifier_block *nb); | 795 | extern int unregister_netdevice_notifier(struct notifier_block *nb); |
792 | extern int call_netdevice_notifiers(unsigned long val, void *v); | 796 | extern int call_netdevice_notifiers(unsigned long val, void *v); |
793 | extern struct net_device *dev_get_by_index(int ifindex); | 797 | extern struct net_device *dev_get_by_index(struct net *net, int ifindex); |
794 | extern struct net_device *__dev_get_by_index(int ifindex); | 798 | extern struct net_device *__dev_get_by_index(struct net *net, int ifindex); |
795 | extern int dev_restart(struct net_device *dev); | 799 | extern int dev_restart(struct net_device *dev); |
796 | #ifdef CONFIG_NETPOLL_TRAP | 800 | #ifdef CONFIG_NETPOLL_TRAP |
797 | extern int netpoll_trap(void); | 801 | extern int netpoll_trap(void); |
@@ -1007,8 +1011,8 @@ extern int netif_rx_ni(struct sk_buff *skb); | |||
1007 | #define HAVE_NETIF_RECEIVE_SKB 1 | 1011 | #define HAVE_NETIF_RECEIVE_SKB 1 |
1008 | extern int netif_receive_skb(struct sk_buff *skb); | 1012 | extern int netif_receive_skb(struct sk_buff *skb); |
1009 | extern int dev_valid_name(const char *name); | 1013 | extern int dev_valid_name(const char *name); |
1010 | extern int dev_ioctl(unsigned int cmd, void __user *); | 1014 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); |
1011 | extern int dev_ethtool(struct ifreq *); | 1015 | extern int dev_ethtool(struct net *net, struct ifreq *); |
1012 | extern unsigned dev_get_flags(const struct net_device *); | 1016 | extern unsigned dev_get_flags(const struct net_device *); |
1013 | extern int dev_change_flags(struct net_device *, unsigned); | 1017 | extern int dev_change_flags(struct net_device *, unsigned); |
1014 | extern int dev_change_name(struct net_device *, char *); | 1018 | extern int dev_change_name(struct net_device *, char *); |
@@ -1327,7 +1331,7 @@ extern void dev_set_allmulti(struct net_device *dev, int inc); | |||
1327 | extern void netdev_state_change(struct net_device *dev); | 1331 | extern void netdev_state_change(struct net_device *dev); |
1328 | extern void netdev_features_change(struct net_device *dev); | 1332 | extern void netdev_features_change(struct net_device *dev); |
1329 | /* Load a device via the kmod */ | 1333 | /* Load a device via the kmod */ |
1330 | extern void dev_load(const char *name); | 1334 | extern void dev_load(struct net *net, const char *name); |
1331 | extern void dev_mcast_init(void); | 1335 | extern void dev_mcast_init(void); |
1332 | extern int netdev_max_backlog; | 1336 | extern int netdev_max_backlog; |
1333 | extern int weight_p; | 1337 | extern int weight_p; |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 547247681345..fac42db7f6d0 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -22,6 +22,10 @@ struct net { | |||
22 | struct proc_dir_entry *proc_net; | 22 | struct proc_dir_entry *proc_net; |
23 | struct proc_dir_entry *proc_net_stat; | 23 | struct proc_dir_entry *proc_net_stat; |
24 | struct proc_dir_entry *proc_net_root; | 24 | struct proc_dir_entry *proc_net_root; |
25 | |||
26 | struct list_head dev_base_head; | ||
27 | struct hlist_head *dev_name_head; | ||
28 | struct hlist_head *dev_index_head; | ||
25 | }; | 29 | }; |
26 | 30 | ||
27 | extern struct net init_net; | 31 | extern struct net init_net; |
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 7968b1d66369..f285de69c615 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __NET_PKT_CLS_H | 2 | #define __NET_PKT_CLS_H |
3 | 3 | ||
4 | #include <linux/pkt_cls.h> | 4 | #include <linux/pkt_cls.h> |
5 | #include <net/net_namespace.h> | ||
5 | #include <net/sch_generic.h> | 6 | #include <net/sch_generic.h> |
6 | #include <net/act_api.h> | 7 | #include <net/act_api.h> |
7 | 8 | ||
@@ -351,7 +352,7 @@ tcf_match_indev(struct sk_buff *skb, char *indev) | |||
351 | if (indev[0]) { | 352 | if (indev[0]) { |
352 | if (!skb->iif) | 353 | if (!skb->iif) |
353 | return 0; | 354 | return 0; |
354 | dev = __dev_get_by_index(skb->iif); | 355 | dev = __dev_get_by_index(&init_net, skb->iif); |
355 | if (!dev || strcmp(indev, dev->name)) | 356 | if (!dev || strcmp(indev, dev->name)) |
356 | return 0; | 357 | return 0; |
357 | } | 358 | } |
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h index 8218288ab7ee..793863e09c69 100644 --- a/include/net/rtnetlink.h +++ b/include/net/rtnetlink.h | |||
@@ -78,7 +78,7 @@ extern void __rtnl_link_unregister(struct rtnl_link_ops *ops); | |||
78 | extern int rtnl_link_register(struct rtnl_link_ops *ops); | 78 | extern int rtnl_link_register(struct rtnl_link_ops *ops); |
79 | extern void rtnl_link_unregister(struct rtnl_link_ops *ops); | 79 | extern void rtnl_link_unregister(struct rtnl_link_ops *ops); |
80 | 80 | ||
81 | extern struct net_device *rtnl_create_link(char *ifname, | 81 | extern struct net_device *rtnl_create_link(struct net *net, char *ifname, |
82 | const struct rtnl_link_ops *ops, struct nlattr *tb[]); | 82 | const struct rtnl_link_ops *ops, struct nlattr *tb[]); |
83 | extern const struct nla_policy ifla_policy[IFLA_MAX+1]; | 83 | extern const struct nla_policy ifla_policy[IFLA_MAX+1]; |
84 | 84 | ||
diff --git a/include/net/wext.h b/include/net/wext.h index c02b8decf3af..80b31d826b7a 100644 --- a/include/net/wext.h +++ b/include/net/wext.h | |||
@@ -5,16 +5,23 @@ | |||
5 | * wireless extensions interface to the core code | 5 | * wireless extensions interface to the core code |
6 | */ | 6 | */ |
7 | 7 | ||
8 | struct net; | ||
9 | |||
8 | #ifdef CONFIG_WIRELESS_EXT | 10 | #ifdef CONFIG_WIRELESS_EXT |
9 | extern int wext_proc_init(void); | 11 | extern int wext_proc_init(struct net *net); |
10 | extern int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | 12 | extern void wext_proc_exit(struct net *net); |
13 | extern int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd, | ||
11 | void __user *arg); | 14 | void __user *arg); |
12 | #else | 15 | #else |
13 | static inline int wext_proc_init(void) | 16 | static inline int wext_proc_init(struct net *net) |
14 | { | 17 | { |
15 | return 0; | 18 | return 0; |
16 | } | 19 | } |
17 | static inline int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | 20 | static inline void wext_proc_exit(struct net *net) |
21 | { | ||
22 | return; | ||
23 | } | ||
24 | static inline int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd, | ||
18 | void __user *arg) | 25 | void __user *arg) |
19 | { | 26 | { |
20 | return -EINVAL; | 27 | return -EINVAL; |
diff --git a/net/802/tr.c b/net/802/tr.c index 032c31e748eb..55c76d77d322 100644 --- a/net/802/tr.c +++ b/net/802/tr.c | |||
@@ -533,7 +533,7 @@ static int rif_seq_show(struct seq_file *seq, void *v) | |||
533 | seq_puts(seq, | 533 | seq_puts(seq, |
534 | "if TR address TTL rcf routing segments\n"); | 534 | "if TR address TTL rcf routing segments\n"); |
535 | else { | 535 | else { |
536 | struct net_device *dev = dev_get_by_index(entry->iface); | 536 | struct net_device *dev = dev_get_by_index(&init_net, entry->iface); |
537 | long ttl = (long) (entry->last_used + sysctl_tr_rif_timeout) | 537 | long ttl = (long) (entry->last_used + sysctl_tr_rif_timeout) |
538 | - (long) jiffies; | 538 | - (long) jiffies; |
539 | 539 | ||
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index d0d36fdedbe9..a9ced0a6f4c0 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -51,7 +51,7 @@ static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; | |||
51 | static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; | 51 | static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; |
52 | 52 | ||
53 | static int vlan_device_event(struct notifier_block *, unsigned long, void *); | 53 | static int vlan_device_event(struct notifier_block *, unsigned long, void *); |
54 | static int vlan_ioctl_handler(void __user *); | 54 | static int vlan_ioctl_handler(struct net *net, void __user *); |
55 | static int unregister_vlan_dev(struct net_device *, unsigned short ); | 55 | static int unregister_vlan_dev(struct net_device *, unsigned short ); |
56 | 56 | ||
57 | static struct notifier_block vlan_notifier_block = { | 57 | static struct notifier_block vlan_notifier_block = { |
@@ -697,7 +697,7 @@ out: | |||
697 | * o execute requested action or pass command to the device driver | 697 | * o execute requested action or pass command to the device driver |
698 | * arg is really a struct vlan_ioctl_args __user *. | 698 | * arg is really a struct vlan_ioctl_args __user *. |
699 | */ | 699 | */ |
700 | static int vlan_ioctl_handler(void __user *arg) | 700 | static int vlan_ioctl_handler(struct net *net, void __user *arg) |
701 | { | 701 | { |
702 | int err; | 702 | int err; |
703 | unsigned short vid = 0; | 703 | unsigned short vid = 0; |
@@ -726,7 +726,7 @@ static int vlan_ioctl_handler(void __user *arg) | |||
726 | case GET_VLAN_REALDEV_NAME_CMD: | 726 | case GET_VLAN_REALDEV_NAME_CMD: |
727 | case GET_VLAN_VID_CMD: | 727 | case GET_VLAN_VID_CMD: |
728 | err = -ENODEV; | 728 | err = -ENODEV; |
729 | dev = __dev_get_by_name(args.device1); | 729 | dev = __dev_get_by_name(&init_net, args.device1); |
730 | if (!dev) | 730 | if (!dev) |
731 | goto out; | 731 | goto out; |
732 | 732 | ||
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c index 6cdd1e015e2d..0996185e2ed5 100644 --- a/net/8021q/vlan_netlink.c +++ b/net/8021q/vlan_netlink.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/netdevice.h> | 12 | #include <linux/netdevice.h> |
13 | #include <linux/if_vlan.h> | 13 | #include <linux/if_vlan.h> |
14 | #include <net/net_namespace.h> | ||
14 | #include <net/netlink.h> | 15 | #include <net/netlink.h> |
15 | #include <net/rtnetlink.h> | 16 | #include <net/rtnetlink.h> |
16 | #include "vlan.h" | 17 | #include "vlan.h" |
@@ -112,7 +113,7 @@ static int vlan_newlink(struct net_device *dev, | |||
112 | 113 | ||
113 | if (!tb[IFLA_LINK]) | 114 | if (!tb[IFLA_LINK]) |
114 | return -EINVAL; | 115 | return -EINVAL; |
115 | real_dev = __dev_get_by_index(nla_get_u32(tb[IFLA_LINK])); | 116 | real_dev = __dev_get_by_index(&init_net, nla_get_u32(tb[IFLA_LINK])); |
116 | if (!real_dev) | 117 | if (!real_dev) |
117 | return -ENODEV; | 118 | return -ENODEV; |
118 | 119 | ||
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index ac80e6b9ef53..6cefdf8e381a 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
@@ -254,7 +254,7 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos) | |||
254 | if (*pos == 0) | 254 | if (*pos == 0) |
255 | return SEQ_START_TOKEN; | 255 | return SEQ_START_TOKEN; |
256 | 256 | ||
257 | for_each_netdev(dev) { | 257 | for_each_netdev(&init_net, dev) { |
258 | if (!is_vlan_dev(dev)) | 258 | if (!is_vlan_dev(dev)) |
259 | continue; | 259 | continue; |
260 | 260 | ||
@@ -273,9 +273,9 @@ static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
273 | 273 | ||
274 | dev = (struct net_device *)v; | 274 | dev = (struct net_device *)v; |
275 | if (v == SEQ_START_TOKEN) | 275 | if (v == SEQ_START_TOKEN) |
276 | dev = net_device_entry(&dev_base_head); | 276 | dev = net_device_entry(&init_net.dev_base_head); |
277 | 277 | ||
278 | for_each_netdev_continue(dev) { | 278 | for_each_netdev_continue(&init_net, dev) { |
279 | if (!is_vlan_dev(dev)) | 279 | if (!is_vlan_dev(dev)) |
280 | continue; | 280 | continue; |
281 | 281 | ||
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 36fcdbf923c4..7c0b5151d526 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -677,7 +677,7 @@ static int atif_ioctl(int cmd, void __user *arg) | |||
677 | if (copy_from_user(&atreq, arg, sizeof(atreq))) | 677 | if (copy_from_user(&atreq, arg, sizeof(atreq))) |
678 | return -EFAULT; | 678 | return -EFAULT; |
679 | 679 | ||
680 | dev = __dev_get_by_name(atreq.ifr_name); | 680 | dev = __dev_get_by_name(&init_net, atreq.ifr_name); |
681 | if (!dev) | 681 | if (!dev) |
682 | return -ENODEV; | 682 | return -ENODEV; |
683 | 683 | ||
@@ -901,7 +901,7 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg) | |||
901 | if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) | 901 | if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) |
902 | return -EFAULT; | 902 | return -EFAULT; |
903 | name[IFNAMSIZ-1] = '\0'; | 903 | name[IFNAMSIZ-1] = '\0'; |
904 | dev = __dev_get_by_name(name); | 904 | dev = __dev_get_by_name(&init_net, name); |
905 | if (!dev) | 905 | if (!dev) |
906 | return -ENODEV; | 906 | return -ENODEV; |
907 | } | 907 | } |
@@ -1273,7 +1273,7 @@ static __inline__ int is_ip_over_ddp(struct sk_buff *skb) | |||
1273 | 1273 | ||
1274 | static int handle_ip_over_ddp(struct sk_buff *skb) | 1274 | static int handle_ip_over_ddp(struct sk_buff *skb) |
1275 | { | 1275 | { |
1276 | struct net_device *dev = __dev_get_by_name("ipddp0"); | 1276 | struct net_device *dev = __dev_get_by_name(&init_net, "ipddp0"); |
1277 | struct net_device_stats *stats; | 1277 | struct net_device_stats *stats; |
1278 | 1278 | ||
1279 | /* This needs to be able to handle ipddp"N" devices */ | 1279 | /* This needs to be able to handle ipddp"N" devices */ |
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 0968430a7f58..2086396de177 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
@@ -244,7 +244,7 @@ static struct net_device *find_lec_by_itfnum(int itf) | |||
244 | char name[IFNAMSIZ]; | 244 | char name[IFNAMSIZ]; |
245 | 245 | ||
246 | sprintf(name, "lec%d", itf); | 246 | sprintf(name, "lec%d", itf); |
247 | dev = dev_get_by_name(name); | 247 | dev = dev_get_by_name(&init_net, name); |
248 | 248 | ||
249 | return dev; | 249 | return dev; |
250 | } | 250 | } |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 8d13a8bca0e0..993e5c75e909 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -631,7 +631,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname, | |||
631 | break; | 631 | break; |
632 | } | 632 | } |
633 | 633 | ||
634 | dev = dev_get_by_name(devname); | 634 | dev = dev_get_by_name(&init_net, devname); |
635 | if (dev == NULL) { | 635 | if (dev == NULL) { |
636 | res = -ENODEV; | 636 | res = -ENODEV; |
637 | break; | 637 | break; |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 9272f12f664c..935784f736b3 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -303,7 +303,7 @@ int br_del_bridge(const char *name) | |||
303 | int ret = 0; | 303 | int ret = 0; |
304 | 304 | ||
305 | rtnl_lock(); | 305 | rtnl_lock(); |
306 | dev = __dev_get_by_name(name); | 306 | dev = __dev_get_by_name(&init_net, name); |
307 | if (dev == NULL) | 307 | if (dev == NULL) |
308 | ret = -ENXIO; /* Could not find device */ | 308 | ret = -ENXIO; /* Could not find device */ |
309 | 309 | ||
@@ -444,7 +444,7 @@ void __exit br_cleanup_bridges(void) | |||
444 | struct net_device *dev, *nxt; | 444 | struct net_device *dev, *nxt; |
445 | 445 | ||
446 | rtnl_lock(); | 446 | rtnl_lock(); |
447 | for_each_netdev_safe(dev, nxt) | 447 | for_each_netdev_safe(&init_net, dev, nxt) |
448 | if (dev->priv_flags & IFF_EBRIDGE) | 448 | if (dev->priv_flags & IFF_EBRIDGE) |
449 | del_br(dev->priv); | 449 | del_br(dev->priv); |
450 | rtnl_unlock(); | 450 | rtnl_unlock(); |
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c index bb15e9e259b1..0655a5f07f58 100644 --- a/net/bridge/br_ioctl.c +++ b/net/bridge/br_ioctl.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/if_bridge.h> | 18 | #include <linux/if_bridge.h> |
19 | #include <linux/netdevice.h> | 19 | #include <linux/netdevice.h> |
20 | #include <linux/times.h> | 20 | #include <linux/times.h> |
21 | #include <net/net_namespace.h> | ||
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
22 | #include "br_private.h" | 23 | #include "br_private.h" |
23 | 24 | ||
@@ -27,7 +28,7 @@ static int get_bridge_ifindices(int *indices, int num) | |||
27 | struct net_device *dev; | 28 | struct net_device *dev; |
28 | int i = 0; | 29 | int i = 0; |
29 | 30 | ||
30 | for_each_netdev(dev) { | 31 | for_each_netdev(&init_net, dev) { |
31 | if (i >= num) | 32 | if (i >= num) |
32 | break; | 33 | break; |
33 | if (dev->priv_flags & IFF_EBRIDGE) | 34 | if (dev->priv_flags & IFF_EBRIDGE) |
@@ -90,7 +91,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd) | |||
90 | if (!capable(CAP_NET_ADMIN)) | 91 | if (!capable(CAP_NET_ADMIN)) |
91 | return -EPERM; | 92 | return -EPERM; |
92 | 93 | ||
93 | dev = dev_get_by_index(ifindex); | 94 | dev = dev_get_by_index(&init_net, ifindex); |
94 | if (dev == NULL) | 95 | if (dev == NULL) |
95 | return -EINVAL; | 96 | return -EINVAL; |
96 | 97 | ||
@@ -364,7 +365,7 @@ static int old_deviceless(void __user *uarg) | |||
364 | return -EOPNOTSUPP; | 365 | return -EOPNOTSUPP; |
365 | } | 366 | } |
366 | 367 | ||
367 | int br_ioctl_deviceless_stub(unsigned int cmd, void __user *uarg) | 368 | int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *uarg) |
368 | { | 369 | { |
369 | switch (cmd) { | 370 | switch (cmd) { |
370 | case SIOCGIFBR: | 371 | case SIOCGIFBR: |
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 0fcf6f073064..53ab8e0cb518 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <net/rtnetlink.h> | 14 | #include <net/rtnetlink.h> |
15 | #include <net/net_namespace.h> | ||
15 | #include "br_private.h" | 16 | #include "br_private.h" |
16 | 17 | ||
17 | static inline size_t br_nlmsg_size(void) | 18 | static inline size_t br_nlmsg_size(void) |
@@ -110,7 +111,7 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
110 | int idx; | 111 | int idx; |
111 | 112 | ||
112 | idx = 0; | 113 | idx = 0; |
113 | for_each_netdev(dev) { | 114 | for_each_netdev(&init_net, dev) { |
114 | /* not a bridge port */ | 115 | /* not a bridge port */ |
115 | if (dev->br_port == NULL || idx < cb->args[0]) | 116 | if (dev->br_port == NULL || idx < cb->args[0]) |
116 | goto skip; | 117 | goto skip; |
@@ -155,7 +156,7 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
155 | if (new_state > BR_STATE_BLOCKING) | 156 | if (new_state > BR_STATE_BLOCKING) |
156 | return -EINVAL; | 157 | return -EINVAL; |
157 | 158 | ||
158 | dev = __dev_get_by_index(ifm->ifi_index); | 159 | dev = __dev_get_by_index(&init_net, ifm->ifi_index); |
159 | if (!dev) | 160 | if (!dev) |
160 | return -ENODEV; | 161 | return -ENODEV; |
161 | 162 | ||
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index e6dc6f52990d..f666f7b28ff5 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -192,7 +192,7 @@ extern struct sk_buff *br_handle_frame(struct net_bridge_port *p, | |||
192 | 192 | ||
193 | /* br_ioctl.c */ | 193 | /* br_ioctl.c */ |
194 | extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 194 | extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
195 | extern int br_ioctl_deviceless_stub(unsigned int cmd, void __user *arg); | 195 | extern int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *arg); |
196 | 196 | ||
197 | /* br_netfilter.c */ | 197 | /* br_netfilter.c */ |
198 | #ifdef CONFIG_BRIDGE_NETFILTER | 198 | #ifdef CONFIG_BRIDGE_NETFILTER |
diff --git a/net/core/dev.c b/net/core/dev.c index 40fd66fbe4e1..3a3d5ee73909 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -190,25 +190,22 @@ static struct net_dma net_dma = { | |||
190 | * unregister_netdevice(), which must be called with the rtnl | 190 | * unregister_netdevice(), which must be called with the rtnl |
191 | * semaphore held. | 191 | * semaphore held. |
192 | */ | 192 | */ |
193 | LIST_HEAD(dev_base_head); | ||
194 | DEFINE_RWLOCK(dev_base_lock); | 193 | DEFINE_RWLOCK(dev_base_lock); |
195 | 194 | ||
196 | EXPORT_SYMBOL(dev_base_head); | ||
197 | EXPORT_SYMBOL(dev_base_lock); | 195 | EXPORT_SYMBOL(dev_base_lock); |
198 | 196 | ||
199 | #define NETDEV_HASHBITS 8 | 197 | #define NETDEV_HASHBITS 8 |
200 | static struct hlist_head dev_name_head[1<<NETDEV_HASHBITS]; | 198 | #define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS) |
201 | static struct hlist_head dev_index_head[1<<NETDEV_HASHBITS]; | ||
202 | 199 | ||
203 | static inline struct hlist_head *dev_name_hash(const char *name) | 200 | static inline struct hlist_head *dev_name_hash(struct net *net, const char *name) |
204 | { | 201 | { |
205 | unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ)); | 202 | unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ)); |
206 | return &dev_name_head[hash & ((1<<NETDEV_HASHBITS)-1)]; | 203 | return &net->dev_name_head[hash & ((1 << NETDEV_HASHBITS) - 1)]; |
207 | } | 204 | } |
208 | 205 | ||
209 | static inline struct hlist_head *dev_index_hash(int ifindex) | 206 | static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex) |
210 | { | 207 | { |
211 | return &dev_index_head[ifindex & ((1<<NETDEV_HASHBITS)-1)]; | 208 | return &net->dev_index_head[ifindex & ((1 << NETDEV_HASHBITS) - 1)]; |
212 | } | 209 | } |
213 | 210 | ||
214 | /* | 211 | /* |
@@ -492,7 +489,7 @@ unsigned long netdev_boot_base(const char *prefix, int unit) | |||
492 | * If device already registered then return base of 1 | 489 | * If device already registered then return base of 1 |
493 | * to indicate not to probe for this interface | 490 | * to indicate not to probe for this interface |
494 | */ | 491 | */ |
495 | if (__dev_get_by_name(name)) | 492 | if (__dev_get_by_name(&init_net, name)) |
496 | return 1; | 493 | return 1; |
497 | 494 | ||
498 | for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) | 495 | for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) |
@@ -547,11 +544,11 @@ __setup("netdev=", netdev_boot_setup); | |||
547 | * careful with locks. | 544 | * careful with locks. |
548 | */ | 545 | */ |
549 | 546 | ||
550 | struct net_device *__dev_get_by_name(const char *name) | 547 | struct net_device *__dev_get_by_name(struct net *net, const char *name) |
551 | { | 548 | { |
552 | struct hlist_node *p; | 549 | struct hlist_node *p; |
553 | 550 | ||
554 | hlist_for_each(p, dev_name_hash(name)) { | 551 | hlist_for_each(p, dev_name_hash(net, name)) { |
555 | struct net_device *dev | 552 | struct net_device *dev |
556 | = hlist_entry(p, struct net_device, name_hlist); | 553 | = hlist_entry(p, struct net_device, name_hlist); |
557 | if (!strncmp(dev->name, name, IFNAMSIZ)) | 554 | if (!strncmp(dev->name, name, IFNAMSIZ)) |
@@ -571,12 +568,12 @@ struct net_device *__dev_get_by_name(const char *name) | |||
571 | * matching device is found. | 568 | * matching device is found. |
572 | */ | 569 | */ |
573 | 570 | ||
574 | struct net_device *dev_get_by_name(const char *name) | 571 | struct net_device *dev_get_by_name(struct net *net, const char *name) |
575 | { | 572 | { |
576 | struct net_device *dev; | 573 | struct net_device *dev; |
577 | 574 | ||
578 | read_lock(&dev_base_lock); | 575 | read_lock(&dev_base_lock); |
579 | dev = __dev_get_by_name(name); | 576 | dev = __dev_get_by_name(net, name); |
580 | if (dev) | 577 | if (dev) |
581 | dev_hold(dev); | 578 | dev_hold(dev); |
582 | read_unlock(&dev_base_lock); | 579 | read_unlock(&dev_base_lock); |
@@ -594,11 +591,11 @@ struct net_device *dev_get_by_name(const char *name) | |||
594 | * or @dev_base_lock. | 591 | * or @dev_base_lock. |
595 | */ | 592 | */ |
596 | 593 | ||
597 | struct net_device *__dev_get_by_index(int ifindex) | 594 | struct net_device *__dev_get_by_index(struct net *net, int ifindex) |
598 | { | 595 | { |
599 | struct hlist_node *p; | 596 | struct hlist_node *p; |
600 | 597 | ||
601 | hlist_for_each(p, dev_index_hash(ifindex)) { | 598 | hlist_for_each(p, dev_index_hash(net, ifindex)) { |
602 | struct net_device *dev | 599 | struct net_device *dev |
603 | = hlist_entry(p, struct net_device, index_hlist); | 600 | = hlist_entry(p, struct net_device, index_hlist); |
604 | if (dev->ifindex == ifindex) | 601 | if (dev->ifindex == ifindex) |
@@ -618,12 +615,12 @@ struct net_device *__dev_get_by_index(int ifindex) | |||
618 | * dev_put to indicate they have finished with it. | 615 | * dev_put to indicate they have finished with it. |
619 | */ | 616 | */ |
620 | 617 | ||
621 | struct net_device *dev_get_by_index(int ifindex) | 618 | struct net_device *dev_get_by_index(struct net *net, int ifindex) |
622 | { | 619 | { |
623 | struct net_device *dev; | 620 | struct net_device *dev; |
624 | 621 | ||
625 | read_lock(&dev_base_lock); | 622 | read_lock(&dev_base_lock); |
626 | dev = __dev_get_by_index(ifindex); | 623 | dev = __dev_get_by_index(net, ifindex); |
627 | if (dev) | 624 | if (dev) |
628 | dev_hold(dev); | 625 | dev_hold(dev); |
629 | read_unlock(&dev_base_lock); | 626 | read_unlock(&dev_base_lock); |
@@ -644,13 +641,13 @@ struct net_device *dev_get_by_index(int ifindex) | |||
644 | * If the API was consistent this would be __dev_get_by_hwaddr | 641 | * If the API was consistent this would be __dev_get_by_hwaddr |
645 | */ | 642 | */ |
646 | 643 | ||
647 | struct net_device *dev_getbyhwaddr(unsigned short type, char *ha) | 644 | struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *ha) |
648 | { | 645 | { |
649 | struct net_device *dev; | 646 | struct net_device *dev; |
650 | 647 | ||
651 | ASSERT_RTNL(); | 648 | ASSERT_RTNL(); |
652 | 649 | ||
653 | for_each_netdev(dev) | 650 | for_each_netdev(&init_net, dev) |
654 | if (dev->type == type && | 651 | if (dev->type == type && |
655 | !memcmp(dev->dev_addr, ha, dev->addr_len)) | 652 | !memcmp(dev->dev_addr, ha, dev->addr_len)) |
656 | return dev; | 653 | return dev; |
@@ -660,12 +657,12 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha) | |||
660 | 657 | ||
661 | EXPORT_SYMBOL(dev_getbyhwaddr); | 658 | EXPORT_SYMBOL(dev_getbyhwaddr); |
662 | 659 | ||
663 | struct net_device *__dev_getfirstbyhwtype(unsigned short type) | 660 | struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type) |
664 | { | 661 | { |
665 | struct net_device *dev; | 662 | struct net_device *dev; |
666 | 663 | ||
667 | ASSERT_RTNL(); | 664 | ASSERT_RTNL(); |
668 | for_each_netdev(dev) | 665 | for_each_netdev(net, dev) |
669 | if (dev->type == type) | 666 | if (dev->type == type) |
670 | return dev; | 667 | return dev; |
671 | 668 | ||
@@ -674,12 +671,12 @@ struct net_device *__dev_getfirstbyhwtype(unsigned short type) | |||
674 | 671 | ||
675 | EXPORT_SYMBOL(__dev_getfirstbyhwtype); | 672 | EXPORT_SYMBOL(__dev_getfirstbyhwtype); |
676 | 673 | ||
677 | struct net_device *dev_getfirstbyhwtype(unsigned short type) | 674 | struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type) |
678 | { | 675 | { |
679 | struct net_device *dev; | 676 | struct net_device *dev; |
680 | 677 | ||
681 | rtnl_lock(); | 678 | rtnl_lock(); |
682 | dev = __dev_getfirstbyhwtype(type); | 679 | dev = __dev_getfirstbyhwtype(net, type); |
683 | if (dev) | 680 | if (dev) |
684 | dev_hold(dev); | 681 | dev_hold(dev); |
685 | rtnl_unlock(); | 682 | rtnl_unlock(); |
@@ -699,13 +696,13 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype); | |||
699 | * dev_put to indicate they have finished with it. | 696 | * dev_put to indicate they have finished with it. |
700 | */ | 697 | */ |
701 | 698 | ||
702 | struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mask) | 699 | struct net_device * dev_get_by_flags(struct net *net, unsigned short if_flags, unsigned short mask) |
703 | { | 700 | { |
704 | struct net_device *dev, *ret; | 701 | struct net_device *dev, *ret; |
705 | 702 | ||
706 | ret = NULL; | 703 | ret = NULL; |
707 | read_lock(&dev_base_lock); | 704 | read_lock(&dev_base_lock); |
708 | for_each_netdev(dev) { | 705 | for_each_netdev(net, dev) { |
709 | if (((dev->flags ^ if_flags) & mask) == 0) { | 706 | if (((dev->flags ^ if_flags) & mask) == 0) { |
710 | dev_hold(dev); | 707 | dev_hold(dev); |
711 | ret = dev; | 708 | ret = dev; |
@@ -763,6 +760,10 @@ int dev_alloc_name(struct net_device *dev, const char *name) | |||
763 | const int max_netdevices = 8*PAGE_SIZE; | 760 | const int max_netdevices = 8*PAGE_SIZE; |
764 | long *inuse; | 761 | long *inuse; |
765 | struct net_device *d; | 762 | struct net_device *d; |
763 | struct net *net; | ||
764 | |||
765 | BUG_ON(!dev->nd_net); | ||
766 | net = dev->nd_net; | ||
766 | 767 | ||
767 | p = strnchr(name, IFNAMSIZ-1, '%'); | 768 | p = strnchr(name, IFNAMSIZ-1, '%'); |
768 | if (p) { | 769 | if (p) { |
@@ -779,7 +780,7 @@ int dev_alloc_name(struct net_device *dev, const char *name) | |||
779 | if (!inuse) | 780 | if (!inuse) |
780 | return -ENOMEM; | 781 | return -ENOMEM; |
781 | 782 | ||
782 | for_each_netdev(d) { | 783 | for_each_netdev(net, d) { |
783 | if (!sscanf(d->name, name, &i)) | 784 | if (!sscanf(d->name, name, &i)) |
784 | continue; | 785 | continue; |
785 | if (i < 0 || i >= max_netdevices) | 786 | if (i < 0 || i >= max_netdevices) |
@@ -796,7 +797,7 @@ int dev_alloc_name(struct net_device *dev, const char *name) | |||
796 | } | 797 | } |
797 | 798 | ||
798 | snprintf(buf, sizeof(buf), name, i); | 799 | snprintf(buf, sizeof(buf), name, i); |
799 | if (!__dev_get_by_name(buf)) { | 800 | if (!__dev_get_by_name(net, buf)) { |
800 | strlcpy(dev->name, buf, IFNAMSIZ); | 801 | strlcpy(dev->name, buf, IFNAMSIZ); |
801 | return i; | 802 | return i; |
802 | } | 803 | } |
@@ -822,9 +823,12 @@ int dev_change_name(struct net_device *dev, char *newname) | |||
822 | char oldname[IFNAMSIZ]; | 823 | char oldname[IFNAMSIZ]; |
823 | int err = 0; | 824 | int err = 0; |
824 | int ret; | 825 | int ret; |
826 | struct net *net; | ||
825 | 827 | ||
826 | ASSERT_RTNL(); | 828 | ASSERT_RTNL(); |
829 | BUG_ON(!dev->nd_net); | ||
827 | 830 | ||
831 | net = dev->nd_net; | ||
828 | if (dev->flags & IFF_UP) | 832 | if (dev->flags & IFF_UP) |
829 | return -EBUSY; | 833 | return -EBUSY; |
830 | 834 | ||
@@ -839,7 +843,7 @@ int dev_change_name(struct net_device *dev, char *newname) | |||
839 | return err; | 843 | return err; |
840 | strcpy(newname, dev->name); | 844 | strcpy(newname, dev->name); |
841 | } | 845 | } |
842 | else if (__dev_get_by_name(newname)) | 846 | else if (__dev_get_by_name(net, newname)) |
843 | return -EEXIST; | 847 | return -EEXIST; |
844 | else | 848 | else |
845 | strlcpy(dev->name, newname, IFNAMSIZ); | 849 | strlcpy(dev->name, newname, IFNAMSIZ); |
@@ -849,7 +853,7 @@ rollback: | |||
849 | 853 | ||
850 | write_lock_bh(&dev_base_lock); | 854 | write_lock_bh(&dev_base_lock); |
851 | hlist_del(&dev->name_hlist); | 855 | hlist_del(&dev->name_hlist); |
852 | hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); | 856 | hlist_add_head(&dev->name_hlist, dev_name_hash(net, dev->name)); |
853 | write_unlock_bh(&dev_base_lock); | 857 | write_unlock_bh(&dev_base_lock); |
854 | 858 | ||
855 | ret = raw_notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev); | 859 | ret = raw_notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev); |
@@ -908,12 +912,12 @@ void netdev_state_change(struct net_device *dev) | |||
908 | * available in this kernel then it becomes a nop. | 912 | * available in this kernel then it becomes a nop. |
909 | */ | 913 | */ |
910 | 914 | ||
911 | void dev_load(const char *name) | 915 | void dev_load(struct net *net, const char *name) |
912 | { | 916 | { |
913 | struct net_device *dev; | 917 | struct net_device *dev; |
914 | 918 | ||
915 | read_lock(&dev_base_lock); | 919 | read_lock(&dev_base_lock); |
916 | dev = __dev_get_by_name(name); | 920 | dev = __dev_get_by_name(net, name); |
917 | read_unlock(&dev_base_lock); | 921 | read_unlock(&dev_base_lock); |
918 | 922 | ||
919 | if (!dev && capable(CAP_SYS_MODULE)) | 923 | if (!dev && capable(CAP_SYS_MODULE)) |
@@ -1052,6 +1056,8 @@ int dev_close(struct net_device *dev) | |||
1052 | } | 1056 | } |
1053 | 1057 | ||
1054 | 1058 | ||
1059 | static int dev_boot_phase = 1; | ||
1060 | |||
1055 | /* | 1061 | /* |
1056 | * Device change register/unregister. These are not inline or static | 1062 | * Device change register/unregister. These are not inline or static |
1057 | * as we export them to the world. | 1063 | * as we export them to the world. |
@@ -1075,23 +1081,27 @@ int register_netdevice_notifier(struct notifier_block *nb) | |||
1075 | { | 1081 | { |
1076 | struct net_device *dev; | 1082 | struct net_device *dev; |
1077 | struct net_device *last; | 1083 | struct net_device *last; |
1084 | struct net *net; | ||
1078 | int err; | 1085 | int err; |
1079 | 1086 | ||
1080 | rtnl_lock(); | 1087 | rtnl_lock(); |
1081 | err = raw_notifier_chain_register(&netdev_chain, nb); | 1088 | err = raw_notifier_chain_register(&netdev_chain, nb); |
1082 | if (err) | 1089 | if (err) |
1083 | goto unlock; | 1090 | goto unlock; |
1091 | if (dev_boot_phase) | ||
1092 | goto unlock; | ||
1093 | for_each_net(net) { | ||
1094 | for_each_netdev(net, dev) { | ||
1095 | err = nb->notifier_call(nb, NETDEV_REGISTER, dev); | ||
1096 | err = notifier_to_errno(err); | ||
1097 | if (err) | ||
1098 | goto rollback; | ||
1099 | |||
1100 | if (!(dev->flags & IFF_UP)) | ||
1101 | continue; | ||
1084 | 1102 | ||
1085 | for_each_netdev(dev) { | 1103 | nb->notifier_call(nb, NETDEV_UP, dev); |
1086 | err = nb->notifier_call(nb, NETDEV_REGISTER, dev); | 1104 | } |
1087 | err = notifier_to_errno(err); | ||
1088 | if (err) | ||
1089 | goto rollback; | ||
1090 | |||
1091 | if (!(dev->flags & IFF_UP)) | ||
1092 | continue; | ||
1093 | |||
1094 | nb->notifier_call(nb, NETDEV_UP, dev); | ||
1095 | } | 1105 | } |
1096 | 1106 | ||
1097 | unlock: | 1107 | unlock: |
@@ -1100,15 +1110,17 @@ unlock: | |||
1100 | 1110 | ||
1101 | rollback: | 1111 | rollback: |
1102 | last = dev; | 1112 | last = dev; |
1103 | for_each_netdev(dev) { | 1113 | for_each_net(net) { |
1104 | if (dev == last) | 1114 | for_each_netdev(net, dev) { |
1105 | break; | 1115 | if (dev == last) |
1116 | break; | ||
1106 | 1117 | ||
1107 | if (dev->flags & IFF_UP) { | 1118 | if (dev->flags & IFF_UP) { |
1108 | nb->notifier_call(nb, NETDEV_GOING_DOWN, dev); | 1119 | nb->notifier_call(nb, NETDEV_GOING_DOWN, dev); |
1109 | nb->notifier_call(nb, NETDEV_DOWN, dev); | 1120 | nb->notifier_call(nb, NETDEV_DOWN, dev); |
1121 | } | ||
1122 | nb->notifier_call(nb, NETDEV_UNREGISTER, dev); | ||
1110 | } | 1123 | } |
1111 | nb->notifier_call(nb, NETDEV_UNREGISTER, dev); | ||
1112 | } | 1124 | } |
1113 | goto unlock; | 1125 | goto unlock; |
1114 | } | 1126 | } |
@@ -2187,7 +2199,7 @@ int register_gifconf(unsigned int family, gifconf_func_t * gifconf) | |||
2187 | * match. --pb | 2199 | * match. --pb |
2188 | */ | 2200 | */ |
2189 | 2201 | ||
2190 | static int dev_ifname(struct ifreq __user *arg) | 2202 | static int dev_ifname(struct net *net, struct ifreq __user *arg) |
2191 | { | 2203 | { |
2192 | struct net_device *dev; | 2204 | struct net_device *dev; |
2193 | struct ifreq ifr; | 2205 | struct ifreq ifr; |
@@ -2200,7 +2212,7 @@ static int dev_ifname(struct ifreq __user *arg) | |||
2200 | return -EFAULT; | 2212 | return -EFAULT; |
2201 | 2213 | ||
2202 | read_lock(&dev_base_lock); | 2214 | read_lock(&dev_base_lock); |
2203 | dev = __dev_get_by_index(ifr.ifr_ifindex); | 2215 | dev = __dev_get_by_index(net, ifr.ifr_ifindex); |
2204 | if (!dev) { | 2216 | if (!dev) { |
2205 | read_unlock(&dev_base_lock); | 2217 | read_unlock(&dev_base_lock); |
2206 | return -ENODEV; | 2218 | return -ENODEV; |
@@ -2220,7 +2232,7 @@ static int dev_ifname(struct ifreq __user *arg) | |||
2220 | * Thus we will need a 'compatibility mode'. | 2232 | * Thus we will need a 'compatibility mode'. |
2221 | */ | 2233 | */ |
2222 | 2234 | ||
2223 | static int dev_ifconf(char __user *arg) | 2235 | static int dev_ifconf(struct net *net, char __user *arg) |
2224 | { | 2236 | { |
2225 | struct ifconf ifc; | 2237 | struct ifconf ifc; |
2226 | struct net_device *dev; | 2238 | struct net_device *dev; |
@@ -2244,7 +2256,7 @@ static int dev_ifconf(char __user *arg) | |||
2244 | */ | 2256 | */ |
2245 | 2257 | ||
2246 | total = 0; | 2258 | total = 0; |
2247 | for_each_netdev(dev) { | 2259 | for_each_netdev(net, dev) { |
2248 | for (i = 0; i < NPROTO; i++) { | 2260 | for (i = 0; i < NPROTO; i++) { |
2249 | if (gifconf_list[i]) { | 2261 | if (gifconf_list[i]) { |
2250 | int done; | 2262 | int done; |
@@ -2278,6 +2290,7 @@ static int dev_ifconf(char __user *arg) | |||
2278 | */ | 2290 | */ |
2279 | void *dev_seq_start(struct seq_file *seq, loff_t *pos) | 2291 | void *dev_seq_start(struct seq_file *seq, loff_t *pos) |
2280 | { | 2292 | { |
2293 | struct net *net = seq->private; | ||
2281 | loff_t off; | 2294 | loff_t off; |
2282 | struct net_device *dev; | 2295 | struct net_device *dev; |
2283 | 2296 | ||
@@ -2286,7 +2299,7 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos) | |||
2286 | return SEQ_START_TOKEN; | 2299 | return SEQ_START_TOKEN; |
2287 | 2300 | ||
2288 | off = 1; | 2301 | off = 1; |
2289 | for_each_netdev(dev) | 2302 | for_each_netdev(net, dev) |
2290 | if (off++ == *pos) | 2303 | if (off++ == *pos) |
2291 | return dev; | 2304 | return dev; |
2292 | 2305 | ||
@@ -2295,9 +2308,10 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos) | |||
2295 | 2308 | ||
2296 | void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2309 | void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
2297 | { | 2310 | { |
2311 | struct net *net = seq->private; | ||
2298 | ++*pos; | 2312 | ++*pos; |
2299 | return v == SEQ_START_TOKEN ? | 2313 | return v == SEQ_START_TOKEN ? |
2300 | first_net_device() : next_net_device((struct net_device *)v); | 2314 | first_net_device(net) : next_net_device((struct net_device *)v); |
2301 | } | 2315 | } |
2302 | 2316 | ||
2303 | void dev_seq_stop(struct seq_file *seq, void *v) | 2317 | void dev_seq_stop(struct seq_file *seq, void *v) |
@@ -2393,7 +2407,22 @@ static const struct seq_operations dev_seq_ops = { | |||
2393 | 2407 | ||
2394 | static int dev_seq_open(struct inode *inode, struct file *file) | 2408 | static int dev_seq_open(struct inode *inode, struct file *file) |
2395 | { | 2409 | { |
2396 | return seq_open(file, &dev_seq_ops); | 2410 | struct seq_file *seq; |
2411 | int res; | ||
2412 | res = seq_open(file, &dev_seq_ops); | ||
2413 | if (!res) { | ||
2414 | seq = file->private_data; | ||
2415 | seq->private = get_net(PROC_NET(inode)); | ||
2416 | } | ||
2417 | return res; | ||
2418 | } | ||
2419 | |||
2420 | static int dev_seq_release(struct inode *inode, struct file *file) | ||
2421 | { | ||
2422 | struct seq_file *seq = file->private_data; | ||
2423 | struct net *net = seq->private; | ||
2424 | put_net(net); | ||
2425 | return seq_release(inode, file); | ||
2397 | } | 2426 | } |
2398 | 2427 | ||
2399 | static const struct file_operations dev_seq_fops = { | 2428 | static const struct file_operations dev_seq_fops = { |
@@ -2401,7 +2430,7 @@ static const struct file_operations dev_seq_fops = { | |||
2401 | .open = dev_seq_open, | 2430 | .open = dev_seq_open, |
2402 | .read = seq_read, | 2431 | .read = seq_read, |
2403 | .llseek = seq_lseek, | 2432 | .llseek = seq_lseek, |
2404 | .release = seq_release, | 2433 | .release = dev_seq_release, |
2405 | }; | 2434 | }; |
2406 | 2435 | ||
2407 | static const struct seq_operations softnet_seq_ops = { | 2436 | static const struct seq_operations softnet_seq_ops = { |
@@ -2553,30 +2582,49 @@ static const struct file_operations ptype_seq_fops = { | |||
2553 | }; | 2582 | }; |
2554 | 2583 | ||
2555 | 2584 | ||
2556 | static int __init dev_proc_init(void) | 2585 | static int dev_proc_net_init(struct net *net) |
2557 | { | 2586 | { |
2558 | int rc = -ENOMEM; | 2587 | int rc = -ENOMEM; |
2559 | 2588 | ||
2560 | if (!proc_net_fops_create(&init_net, "dev", S_IRUGO, &dev_seq_fops)) | 2589 | if (!proc_net_fops_create(net, "dev", S_IRUGO, &dev_seq_fops)) |
2561 | goto out; | 2590 | goto out; |
2562 | if (!proc_net_fops_create(&init_net, "softnet_stat", S_IRUGO, &softnet_seq_fops)) | 2591 | if (!proc_net_fops_create(net, "softnet_stat", S_IRUGO, &softnet_seq_fops)) |
2563 | goto out_dev; | 2592 | goto out_dev; |
2564 | if (!proc_net_fops_create(&init_net, "ptype", S_IRUGO, &ptype_seq_fops)) | 2593 | if (!proc_net_fops_create(net, "ptype", S_IRUGO, &ptype_seq_fops)) |
2565 | goto out_softnet; | 2594 | goto out_softnet; |
2566 | 2595 | ||
2567 | if (wext_proc_init()) | 2596 | if (wext_proc_init(net)) |
2568 | goto out_ptype; | 2597 | goto out_ptype; |
2569 | rc = 0; | 2598 | rc = 0; |
2570 | out: | 2599 | out: |
2571 | return rc; | 2600 | return rc; |
2572 | out_ptype: | 2601 | out_ptype: |
2573 | proc_net_remove(&init_net, "ptype"); | 2602 | proc_net_remove(net, "ptype"); |
2574 | out_softnet: | 2603 | out_softnet: |
2575 | proc_net_remove(&init_net, "softnet_stat"); | 2604 | proc_net_remove(net, "softnet_stat"); |
2576 | out_dev: | 2605 | out_dev: |
2577 | proc_net_remove(&init_net, "dev"); | 2606 | proc_net_remove(net, "dev"); |
2578 | goto out; | 2607 | goto out; |
2579 | } | 2608 | } |
2609 | |||
2610 | static void dev_proc_net_exit(struct net *net) | ||
2611 | { | ||
2612 | wext_proc_exit(net); | ||
2613 | |||
2614 | proc_net_remove(net, "ptype"); | ||
2615 | proc_net_remove(net, "softnet_stat"); | ||
2616 | proc_net_remove(net, "dev"); | ||
2617 | } | ||
2618 | |||
2619 | static struct pernet_operations dev_proc_ops = { | ||
2620 | .init = dev_proc_net_init, | ||
2621 | .exit = dev_proc_net_exit, | ||
2622 | }; | ||
2623 | |||
2624 | static int __init dev_proc_init(void) | ||
2625 | { | ||
2626 | return register_pernet_subsys(&dev_proc_ops); | ||
2627 | } | ||
2580 | #else | 2628 | #else |
2581 | #define dev_proc_init() 0 | 2629 | #define dev_proc_init() 0 |
2582 | #endif /* CONFIG_PROC_FS */ | 2630 | #endif /* CONFIG_PROC_FS */ |
@@ -3011,10 +3059,10 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) | |||
3011 | /* | 3059 | /* |
3012 | * Perform the SIOCxIFxxx calls. | 3060 | * Perform the SIOCxIFxxx calls. |
3013 | */ | 3061 | */ |
3014 | static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd) | 3062 | static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) |
3015 | { | 3063 | { |
3016 | int err; | 3064 | int err; |
3017 | struct net_device *dev = __dev_get_by_name(ifr->ifr_name); | 3065 | struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); |
3018 | 3066 | ||
3019 | if (!dev) | 3067 | if (!dev) |
3020 | return -ENODEV; | 3068 | return -ENODEV; |
@@ -3167,7 +3215,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd) | |||
3167 | * positive or a negative errno code on error. | 3215 | * positive or a negative errno code on error. |
3168 | */ | 3216 | */ |
3169 | 3217 | ||
3170 | int dev_ioctl(unsigned int cmd, void __user *arg) | 3218 | int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) |
3171 | { | 3219 | { |
3172 | struct ifreq ifr; | 3220 | struct ifreq ifr; |
3173 | int ret; | 3221 | int ret; |
@@ -3180,12 +3228,12 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3180 | 3228 | ||
3181 | if (cmd == SIOCGIFCONF) { | 3229 | if (cmd == SIOCGIFCONF) { |
3182 | rtnl_lock(); | 3230 | rtnl_lock(); |
3183 | ret = dev_ifconf((char __user *) arg); | 3231 | ret = dev_ifconf(net, (char __user *) arg); |
3184 | rtnl_unlock(); | 3232 | rtnl_unlock(); |
3185 | return ret; | 3233 | return ret; |
3186 | } | 3234 | } |
3187 | if (cmd == SIOCGIFNAME) | 3235 | if (cmd == SIOCGIFNAME) |
3188 | return dev_ifname((struct ifreq __user *)arg); | 3236 | return dev_ifname(net, (struct ifreq __user *)arg); |
3189 | 3237 | ||
3190 | if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) | 3238 | if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) |
3191 | return -EFAULT; | 3239 | return -EFAULT; |
@@ -3215,9 +3263,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3215 | case SIOCGIFMAP: | 3263 | case SIOCGIFMAP: |
3216 | case SIOCGIFINDEX: | 3264 | case SIOCGIFINDEX: |
3217 | case SIOCGIFTXQLEN: | 3265 | case SIOCGIFTXQLEN: |
3218 | dev_load(ifr.ifr_name); | 3266 | dev_load(net, ifr.ifr_name); |
3219 | read_lock(&dev_base_lock); | 3267 | read_lock(&dev_base_lock); |
3220 | ret = dev_ifsioc(&ifr, cmd); | 3268 | ret = dev_ifsioc(net, &ifr, cmd); |
3221 | read_unlock(&dev_base_lock); | 3269 | read_unlock(&dev_base_lock); |
3222 | if (!ret) { | 3270 | if (!ret) { |
3223 | if (colon) | 3271 | if (colon) |
@@ -3229,9 +3277,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3229 | return ret; | 3277 | return ret; |
3230 | 3278 | ||
3231 | case SIOCETHTOOL: | 3279 | case SIOCETHTOOL: |
3232 | dev_load(ifr.ifr_name); | 3280 | dev_load(net, ifr.ifr_name); |
3233 | rtnl_lock(); | 3281 | rtnl_lock(); |
3234 | ret = dev_ethtool(&ifr); | 3282 | ret = dev_ethtool(net, &ifr); |
3235 | rtnl_unlock(); | 3283 | rtnl_unlock(); |
3236 | if (!ret) { | 3284 | if (!ret) { |
3237 | if (colon) | 3285 | if (colon) |
@@ -3253,9 +3301,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3253 | case SIOCSIFNAME: | 3301 | case SIOCSIFNAME: |
3254 | if (!capable(CAP_NET_ADMIN)) | 3302 | if (!capable(CAP_NET_ADMIN)) |
3255 | return -EPERM; | 3303 | return -EPERM; |
3256 | dev_load(ifr.ifr_name); | 3304 | dev_load(net, ifr.ifr_name); |
3257 | rtnl_lock(); | 3305 | rtnl_lock(); |
3258 | ret = dev_ifsioc(&ifr, cmd); | 3306 | ret = dev_ifsioc(net, &ifr, cmd); |
3259 | rtnl_unlock(); | 3307 | rtnl_unlock(); |
3260 | if (!ret) { | 3308 | if (!ret) { |
3261 | if (colon) | 3309 | if (colon) |
@@ -3294,9 +3342,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3294 | /* fall through */ | 3342 | /* fall through */ |
3295 | case SIOCBONDSLAVEINFOQUERY: | 3343 | case SIOCBONDSLAVEINFOQUERY: |
3296 | case SIOCBONDINFOQUERY: | 3344 | case SIOCBONDINFOQUERY: |
3297 | dev_load(ifr.ifr_name); | 3345 | dev_load(net, ifr.ifr_name); |
3298 | rtnl_lock(); | 3346 | rtnl_lock(); |
3299 | ret = dev_ifsioc(&ifr, cmd); | 3347 | ret = dev_ifsioc(net, &ifr, cmd); |
3300 | rtnl_unlock(); | 3348 | rtnl_unlock(); |
3301 | return ret; | 3349 | return ret; |
3302 | 3350 | ||
@@ -3316,9 +3364,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3316 | if (cmd == SIOCWANDEV || | 3364 | if (cmd == SIOCWANDEV || |
3317 | (cmd >= SIOCDEVPRIVATE && | 3365 | (cmd >= SIOCDEVPRIVATE && |
3318 | cmd <= SIOCDEVPRIVATE + 15)) { | 3366 | cmd <= SIOCDEVPRIVATE + 15)) { |
3319 | dev_load(ifr.ifr_name); | 3367 | dev_load(net, ifr.ifr_name); |
3320 | rtnl_lock(); | 3368 | rtnl_lock(); |
3321 | ret = dev_ifsioc(&ifr, cmd); | 3369 | ret = dev_ifsioc(net, &ifr, cmd); |
3322 | rtnl_unlock(); | 3370 | rtnl_unlock(); |
3323 | if (!ret && copy_to_user(arg, &ifr, | 3371 | if (!ret && copy_to_user(arg, &ifr, |
3324 | sizeof(struct ifreq))) | 3372 | sizeof(struct ifreq))) |
@@ -3327,7 +3375,7 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3327 | } | 3375 | } |
3328 | /* Take care of Wireless Extensions */ | 3376 | /* Take care of Wireless Extensions */ |
3329 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) | 3377 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) |
3330 | return wext_handle_ioctl(&ifr, cmd, arg); | 3378 | return wext_handle_ioctl(net, &ifr, cmd, arg); |
3331 | return -EINVAL; | 3379 | return -EINVAL; |
3332 | } | 3380 | } |
3333 | } | 3381 | } |
@@ -3340,19 +3388,17 @@ int dev_ioctl(unsigned int cmd, void __user *arg) | |||
3340 | * number. The caller must hold the rtnl semaphore or the | 3388 | * number. The caller must hold the rtnl semaphore or the |
3341 | * dev_base_lock to be sure it remains unique. | 3389 | * dev_base_lock to be sure it remains unique. |
3342 | */ | 3390 | */ |
3343 | static int dev_new_index(void) | 3391 | static int dev_new_index(struct net *net) |
3344 | { | 3392 | { |
3345 | static int ifindex; | 3393 | static int ifindex; |
3346 | for (;;) { | 3394 | for (;;) { |
3347 | if (++ifindex <= 0) | 3395 | if (++ifindex <= 0) |
3348 | ifindex = 1; | 3396 | ifindex = 1; |
3349 | if (!__dev_get_by_index(ifindex)) | 3397 | if (!__dev_get_by_index(net, ifindex)) |
3350 | return ifindex; | 3398 | return ifindex; |
3351 | } | 3399 | } |
3352 | } | 3400 | } |
3353 | 3401 | ||
3354 | static int dev_boot_phase = 1; | ||
3355 | |||
3356 | /* Delayed registration/unregisteration */ | 3402 | /* Delayed registration/unregisteration */ |
3357 | static DEFINE_SPINLOCK(net_todo_list_lock); | 3403 | static DEFINE_SPINLOCK(net_todo_list_lock); |
3358 | static struct list_head net_todo_list = LIST_HEAD_INIT(net_todo_list); | 3404 | static struct list_head net_todo_list = LIST_HEAD_INIT(net_todo_list); |
@@ -3386,6 +3432,7 @@ int register_netdevice(struct net_device *dev) | |||
3386 | struct hlist_head *head; | 3432 | struct hlist_head *head; |
3387 | struct hlist_node *p; | 3433 | struct hlist_node *p; |
3388 | int ret; | 3434 | int ret; |
3435 | struct net *net; | ||
3389 | 3436 | ||
3390 | BUG_ON(dev_boot_phase); | 3437 | BUG_ON(dev_boot_phase); |
3391 | ASSERT_RTNL(); | 3438 | ASSERT_RTNL(); |
@@ -3394,6 +3441,8 @@ int register_netdevice(struct net_device *dev) | |||
3394 | 3441 | ||
3395 | /* When net_device's are persistent, this will be fatal. */ | 3442 | /* When net_device's are persistent, this will be fatal. */ |
3396 | BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); | 3443 | BUG_ON(dev->reg_state != NETREG_UNINITIALIZED); |
3444 | BUG_ON(!dev->nd_net); | ||
3445 | net = dev->nd_net; | ||
3397 | 3446 | ||
3398 | spin_lock_init(&dev->queue_lock); | 3447 | spin_lock_init(&dev->queue_lock); |
3399 | spin_lock_init(&dev->_xmit_lock); | 3448 | spin_lock_init(&dev->_xmit_lock); |
@@ -3418,12 +3467,12 @@ int register_netdevice(struct net_device *dev) | |||
3418 | goto err_uninit; | 3467 | goto err_uninit; |
3419 | } | 3468 | } |
3420 | 3469 | ||
3421 | dev->ifindex = dev_new_index(); | 3470 | dev->ifindex = dev_new_index(net); |
3422 | if (dev->iflink == -1) | 3471 | if (dev->iflink == -1) |
3423 | dev->iflink = dev->ifindex; | 3472 | dev->iflink = dev->ifindex; |
3424 | 3473 | ||
3425 | /* Check for existence of name */ | 3474 | /* Check for existence of name */ |
3426 | head = dev_name_hash(dev->name); | 3475 | head = dev_name_hash(net, dev->name); |
3427 | hlist_for_each(p, head) { | 3476 | hlist_for_each(p, head) { |
3428 | struct net_device *d | 3477 | struct net_device *d |
3429 | = hlist_entry(p, struct net_device, name_hlist); | 3478 | = hlist_entry(p, struct net_device, name_hlist); |
@@ -3501,9 +3550,9 @@ int register_netdevice(struct net_device *dev) | |||
3501 | 3550 | ||
3502 | dev_init_scheduler(dev); | 3551 | dev_init_scheduler(dev); |
3503 | write_lock_bh(&dev_base_lock); | 3552 | write_lock_bh(&dev_base_lock); |
3504 | list_add_tail(&dev->dev_list, &dev_base_head); | 3553 | list_add_tail(&dev->dev_list, &net->dev_base_head); |
3505 | hlist_add_head(&dev->name_hlist, head); | 3554 | hlist_add_head(&dev->name_hlist, head); |
3506 | hlist_add_head(&dev->index_hlist, dev_index_hash(dev->ifindex)); | 3555 | hlist_add_head(&dev->index_hlist, dev_index_hash(net, dev->ifindex)); |
3507 | dev_hold(dev); | 3556 | dev_hold(dev); |
3508 | write_unlock_bh(&dev_base_lock); | 3557 | write_unlock_bh(&dev_base_lock); |
3509 | 3558 | ||
@@ -4067,6 +4116,45 @@ int netdev_compute_features(unsigned long all, unsigned long one) | |||
4067 | } | 4116 | } |
4068 | EXPORT_SYMBOL(netdev_compute_features); | 4117 | EXPORT_SYMBOL(netdev_compute_features); |
4069 | 4118 | ||
4119 | /* Initialize per network namespace state */ | ||
4120 | static int netdev_init(struct net *net) | ||
4121 | { | ||
4122 | int i; | ||
4123 | INIT_LIST_HEAD(&net->dev_base_head); | ||
4124 | rwlock_init(&dev_base_lock); | ||
4125 | |||
4126 | net->dev_name_head = kmalloc( | ||
4127 | sizeof(*net->dev_name_head)*NETDEV_HASHENTRIES, GFP_KERNEL); | ||
4128 | if (!net->dev_name_head) | ||
4129 | return -ENOMEM; | ||
4130 | |||
4131 | net->dev_index_head = kmalloc( | ||
4132 | sizeof(*net->dev_index_head)*NETDEV_HASHENTRIES, GFP_KERNEL); | ||
4133 | if (!net->dev_index_head) { | ||
4134 | kfree(net->dev_name_head); | ||
4135 | return -ENOMEM; | ||
4136 | } | ||
4137 | |||
4138 | for (i = 0; i < NETDEV_HASHENTRIES; i++) | ||
4139 | INIT_HLIST_HEAD(&net->dev_name_head[i]); | ||
4140 | |||
4141 | for (i = 0; i < NETDEV_HASHENTRIES; i++) | ||
4142 | INIT_HLIST_HEAD(&net->dev_index_head[i]); | ||
4143 | |||
4144 | return 0; | ||
4145 | } | ||
4146 | |||
4147 | static void netdev_exit(struct net *net) | ||
4148 | { | ||
4149 | kfree(net->dev_name_head); | ||
4150 | kfree(net->dev_index_head); | ||
4151 | } | ||
4152 | |||
4153 | static struct pernet_operations netdev_net_ops = { | ||
4154 | .init = netdev_init, | ||
4155 | .exit = netdev_exit, | ||
4156 | }; | ||
4157 | |||
4070 | /* | 4158 | /* |
4071 | * Initialize the DEV module. At boot time this walks the device list and | 4159 | * Initialize the DEV module. At boot time this walks the device list and |
4072 | * unhooks any devices that fail to initialise (normally hardware not | 4160 | * unhooks any devices that fail to initialise (normally hardware not |
@@ -4094,11 +4182,8 @@ static int __init net_dev_init(void) | |||
4094 | for (i = 0; i < 16; i++) | 4182 | for (i = 0; i < 16; i++) |
4095 | INIT_LIST_HEAD(&ptype_base[i]); | 4183 | INIT_LIST_HEAD(&ptype_base[i]); |
4096 | 4184 | ||
4097 | for (i = 0; i < ARRAY_SIZE(dev_name_head); i++) | 4185 | if (register_pernet_subsys(&netdev_net_ops)) |
4098 | INIT_HLIST_HEAD(&dev_name_head[i]); | 4186 | goto out; |
4099 | |||
4100 | for (i = 0; i < ARRAY_SIZE(dev_index_head); i++) | ||
4101 | INIT_HLIST_HEAD(&dev_index_head[i]); | ||
4102 | 4187 | ||
4103 | /* | 4188 | /* |
4104 | * Initialise the packet receive queues. | 4189 | * Initialise the packet receive queues. |
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c index 8e069fc207cb..1c4f6198459b 100644 --- a/net/core/dev_mcast.c +++ b/net/core/dev_mcast.c | |||
@@ -187,11 +187,12 @@ EXPORT_SYMBOL(dev_mc_unsync); | |||
187 | #ifdef CONFIG_PROC_FS | 187 | #ifdef CONFIG_PROC_FS |
188 | static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) | 188 | static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) |
189 | { | 189 | { |
190 | struct net *net = seq->private; | ||
190 | struct net_device *dev; | 191 | struct net_device *dev; |
191 | loff_t off = 0; | 192 | loff_t off = 0; |
192 | 193 | ||
193 | read_lock(&dev_base_lock); | 194 | read_lock(&dev_base_lock); |
194 | for_each_netdev(dev) { | 195 | for_each_netdev(net, dev) { |
195 | if (off++ == *pos) | 196 | if (off++ == *pos) |
196 | return dev; | 197 | return dev; |
197 | } | 198 | } |
@@ -240,7 +241,22 @@ static const struct seq_operations dev_mc_seq_ops = { | |||
240 | 241 | ||
241 | static int dev_mc_seq_open(struct inode *inode, struct file *file) | 242 | static int dev_mc_seq_open(struct inode *inode, struct file *file) |
242 | { | 243 | { |
243 | return seq_open(file, &dev_mc_seq_ops); | 244 | struct seq_file *seq; |
245 | int res; | ||
246 | res = seq_open(file, &dev_mc_seq_ops); | ||
247 | if (!res) { | ||
248 | seq = file->private_data; | ||
249 | seq->private = get_net(PROC_NET(inode)); | ||
250 | } | ||
251 | return res; | ||
252 | } | ||
253 | |||
254 | static int dev_mc_seq_release(struct inode *inode, struct file *file) | ||
255 | { | ||
256 | struct seq_file *seq = file->private_data; | ||
257 | struct net *net = seq->private; | ||
258 | put_net(net); | ||
259 | return seq_release(inode, file); | ||
244 | } | 260 | } |
245 | 261 | ||
246 | static const struct file_operations dev_mc_seq_fops = { | 262 | static const struct file_operations dev_mc_seq_fops = { |
@@ -248,14 +264,31 @@ static const struct file_operations dev_mc_seq_fops = { | |||
248 | .open = dev_mc_seq_open, | 264 | .open = dev_mc_seq_open, |
249 | .read = seq_read, | 265 | .read = seq_read, |
250 | .llseek = seq_lseek, | 266 | .llseek = seq_lseek, |
251 | .release = seq_release, | 267 | .release = dev_mc_seq_release, |
252 | }; | 268 | }; |
253 | 269 | ||
254 | #endif | 270 | #endif |
255 | 271 | ||
272 | static int dev_mc_net_init(struct net *net) | ||
273 | { | ||
274 | if (!proc_net_fops_create(net, "dev_mcast", 0, &dev_mc_seq_fops)) | ||
275 | return -ENOMEM; | ||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | static void dev_mc_net_exit(struct net *net) | ||
280 | { | ||
281 | proc_net_remove(net, "dev_mcast"); | ||
282 | } | ||
283 | |||
284 | static struct pernet_operations dev_mc_net_ops = { | ||
285 | .init = dev_mc_net_init, | ||
286 | .exit = dev_mc_net_exit, | ||
287 | }; | ||
288 | |||
256 | void __init dev_mcast_init(void) | 289 | void __init dev_mcast_init(void) |
257 | { | 290 | { |
258 | proc_net_fops_create(&init_net, "dev_mcast", 0, &dev_mc_seq_fops); | 291 | register_pernet_subsys(&dev_mc_net_ops); |
259 | } | 292 | } |
260 | 293 | ||
261 | EXPORT_SYMBOL(dev_mc_add); | 294 | EXPORT_SYMBOL(dev_mc_add); |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 7c43f032a7f9..0d0b13cc1dd3 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -779,9 +779,9 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr, | |||
779 | 779 | ||
780 | /* The main entry point in this file. Called from net/core/dev.c */ | 780 | /* The main entry point in this file. Called from net/core/dev.c */ |
781 | 781 | ||
782 | int dev_ethtool(struct ifreq *ifr) | 782 | int dev_ethtool(struct net *net, struct ifreq *ifr) |
783 | { | 783 | { |
784 | struct net_device *dev = __dev_get_by_name(ifr->ifr_name); | 784 | struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); |
785 | void __user *useraddr = ifr->ifr_data; | 785 | void __user *useraddr = ifr->ifr_data; |
786 | u32 ethcmd; | 786 | u32 ethcmd; |
787 | int rc; | 787 | int rc; |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 9eabe1ae01dc..1ba71baf87ef 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <net/net_namespace.h> | 14 | #include <net/net_namespace.h> |
15 | #include <net/sock.h> | ||
15 | #include <net/fib_rules.h> | 16 | #include <net/fib_rules.h> |
16 | 17 | ||
17 | static LIST_HEAD(rules_ops); | 18 | static LIST_HEAD(rules_ops); |
@@ -198,6 +199,7 @@ errout: | |||
198 | 199 | ||
199 | static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | 200 | static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) |
200 | { | 201 | { |
202 | struct net *net = skb->sk->sk_net; | ||
201 | struct fib_rule_hdr *frh = nlmsg_data(nlh); | 203 | struct fib_rule_hdr *frh = nlmsg_data(nlh); |
202 | struct fib_rules_ops *ops = NULL; | 204 | struct fib_rules_ops *ops = NULL; |
203 | struct fib_rule *rule, *r, *last = NULL; | 205 | struct fib_rule *rule, *r, *last = NULL; |
@@ -235,7 +237,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
235 | 237 | ||
236 | rule->ifindex = -1; | 238 | rule->ifindex = -1; |
237 | nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ); | 239 | nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ); |
238 | dev = __dev_get_by_name(rule->ifname); | 240 | dev = __dev_get_by_name(net, rule->ifname); |
239 | if (dev) | 241 | if (dev) |
240 | rule->ifindex = dev->ifindex; | 242 | rule->ifindex = dev->ifindex; |
241 | } | 243 | } |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 5f25f4f79b8c..2c6577c1eedd 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1441,6 +1441,7 @@ int neigh_table_clear(struct neigh_table *tbl) | |||
1441 | 1441 | ||
1442 | static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 1442 | static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
1443 | { | 1443 | { |
1444 | struct net *net = skb->sk->sk_net; | ||
1444 | struct ndmsg *ndm; | 1445 | struct ndmsg *ndm; |
1445 | struct nlattr *dst_attr; | 1446 | struct nlattr *dst_attr; |
1446 | struct neigh_table *tbl; | 1447 | struct neigh_table *tbl; |
@@ -1456,7 +1457,7 @@ static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
1456 | 1457 | ||
1457 | ndm = nlmsg_data(nlh); | 1458 | ndm = nlmsg_data(nlh); |
1458 | if (ndm->ndm_ifindex) { | 1459 | if (ndm->ndm_ifindex) { |
1459 | dev = dev_get_by_index(ndm->ndm_ifindex); | 1460 | dev = dev_get_by_index(net, ndm->ndm_ifindex); |
1460 | if (dev == NULL) { | 1461 | if (dev == NULL) { |
1461 | err = -ENODEV; | 1462 | err = -ENODEV; |
1462 | goto out; | 1463 | goto out; |
@@ -1506,6 +1507,7 @@ out: | |||
1506 | 1507 | ||
1507 | static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 1508 | static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
1508 | { | 1509 | { |
1510 | struct net *net = skb->sk->sk_net; | ||
1509 | struct ndmsg *ndm; | 1511 | struct ndmsg *ndm; |
1510 | struct nlattr *tb[NDA_MAX+1]; | 1512 | struct nlattr *tb[NDA_MAX+1]; |
1511 | struct neigh_table *tbl; | 1513 | struct neigh_table *tbl; |
@@ -1522,7 +1524,7 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
1522 | 1524 | ||
1523 | ndm = nlmsg_data(nlh); | 1525 | ndm = nlmsg_data(nlh); |
1524 | if (ndm->ndm_ifindex) { | 1526 | if (ndm->ndm_ifindex) { |
1525 | dev = dev_get_by_index(ndm->ndm_ifindex); | 1527 | dev = dev_get_by_index(net, ndm->ndm_ifindex); |
1526 | if (dev == NULL) { | 1528 | if (dev == NULL) { |
1527 | err = -ENODEV; | 1529 | err = -ENODEV; |
1528 | goto out; | 1530 | goto out; |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 0952f936b292..bb7523a5b408 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -653,7 +653,7 @@ int netpoll_setup(struct netpoll *np) | |||
653 | int err; | 653 | int err; |
654 | 654 | ||
655 | if (np->dev_name) | 655 | if (np->dev_name) |
656 | ndev = dev_get_by_name(np->dev_name); | 656 | ndev = dev_get_by_name(&init_net, np->dev_name); |
657 | if (!ndev) { | 657 | if (!ndev) { |
658 | printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", | 658 | printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", |
659 | np->name, np->dev_name); | 659 | np->name, np->dev_name); |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index d7c30ce095a1..94e42be16daa 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -2008,7 +2008,7 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) | |||
2008 | pkt_dev->odev = NULL; | 2008 | pkt_dev->odev = NULL; |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | odev = dev_get_by_name(ifname); | 2011 | odev = dev_get_by_name(&init_net, ifname); |
2012 | if (!odev) { | 2012 | if (!odev) { |
2013 | printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname); | 2013 | printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname); |
2014 | return -ENODEV; | 2014 | return -ENODEV; |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 416768d1e0cd..44f91bb1ae8d 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -306,10 +306,13 @@ EXPORT_SYMBOL_GPL(rtnl_link_register); | |||
306 | void __rtnl_link_unregister(struct rtnl_link_ops *ops) | 306 | void __rtnl_link_unregister(struct rtnl_link_ops *ops) |
307 | { | 307 | { |
308 | struct net_device *dev, *n; | 308 | struct net_device *dev, *n; |
309 | struct net *net; | ||
309 | 310 | ||
310 | for_each_netdev_safe(dev, n) { | 311 | for_each_net(net) { |
311 | if (dev->rtnl_link_ops == ops) | 312 | for_each_netdev_safe(net, dev, n) { |
312 | ops->dellink(dev); | 313 | if (dev->rtnl_link_ops == ops) |
314 | ops->dellink(dev); | ||
315 | } | ||
313 | } | 316 | } |
314 | list_del(&ops->list); | 317 | list_del(&ops->list); |
315 | } | 318 | } |
@@ -693,12 +696,13 @@ nla_put_failure: | |||
693 | 696 | ||
694 | static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | 697 | static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) |
695 | { | 698 | { |
699 | struct net *net = skb->sk->sk_net; | ||
696 | int idx; | 700 | int idx; |
697 | int s_idx = cb->args[0]; | 701 | int s_idx = cb->args[0]; |
698 | struct net_device *dev; | 702 | struct net_device *dev; |
699 | 703 | ||
700 | idx = 0; | 704 | idx = 0; |
701 | for_each_netdev(dev) { | 705 | for_each_netdev(net, dev) { |
702 | if (idx < s_idx) | 706 | if (idx < s_idx) |
703 | goto cont; | 707 | goto cont; |
704 | if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, | 708 | if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, |
@@ -858,6 +862,7 @@ errout: | |||
858 | 862 | ||
859 | static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 863 | static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
860 | { | 864 | { |
865 | struct net *net = skb->sk->sk_net; | ||
861 | struct ifinfomsg *ifm; | 866 | struct ifinfomsg *ifm; |
862 | struct net_device *dev; | 867 | struct net_device *dev; |
863 | int err; | 868 | int err; |
@@ -876,9 +881,9 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
876 | err = -EINVAL; | 881 | err = -EINVAL; |
877 | ifm = nlmsg_data(nlh); | 882 | ifm = nlmsg_data(nlh); |
878 | if (ifm->ifi_index > 0) | 883 | if (ifm->ifi_index > 0) |
879 | dev = dev_get_by_index(ifm->ifi_index); | 884 | dev = dev_get_by_index(net, ifm->ifi_index); |
880 | else if (tb[IFLA_IFNAME]) | 885 | else if (tb[IFLA_IFNAME]) |
881 | dev = dev_get_by_name(ifname); | 886 | dev = dev_get_by_name(net, ifname); |
882 | else | 887 | else |
883 | goto errout; | 888 | goto errout; |
884 | 889 | ||
@@ -904,6 +909,7 @@ errout: | |||
904 | 909 | ||
905 | static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 910 | static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
906 | { | 911 | { |
912 | struct net *net = skb->sk->sk_net; | ||
907 | const struct rtnl_link_ops *ops; | 913 | const struct rtnl_link_ops *ops; |
908 | struct net_device *dev; | 914 | struct net_device *dev; |
909 | struct ifinfomsg *ifm; | 915 | struct ifinfomsg *ifm; |
@@ -920,9 +926,9 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
920 | 926 | ||
921 | ifm = nlmsg_data(nlh); | 927 | ifm = nlmsg_data(nlh); |
922 | if (ifm->ifi_index > 0) | 928 | if (ifm->ifi_index > 0) |
923 | dev = __dev_get_by_index(ifm->ifi_index); | 929 | dev = __dev_get_by_index(net, ifm->ifi_index); |
924 | else if (tb[IFLA_IFNAME]) | 930 | else if (tb[IFLA_IFNAME]) |
925 | dev = __dev_get_by_name(ifname); | 931 | dev = __dev_get_by_name(net, ifname); |
926 | else | 932 | else |
927 | return -EINVAL; | 933 | return -EINVAL; |
928 | 934 | ||
@@ -937,7 +943,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
937 | return 0; | 943 | return 0; |
938 | } | 944 | } |
939 | 945 | ||
940 | struct net_device *rtnl_create_link(char *ifname, | 946 | struct net_device *rtnl_create_link(struct net *net, char *ifname, |
941 | const struct rtnl_link_ops *ops, struct nlattr *tb[]) | 947 | const struct rtnl_link_ops *ops, struct nlattr *tb[]) |
942 | { | 948 | { |
943 | int err; | 949 | int err; |
@@ -954,6 +960,7 @@ struct net_device *rtnl_create_link(char *ifname, | |||
954 | goto err_free; | 960 | goto err_free; |
955 | } | 961 | } |
956 | 962 | ||
963 | dev->nd_net = net; | ||
957 | dev->rtnl_link_ops = ops; | 964 | dev->rtnl_link_ops = ops; |
958 | 965 | ||
959 | if (tb[IFLA_MTU]) | 966 | if (tb[IFLA_MTU]) |
@@ -981,6 +988,7 @@ err: | |||
981 | 988 | ||
982 | static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 989 | static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
983 | { | 990 | { |
991 | struct net *net = skb->sk->sk_net; | ||
984 | const struct rtnl_link_ops *ops; | 992 | const struct rtnl_link_ops *ops; |
985 | struct net_device *dev; | 993 | struct net_device *dev; |
986 | struct ifinfomsg *ifm; | 994 | struct ifinfomsg *ifm; |
@@ -1004,9 +1012,9 @@ replay: | |||
1004 | 1012 | ||
1005 | ifm = nlmsg_data(nlh); | 1013 | ifm = nlmsg_data(nlh); |
1006 | if (ifm->ifi_index > 0) | 1014 | if (ifm->ifi_index > 0) |
1007 | dev = __dev_get_by_index(ifm->ifi_index); | 1015 | dev = __dev_get_by_index(net, ifm->ifi_index); |
1008 | else if (ifname[0]) | 1016 | else if (ifname[0]) |
1009 | dev = __dev_get_by_name(ifname); | 1017 | dev = __dev_get_by_name(net, ifname); |
1010 | else | 1018 | else |
1011 | dev = NULL; | 1019 | dev = NULL; |
1012 | 1020 | ||
@@ -1092,7 +1100,7 @@ replay: | |||
1092 | if (!ifname[0]) | 1100 | if (!ifname[0]) |
1093 | snprintf(ifname, IFNAMSIZ, "%s%%d", ops->kind); | 1101 | snprintf(ifname, IFNAMSIZ, "%s%%d", ops->kind); |
1094 | 1102 | ||
1095 | dev = rtnl_create_link(ifname, ops, tb); | 1103 | dev = rtnl_create_link(net, ifname, ops, tb); |
1096 | 1104 | ||
1097 | if (IS_ERR(dev)) | 1105 | if (IS_ERR(dev)) |
1098 | err = PTR_ERR(dev); | 1106 | err = PTR_ERR(dev); |
@@ -1109,6 +1117,7 @@ replay: | |||
1109 | 1117 | ||
1110 | static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | 1118 | static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) |
1111 | { | 1119 | { |
1120 | struct net *net = skb->sk->sk_net; | ||
1112 | struct ifinfomsg *ifm; | 1121 | struct ifinfomsg *ifm; |
1113 | struct nlattr *tb[IFLA_MAX+1]; | 1122 | struct nlattr *tb[IFLA_MAX+1]; |
1114 | struct net_device *dev = NULL; | 1123 | struct net_device *dev = NULL; |
@@ -1121,7 +1130,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
1121 | 1130 | ||
1122 | ifm = nlmsg_data(nlh); | 1131 | ifm = nlmsg_data(nlh); |
1123 | if (ifm->ifi_index > 0) { | 1132 | if (ifm->ifi_index > 0) { |
1124 | dev = dev_get_by_index(ifm->ifi_index); | 1133 | dev = dev_get_by_index(net, ifm->ifi_index); |
1125 | if (dev == NULL) | 1134 | if (dev == NULL) |
1126 | return -ENODEV; | 1135 | return -ENODEV; |
1127 | } else | 1136 | } else |
diff --git a/net/core/sock.c b/net/core/sock.c index a31455dc7024..4ed9b507c1e7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -367,6 +367,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen) | |||
367 | { | 367 | { |
368 | int ret = -ENOPROTOOPT; | 368 | int ret = -ENOPROTOOPT; |
369 | #ifdef CONFIG_NETDEVICES | 369 | #ifdef CONFIG_NETDEVICES |
370 | struct net *net = sk->sk_net; | ||
370 | char devname[IFNAMSIZ]; | 371 | char devname[IFNAMSIZ]; |
371 | int index; | 372 | int index; |
372 | 373 | ||
@@ -395,7 +396,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen) | |||
395 | if (devname[0] == '\0') { | 396 | if (devname[0] == '\0') { |
396 | index = 0; | 397 | index = 0; |
397 | } else { | 398 | } else { |
398 | struct net_device *dev = dev_get_by_name(devname); | 399 | struct net_device *dev = dev_get_by_name(net, devname); |
399 | 400 | ||
400 | ret = -ENODEV; | 401 | ret = -ENODEV; |
401 | if (!dev) | 402 | if (!dev) |
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 | ||
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index f877f3b5c725..9938e76a8ff6 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -662,7 +662,7 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg) | |||
662 | if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) | 662 | if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) |
663 | return -EFAULT; | 663 | return -EFAULT; |
664 | 664 | ||
665 | if ((dev = dev_get_by_name(ifr.ifr_name)) == NULL) | 665 | if ((dev = dev_get_by_name(&init_net, ifr.ifr_name)) == NULL) |
666 | return -ENODEV; | 666 | return -ENODEV; |
667 | 667 | ||
668 | sec = (struct sockaddr_ec *)&ifr.ifr_addr; | 668 | sec = (struct sockaddr_ec *)&ifr.ifr_addr; |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index a11e7a5c1da4..3a683006d761 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -981,7 +981,7 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev) | |||
981 | if (mask && mask != htonl(0xFFFFFFFF)) | 981 | if (mask && mask != htonl(0xFFFFFFFF)) |
982 | return -EINVAL; | 982 | return -EINVAL; |
983 | if (!dev && (r->arp_flags & ATF_COM)) { | 983 | if (!dev && (r->arp_flags & ATF_COM)) { |
984 | dev = dev_getbyhwaddr(r->arp_ha.sa_family, r->arp_ha.sa_data); | 984 | dev = dev_getbyhwaddr(&init_net, r->arp_ha.sa_family, r->arp_ha.sa_data); |
985 | if (!dev) | 985 | if (!dev) |
986 | return -ENODEV; | 986 | return -ENODEV; |
987 | } | 987 | } |
@@ -1169,7 +1169,7 @@ int arp_ioctl(unsigned int cmd, void __user *arg) | |||
1169 | rtnl_lock(); | 1169 | rtnl_lock(); |
1170 | if (r.arp_dev[0]) { | 1170 | if (r.arp_dev[0]) { |
1171 | err = -ENODEV; | 1171 | err = -ENODEV; |
1172 | if ((dev = __dev_get_by_name(r.arp_dev)) == NULL) | 1172 | if ((dev = __dev_get_by_name(&init_net, r.arp_dev)) == NULL) |
1173 | goto out; | 1173 | goto out; |
1174 | 1174 | ||
1175 | /* Mmmm... It is wrong... ARPHRD_NETROM==0 */ | 1175 | /* Mmmm... It is wrong... ARPHRD_NETROM==0 */ |
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); |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 140bf7a8d877..df17aab193b4 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -334,7 +334,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, | |||
334 | colon = strchr(devname, ':'); | 334 | colon = strchr(devname, ':'); |
335 | if (colon) | 335 | if (colon) |
336 | *colon = 0; | 336 | *colon = 0; |
337 | dev = __dev_get_by_name(devname); | 337 | dev = __dev_get_by_name(&init_net, devname); |
338 | if (!dev) | 338 | if (!dev) |
339 | return -ENODEV; | 339 | return -ENODEV; |
340 | cfg->fc_oif = dev->ifindex; | 340 | cfg->fc_oif = dev->ifindex; |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index c434119deb52..d30fb68d5f4e 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -533,7 +533,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, | |||
533 | return -EINVAL; | 533 | return -EINVAL; |
534 | if (inet_addr_type(nh->nh_gw) != RTN_UNICAST) | 534 | if (inet_addr_type(nh->nh_gw) != RTN_UNICAST) |
535 | return -EINVAL; | 535 | return -EINVAL; |
536 | if ((dev = __dev_get_by_index(nh->nh_oif)) == NULL) | 536 | if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL) |
537 | return -ENODEV; | 537 | return -ENODEV; |
538 | if (!(dev->flags&IFF_UP)) | 538 | if (!(dev->flags&IFF_UP)) |
539 | return -ENETDOWN; | 539 | return -ENETDOWN; |
@@ -799,7 +799,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg) | |||
799 | if (nhs != 1 || nh->nh_gw) | 799 | if (nhs != 1 || nh->nh_gw) |
800 | goto err_inval; | 800 | goto err_inval; |
801 | nh->nh_scope = RT_SCOPE_NOWHERE; | 801 | nh->nh_scope = RT_SCOPE_NOWHERE; |
802 | nh->nh_dev = dev_get_by_index(fi->fib_nh->nh_oif); | 802 | nh->nh_dev = dev_get_by_index(&init_net, fi->fib_nh->nh_oif); |
803 | err = -ENODEV; | 803 | err = -ENODEV; |
804 | if (nh->nh_dev == NULL) | 804 | if (nh->nh_dev == NULL) |
805 | goto failure; | 805 | goto failure; |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 02a899bec196..68a22670f597 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -517,7 +517,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
517 | struct net_device *dev = NULL; | 517 | struct net_device *dev = NULL; |
518 | 518 | ||
519 | if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr) | 519 | if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr) |
520 | dev = dev_get_by_index(rt->fl.iif); | 520 | dev = dev_get_by_index(&init_net, rt->fl.iif); |
521 | 521 | ||
522 | if (dev) { | 522 | if (dev) { |
523 | saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); | 523 | saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index d78599a9dbd5..ad500a43b359 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -2292,7 +2292,7 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq) | |||
2292 | struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); | 2292 | struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); |
2293 | 2293 | ||
2294 | state->in_dev = NULL; | 2294 | state->in_dev = NULL; |
2295 | for_each_netdev(state->dev) { | 2295 | for_each_netdev(&init_net, state->dev) { |
2296 | struct in_device *in_dev; | 2296 | struct in_device *in_dev; |
2297 | in_dev = in_dev_get(state->dev); | 2297 | in_dev = in_dev_get(state->dev); |
2298 | if (!in_dev) | 2298 | if (!in_dev) |
@@ -2454,7 +2454,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq) | |||
2454 | 2454 | ||
2455 | state->idev = NULL; | 2455 | state->idev = NULL; |
2456 | state->im = NULL; | 2456 | state->im = NULL; |
2457 | for_each_netdev(state->dev) { | 2457 | for_each_netdev(&init_net, state->dev) { |
2458 | struct in_device *idev; | 2458 | struct in_device *idev; |
2459 | idev = in_dev_get(state->dev); | 2459 | idev = in_dev_get(state->dev); |
2460 | if (unlikely(idev == NULL)) | 2460 | if (unlikely(idev == NULL)) |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 0231bdcb2ab7..fabb86db763b 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -292,7 +292,7 @@ static void ip_expire(unsigned long arg) | |||
292 | if ((qp->last_in&FIRST_IN) && qp->fragments != NULL) { | 292 | if ((qp->last_in&FIRST_IN) && qp->fragments != NULL) { |
293 | struct sk_buff *head = qp->fragments; | 293 | struct sk_buff *head = qp->fragments; |
294 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ | 294 | /* Send an ICMP "Fragment Reassembly Timeout" message. */ |
295 | if ((head->dev = dev_get_by_index(qp->iif)) != NULL) { | 295 | if ((head->dev = dev_get_by_index(&init_net, qp->iif)) != NULL) { |
296 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); | 296 | icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); |
297 | dev_put(head->dev); | 297 | dev_put(head->dev); |
298 | } | 298 | } |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 5c14ed63e56c..3106225c5e50 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -262,7 +262,7 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int | |||
262 | int i; | 262 | int i; |
263 | for (i=1; i<100; i++) { | 263 | for (i=1; i<100; i++) { |
264 | sprintf(name, "gre%d", i); | 264 | sprintf(name, "gre%d", i); |
265 | if (__dev_get_by_name(name) == NULL) | 265 | if (__dev_get_by_name(&init_net, name) == NULL) |
266 | break; | 266 | break; |
267 | } | 267 | } |
268 | if (i==100) | 268 | if (i==100) |
@@ -1196,7 +1196,7 @@ static int ipgre_tunnel_init(struct net_device *dev) | |||
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | if (!tdev && tunnel->parms.link) | 1198 | if (!tdev && tunnel->parms.link) |
1199 | tdev = __dev_get_by_index(tunnel->parms.link); | 1199 | tdev = __dev_get_by_index(&init_net, tunnel->parms.link); |
1200 | 1200 | ||
1201 | if (tdev) { | 1201 | if (tdev) { |
1202 | hlen = tdev->hard_header_len; | 1202 | hlen = tdev->hard_header_len; |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 6b420aedcdcf..b2b3053dfef7 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -602,7 +602,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
602 | dev_put(dev); | 602 | dev_put(dev); |
603 | } | 603 | } |
604 | } else | 604 | } else |
605 | dev = __dev_get_by_index(mreq.imr_ifindex); | 605 | dev = __dev_get_by_index(&init_net, mreq.imr_ifindex); |
606 | 606 | ||
607 | 607 | ||
608 | err = -EADDRNOTAVAIL; | 608 | err = -EADDRNOTAVAIL; |
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 08ff623371f0..4303851749f6 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
@@ -193,7 +193,7 @@ static int __init ic_open_devs(void) | |||
193 | if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0) | 193 | if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0) |
194 | printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name); | 194 | printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name); |
195 | 195 | ||
196 | for_each_netdev(dev) { | 196 | for_each_netdev(&init_net, dev) { |
197 | if (dev == &loopback_dev) | 197 | if (dev == &loopback_dev) |
198 | continue; | 198 | continue; |
199 | if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : | 199 | if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : |
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 396437242a1b..652bd86e33a3 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
@@ -225,7 +225,7 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c | |||
225 | int i; | 225 | int i; |
226 | for (i=1; i<100; i++) { | 226 | for (i=1; i<100; i++) { |
227 | sprintf(name, "tunl%d", i); | 227 | sprintf(name, "tunl%d", i); |
228 | if (__dev_get_by_name(name) == NULL) | 228 | if (__dev_get_by_name(&init_net, name) == NULL) |
229 | break; | 229 | break; |
230 | } | 230 | } |
231 | if (i==100) | 231 | if (i==100) |
@@ -822,7 +822,7 @@ static int ipip_tunnel_init(struct net_device *dev) | |||
822 | } | 822 | } |
823 | 823 | ||
824 | if (!tdev && tunnel->parms.link) | 824 | if (!tdev && tunnel->parms.link) |
825 | tdev = __dev_get_by_index(tunnel->parms.link); | 825 | tdev = __dev_get_by_index(&init_net, tunnel->parms.link); |
826 | 826 | ||
827 | if (tdev) { | 827 | if (tdev) { |
828 | dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr); | 828 | dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr); |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 036598835c63..b8b4b497fb57 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -125,7 +125,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v) | |||
125 | { | 125 | { |
126 | struct net_device *dev; | 126 | struct net_device *dev; |
127 | 127 | ||
128 | dev = __dev_get_by_name("tunl0"); | 128 | dev = __dev_get_by_name(&init_net, "tunl0"); |
129 | 129 | ||
130 | if (dev) { | 130 | if (dev) { |
131 | int err; | 131 | int err; |
@@ -149,7 +149,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v) | |||
149 | 149 | ||
150 | dev = NULL; | 150 | dev = NULL; |
151 | 151 | ||
152 | if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) { | 152 | if (err == 0 && (dev = __dev_get_by_name(&init_net, p.name)) != NULL) { |
153 | dev->flags |= IFF_MULTICAST; | 153 | dev->flags |= IFF_MULTICAST; |
154 | 154 | ||
155 | in_dev = __in_dev_get_rtnl(dev); | 155 | in_dev = __in_dev_get_rtnl(dev); |
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); |
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 50fc9e009fe4..27f14e1ebd8b 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
@@ -401,7 +401,7 @@ checkentry(const char *tablename, | |||
401 | return false; | 401 | return false; |
402 | } | 402 | } |
403 | 403 | ||
404 | dev = dev_get_by_name(e->ip.iniface); | 404 | dev = dev_get_by_name(&init_net, e->ip.iniface); |
405 | if (!dev) { | 405 | if (!dev) { |
406 | printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface); | 406 | printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface); |
407 | return false; | 407 | return false; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index efd2a9202d68..396c631166a4 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2213,7 +2213,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp) | |||
2213 | 2213 | ||
2214 | 2214 | ||
2215 | if (oldflp->oif) { | 2215 | if (oldflp->oif) { |
2216 | dev_out = dev_get_by_index(oldflp->oif); | 2216 | dev_out = dev_get_by_index(&init_net, oldflp->oif); |
2217 | err = -ENODEV; | 2217 | err = -ENODEV; |
2218 | if (dev_out == NULL) | 2218 | if (dev_out == NULL) |
2219 | goto out; | 2219 | goto out; |
@@ -2592,7 +2592,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2592 | if (iif) { | 2592 | if (iif) { |
2593 | struct net_device *dev; | 2593 | struct net_device *dev; |
2594 | 2594 | ||
2595 | dev = __dev_get_by_index(iif); | 2595 | dev = __dev_get_by_index(&init_net, iif); |
2596 | if (dev == NULL) { | 2596 | if (dev == NULL) { |
2597 | err = -ENODEV; | 2597 | err = -ENODEV; |
2598 | goto errout_free; | 2598 | goto errout_free; |
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); |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 21931c86e95b..e5c5aad44bb1 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -302,7 +302,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
302 | err = -EINVAL; | 302 | err = -EINVAL; |
303 | goto out; | 303 | goto out; |
304 | } | 304 | } |
305 | dev = dev_get_by_index(sk->sk_bound_dev_if); | 305 | dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); |
306 | if (!dev) { | 306 | if (!dev) { |
307 | err = -ENODEV; | 307 | err = -ENODEV; |
308 | goto out; | 308 | goto out; |
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c index 0bd665498d06..d407992c1481 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c | |||
@@ -112,10 +112,10 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr) | |||
112 | } else { | 112 | } else { |
113 | /* router, no matching interface: just pick one */ | 113 | /* router, no matching interface: just pick one */ |
114 | 114 | ||
115 | dev = dev_get_by_flags(IFF_UP, IFF_UP|IFF_LOOPBACK); | 115 | dev = dev_get_by_flags(&init_net, IFF_UP, IFF_UP|IFF_LOOPBACK); |
116 | } | 116 | } |
117 | } else | 117 | } else |
118 | dev = dev_get_by_index(ifindex); | 118 | dev = dev_get_by_index(&init_net, ifindex); |
119 | 119 | ||
120 | if (dev == NULL) { | 120 | if (dev == NULL) { |
121 | err = -ENODEV; | 121 | err = -ENODEV; |
@@ -196,7 +196,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, struct in6_addr *addr) | |||
196 | 196 | ||
197 | write_unlock_bh(&ipv6_sk_ac_lock); | 197 | write_unlock_bh(&ipv6_sk_ac_lock); |
198 | 198 | ||
199 | dev = dev_get_by_index(pac->acl_ifindex); | 199 | dev = dev_get_by_index(&init_net, pac->acl_ifindex); |
200 | if (dev) { | 200 | if (dev) { |
201 | ipv6_dev_ac_dec(dev, &pac->acl_addr); | 201 | ipv6_dev_ac_dec(dev, &pac->acl_addr); |
202 | dev_put(dev); | 202 | dev_put(dev); |
@@ -224,7 +224,7 @@ void ipv6_sock_ac_close(struct sock *sk) | |||
224 | if (pac->acl_ifindex != prev_index) { | 224 | if (pac->acl_ifindex != prev_index) { |
225 | if (dev) | 225 | if (dev) |
226 | dev_put(dev); | 226 | dev_put(dev); |
227 | dev = dev_get_by_index(pac->acl_ifindex); | 227 | dev = dev_get_by_index(&init_net, pac->acl_ifindex); |
228 | prev_index = pac->acl_ifindex; | 228 | prev_index = pac->acl_ifindex; |
229 | } | 229 | } |
230 | if (dev) | 230 | if (dev) |
@@ -429,7 +429,7 @@ int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr) | |||
429 | if (dev) | 429 | if (dev) |
430 | return ipv6_chk_acast_dev(dev, addr); | 430 | return ipv6_chk_acast_dev(dev, addr); |
431 | read_lock(&dev_base_lock); | 431 | read_lock(&dev_base_lock); |
432 | for_each_netdev(dev) | 432 | for_each_netdev(&init_net, dev) |
433 | if (ipv6_chk_acast_dev(dev, addr)) { | 433 | if (ipv6_chk_acast_dev(dev, addr)) { |
434 | found = 1; | 434 | found = 1; |
435 | break; | 435 | break; |
@@ -453,7 +453,7 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq) | |||
453 | struct ac6_iter_state *state = ac6_seq_private(seq); | 453 | struct ac6_iter_state *state = ac6_seq_private(seq); |
454 | 454 | ||
455 | state->idev = NULL; | 455 | state->idev = NULL; |
456 | for_each_netdev(state->dev) { | 456 | for_each_netdev(&init_net, state->dev) { |
457 | struct inet6_dev *idev; | 457 | struct inet6_dev *idev; |
458 | idev = in6_dev_get(state->dev); | 458 | idev = in6_dev_get(state->dev); |
459 | if (!idev) | 459 | if (!idev) |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index fe0f49024a0a..2ed689ac449e 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -544,7 +544,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl, | |||
544 | if (!src_info->ipi6_ifindex) | 544 | if (!src_info->ipi6_ifindex) |
545 | return -EINVAL; | 545 | return -EINVAL; |
546 | else { | 546 | else { |
547 | dev = dev_get_by_index(src_info->ipi6_ifindex); | 547 | dev = dev_get_by_index(&init_net, src_info->ipi6_ifindex); |
548 | if (!dev) | 548 | if (!dev) |
549 | return -ENODEV; | 549 | return -ENODEV; |
550 | } | 550 | } |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index ca774d8e3be3..937625e577c1 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -235,7 +235,7 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p) | |||
235 | int i; | 235 | int i; |
236 | for (i = 1; i < IP6_TNL_MAX; i++) { | 236 | for (i = 1; i < IP6_TNL_MAX; i++) { |
237 | sprintf(name, "ip6tnl%d", i); | 237 | sprintf(name, "ip6tnl%d", i); |
238 | if (__dev_get_by_name(name) == NULL) | 238 | if (__dev_get_by_name(&init_net, name) == NULL) |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | if (i == IP6_TNL_MAX) | 241 | if (i == IP6_TNL_MAX) |
@@ -650,7 +650,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t) | |||
650 | struct net_device *ldev = NULL; | 650 | struct net_device *ldev = NULL; |
651 | 651 | ||
652 | if (p->link) | 652 | if (p->link) |
653 | ldev = dev_get_by_index(p->link); | 653 | ldev = dev_get_by_index(&init_net, p->link); |
654 | 654 | ||
655 | if ((ipv6_addr_is_multicast(&p->laddr) || | 655 | if ((ipv6_addr_is_multicast(&p->laddr) || |
656 | likely(ipv6_chk_addr(&p->laddr, ldev, 0))) && | 656 | likely(ipv6_chk_addr(&p->laddr, ldev, 0))) && |
@@ -786,7 +786,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t) | |||
786 | struct net_device *ldev = NULL; | 786 | struct net_device *ldev = NULL; |
787 | 787 | ||
788 | if (p->link) | 788 | if (p->link) |
789 | ldev = dev_get_by_index(p->link); | 789 | ldev = dev_get_by_index(&init_net, p->link); |
790 | 790 | ||
791 | if (unlikely(!ipv6_chk_addr(&p->laddr, ldev, 0))) | 791 | if (unlikely(!ipv6_chk_addr(&p->laddr, ldev, 0))) |
792 | printk(KERN_WARNING | 792 | printk(KERN_WARNING |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 74254fccbcc8..eb330a44bacd 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -542,7 +542,7 @@ done: | |||
542 | if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val) | 542 | if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val) |
543 | goto e_inval; | 543 | goto e_inval; |
544 | 544 | ||
545 | if (__dev_get_by_index(val) == NULL) { | 545 | if (__dev_get_by_index(&init_net, val) == NULL) { |
546 | retv = -ENODEV; | 546 | retv = -ENODEV; |
547 | break; | 547 | break; |
548 | } | 548 | } |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index a41d5a0b50cc..e2ab43c989d4 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -215,7 +215,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr) | |||
215 | dst_release(&rt->u.dst); | 215 | dst_release(&rt->u.dst); |
216 | } | 216 | } |
217 | } else | 217 | } else |
218 | dev = dev_get_by_index(ifindex); | 218 | dev = dev_get_by_index(&init_net, ifindex); |
219 | 219 | ||
220 | if (dev == NULL) { | 220 | if (dev == NULL) { |
221 | sock_kfree_s(sk, mc_lst, sizeof(*mc_lst)); | 221 | sock_kfree_s(sk, mc_lst, sizeof(*mc_lst)); |
@@ -266,7 +266,7 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr) | |||
266 | *lnk = mc_lst->next; | 266 | *lnk = mc_lst->next; |
267 | write_unlock_bh(&ipv6_sk_mc_lock); | 267 | write_unlock_bh(&ipv6_sk_mc_lock); |
268 | 268 | ||
269 | if ((dev = dev_get_by_index(mc_lst->ifindex)) != NULL) { | 269 | if ((dev = dev_get_by_index(&init_net, mc_lst->ifindex)) != NULL) { |
270 | struct inet6_dev *idev = in6_dev_get(dev); | 270 | struct inet6_dev *idev = in6_dev_get(dev); |
271 | 271 | ||
272 | (void) ip6_mc_leave_src(sk, mc_lst, idev); | 272 | (void) ip6_mc_leave_src(sk, mc_lst, idev); |
@@ -301,7 +301,7 @@ static struct inet6_dev *ip6_mc_find_dev(struct in6_addr *group, int ifindex) | |||
301 | dst_release(&rt->u.dst); | 301 | dst_release(&rt->u.dst); |
302 | } | 302 | } |
303 | } else | 303 | } else |
304 | dev = dev_get_by_index(ifindex); | 304 | dev = dev_get_by_index(&init_net, ifindex); |
305 | 305 | ||
306 | if (!dev) | 306 | if (!dev) |
307 | return NULL; | 307 | return NULL; |
@@ -332,7 +332,7 @@ void ipv6_sock_mc_close(struct sock *sk) | |||
332 | np->ipv6_mc_list = mc_lst->next; | 332 | np->ipv6_mc_list = mc_lst->next; |
333 | write_unlock_bh(&ipv6_sk_mc_lock); | 333 | write_unlock_bh(&ipv6_sk_mc_lock); |
334 | 334 | ||
335 | dev = dev_get_by_index(mc_lst->ifindex); | 335 | dev = dev_get_by_index(&init_net, mc_lst->ifindex); |
336 | if (dev) { | 336 | if (dev) { |
337 | struct inet6_dev *idev = in6_dev_get(dev); | 337 | struct inet6_dev *idev = in6_dev_get(dev); |
338 | 338 | ||
@@ -2333,7 +2333,7 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq) | |||
2333 | struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); | 2333 | struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq); |
2334 | 2334 | ||
2335 | state->idev = NULL; | 2335 | state->idev = NULL; |
2336 | for_each_netdev(state->dev) { | 2336 | for_each_netdev(&init_net, state->dev) { |
2337 | struct inet6_dev *idev; | 2337 | struct inet6_dev *idev; |
2338 | idev = in6_dev_get(state->dev); | 2338 | idev = in6_dev_get(state->dev); |
2339 | if (!idev) | 2339 | if (!idev) |
@@ -2477,7 +2477,7 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq) | |||
2477 | 2477 | ||
2478 | state->idev = NULL; | 2478 | state->idev = NULL; |
2479 | state->im = NULL; | 2479 | state->im = NULL; |
2480 | for_each_netdev(state->dev) { | 2480 | for_each_netdev(&init_net, state->dev) { |
2481 | struct inet6_dev *idev; | 2481 | struct inet6_dev *idev; |
2482 | idev = in6_dev_get(state->dev); | 2482 | idev = in6_dev_get(state->dev); |
2483 | if (unlikely(idev == NULL)) | 2483 | if (unlikely(idev == NULL)) |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 38a3d21c2585..bdd0974e6775 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -283,7 +283,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
283 | if (!sk->sk_bound_dev_if) | 283 | if (!sk->sk_bound_dev_if) |
284 | goto out; | 284 | goto out; |
285 | 285 | ||
286 | dev = dev_get_by_index(sk->sk_bound_dev_if); | 286 | dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if); |
287 | if (!dev) { | 287 | if (!dev) { |
288 | err = -ENODEV; | 288 | err = -ENODEV; |
289 | goto out; | 289 | goto out; |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index de795c04e34c..31601c993541 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -301,7 +301,7 @@ static void ip6_frag_expire(unsigned long data) | |||
301 | 301 | ||
302 | fq_kill(fq); | 302 | fq_kill(fq); |
303 | 303 | ||
304 | dev = dev_get_by_index(fq->iif); | 304 | dev = dev_get_by_index(&init_net, fq->iif); |
305 | if (!dev) | 305 | if (!dev) |
306 | goto out; | 306 | goto out; |
307 | 307 | ||
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index f4f0c341e5c8..5bdd9d4010fe 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1130,7 +1130,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1130 | #endif | 1130 | #endif |
1131 | if (cfg->fc_ifindex) { | 1131 | if (cfg->fc_ifindex) { |
1132 | err = -ENODEV; | 1132 | err = -ENODEV; |
1133 | dev = dev_get_by_index(cfg->fc_ifindex); | 1133 | dev = dev_get_by_index(&init_net, cfg->fc_ifindex); |
1134 | if (!dev) | 1134 | if (!dev) |
1135 | goto out; | 1135 | goto out; |
1136 | idev = in6_dev_get(dev); | 1136 | idev = in6_dev_get(dev); |
@@ -2265,7 +2265,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2265 | 2265 | ||
2266 | if (iif) { | 2266 | if (iif) { |
2267 | struct net_device *dev; | 2267 | struct net_device *dev; |
2268 | dev = __dev_get_by_index(iif); | 2268 | dev = __dev_get_by_index(&init_net, iif); |
2269 | if (!dev) { | 2269 | if (!dev) { |
2270 | err = -ENODEV; | 2270 | err = -ENODEV; |
2271 | goto errout; | 2271 | goto errout; |
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index eb20bb690abd..e79f419b1731 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -167,7 +167,7 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int | |||
167 | int i; | 167 | int i; |
168 | for (i=1; i<100; i++) { | 168 | for (i=1; i<100; i++) { |
169 | sprintf(name, "sit%d", i); | 169 | sprintf(name, "sit%d", i); |
170 | if (__dev_get_by_name(name) == NULL) | 170 | if (__dev_get_by_name(&init_net, name) == NULL) |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | if (i==100) | 173 | if (i==100) |
@@ -761,7 +761,7 @@ static int ipip6_tunnel_init(struct net_device *dev) | |||
761 | } | 761 | } |
762 | 762 | ||
763 | if (!tdev && tunnel->parms.link) | 763 | if (!tdev && tunnel->parms.link) |
764 | tdev = __dev_get_by_index(tunnel->parms.link); | 764 | tdev = __dev_get_by_index(&init_net, tunnel->parms.link); |
765 | 765 | ||
766 | if (tdev) { | 766 | if (tdev) { |
767 | dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr); | 767 | dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr); |
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 24921f12e9af..29b063d43120 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -989,7 +989,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef) | |||
989 | if (intrfc) | 989 | if (intrfc) |
990 | ipxitf_put(intrfc); | 990 | ipxitf_put(intrfc); |
991 | 991 | ||
992 | dev = dev_get_by_name(idef->ipx_device); | 992 | dev = dev_get_by_name(&init_net, idef->ipx_device); |
993 | rc = -ENODEV; | 993 | rc = -ENODEV; |
994 | if (!dev) | 994 | if (!dev) |
995 | goto out; | 995 | goto out; |
@@ -1097,7 +1097,7 @@ static int ipxitf_delete(struct ipx_interface_definition *idef) | |||
1097 | if (!dlink_type) | 1097 | if (!dlink_type) |
1098 | goto out; | 1098 | goto out; |
1099 | 1099 | ||
1100 | dev = __dev_get_by_name(idef->ipx_device); | 1100 | dev = __dev_get_by_name(&init_net, idef->ipx_device); |
1101 | rc = -ENODEV; | 1101 | rc = -ENODEV; |
1102 | if (!dev) | 1102 | if (!dev) |
1103 | goto out; | 1103 | goto out; |
@@ -1192,7 +1192,7 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg) | |||
1192 | if (copy_from_user(&ifr, arg, sizeof(ifr))) | 1192 | if (copy_from_user(&ifr, arg, sizeof(ifr))) |
1193 | break; | 1193 | break; |
1194 | sipx = (struct sockaddr_ipx *)&ifr.ifr_addr; | 1194 | sipx = (struct sockaddr_ipx *)&ifr.ifr_addr; |
1195 | dev = __dev_get_by_name(ifr.ifr_name); | 1195 | dev = __dev_get_by_name(&init_net, ifr.ifr_name); |
1196 | rc = -ENODEV; | 1196 | rc = -ENODEV; |
1197 | if (!dev) | 1197 | if (!dev) |
1198 | break; | 1198 | break; |
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c index 1e429c929739..cd9ff176ecde 100644 --- a/net/irda/irnetlink.c +++ b/net/irda/irnetlink.c | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/socket.h> | 16 | #include <linux/socket.h> |
17 | #include <linux/irda.h> | 17 | #include <linux/irda.h> |
18 | #include <net/net_namespace.h> | ||
18 | #include <net/sock.h> | 19 | #include <net/sock.h> |
19 | #include <net/irda/irda.h> | 20 | #include <net/irda/irda.h> |
20 | #include <net/irda/irlap.h> | 21 | #include <net/irda/irlap.h> |
@@ -30,7 +31,7 @@ static struct genl_family irda_nl_family = { | |||
30 | .maxattr = IRDA_NL_CMD_MAX, | 31 | .maxattr = IRDA_NL_CMD_MAX, |
31 | }; | 32 | }; |
32 | 33 | ||
33 | static struct net_device * ifname_to_netdev(struct genl_info *info) | 34 | static struct net_device * ifname_to_netdev(struct net *net, struct genl_info *info) |
34 | { | 35 | { |
35 | char * ifname; | 36 | char * ifname; |
36 | 37 | ||
@@ -41,7 +42,7 @@ static struct net_device * ifname_to_netdev(struct genl_info *info) | |||
41 | 42 | ||
42 | IRDA_DEBUG(5, "%s(): Looking for %s\n", __FUNCTION__, ifname); | 43 | IRDA_DEBUG(5, "%s(): Looking for %s\n", __FUNCTION__, ifname); |
43 | 44 | ||
44 | return dev_get_by_name(ifname); | 45 | return dev_get_by_name(net, ifname); |
45 | } | 46 | } |
46 | 47 | ||
47 | static int irda_nl_set_mode(struct sk_buff *skb, struct genl_info *info) | 48 | static int irda_nl_set_mode(struct sk_buff *skb, struct genl_info *info) |
@@ -57,7 +58,7 @@ static int irda_nl_set_mode(struct sk_buff *skb, struct genl_info *info) | |||
57 | 58 | ||
58 | IRDA_DEBUG(5, "%s(): Switching to mode: %d\n", __FUNCTION__, mode); | 59 | IRDA_DEBUG(5, "%s(): Switching to mode: %d\n", __FUNCTION__, mode); |
59 | 60 | ||
60 | dev = ifname_to_netdev(info); | 61 | dev = ifname_to_netdev(&init_net, info); |
61 | if (!dev) | 62 | if (!dev) |
62 | return -ENODEV; | 63 | return -ENODEV; |
63 | 64 | ||
@@ -82,7 +83,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info) | |||
82 | void *hdr; | 83 | void *hdr; |
83 | int ret = -ENOBUFS; | 84 | int ret = -ENOBUFS; |
84 | 85 | ||
85 | dev = ifname_to_netdev(info); | 86 | dev = ifname_to_netdev(&init_net, info); |
86 | if (!dev) | 87 | if (!dev) |
87 | return -ENODEV; | 88 | return -ENODEV; |
88 | 89 | ||
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index b48244156e75..49eacba824df 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
@@ -252,7 +252,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) | |||
252 | if (!sock_flag(sk, SOCK_ZAPPED)) | 252 | if (!sock_flag(sk, SOCK_ZAPPED)) |
253 | goto out; | 253 | goto out; |
254 | rc = -ENODEV; | 254 | rc = -ENODEV; |
255 | llc->dev = dev_getfirstbyhwtype(addr->sllc_arphrd); | 255 | llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd); |
256 | if (!llc->dev) | 256 | if (!llc->dev) |
257 | goto out; | 257 | goto out; |
258 | rc = -EUSERS; | 258 | rc = -EUSERS; |
@@ -303,7 +303,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
303 | goto out; | 303 | goto out; |
304 | rc = -ENODEV; | 304 | rc = -ENODEV; |
305 | rtnl_lock(); | 305 | rtnl_lock(); |
306 | llc->dev = dev_getbyhwaddr(addr->sllc_arphrd, addr->sllc_mac); | 306 | llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, addr->sllc_mac); |
307 | rtnl_unlock(); | 307 | rtnl_unlock(); |
308 | if (!llc->dev) | 308 | if (!llc->dev) |
309 | goto out; | 309 | goto out; |
diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c index d4b13a031fd5..248b5903bb13 100644 --- a/net/llc/llc_core.c +++ b/net/llc/llc_core.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/string.h> | 20 | #include <linux/string.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <net/net_namespace.h> | ||
22 | #include <net/llc.h> | 23 | #include <net/llc.h> |
23 | 24 | ||
24 | LIST_HEAD(llc_sap_list); | 25 | LIST_HEAD(llc_sap_list); |
@@ -162,7 +163,7 @@ static int __init llc_init(void) | |||
162 | { | 163 | { |
163 | struct net_device *dev; | 164 | struct net_device *dev; |
164 | 165 | ||
165 | dev = first_net_device(); | 166 | dev = first_net_device(&init_net); |
166 | if (dev != NULL) | 167 | if (dev != NULL) |
167 | dev = next_net_device(dev); | 168 | dev = next_net_device(dev); |
168 | 169 | ||
diff --git a/net/mac80211/ieee80211.c b/net/mac80211/ieee80211.c index 73e314e33de2..506cfa06b184 100644 --- a/net/mac80211/ieee80211.c +++ b/net/mac80211/ieee80211.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/wireless.h> | 21 | #include <linux/wireless.h> |
22 | #include <linux/rtnetlink.h> | 22 | #include <linux/rtnetlink.h> |
23 | #include <linux/bitmap.h> | 23 | #include <linux/bitmap.h> |
24 | #include <net/net_namespace.h> | ||
24 | #include <net/cfg80211.h> | 25 | #include <net/cfg80211.h> |
25 | 26 | ||
26 | #include "ieee80211_common.h" | 27 | #include "ieee80211_common.h" |
diff --git a/net/mac80211/ieee80211_cfg.c b/net/mac80211/ieee80211_cfg.c index 509096edb324..b1c13bc9c3ca 100644 --- a/net/mac80211/ieee80211_cfg.c +++ b/net/mac80211/ieee80211_cfg.c | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #include <linux/nl80211.h> | 9 | #include <linux/nl80211.h> |
10 | #include <linux/rtnetlink.h> | 10 | #include <linux/rtnetlink.h> |
11 | #include <net/net_namespace.h> | ||
11 | #include <net/cfg80211.h> | 12 | #include <net/cfg80211.h> |
12 | #include "ieee80211_i.h" | 13 | #include "ieee80211_i.h" |
13 | #include "ieee80211_cfg.h" | 14 | #include "ieee80211_cfg.h" |
@@ -50,7 +51,7 @@ static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex) | |||
50 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) | 51 | if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) |
51 | return -ENODEV; | 52 | return -ENODEV; |
52 | 53 | ||
53 | dev = dev_get_by_index(ifindex); | 54 | dev = dev_get_by_index(&init_net, ifindex); |
54 | if (!dev) | 55 | if (!dev) |
55 | return 0; | 56 | return 0; |
56 | 57 | ||
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index b65ff6536244..9e952e37b7df 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
18 | #include <linux/etherdevice.h> | 18 | #include <linux/etherdevice.h> |
19 | #include <linux/bitmap.h> | 19 | #include <linux/bitmap.h> |
20 | #include <net/net_namespace.h> | ||
20 | #include <net/ieee80211_radiotap.h> | 21 | #include <net/ieee80211_radiotap.h> |
21 | #include <net/cfg80211.h> | 22 | #include <net/cfg80211.h> |
22 | #include <net/mac80211.h> | 23 | #include <net/mac80211.h> |
@@ -1018,7 +1019,7 @@ static int inline ieee80211_tx_prepare(struct ieee80211_txrx_data *tx, | |||
1018 | struct net_device *dev; | 1019 | struct net_device *dev; |
1019 | 1020 | ||
1020 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | 1021 | pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; |
1021 | dev = dev_get_by_index(pkt_data->ifindex); | 1022 | dev = dev_get_by_index(&init_net, pkt_data->ifindex); |
1022 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { | 1023 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { |
1023 | dev_put(dev); | 1024 | dev_put(dev); |
1024 | dev = NULL; | 1025 | dev = NULL; |
@@ -1226,7 +1227,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, | |||
1226 | memset(&control, 0, sizeof(struct ieee80211_tx_control)); | 1227 | memset(&control, 0, sizeof(struct ieee80211_tx_control)); |
1227 | 1228 | ||
1228 | if (pkt_data->ifindex) | 1229 | if (pkt_data->ifindex) |
1229 | odev = dev_get_by_index(pkt_data->ifindex); | 1230 | odev = dev_get_by_index(&init_net, pkt_data->ifindex); |
1230 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { | 1231 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { |
1231 | dev_put(odev); | 1232 | dev_put(odev); |
1232 | odev = NULL; | 1233 | odev = NULL; |
@@ -1722,7 +1723,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id, | |||
1722 | u8 *b_head, *b_tail; | 1723 | u8 *b_head, *b_tail; |
1723 | int bh_len, bt_len; | 1724 | int bh_len, bt_len; |
1724 | 1725 | ||
1725 | bdev = dev_get_by_index(if_id); | 1726 | bdev = dev_get_by_index(&init_net, if_id); |
1726 | if (bdev) { | 1727 | if (bdev) { |
1727 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | 1728 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); |
1728 | ap = &sdata->u.ap; | 1729 | ap = &sdata->u.ap; |
@@ -1836,7 +1837,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | |||
1836 | struct ieee80211_sub_if_data *sdata; | 1837 | struct ieee80211_sub_if_data *sdata; |
1837 | struct ieee80211_if_ap *bss = NULL; | 1838 | struct ieee80211_if_ap *bss = NULL; |
1838 | 1839 | ||
1839 | bdev = dev_get_by_index(if_id); | 1840 | bdev = dev_get_by_index(&init_net, if_id); |
1840 | if (bdev) { | 1841 | if (bdev) { |
1841 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); | 1842 | sdata = IEEE80211_DEV_TO_SUB_IF(bdev); |
1842 | bss = &sdata->u.ap; | 1843 | bss = &sdata->u.ap; |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 07686bda26cd..c970996ba6f9 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/if_arp.h> | 20 | #include <linux/if_arp.h> |
21 | #include <linux/wireless.h> | 21 | #include <linux/wireless.h> |
22 | #include <linux/bitmap.h> | 22 | #include <linux/bitmap.h> |
23 | #include <net/net_namespace.h> | ||
23 | #include <net/cfg80211.h> | 24 | #include <net/cfg80211.h> |
24 | 25 | ||
25 | #include "ieee80211_i.h" | 26 | #include "ieee80211_i.h" |
@@ -318,7 +319,7 @@ __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, | |||
318 | size_t frame_len, int rate) | 319 | size_t frame_len, int rate) |
319 | { | 320 | { |
320 | struct ieee80211_local *local = hw_to_local(hw); | 321 | struct ieee80211_local *local = hw_to_local(hw); |
321 | struct net_device *bdev = dev_get_by_index(if_id); | 322 | struct net_device *bdev = dev_get_by_index(&init_net, if_id); |
322 | struct ieee80211_sub_if_data *sdata; | 323 | struct ieee80211_sub_if_data *sdata; |
323 | u16 dur; | 324 | u16 dur; |
324 | int erp; | 325 | int erp; |
@@ -342,7 +343,7 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, | |||
342 | { | 343 | { |
343 | struct ieee80211_local *local = hw_to_local(hw); | 344 | struct ieee80211_local *local = hw_to_local(hw); |
344 | struct ieee80211_rate *rate; | 345 | struct ieee80211_rate *rate; |
345 | struct net_device *bdev = dev_get_by_index(if_id); | 346 | struct net_device *bdev = dev_get_by_index(&init_net, if_id); |
346 | struct ieee80211_sub_if_data *sdata; | 347 | struct ieee80211_sub_if_data *sdata; |
347 | int short_preamble; | 348 | int short_preamble; |
348 | int erp; | 349 | int erp; |
@@ -378,7 +379,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, | |||
378 | { | 379 | { |
379 | struct ieee80211_local *local = hw_to_local(hw); | 380 | struct ieee80211_local *local = hw_to_local(hw); |
380 | struct ieee80211_rate *rate; | 381 | struct ieee80211_rate *rate; |
381 | struct net_device *bdev = dev_get_by_index(if_id); | 382 | struct net_device *bdev = dev_get_by_index(&init_net, if_id); |
382 | struct ieee80211_sub_if_data *sdata; | 383 | struct ieee80211_sub_if_data *sdata; |
383 | int short_preamble; | 384 | int short_preamble; |
384 | int erp; | 385 | int erp; |
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index 24fe4a66d297..e943c16552a2 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c | |||
@@ -580,7 +580,7 @@ static struct net_device *nr_ax25_dev_get(char *devname) | |||
580 | { | 580 | { |
581 | struct net_device *dev; | 581 | struct net_device *dev; |
582 | 582 | ||
583 | if ((dev = dev_get_by_name(devname)) == NULL) | 583 | if ((dev = dev_get_by_name(&init_net, devname)) == NULL) |
584 | return NULL; | 584 | return NULL; |
585 | 585 | ||
586 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25) | 586 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25) |
@@ -598,7 +598,7 @@ struct net_device *nr_dev_first(void) | |||
598 | struct net_device *dev, *first = NULL; | 598 | struct net_device *dev, *first = NULL; |
599 | 599 | ||
600 | read_lock(&dev_base_lock); | 600 | read_lock(&dev_base_lock); |
601 | for_each_netdev(dev) { | 601 | for_each_netdev(&init_net, dev) { |
602 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM) | 602 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM) |
603 | if (first == NULL || strncmp(dev->name, first->name, 3) < 0) | 603 | if (first == NULL || strncmp(dev->name, first->name, 3) < 0) |
604 | first = dev; | 604 | first = dev; |
@@ -618,7 +618,7 @@ struct net_device *nr_dev_get(ax25_address *addr) | |||
618 | struct net_device *dev; | 618 | struct net_device *dev; |
619 | 619 | ||
620 | read_lock(&dev_base_lock); | 620 | read_lock(&dev_base_lock); |
621 | for_each_netdev(dev) { | 621 | for_each_netdev(&init_net, dev) { |
622 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) { | 622 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) { |
623 | dev_hold(dev); | 623 | dev_hold(dev); |
624 | goto out; | 624 | goto out; |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ad0052524e88..745e2cb87c96 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -347,7 +347,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
347 | */ | 347 | */ |
348 | 348 | ||
349 | saddr->spkt_device[13] = 0; | 349 | saddr->spkt_device[13] = 0; |
350 | dev = dev_get_by_name(saddr->spkt_device); | 350 | dev = dev_get_by_name(&init_net, saddr->spkt_device); |
351 | err = -ENODEV; | 351 | err = -ENODEV; |
352 | if (dev == NULL) | 352 | if (dev == NULL) |
353 | goto out_unlock; | 353 | goto out_unlock; |
@@ -742,7 +742,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
742 | } | 742 | } |
743 | 743 | ||
744 | 744 | ||
745 | dev = dev_get_by_index(ifindex); | 745 | dev = dev_get_by_index(&init_net, ifindex); |
746 | err = -ENXIO; | 746 | err = -ENXIO; |
747 | if (dev == NULL) | 747 | if (dev == NULL) |
748 | goto out_unlock; | 748 | goto out_unlock; |
@@ -937,7 +937,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add | |||
937 | return -EINVAL; | 937 | return -EINVAL; |
938 | strlcpy(name,uaddr->sa_data,sizeof(name)); | 938 | strlcpy(name,uaddr->sa_data,sizeof(name)); |
939 | 939 | ||
940 | dev = dev_get_by_name(name); | 940 | dev = dev_get_by_name(&init_net, name); |
941 | if (dev) { | 941 | if (dev) { |
942 | err = packet_do_bind(sk, dev, pkt_sk(sk)->num); | 942 | err = packet_do_bind(sk, dev, pkt_sk(sk)->num); |
943 | dev_put(dev); | 943 | dev_put(dev); |
@@ -964,7 +964,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len | |||
964 | 964 | ||
965 | if (sll->sll_ifindex) { | 965 | if (sll->sll_ifindex) { |
966 | err = -ENODEV; | 966 | err = -ENODEV; |
967 | dev = dev_get_by_index(sll->sll_ifindex); | 967 | dev = dev_get_by_index(&init_net, sll->sll_ifindex); |
968 | if (dev == NULL) | 968 | if (dev == NULL) |
969 | goto out; | 969 | goto out; |
970 | } | 970 | } |
@@ -1161,7 +1161,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr, | |||
1161 | return -EOPNOTSUPP; | 1161 | return -EOPNOTSUPP; |
1162 | 1162 | ||
1163 | uaddr->sa_family = AF_PACKET; | 1163 | uaddr->sa_family = AF_PACKET; |
1164 | dev = dev_get_by_index(pkt_sk(sk)->ifindex); | 1164 | dev = dev_get_by_index(&init_net, pkt_sk(sk)->ifindex); |
1165 | if (dev) { | 1165 | if (dev) { |
1166 | strlcpy(uaddr->sa_data, dev->name, 15); | 1166 | strlcpy(uaddr->sa_data, dev->name, 15); |
1167 | dev_put(dev); | 1167 | dev_put(dev); |
@@ -1186,7 +1186,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr, | |||
1186 | sll->sll_family = AF_PACKET; | 1186 | sll->sll_family = AF_PACKET; |
1187 | sll->sll_ifindex = po->ifindex; | 1187 | sll->sll_ifindex = po->ifindex; |
1188 | sll->sll_protocol = po->num; | 1188 | sll->sll_protocol = po->num; |
1189 | dev = dev_get_by_index(po->ifindex); | 1189 | dev = dev_get_by_index(&init_net, po->ifindex); |
1190 | if (dev) { | 1190 | if (dev) { |
1191 | sll->sll_hatype = dev->type; | 1191 | sll->sll_hatype = dev->type; |
1192 | sll->sll_halen = dev->addr_len; | 1192 | sll->sll_halen = dev->addr_len; |
@@ -1238,7 +1238,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq) | |||
1238 | rtnl_lock(); | 1238 | rtnl_lock(); |
1239 | 1239 | ||
1240 | err = -ENODEV; | 1240 | err = -ENODEV; |
1241 | dev = __dev_get_by_index(mreq->mr_ifindex); | 1241 | dev = __dev_get_by_index(&init_net, mreq->mr_ifindex); |
1242 | if (!dev) | 1242 | if (!dev) |
1243 | goto done; | 1243 | goto done; |
1244 | 1244 | ||
@@ -1292,7 +1292,7 @@ static int packet_mc_drop(struct sock *sk, struct packet_mreq_max *mreq) | |||
1292 | if (--ml->count == 0) { | 1292 | if (--ml->count == 0) { |
1293 | struct net_device *dev; | 1293 | struct net_device *dev; |
1294 | *mlp = ml->next; | 1294 | *mlp = ml->next; |
1295 | dev = dev_get_by_index(ml->ifindex); | 1295 | dev = dev_get_by_index(&init_net, ml->ifindex); |
1296 | if (dev) { | 1296 | if (dev) { |
1297 | packet_dev_mc(dev, ml, -1); | 1297 | packet_dev_mc(dev, ml, -1); |
1298 | dev_put(dev); | 1298 | dev_put(dev); |
@@ -1320,7 +1320,7 @@ static void packet_flush_mclist(struct sock *sk) | |||
1320 | struct net_device *dev; | 1320 | struct net_device *dev; |
1321 | 1321 | ||
1322 | po->mclist = ml->next; | 1322 | po->mclist = ml->next; |
1323 | if ((dev = dev_get_by_index(ml->ifindex)) != NULL) { | 1323 | if ((dev = dev_get_by_index(&init_net, ml->ifindex)) != NULL) { |
1324 | packet_dev_mc(dev, ml, -1); | 1324 | packet_dev_mc(dev, ml, -1); |
1325 | dev_put(dev); | 1325 | dev_put(dev); |
1326 | } | 1326 | } |
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index 96f61a71b252..540c0f26ffee 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c | |||
@@ -583,7 +583,7 @@ static struct net_device *rose_ax25_dev_get(char *devname) | |||
583 | { | 583 | { |
584 | struct net_device *dev; | 584 | struct net_device *dev; |
585 | 585 | ||
586 | if ((dev = dev_get_by_name(devname)) == NULL) | 586 | if ((dev = dev_get_by_name(&init_net, devname)) == NULL) |
587 | return NULL; | 587 | return NULL; |
588 | 588 | ||
589 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25) | 589 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25) |
@@ -601,7 +601,7 @@ struct net_device *rose_dev_first(void) | |||
601 | struct net_device *dev, *first = NULL; | 601 | struct net_device *dev, *first = NULL; |
602 | 602 | ||
603 | read_lock(&dev_base_lock); | 603 | read_lock(&dev_base_lock); |
604 | for_each_netdev(dev) { | 604 | for_each_netdev(&init_net, dev) { |
605 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE) | 605 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE) |
606 | if (first == NULL || strncmp(dev->name, first->name, 3) < 0) | 606 | if (first == NULL || strncmp(dev->name, first->name, 3) < 0) |
607 | first = dev; | 607 | first = dev; |
@@ -619,7 +619,7 @@ struct net_device *rose_dev_get(rose_address *addr) | |||
619 | struct net_device *dev; | 619 | struct net_device *dev; |
620 | 620 | ||
621 | read_lock(&dev_base_lock); | 621 | read_lock(&dev_base_lock); |
622 | for_each_netdev(dev) { | 622 | for_each_netdev(&init_net, dev) { |
623 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) { | 623 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) { |
624 | dev_hold(dev); | 624 | dev_hold(dev); |
625 | goto out; | 625 | goto out; |
@@ -636,7 +636,7 @@ static int rose_dev_exists(rose_address *addr) | |||
636 | struct net_device *dev; | 636 | struct net_device *dev; |
637 | 637 | ||
638 | read_lock(&dev_base_lock); | 638 | read_lock(&dev_base_lock); |
639 | for_each_netdev(dev) { | 639 | for_each_netdev(&init_net, dev) { |
640 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) | 640 | if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) |
641 | goto out; | 641 | goto out; |
642 | } | 642 | } |
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c index 579578944ae7..fd7bca4d5c20 100644 --- a/net/sched/act_mirred.c +++ b/net/sched/act_mirred.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/rtnetlink.h> | 20 | #include <linux/rtnetlink.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <net/net_namespace.h> | ||
23 | #include <net/netlink.h> | 24 | #include <net/netlink.h> |
24 | #include <net/pkt_sched.h> | 25 | #include <net/pkt_sched.h> |
25 | #include <linux/tc_act/tc_mirred.h> | 26 | #include <linux/tc_act/tc_mirred.h> |
@@ -73,7 +74,7 @@ static int tcf_mirred_init(struct rtattr *rta, struct rtattr *est, | |||
73 | parm = RTA_DATA(tb[TCA_MIRRED_PARMS-1]); | 74 | parm = RTA_DATA(tb[TCA_MIRRED_PARMS-1]); |
74 | 75 | ||
75 | if (parm->ifindex) { | 76 | if (parm->ifindex) { |
76 | dev = __dev_get_by_index(parm->ifindex); | 77 | dev = __dev_get_by_index(&init_net, parm->ifindex); |
77 | if (dev == NULL) | 78 | if (dev == NULL) |
78 | return -ENODEV; | 79 | return -ENODEV; |
79 | switch (dev->type) { | 80 | switch (dev->type) { |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 5f0fbca7393f..03657976fd50 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -154,7 +154,7 @@ replay: | |||
154 | /* Find head of filter chain. */ | 154 | /* Find head of filter chain. */ |
155 | 155 | ||
156 | /* Find link */ | 156 | /* Find link */ |
157 | if ((dev = __dev_get_by_index(t->tcm_ifindex)) == NULL) | 157 | if ((dev = __dev_get_by_index(&init_net, t->tcm_ifindex)) == NULL) |
158 | return -ENODEV; | 158 | return -ENODEV; |
159 | 159 | ||
160 | /* Find qdisc */ | 160 | /* Find qdisc */ |
@@ -387,7 +387,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb) | |||
387 | 387 | ||
388 | if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm))) | 388 | if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm))) |
389 | return skb->len; | 389 | return skb->len; |
390 | if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 390 | if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) |
391 | return skb->len; | 391 | return skb->len; |
392 | 392 | ||
393 | if (!tcm->tcm_parent) | 393 | if (!tcm->tcm_parent) |
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 650f09c8bd6a..e9989610712c 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -291,7 +291,7 @@ META_COLLECTOR(var_sk_bound_if) | |||
291 | } else { | 291 | } else { |
292 | struct net_device *dev; | 292 | struct net_device *dev; |
293 | 293 | ||
294 | dev = dev_get_by_index(skb->sk->sk_bound_dev_if); | 294 | dev = dev_get_by_index(&init_net, skb->sk->sk_bound_dev_if); |
295 | *err = var_dev(dev, dst); | 295 | *err = var_dev(dev, dst); |
296 | if (dev) | 296 | if (dev) |
297 | dev_put(dev); | 297 | dev_put(dev); |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index efc383c58f1e..39d32780c80b 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -607,7 +607,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
607 | struct Qdisc *p = NULL; | 607 | struct Qdisc *p = NULL; |
608 | int err; | 608 | int err; |
609 | 609 | ||
610 | if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 610 | if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) |
611 | return -ENODEV; | 611 | return -ENODEV; |
612 | 612 | ||
613 | if (clid) { | 613 | if (clid) { |
@@ -674,7 +674,7 @@ replay: | |||
674 | clid = tcm->tcm_parent; | 674 | clid = tcm->tcm_parent; |
675 | q = p = NULL; | 675 | q = p = NULL; |
676 | 676 | ||
677 | if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 677 | if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) |
678 | return -ENODEV; | 678 | return -ENODEV; |
679 | 679 | ||
680 | if (clid) { | 680 | if (clid) { |
@@ -881,7 +881,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb) | |||
881 | s_q_idx = q_idx = cb->args[1]; | 881 | s_q_idx = q_idx = cb->args[1]; |
882 | read_lock(&dev_base_lock); | 882 | read_lock(&dev_base_lock); |
883 | idx = 0; | 883 | idx = 0; |
884 | for_each_netdev(dev) { | 884 | for_each_netdev(&init_net, dev) { |
885 | if (idx < s_idx) | 885 | if (idx < s_idx) |
886 | goto cont; | 886 | goto cont; |
887 | if (idx > s_idx) | 887 | if (idx > s_idx) |
@@ -932,7 +932,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
932 | u32 qid = TC_H_MAJ(clid); | 932 | u32 qid = TC_H_MAJ(clid); |
933 | int err; | 933 | int err; |
934 | 934 | ||
935 | if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 935 | if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) |
936 | return -ENODEV; | 936 | return -ENODEV; |
937 | 937 | ||
938 | /* | 938 | /* |
@@ -1115,7 +1115,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) | |||
1115 | 1115 | ||
1116 | if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm))) | 1116 | if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm))) |
1117 | return 0; | 1117 | return 0; |
1118 | if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 1118 | if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL) |
1119 | return 0; | 1119 | return 0; |
1120 | 1120 | ||
1121 | s_t = cb->args[0]; | 1121 | s_t = cb->args[0]; |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index ddeb4882ec75..9de3ddaa2768 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -855,7 +855,7 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr) | |||
855 | if (type & IPV6_ADDR_LINKLOCAL) { | 855 | if (type & IPV6_ADDR_LINKLOCAL) { |
856 | if (!addr->v6.sin6_scope_id) | 856 | if (!addr->v6.sin6_scope_id) |
857 | return 0; | 857 | return 0; |
858 | dev = dev_get_by_index(addr->v6.sin6_scope_id); | 858 | dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id); |
859 | if (!dev) | 859 | if (!dev) |
860 | return 0; | 860 | return 0; |
861 | if (!ipv6_chk_addr(&addr->v6.sin6_addr, dev, 0)) { | 861 | if (!ipv6_chk_addr(&addr->v6.sin6_addr, dev, 0)) { |
@@ -886,7 +886,7 @@ static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr) | |||
886 | if (type & IPV6_ADDR_LINKLOCAL) { | 886 | if (type & IPV6_ADDR_LINKLOCAL) { |
887 | if (!addr->v6.sin6_scope_id) | 887 | if (!addr->v6.sin6_scope_id) |
888 | return 0; | 888 | return 0; |
889 | dev = dev_get_by_index(addr->v6.sin6_scope_id); | 889 | dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id); |
890 | if (!dev) | 890 | if (!dev) |
891 | return 0; | 891 | return 0; |
892 | dev_put(dev); | 892 | dev_put(dev); |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index af67c839ef98..54edcd978f75 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -179,7 +179,7 @@ static void sctp_get_local_addr_list(void) | |||
179 | struct sctp_af *af; | 179 | struct sctp_af *af; |
180 | 180 | ||
181 | read_lock(&dev_base_lock); | 181 | read_lock(&dev_base_lock); |
182 | for_each_netdev(dev) { | 182 | for_each_netdev(&init_net, dev) { |
183 | __list_for_each(pos, &sctp_address_families) { | 183 | __list_for_each(pos, &sctp_address_families) { |
184 | af = list_entry(pos, struct sctp_af, list); | 184 | af = list_entry(pos, struct sctp_af, list); |
185 | af->copy_addrlist(&sctp_local_addr_list, dev); | 185 | af->copy_addrlist(&sctp_local_addr_list, dev); |
diff --git a/net/socket.c b/net/socket.c index a714c6d4e4a1..bc16eee4dc80 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -791,9 +791,9 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
791 | */ | 791 | */ |
792 | 792 | ||
793 | static DEFINE_MUTEX(br_ioctl_mutex); | 793 | static DEFINE_MUTEX(br_ioctl_mutex); |
794 | static int (*br_ioctl_hook) (unsigned int cmd, void __user *arg) = NULL; | 794 | static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL; |
795 | 795 | ||
796 | void brioctl_set(int (*hook) (unsigned int, void __user *)) | 796 | void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *)) |
797 | { | 797 | { |
798 | mutex_lock(&br_ioctl_mutex); | 798 | mutex_lock(&br_ioctl_mutex); |
799 | br_ioctl_hook = hook; | 799 | br_ioctl_hook = hook; |
@@ -803,9 +803,9 @@ void brioctl_set(int (*hook) (unsigned int, void __user *)) | |||
803 | EXPORT_SYMBOL(brioctl_set); | 803 | EXPORT_SYMBOL(brioctl_set); |
804 | 804 | ||
805 | static DEFINE_MUTEX(vlan_ioctl_mutex); | 805 | static DEFINE_MUTEX(vlan_ioctl_mutex); |
806 | static int (*vlan_ioctl_hook) (void __user *arg); | 806 | static int (*vlan_ioctl_hook) (struct net *, void __user *arg); |
807 | 807 | ||
808 | void vlan_ioctl_set(int (*hook) (void __user *)) | 808 | void vlan_ioctl_set(int (*hook) (struct net *, void __user *)) |
809 | { | 809 | { |
810 | mutex_lock(&vlan_ioctl_mutex); | 810 | mutex_lock(&vlan_ioctl_mutex); |
811 | vlan_ioctl_hook = hook; | 811 | vlan_ioctl_hook = hook; |
@@ -834,16 +834,20 @@ EXPORT_SYMBOL(dlci_ioctl_set); | |||
834 | static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | 834 | static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) |
835 | { | 835 | { |
836 | struct socket *sock; | 836 | struct socket *sock; |
837 | struct sock *sk; | ||
837 | void __user *argp = (void __user *)arg; | 838 | void __user *argp = (void __user *)arg; |
838 | int pid, err; | 839 | int pid, err; |
840 | struct net *net; | ||
839 | 841 | ||
840 | sock = file->private_data; | 842 | sock = file->private_data; |
843 | sk = sock->sk; | ||
844 | net = sk->sk_net; | ||
841 | if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) { | 845 | if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) { |
842 | err = dev_ioctl(cmd, argp); | 846 | err = dev_ioctl(net, cmd, argp); |
843 | } else | 847 | } else |
844 | #ifdef CONFIG_WIRELESS_EXT | 848 | #ifdef CONFIG_WIRELESS_EXT |
845 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { | 849 | if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) { |
846 | err = dev_ioctl(cmd, argp); | 850 | err = dev_ioctl(net, cmd, argp); |
847 | } else | 851 | } else |
848 | #endif /* CONFIG_WIRELESS_EXT */ | 852 | #endif /* CONFIG_WIRELESS_EXT */ |
849 | switch (cmd) { | 853 | switch (cmd) { |
@@ -869,7 +873,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
869 | 873 | ||
870 | mutex_lock(&br_ioctl_mutex); | 874 | mutex_lock(&br_ioctl_mutex); |
871 | if (br_ioctl_hook) | 875 | if (br_ioctl_hook) |
872 | err = br_ioctl_hook(cmd, argp); | 876 | err = br_ioctl_hook(net, cmd, argp); |
873 | mutex_unlock(&br_ioctl_mutex); | 877 | mutex_unlock(&br_ioctl_mutex); |
874 | break; | 878 | break; |
875 | case SIOCGIFVLAN: | 879 | case SIOCGIFVLAN: |
@@ -880,7 +884,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
880 | 884 | ||
881 | mutex_lock(&vlan_ioctl_mutex); | 885 | mutex_lock(&vlan_ioctl_mutex); |
882 | if (vlan_ioctl_hook) | 886 | if (vlan_ioctl_hook) |
883 | err = vlan_ioctl_hook(argp); | 887 | err = vlan_ioctl_hook(net, argp); |
884 | mutex_unlock(&vlan_ioctl_mutex); | 888 | mutex_unlock(&vlan_ioctl_mutex); |
885 | break; | 889 | break; |
886 | case SIOCADDDLCI: | 890 | case SIOCADDDLCI: |
@@ -903,7 +907,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
903 | * to the NIC driver. | 907 | * to the NIC driver. |
904 | */ | 908 | */ |
905 | if (err == -ENOIOCTLCMD) | 909 | if (err == -ENOIOCTLCMD) |
906 | err = dev_ioctl(cmd, argp); | 910 | err = dev_ioctl(net, cmd, argp); |
907 | break; | 911 | break; |
908 | } | 912 | } |
909 | return err; | 913 | return err; |
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 406f0d26fa81..d6fc0575816b 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -135,7 +135,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
135 | 135 | ||
136 | /* Find device with specified name */ | 136 | /* Find device with specified name */ |
137 | 137 | ||
138 | for_each_netdev(pdev){ | 138 | for_each_netdev(&init_net, pdev){ |
139 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { | 139 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { |
140 | dev = pdev; | 140 | dev = pdev; |
141 | break; | 141 | break; |
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index b8069afe0410..e8b3409d6c8b 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -673,7 +673,22 @@ static const struct seq_operations wireless_seq_ops = { | |||
673 | 673 | ||
674 | static int wireless_seq_open(struct inode *inode, struct file *file) | 674 | static int wireless_seq_open(struct inode *inode, struct file *file) |
675 | { | 675 | { |
676 | return seq_open(file, &wireless_seq_ops); | 676 | struct seq_file *seq; |
677 | int res; | ||
678 | res = seq_open(file, &wireless_seq_ops); | ||
679 | if (!res) { | ||
680 | seq = file->private_data; | ||
681 | seq->private = get_net(PROC_NET(inode)); | ||
682 | } | ||
683 | return res; | ||
684 | } | ||
685 | |||
686 | static int wireless_seq_release(struct inode *inode, struct file *file) | ||
687 | { | ||
688 | struct seq_file *seq = file->private_data; | ||
689 | struct net *net = seq->private; | ||
690 | put_net(net); | ||
691 | return seq_release(inode, file); | ||
677 | } | 692 | } |
678 | 693 | ||
679 | static const struct file_operations wireless_seq_fops = { | 694 | static const struct file_operations wireless_seq_fops = { |
@@ -681,17 +696,22 @@ static const struct file_operations wireless_seq_fops = { | |||
681 | .open = wireless_seq_open, | 696 | .open = wireless_seq_open, |
682 | .read = seq_read, | 697 | .read = seq_read, |
683 | .llseek = seq_lseek, | 698 | .llseek = seq_lseek, |
684 | .release = seq_release, | 699 | .release = wireless_seq_release, |
685 | }; | 700 | }; |
686 | 701 | ||
687 | int __init wext_proc_init(void) | 702 | int wext_proc_init(struct net *net) |
688 | { | 703 | { |
689 | /* Create /proc/net/wireless entry */ | 704 | /* Create /proc/net/wireless entry */ |
690 | if (!proc_net_fops_create(&init_net, "wireless", S_IRUGO, &wireless_seq_fops)) | 705 | if (!proc_net_fops_create(net, "wireless", S_IRUGO, &wireless_seq_fops)) |
691 | return -ENOMEM; | 706 | return -ENOMEM; |
692 | 707 | ||
693 | return 0; | 708 | return 0; |
694 | } | 709 | } |
710 | |||
711 | void wext_proc_exit(struct net *net) | ||
712 | { | ||
713 | proc_net_remove(net, "wireless"); | ||
714 | } | ||
695 | #endif /* CONFIG_PROC_FS */ | 715 | #endif /* CONFIG_PROC_FS */ |
696 | 716 | ||
697 | /************************** IOCTL SUPPORT **************************/ | 717 | /************************** IOCTL SUPPORT **************************/ |
@@ -1011,7 +1031,7 @@ static int ioctl_private_call(struct net_device *dev, struct ifreq *ifr, | |||
1011 | * Main IOCTl dispatcher. | 1031 | * Main IOCTl dispatcher. |
1012 | * Check the type of IOCTL and call the appropriate wrapper... | 1032 | * Check the type of IOCTL and call the appropriate wrapper... |
1013 | */ | 1033 | */ |
1014 | static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | 1034 | static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd) |
1015 | { | 1035 | { |
1016 | struct net_device *dev; | 1036 | struct net_device *dev; |
1017 | iw_handler handler; | 1037 | iw_handler handler; |
@@ -1020,7 +1040,7 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1020 | * The copy_to/from_user() of ifr is also dealt with in there */ | 1040 | * The copy_to/from_user() of ifr is also dealt with in there */ |
1021 | 1041 | ||
1022 | /* Make sure the device exist */ | 1042 | /* Make sure the device exist */ |
1023 | if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL) | 1043 | if ((dev = __dev_get_by_name(net, ifr->ifr_name)) == NULL) |
1024 | return -ENODEV; | 1044 | return -ENODEV; |
1025 | 1045 | ||
1026 | /* A bunch of special cases, then the generic case... | 1046 | /* A bunch of special cases, then the generic case... |
@@ -1054,7 +1074,7 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1054 | } | 1074 | } |
1055 | 1075 | ||
1056 | /* entry point from dev ioctl */ | 1076 | /* entry point from dev ioctl */ |
1057 | int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | 1077 | int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd, |
1058 | void __user *arg) | 1078 | void __user *arg) |
1059 | { | 1079 | { |
1060 | int ret; | 1080 | int ret; |
@@ -1066,9 +1086,9 @@ int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, | |||
1066 | && !capable(CAP_NET_ADMIN)) | 1086 | && !capable(CAP_NET_ADMIN)) |
1067 | return -EPERM; | 1087 | return -EPERM; |
1068 | 1088 | ||
1069 | dev_load(ifr->ifr_name); | 1089 | dev_load(net, ifr->ifr_name); |
1070 | rtnl_lock(); | 1090 | rtnl_lock(); |
1071 | ret = wireless_process_ioctl(ifr, cmd); | 1091 | ret = wireless_process_ioctl(net, ifr, cmd); |
1072 | rtnl_unlock(); | 1092 | rtnl_unlock(); |
1073 | if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq))) | 1093 | if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq))) |
1074 | return -EFAULT; | 1094 | return -EFAULT; |
diff --git a/net/x25/x25_route.c b/net/x25/x25_route.c index 060fcfaa2f47..86b5b4da097c 100644 --- a/net/x25/x25_route.c +++ b/net/x25/x25_route.c | |||
@@ -129,7 +129,7 @@ void x25_route_device_down(struct net_device *dev) | |||
129 | */ | 129 | */ |
130 | struct net_device *x25_dev_get(char *devname) | 130 | struct net_device *x25_dev_get(char *devname) |
131 | { | 131 | { |
132 | struct net_device *dev = dev_get_by_name(devname); | 132 | struct net_device *dev = dev_get_by_name(&init_net, devname); |
133 | 133 | ||
134 | if (dev && | 134 | if (dev && |
135 | (!(dev->flags & IFF_UP) || (dev->type != ARPHRD_X25 | 135 | (!(dev->flags & IFF_UP) || (dev->type != ARPHRD_X25 |