[NET]: Make the device list and device lookups per namespace.
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 17 Sep 2007 18:56:21 +0000 (11:56 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:49:10 +0000 (16:49 -0700)
This patch makes most of the generic device layer network
namespace safe.  This patch makes dev_base_head a
network namespace variable, and then it picks up
a few associated variables.  The functions:
dev_getbyhwaddr
dev_getfirsthwbytype
dev_get_by_flags
dev_get_by_name
__dev_get_by_name
dev_get_by_index
__dev_get_by_index
dev_ioctl
dev_ethtool
dev_load
wireless_process_ioctl

were modified to take a network namespace argument, and
deal with it.

vlan_ioctl_set and brioctl_set were modified so their
hooks will receive a network namespace argument.

So basically anthing in the core of the network stack that was
affected to by the change of dev_base was modified to handle
multiple network namespaces.  The rest of the network stack was
simply modified to explicitly use &init_net the initial network
namespace.  This can be fixed when those components of the network
stack are modified to handle multiple network namespaces.

For now the ifindex generator is left global.

Fundametally ifindex numbers are per namespace, or else
we will have corner case problems with migration when
we get that far.

At the same time there are assumptions in the network stack
that the ifindex of a network device won't change.  Making
the ifindex number global seems a good compromise until
the network stack can cope with ifindex changes when
you change namespaces, and the like.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
99 files changed:
arch/s390/appldata/appldata_net_sum.c
arch/sparc64/solaris/ioctl.c
drivers/atm/idt77252.c
drivers/block/aoe/aoecmd.c
drivers/infiniband/hw/cxgb3/cxio_hal.c
drivers/net/bonding/bond_main.c
drivers/net/bonding/bond_sysfs.c
drivers/net/eql.c
drivers/net/ifb.c
drivers/net/macvlan.c
drivers/net/pppoe.c
drivers/net/shaper.c
drivers/net/tun.c
drivers/net/veth.c
drivers/net/wan/dlci.c
drivers/net/wan/sbni.c
drivers/net/wireless/strip.c
drivers/parisc/led.c
fs/afs/netdevices.c
include/linux/if_bridge.h
include/linux/if_vlan.h
include/linux/netdevice.h
include/net/net_namespace.h
include/net/pkt_cls.h
include/net/rtnetlink.h
include/net/wext.h
net/802/tr.c
net/8021q/vlan.c
net/8021q/vlan_netlink.c
net/8021q/vlanproc.c
net/appletalk/ddp.c
net/atm/mpc.c
net/ax25/af_ax25.c
net/bridge/br_if.c
net/bridge/br_ioctl.c
net/bridge/br_netlink.c
net/bridge/br_private.h
net/core/dev.c
net/core/dev_mcast.c
net/core/ethtool.c
net/core/fib_rules.c
net/core/neighbour.c
net/core/netpoll.c
net/core/pktgen.c
net/core/rtnetlink.c
net/core/sock.c
net/decnet/af_decnet.c
net/decnet/dn_dev.c
net/decnet/dn_fib.c
net/decnet/dn_route.c
net/decnet/sysctl_net_decnet.c
net/econet/af_econet.c
net/ipv4/arp.c
net/ipv4/devinet.c
net/ipv4/fib_frontend.c
net/ipv4/fib_semantics.c
net/ipv4/icmp.c
net/ipv4/igmp.c
net/ipv4/ip_fragment.c
net/ipv4/ip_gre.c
net/ipv4/ip_sockglue.c
net/ipv4/ipconfig.c
net/ipv4/ipip.c
net/ipv4/ipmr.c
net/ipv4/ipvs/ip_vs_sync.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/route.c
net/ipv6/addrconf.c
net/ipv6/af_inet6.c
net/ipv6/anycast.c
net/ipv6/datagram.c
net/ipv6/ip6_tunnel.c
net/ipv6/ipv6_sockglue.c
net/ipv6/mcast.c
net/ipv6/raw.c
net/ipv6/reassembly.c
net/ipv6/route.c
net/ipv6/sit.c
net/ipx/af_ipx.c
net/irda/irnetlink.c
net/llc/af_llc.c
net/llc/llc_core.c
net/mac80211/ieee80211.c
net/mac80211/ieee80211_cfg.c
net/mac80211/tx.c
net/mac80211/util.c
net/netrom/nr_route.c
net/packet/af_packet.c
net/rose/rose_route.c
net/sched/act_mirred.c
net/sched/cls_api.c
net/sched/em_meta.c
net/sched/sch_api.c
net/sctp/ipv6.c
net/sctp/protocol.c
net/socket.c
net/tipc/eth_media.c
net/wireless/wext.c
net/x25/x25_route.c

index 2180ac105b05f5ba8f7b0f08328b615530d72304..6c1815a47714389e0f6664722e7c3563907a930a 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/kernel_stat.h>
 #include <linux/netdevice.h>
+#include <net/net_namespace.h>
 
 #include "appldata.h"
 
@@ -107,7 +108,7 @@ static void appldata_get_net_sum_data(void *data)
        tx_dropped = 0;
        collisions = 0;
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                stats = dev->get_stats(dev);
                rx_packets += stats->rx_packets;
                tx_packets += stats->tx_packets;
index 18352a49862842f6e6f432b1799b5370139e3358..8ad10a6d993bacc5821f3c15e308202ca82514c8 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/compat.h>
 
 #include <net/sock.h>
+#include <net/net_namespace.h>
 
 #include <asm/uaccess.h>
 #include <asm/termios.h>
@@ -686,7 +687,7 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
                        int i = 0;
                        
                        read_lock_bh(&dev_base_lock);
-                       for_each_netdev(d)
+                       for_each_netdev(&init_net, d)
                                i++;
                        read_unlock_bh(&dev_base_lock);
 
index f8b1700f4c16df01d40401d83df1df811dd10889..eee54c0cde6819ad064ada9cb619bdb3954f0052 100644 (file)
@@ -3576,7 +3576,7 @@ init_card(struct atm_dev *dev)
         * XXX: <hack>
         */
        sprintf(tname, "eth%d", card->index);
-       tmp = dev_get_by_name(tname);   /* jhs: was "tmp = dev_get(tname);" */
+       tmp = dev_get_by_name(&init_net, tname);        /* jhs: was "tmp = dev_get(tname);" */
        if (tmp) {
                memcpy(card->atmdev->esi, tmp->dev_addr, 6);
 
index 01fbdd38e3be21979027538b64b5cd56dc516f0c..30394f78cac2bd7928cc1f8b26d662c668f354d1 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/genhd.h>
+#include <net/net_namespace.h>
 #include <asm/unaligned.h>
 #include "aoe.h"
 
@@ -194,7 +195,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
        sl = sl_tail = NULL;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(ifp) {
+       for_each_netdev(&init_net, ifp) {
                dev_hold(ifp);
                if (!is_aoe_netif(ifp))
                        goto cont;
index beb2a381467f75abf2ae04711c810bb224f80888..eec6a30840ca0a16763105b67702c00f3e7c6836 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/pci.h>
 #include <linux/dma-mapping.h>
+#include <net/net_namespace.h>
 
 #include "cxio_resource.h"
 #include "cxio_hal.h"
@@ -894,7 +895,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
                if (cxio_hal_find_rdev_by_name(rdev_p->dev_name)) {
                        return -EBUSY;
                }
-               netdev_p = dev_get_by_name(rdev_p->dev_name);
+               netdev_p = dev_get_by_name(&init_net, rdev_p->dev_name);
                if (!netdev_p) {
                        return -EINVAL;
                }
index cf97d8a6326e21544ebe5d04b186b273fc9335ee..559fe9437e0b6ed2937d0056853d8255cfcc570f 100644 (file)
@@ -3719,7 +3719,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
        }
 
        down_write(&(bonding_rwsem));
-       slave_dev = dev_get_by_name(ifr->ifr_slave);
+       slave_dev = dev_get_by_name(&init_net, ifr->ifr_slave);
 
        dprintk("slave_dev=%p: \n", slave_dev);
 
index 60cccf2aa9594e5c98eefd4e93622fdf5257bec9..8289e27a360a399f7b9a29405ba1468289446ffa 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/ctype.h>
 #include <linux/inet.h>
 #include <linux/rtnetlink.h>
+#include <net/net_namespace.h>
 
 /* #define BONDING_DEBUG 1 */
 #include "bonding.h"
@@ -299,7 +300,7 @@ static ssize_t bonding_store_slaves(struct device *d,
                read_unlock_bh(&bond->lock);
                printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n",
                       bond->dev->name, ifname);
-               dev = dev_get_by_name(ifname);
+               dev = dev_get_by_name(&init_net, ifname);
                if (!dev) {
                        printk(KERN_INFO DRV_NAME
                               ": %s: Interface %s does not exist!\n",
index 102218c4a907ec9606ab53f04b927775aa22ccd7..f1cc66dcbdfdc58dc9f21988a5533d8256bffa6f 100644 (file)
 #include <linux/init.h>
 #include <linux/timer.h>
 #include <linux/netdevice.h>
+#include <net/net_namespace.h>
 
 #include <linux/if.h>
 #include <linux/if_arp.h>
@@ -412,7 +413,7 @@ static int eql_enslave(struct net_device *master_dev, slaving_request_t __user *
        if (copy_from_user(&srq, srqp, sizeof (slaving_request_t)))
                return -EFAULT;
 
-       slave_dev  = dev_get_by_name(srq.slave_name);
+       slave_dev  = dev_get_by_name(&init_net, srq.slave_name);
        if (slave_dev) {
                if ((master_dev->flags & IFF_UP) == IFF_UP) {
                        /* 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
        if (copy_from_user(&srq, srqp, sizeof (slaving_request_t)))
                return -EFAULT;
 
-       slave_dev = dev_get_by_name(srq.slave_name);
+       slave_dev = dev_get_by_name(&init_net, srq.slave_name);
        ret = -EINVAL;
        if (slave_dev) {
                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)
        if (copy_from_user(&sc, scp, sizeof (slave_config_t)))
                return -EFAULT;
 
-       slave_dev = dev_get_by_name(sc.slave_name);
+       slave_dev = dev_get_by_name(&init_net, sc.slave_name);
        if (!slave_dev)
                return -ENODEV;
 
@@ -528,7 +529,7 @@ static int eql_s_slave_cfg(struct net_device *dev, slave_config_t __user *scp)
        if (copy_from_user(&sc, scp, sizeof (slave_config_t)))
                return -EFAULT;
 
-       slave_dev = dev_get_by_name(sc.slave_name);
+       slave_dev = dev_get_by_name(&init_net, sc.slave_name);
        if (!slave_dev)
                return -ENODEV;
 
index f5c3598e59afd928d89085e841e45b62fc6c9b92..b06c6db4383ab4bb56591ea8a83b078e78087705 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/init.h>
 #include <linux/moduleparam.h>
 #include <net/pkt_sched.h>
+#include <net/net_namespace.h>
 
 #define TX_TIMEOUT  (2*HZ)
 
@@ -97,7 +98,7 @@ static void ri_tasklet(unsigned long dev)
                stats->tx_packets++;
                stats->tx_bytes +=skb->len;
 
-               skb->dev = __dev_get_by_index(skb->iif);
+               skb->dev = __dev_get_by_index(&init_net, skb->iif);
                if (!skb->dev) {
                        dev_kfree_skb(skb);
                        stats->tx_dropped++;
index dc74d006e01f0cf67b39dddad2180b0cbfa4272b..2de073da182cabc26004619edcaacd7a17029d1f 100644 (file)
@@ -376,7 +376,7 @@ static int macvlan_newlink(struct net_device *dev,
        if (!tb[IFLA_LINK])
                return -EINVAL;
 
-       lowerdev = __dev_get_by_index(nla_get_u32(tb[IFLA_LINK]));
+       lowerdev = __dev_get_by_index(dev->nd_net, nla_get_u32(tb[IFLA_LINK]));
        if (lowerdev == NULL)
                return -ENODEV;
 
index c5c70e4b1d3616a2c7902d7bca22fe7e62d03183..2f130e06b6dce0b079f1e521e26f180474932231 100644 (file)
@@ -216,7 +216,7 @@ static inline struct pppox_sock *get_item_by_addr(struct sockaddr_pppox *sp)
        struct net_device *dev;
        int ifindex;
 
-       dev = dev_get_by_name(sp->sa_addr.pppoe.dev);
+       dev = dev_get_by_name(&init_net, sp->sa_addr.pppoe.dev);
        if(!dev)
                return NULL;
        ifindex = dev->ifindex;
@@ -603,7 +603,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr,
 
        /* Don't re-bind if sid==0 */
        if (sp->sa_addr.pppoe.sid != 0) {
-               dev = dev_get_by_name(sp->sa_addr.pppoe.dev);
+               dev = dev_get_by_name(&init_net, sp->sa_addr.pppoe.dev);
 
                error = -ENODEV;
                if (!dev)
index 4c3d98ff4cd48bab194c6f521e94b1522cd71203..3773b3858bd4a84f5edfbb900a64871b9f7ea646 100644 (file)
@@ -86,6 +86,7 @@
 
 #include <net/dst.h>
 #include <net/arp.h>
+#include <net/net_namespace.h>
 
 struct shaper_cb {
        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)
        {
                case SHAPER_SET_DEV:
                {
-                       struct net_device *them=__dev_get_by_name(ss->ss_name);
+                       struct net_device *them=__dev_get_by_name(&init_net, ss->ss_name);
                        if(them==NULL)
                                return -ENODEV;
                        if(sh->dev)
index 62b2b3005019c90865ef0f019f16d8d2607089f0..691d264fbb6f3371cfbccd28942c707807462d6a 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/if_ether.h>
 #include <linux/if_tun.h>
 #include <linux/crc32.h>
+#include <net/net_namespace.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -475,7 +476,7 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
                     !capable(CAP_NET_ADMIN))
                        return -EPERM;
        }
-       else if (__dev_get_by_name(ifr->ifr_name))
+       else if (__dev_get_by_name(&init_net, ifr->ifr_name))
                return -EINVAL;
        else {
                char *name;
index ca1c6893b80971ef0761c803c1c8cc3737fcd5a4..2c86a4459d8a500e684f9782dafc167edba42290 100644 (file)
@@ -345,7 +345,7 @@ static int veth_newlink(struct net_device *dev,
        else
                snprintf(ifname, IFNAMSIZ, DRV_NAME "%%d");
 
-       peer = rtnl_create_link(ifname, &veth_link_ops, tbp);
+       peer = rtnl_create_link(dev->nd_net, ifname, &veth_link_ops, tbp);
        if (IS_ERR(peer))
                return PTR_ERR(peer);
 
index 61041d5186ac087c79dd3dbe7cd39f318f15aebe..bc12810157e09449a956bd2b0e6661d5d4cddd0d 100644 (file)
@@ -361,7 +361,7 @@ static int dlci_add(struct dlci_add *dlci)
 
 
        /* validate slave device */
-       slave = dev_get_by_name(dlci->devname);
+       slave = dev_get_by_name(&init_net, dlci->devname);
        if (!slave)
                return -ENODEV;
 
@@ -427,7 +427,7 @@ static int dlci_del(struct dlci_add *dlci)
        int                     err;
 
        /* validate slave device */
-       master = __dev_get_by_name(dlci->devname);
+       master = __dev_get_by_name(&init_net, dlci->devname);
        if (!master)
                return(-ENODEV);
 
index 1cc18e787a65e4c39dc8e0e1fff2eed027d1ab6c..8d7e01e8f56f3e53af6cdbed38c3c8a3d9ecbee3 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/init.h>
 #include <linux/delay.h>
 
+#include <net/net_namespace.h>
 #include <net/arp.h>
 
 #include <asm/io.h>
@@ -1361,7 +1362,7 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
 
                if (copy_from_user( slave_name, ifr->ifr_data, sizeof slave_name ))
                        return -EFAULT;
-               slave_dev = dev_get_by_name( slave_name );
+               slave_dev = dev_get_by_name(&init_net, slave_name );
                if( !slave_dev  ||  !(slave_dev->flags & IFF_UP) ) {
                        printk( KERN_ERR "%s: trying to enslave non-active "
                                "device %s\n", dev->name, slave_name );
index edb214e8c744502c7f45ce36fb15b38ca6a32ace..904e548e679542aa71bf2cf59db4085017557644 100644 (file)
@@ -1972,7 +1972,7 @@ static struct net_device *get_strip_dev(struct strip *strip_info)
                      sizeof(zero_address))) {
                struct net_device *dev;
                read_lock_bh(&dev_base_lock);
-               for_each_netdev(dev) {
+               for_each_netdev(&init_net, dev) {
                        if (dev->type == strip_info->dev->type &&
                            !memcmp(dev->dev_addr,
                                    &strip_info->true_dev_addr,
index e5d7ed92d6f780ba746b177c14cf6eab9b814bfe..a6d6b2488ffc267c475a09c849f5f18c73e53cbb 100644 (file)
@@ -359,7 +359,7 @@ static __inline__ int led_get_net_activity(void)
         * for reading should be OK */
        read_lock(&dev_base_lock);
        rcu_read_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
            struct net_device_stats *stats;
            struct in_device *in_dev = __in_dev_get_rcu(dev);
            if (!in_dev || !in_dev->ifa_list)
index fc27d4b52e5fdf0d461348ff8cf588109e7081bb..49f189423063d6c760a35f5e2e63bf188cf2bd48 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/inetdevice.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
+#include <net/net_namespace.h>
 #include "internal.h"
 
 /*
@@ -23,7 +24,7 @@ int afs_get_MAC_address(u8 *mac, size_t maclen)
                BUG();
 
        rtnl_lock();
-       dev = __dev_getfirstbyhwtype(ARPHRD_ETHER);
+       dev = __dev_getfirstbyhwtype(&init_net, ARPHRD_ETHER);
        if (dev) {
                memcpy(mac, dev->dev_addr, maclen);
                ret = 0;
@@ -47,7 +48,7 @@ int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
        ASSERT(maxbufs > 0);
 
        rtnl_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
                        continue;
                idev = __in_dev_get_rtnl(dev);
index 4ff211d98769d532d3c1be2a7f5e6194ebac1390..99e3a1a0009955472f4eacb84040613f75e21cc9 100644 (file)
@@ -104,7 +104,7 @@ struct __fdb_entry
 
 #include <linux/netdevice.h>
 
-extern void brioctl_set(int (*ioctl_hook)(unsigned int, void __user *));
+extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
 extern struct sk_buff *(*br_handle_frame_hook)(struct net_bridge_port *p,
                                               struct sk_buff *skb);
 extern int (*br_should_route_hook)(struct sk_buff **pskb);
index f8443fdb124a7fc2e6ebc824fc8aac5b1423a80e..976d4b1067d1fb80ac72abc23f9e66e466e523f9 100644 (file)
@@ -62,7 +62,7 @@ struct vlan_hdr {
 #define VLAN_VID_MASK  0xfff
 
 /* found in socket.c */
-extern void vlan_ioctl_set(int (*hook)(void __user *));
+extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
 
 #define VLAN_NAME "vlan"
 
index dc3c15b726bcafe5d0fbe0a3a0944c2ba661df6e..7353b3e1f4fcbb8c76267365833c12ca4e26ea27 100644 (file)
@@ -741,44 +741,48 @@ struct packet_type {
 #include <linux/notifier.h>
 
 extern struct net_device               loopback_dev;           /* The loopback */
-extern struct list_head                        dev_base_head;          /* All devices */
 extern rwlock_t                                dev_base_lock;          /* Device list lock */
 
-#define for_each_netdev(d)             \
-               list_for_each_entry(d, &dev_base_head, dev_list)
-#define for_each_netdev_safe(d, n)     \
-               list_for_each_entry_safe(d, n, &dev_base_head, dev_list)
-#define for_each_netdev_continue(d)            \
-               list_for_each_entry_continue(d, &dev_base_head, dev_list)
-#define net_device_entry(lh)   list_entry(lh, struct net_device, dev_list)
-
-static inline struct net_device *next_net_device(struct net_device *dev)
-{
-       struct list_head *lh;
 
-       lh = dev->dev_list.next;
-       return lh == &dev_base_head ? NULL : net_device_entry(lh);
-}
+#define for_each_netdev(net, d)                \
+               list_for_each_entry(d, &(net)->dev_base_head, dev_list)
+#define for_each_netdev_safe(net, d, n)        \
+               list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list)
+#define for_each_netdev_continue(net, d)               \
+               list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list)
+#define net_device_entry(lh)   list_entry(lh, struct net_device, dev_list)
 
-static inline struct net_device *first_net_device(void)
-{
-       return list_empty(&dev_base_head) ? NULL :
-               net_device_entry(dev_base_head.next);
-}
+#define next_net_device(d)                                             \
+({                                                                     \
+       struct net_device *dev = d;                                     \
+       struct list_head *lh;                                           \
+       struct net *net;                                                \
+                                                                       \
+       net = dev->nd_net;                                              \
+       lh = dev->dev_list.next;                                        \
+       lh == &net->dev_base_head ? NULL : net_device_entry(lh);        \
+})
+
+#define first_net_device(N)                                    \
+({                                                             \
+       struct net *NET = (N);                                  \
+       list_empty(&NET->dev_base_head) ? NULL :                \
+               net_device_entry(NET->dev_base_head.next);      \
+})
 
 extern int                     netdev_boot_setup_check(struct net_device *dev);
 extern unsigned long           netdev_boot_base(const char *prefix, int unit);
-extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
-extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
-extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
+extern struct net_device    *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr);
+extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type);
+extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type);
 extern void            dev_add_pack(struct packet_type *pt);
 extern void            dev_remove_pack(struct packet_type *pt);
 extern void            __dev_remove_pack(struct packet_type *pt);
 
-extern struct net_device       *dev_get_by_flags(unsigned short flags,
+extern struct net_device       *dev_get_by_flags(struct net *net, unsigned short flags,
                                                  unsigned short mask);
-extern struct net_device       *dev_get_by_name(const char *name);
-extern struct net_device       *__dev_get_by_name(const char *name);
+extern struct net_device       *dev_get_by_name(struct net *net, const char *name);
+extern struct net_device       *__dev_get_by_name(struct net *net, const char *name);
 extern int             dev_alloc_name(struct net_device *dev, const char *name);
 extern int             dev_open(struct net_device *dev);
 extern int             dev_close(struct net_device *dev);
@@ -790,8 +794,8 @@ extern void         synchronize_net(void);
 extern int             register_netdevice_notifier(struct notifier_block *nb);
 extern int             unregister_netdevice_notifier(struct notifier_block *nb);
 extern int             call_netdevice_notifiers(unsigned long val, void *v);
-extern struct net_device       *dev_get_by_index(int ifindex);
-extern struct net_device       *__dev_get_by_index(int ifindex);
+extern struct net_device       *dev_get_by_index(struct net *net, int ifindex);
+extern struct net_device       *__dev_get_by_index(struct net *net, int ifindex);
 extern int             dev_restart(struct net_device *dev);
 #ifdef CONFIG_NETPOLL_TRAP
 extern int             netpoll_trap(void);
@@ -1007,8 +1011,8 @@ extern int                netif_rx_ni(struct sk_buff *skb);
 #define HAVE_NETIF_RECEIVE_SKB 1
 extern int             netif_receive_skb(struct sk_buff *skb);
 extern int             dev_valid_name(const char *name);
-extern int             dev_ioctl(unsigned int cmd, void __user *);
-extern int             dev_ethtool(struct ifreq *);
+extern int             dev_ioctl(struct net *net, unsigned int cmd, void __user *);
+extern int             dev_ethtool(struct net *net, struct ifreq *);
 extern unsigned                dev_get_flags(const struct net_device *);
 extern int             dev_change_flags(struct net_device *, unsigned);
 extern int             dev_change_name(struct net_device *, char *);
@@ -1327,7 +1331,7 @@ extern void               dev_set_allmulti(struct net_device *dev, int inc);
 extern void            netdev_state_change(struct net_device *dev);
 extern void            netdev_features_change(struct net_device *dev);
 /* Load a device via the kmod */
-extern void            dev_load(const char *name);
+extern void            dev_load(struct net *net, const char *name);
 extern void            dev_mcast_init(void);
 extern int             netdev_max_backlog;
 extern int             weight_p;
index 547247681345de3e86a217380cab8d7599d6a3f0..fac42db7f6d0772b8d2fbd3c93bb075a5b7f2577 100644 (file)
@@ -22,6 +22,10 @@ struct net {
        struct proc_dir_entry   *proc_net;
        struct proc_dir_entry   *proc_net_stat;
        struct proc_dir_entry   *proc_net_root;
+
+       struct list_head        dev_base_head;
+       struct hlist_head       *dev_name_head;
+       struct hlist_head       *dev_index_head;
 };
 
 extern struct net init_net;
index 7968b1d66369abd3a7efbbb1a732b4affc066987..f285de69c615edeb003eb3e3e5ca9746cdcb7fda 100644 (file)
@@ -2,6 +2,7 @@
 #define __NET_PKT_CLS_H
 
 #include <linux/pkt_cls.h>
+#include <net/net_namespace.h>
 #include <net/sch_generic.h>
 #include <net/act_api.h>
 
@@ -351,7 +352,7 @@ tcf_match_indev(struct sk_buff *skb, char *indev)
        if (indev[0]) {
                if  (!skb->iif)
                        return 0;
-               dev = __dev_get_by_index(skb->iif);
+               dev = __dev_get_by_index(&init_net, skb->iif);
                if (!dev || strcmp(indev, dev->name))
                        return 0;
        }
index 8218288ab7eec8697f4e4e2a9a492b28059d2f76..793863e09c69c8e35ea6a1f729f67763ce40b717 100644 (file)
@@ -78,7 +78,7 @@ extern void   __rtnl_link_unregister(struct rtnl_link_ops *ops);
 extern int     rtnl_link_register(struct rtnl_link_ops *ops);
 extern void    rtnl_link_unregister(struct rtnl_link_ops *ops);
 
-extern struct net_device *rtnl_create_link(char *ifname,
+extern struct net_device *rtnl_create_link(struct net *net, char *ifname,
                const struct rtnl_link_ops *ops, struct nlattr *tb[]);
 extern const struct nla_policy ifla_policy[IFLA_MAX+1];
 
index c02b8decf3af8324b104bfeb5f9593785ec2f321..80b31d826b7a8a3f3765bf0dc6fc569eefc930da 100644 (file)
@@ -5,16 +5,23 @@
  * wireless extensions interface to the core code
  */
 
+struct net;
+
 #ifdef CONFIG_WIRELESS_EXT
-extern int wext_proc_init(void);
-extern int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
+extern int wext_proc_init(struct net *net);
+extern void wext_proc_exit(struct net *net);
+extern int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
                             void __user *arg);
 #else
-static inline int wext_proc_init(void)
+static inline int wext_proc_init(struct net *net)
 {
        return 0;
 }
-static inline int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
+static inline void wext_proc_exit(struct net *net)
+{
+       return;
+}
+static inline int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
                                    void __user *arg)
 {
        return -EINVAL;
index 032c31e748eb3bc8f120fbb940cd7f544a114d55..55c76d77d3223e3ca6248916a86c6b2011916daa 100644 (file)
@@ -533,7 +533,7 @@ static int rif_seq_show(struct seq_file *seq, void *v)
                seq_puts(seq,
                     "if     TR address       TTL   rcf   routing segments\n");
        else {
-               struct net_device *dev = dev_get_by_index(entry->iface);
+               struct net_device *dev = dev_get_by_index(&init_net, entry->iface);
                long ttl = (long) (entry->last_used + sysctl_tr_rif_timeout)
                                - (long) jiffies;
 
index d0d36fdedbe988123e5458c5271351b98ba55498..a9ced0a6f4c083061cdd27f8b3f0a41b47756238 100644 (file)
@@ -51,7 +51,7 @@ static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
 static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
 
 static int vlan_device_event(struct notifier_block *, unsigned long, void *);
-static int vlan_ioctl_handler(void __user *);
+static int vlan_ioctl_handler(struct net *net, void __user *);
 static int unregister_vlan_dev(struct net_device *, unsigned short );
 
 static struct notifier_block vlan_notifier_block = {
@@ -697,7 +697,7 @@ out:
  *     o execute requested action or pass command to the device driver
  *   arg is really a struct vlan_ioctl_args __user *.
  */
-static int vlan_ioctl_handler(void __user *arg)
+static int vlan_ioctl_handler(struct net *net, void __user *arg)
 {
        int err;
        unsigned short vid = 0;
@@ -726,7 +726,7 @@ static int vlan_ioctl_handler(void __user *arg)
        case GET_VLAN_REALDEV_NAME_CMD:
        case GET_VLAN_VID_CMD:
                err = -ENODEV;
-               dev = __dev_get_by_name(args.device1);
+               dev = __dev_get_by_name(&init_net, args.device1);
                if (!dev)
                        goto out;
 
index 6cdd1e015e2d6f17dfaa419e1a7b49428d88cd91..0996185e2ed5dd816946df9fdcf10a1d4a1d4b13 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
+#include <net/net_namespace.h>
 #include <net/netlink.h>
 #include <net/rtnetlink.h>
 #include "vlan.h"
@@ -112,7 +113,7 @@ static int vlan_newlink(struct net_device *dev,
 
        if (!tb[IFLA_LINK])
                return -EINVAL;
-       real_dev = __dev_get_by_index(nla_get_u32(tb[IFLA_LINK]));
+       real_dev = __dev_get_by_index(&init_net, nla_get_u32(tb[IFLA_LINK]));
        if (!real_dev)
                return -ENODEV;
 
index ac80e6b9ef5351616cf119a31cfe4379fba22d9a..6cefdf8e381a3b40bf9d6d78c5535e25bab6f612 100644 (file)
@@ -254,7 +254,7 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (!is_vlan_dev(dev))
                        continue;
 
@@ -273,9 +273,9 @@ static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        dev = (struct net_device *)v;
        if (v == SEQ_START_TOKEN)
-               dev = net_device_entry(&dev_base_head);
+               dev = net_device_entry(&init_net.dev_base_head);
 
-       for_each_netdev_continue(dev) {
+       for_each_netdev_continue(&init_net, dev) {
                if (!is_vlan_dev(dev))
                        continue;
 
index 36fcdbf923c4362e457141a19fe9827b3abd333c..7c0b5151d5265408614fda8c25e489aff50c5b41 100644 (file)
@@ -677,7 +677,7 @@ static int atif_ioctl(int cmd, void __user *arg)
        if (copy_from_user(&atreq, arg, sizeof(atreq)))
                return -EFAULT;
 
-       dev = __dev_get_by_name(atreq.ifr_name);
+       dev = __dev_get_by_name(&init_net, atreq.ifr_name);
        if (!dev)
                return -ENODEV;
 
@@ -901,7 +901,7 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
                                if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1))
                                        return -EFAULT;
                                name[IFNAMSIZ-1] = '\0';
-                               dev = __dev_get_by_name(name);
+                               dev = __dev_get_by_name(&init_net, name);
                                if (!dev)
                                        return -ENODEV;
                        }
@@ -1273,7 +1273,7 @@ static __inline__ int is_ip_over_ddp(struct sk_buff *skb)
 
 static int handle_ip_over_ddp(struct sk_buff *skb)
 {
-       struct net_device *dev = __dev_get_by_name("ipddp0");
+       struct net_device *dev = __dev_get_by_name(&init_net, "ipddp0");
        struct net_device_stats *stats;
 
        /* This needs to be able to handle ipddp"N" devices */
index 0968430a7f58274dfb459737c0eb4db660e3d311..2086396de177557a71d9e1da1a7c52bf218ae359 100644 (file)
@@ -244,7 +244,7 @@ static struct net_device *find_lec_by_itfnum(int itf)
        char name[IFNAMSIZ];
 
        sprintf(name, "lec%d", itf);
-       dev = dev_get_by_name(name);
+       dev = dev_get_by_name(&init_net, name);
 
        return dev;
 }
index 8d13a8bca0e01128cd5a220d9c8f457254858435..993e5c75e90908c22c079f02ae5646f250fbfa8f 100644 (file)
@@ -631,7 +631,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
                        break;
                }
 
-               dev = dev_get_by_name(devname);
+               dev = dev_get_by_name(&init_net, devname);
                if (dev == NULL) {
                        res = -ENODEV;
                        break;
index 9272f12f664cfb6a4604e041652c824b30480abf..935784f736b3d0f88cff37c76140a5c22a167dd2 100644 (file)
@@ -303,7 +303,7 @@ int br_del_bridge(const char *name)
        int ret = 0;
 
        rtnl_lock();
-       dev = __dev_get_by_name(name);
+       dev = __dev_get_by_name(&init_net, name);
        if (dev == NULL)
                ret =  -ENXIO;  /* Could not find device */
 
@@ -444,7 +444,7 @@ void __exit br_cleanup_bridges(void)
        struct net_device *dev, *nxt;
 
        rtnl_lock();
-       for_each_netdev_safe(dev, nxt)
+       for_each_netdev_safe(&init_net, dev, nxt)
                if (dev->priv_flags & IFF_EBRIDGE)
                        del_br(dev->priv);
        rtnl_unlock();
index bb15e9e259b12e0bae720bf3fa7ff93ad2eb6afc..0655a5f07f58aeef86a3ef934949cffbda360e6e 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/if_bridge.h>
 #include <linux/netdevice.h>
 #include <linux/times.h>
+#include <net/net_namespace.h>
 #include <asm/uaccess.h>
 #include "br_private.h"
 
@@ -27,7 +28,7 @@ static int get_bridge_ifindices(int *indices, int num)
        struct net_device *dev;
        int i = 0;
 
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (i >= num)
                        break;
                if (dev->priv_flags & IFF_EBRIDGE)
@@ -90,7 +91,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
 
-       dev = dev_get_by_index(ifindex);
+       dev = dev_get_by_index(&init_net, ifindex);
        if (dev == NULL)
                return -EINVAL;
 
@@ -364,7 +365,7 @@ static int old_deviceless(void __user *uarg)
        return -EOPNOTSUPP;
 }
 
-int br_ioctl_deviceless_stub(unsigned int cmd, void __user *uarg)
+int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *uarg)
 {
        switch (cmd) {
        case SIOCGIFBR:
index 0fcf6f073064feb4c2d29753246fe93186782637..53ab8e0cb5189c40a880b92b9b49e9c9e0aad85e 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <net/rtnetlink.h>
+#include <net/net_namespace.h>
 #include "br_private.h"
 
 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)
        int idx;
 
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                /* not a bridge port */
                if (dev->br_port == NULL || idx < cb->args[0])
                        goto skip;
@@ -155,7 +156,7 @@ static int br_rtm_setlink(struct sk_buff *skb,  struct nlmsghdr *nlh, void *arg)
        if (new_state > BR_STATE_BLOCKING)
                return -EINVAL;
 
-       dev = __dev_get_by_index(ifm->ifi_index);
+       dev = __dev_get_by_index(&init_net, ifm->ifi_index);
        if (!dev)
                return -ENODEV;
 
index e6dc6f52990d1946d083ea7a254453a244b7306c..f666f7b28ff584d7222a9763c95288c6d63da11d 100644 (file)
@@ -192,7 +192,7 @@ extern struct sk_buff *br_handle_frame(struct net_bridge_port *p,
 
 /* br_ioctl.c */
 extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-extern int br_ioctl_deviceless_stub(unsigned int cmd, void __user *arg);
+extern int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *arg);
 
 /* br_netfilter.c */
 #ifdef CONFIG_BRIDGE_NETFILTER
index 40fd66fbe4e181de8433188286ae016b7f7ad40b..3a3d5ee739098b66f4a84ca0d708aff275a3b64a 100644 (file)
@@ -190,25 +190,22 @@ static struct net_dma net_dma = {
  * unregister_netdevice(), which must be called with the rtnl
  * semaphore held.
  */
-LIST_HEAD(dev_base_head);
 DEFINE_RWLOCK(dev_base_lock);
 
-EXPORT_SYMBOL(dev_base_head);
 EXPORT_SYMBOL(dev_base_lock);
 
 #define NETDEV_HASHBITS        8
-static struct hlist_head dev_name_head[1<<NETDEV_HASHBITS];
-static struct hlist_head dev_index_head[1<<NETDEV_HASHBITS];
+#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS)
 
-static inline struct hlist_head *dev_name_hash(const char *name)
+static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
 {
        unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ));
-       return &dev_name_head[hash & ((1<<NETDEV_HASHBITS)-1)];
+       return &net->dev_name_head[hash & ((1 << NETDEV_HASHBITS) - 1)];
 }
 
-static inline struct hlist_head *dev_index_hash(int ifindex)
+static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex)
 {
-       return &dev_index_head[ifindex & ((1<<NETDEV_HASHBITS)-1)];
+       return &net->dev_index_head[ifindex & ((1 << NETDEV_HASHBITS) - 1)];
 }
 
 /*
@@ -492,7 +489,7 @@ unsigned long netdev_boot_base(const char *prefix, int unit)
         * If device already registered then return base of 1
         * to indicate not to probe for this interface
         */
-       if (__dev_get_by_name(name))
+       if (__dev_get_by_name(&init_net, name))
                return 1;
 
        for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
@@ -547,11 +544,11 @@ __setup("netdev=", netdev_boot_setup);
  *     careful with locks.
  */
 
-struct net_device *__dev_get_by_name(const char *name)
+struct net_device *__dev_get_by_name(struct net *net, const char *name)
 {
        struct hlist_node *p;
 
-       hlist_for_each(p, dev_name_hash(name)) {
+       hlist_for_each(p, dev_name_hash(net, name)) {
                struct net_device *dev
                        = hlist_entry(p, struct net_device, name_hlist);
                if (!strncmp(dev->name, name, IFNAMSIZ))
@@ -571,12 +568,12 @@ struct net_device *__dev_get_by_name(const char *name)
  *     matching device is found.
  */
 
-struct net_device *dev_get_by_name(const char *name)
+struct net_device *dev_get_by_name(struct net *net, const char *name)
 {
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       dev = __dev_get_by_name(name);
+       dev = __dev_get_by_name(net, name);
        if (dev)
                dev_hold(dev);
        read_unlock(&dev_base_lock);
@@ -594,11 +591,11 @@ struct net_device *dev_get_by_name(const char *name)
  *     or @dev_base_lock.
  */
 
-struct net_device *__dev_get_by_index(int ifindex)
+struct net_device *__dev_get_by_index(struct net *net, int ifindex)
 {
        struct hlist_node *p;
 
-       hlist_for_each(p, dev_index_hash(ifindex)) {
+       hlist_for_each(p, dev_index_hash(net, ifindex)) {
                struct net_device *dev
                        = hlist_entry(p, struct net_device, index_hlist);
                if (dev->ifindex == ifindex)
@@ -618,12 +615,12 @@ struct net_device *__dev_get_by_index(int ifindex)
  *     dev_put to indicate they have finished with it.
  */
 
-struct net_device *dev_get_by_index(int ifindex)
+struct net_device *dev_get_by_index(struct net *net, int ifindex)
 {
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       dev = __dev_get_by_index(ifindex);
+       dev = __dev_get_by_index(net, ifindex);
        if (dev)
                dev_hold(dev);
        read_unlock(&dev_base_lock);
@@ -644,13 +641,13 @@ struct net_device *dev_get_by_index(int ifindex)
  *     If the API was consistent this would be __dev_get_by_hwaddr
  */
 
-struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
+struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *ha)
 {
        struct net_device *dev;
 
        ASSERT_RTNL();
 
-       for_each_netdev(dev)
+       for_each_netdev(&init_net, dev)
                if (dev->type == type &&
                    !memcmp(dev->dev_addr, ha, dev->addr_len))
                        return dev;
@@ -660,12 +657,12 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
 
 EXPORT_SYMBOL(dev_getbyhwaddr);
 
-struct net_device *__dev_getfirstbyhwtype(unsigned short type)
+struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type)
 {
        struct net_device *dev;
 
        ASSERT_RTNL();
-       for_each_netdev(dev)
+       for_each_netdev(net, dev)
                if (dev->type == type)
                        return dev;
 
@@ -674,12 +671,12 @@ struct net_device *__dev_getfirstbyhwtype(unsigned short type)
 
 EXPORT_SYMBOL(__dev_getfirstbyhwtype);
 
-struct net_device *dev_getfirstbyhwtype(unsigned short type)
+struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
 {
        struct net_device *dev;
 
        rtnl_lock();
-       dev = __dev_getfirstbyhwtype(type);
+       dev = __dev_getfirstbyhwtype(net, type);
        if (dev)
                dev_hold(dev);
        rtnl_unlock();
@@ -699,13 +696,13 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype);
  *     dev_put to indicate they have finished with it.
  */
 
-struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mask)
+struct net_device * dev_get_by_flags(struct net *net, unsigned short if_flags, unsigned short mask)
 {
        struct net_device *dev, *ret;
 
        ret = NULL;
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(net, dev) {
                if (((dev->flags ^ if_flags) & mask) == 0) {
                        dev_hold(dev);
                        ret = dev;
@@ -763,6 +760,10 @@ int dev_alloc_name(struct net_device *dev, const char *name)
        const int max_netdevices = 8*PAGE_SIZE;
        long *inuse;
        struct net_device *d;
+       struct net *net;
+
+       BUG_ON(!dev->nd_net);
+       net = dev->nd_net;
 
        p = strnchr(name, IFNAMSIZ-1, '%');
        if (p) {
@@ -779,7 +780,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
                if (!inuse)
                        return -ENOMEM;
 
-               for_each_netdev(d) {
+               for_each_netdev(net, d) {
                        if (!sscanf(d->name, name, &i))
                                continue;
                        if (i < 0 || i >= max_netdevices)
@@ -796,7 +797,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
        }
 
        snprintf(buf, sizeof(buf), name, i);
-       if (!__dev_get_by_name(buf)) {
+       if (!__dev_get_by_name(net, buf)) {
                strlcpy(dev->name, buf, IFNAMSIZ);
                return i;
        }
@@ -822,9 +823,12 @@ int dev_change_name(struct net_device *dev, char *newname)
        char oldname[IFNAMSIZ];
        int err = 0;
        int ret;
+       struct net *net;
 
        ASSERT_RTNL();
+       BUG_ON(!dev->nd_net);
 
+       net = dev->nd_net;
        if (dev->flags & IFF_UP)
                return -EBUSY;
 
@@ -839,7 +843,7 @@ int dev_change_name(struct net_device *dev, char *newname)
                        return err;
                strcpy(newname, dev->name);
        }
-       else if (__dev_get_by_name(newname))
+       else if (__dev_get_by_name(net, newname))
                return -EEXIST;
        else
                strlcpy(dev->name, newname, IFNAMSIZ);
@@ -849,7 +853,7 @@ rollback:
 
        write_lock_bh(&dev_base_lock);
        hlist_del(&dev->name_hlist);
-       hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
+       hlist_add_head(&dev->name_hlist, dev_name_hash(net, dev->name));
        write_unlock_bh(&dev_base_lock);
 
        ret = raw_notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev);
@@ -908,12 +912,12 @@ void netdev_state_change(struct net_device *dev)
  *     available in this kernel then it becomes a nop.
  */
 
-void dev_load(const char *name)
+void dev_load(struct net *net, const char *name)
 {
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       dev = __dev_get_by_name(name);
+       dev = __dev_get_by_name(net, name);
        read_unlock(&dev_base_lock);
 
        if (!dev && capable(CAP_SYS_MODULE))
@@ -1052,6 +1056,8 @@ int dev_close(struct net_device *dev)
 }
 
 
+static int dev_boot_phase = 1;
+
 /*
  *     Device change register/unregister. These are not inline or static
  *     as we export them to the world.
@@ -1075,23 +1081,27 @@ int register_netdevice_notifier(struct notifier_block *nb)
 {
        struct net_device *dev;
        struct net_device *last;
+       struct net *net;
        int err;
 
        rtnl_lock();
        err = raw_notifier_chain_register(&netdev_chain, nb);
        if (err)
                goto unlock;
+       if (dev_boot_phase)
+               goto unlock;
+       for_each_net(net) {
+               for_each_netdev(net, dev) {
+                       err = nb->notifier_call(nb, NETDEV_REGISTER, dev);
+                       err = notifier_to_errno(err);
+                       if (err)
+                               goto rollback;
+
+                       if (!(dev->flags & IFF_UP))
+                               continue;
 
-       for_each_netdev(dev) {
-               err = nb->notifier_call(nb, NETDEV_REGISTER, dev);
-               err = notifier_to_errno(err);
-               if (err)
-                       goto rollback;
-
-               if (!(dev->flags & IFF_UP))
-                       continue;
-
-               nb->notifier_call(nb, NETDEV_UP, dev);
+                       nb->notifier_call(nb, NETDEV_UP, dev);
+               }
        }
 
 unlock:
@@ -1100,15 +1110,17 @@ unlock:
 
 rollback:
        last = dev;
-       for_each_netdev(dev) {
-               if (dev == last)
-                       break;
+       for_each_net(net) {
+               for_each_netdev(net, dev) {
+                       if (dev == last)
+                               break;
 
-               if (dev->flags & IFF_UP) {
-                       nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
-                       nb->notifier_call(nb, NETDEV_DOWN, dev);
+                       if (dev->flags & IFF_UP) {
+                               nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
+                               nb->notifier_call(nb, NETDEV_DOWN, dev);
+                       }
+                       nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
                }
-               nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
        }
        goto unlock;
 }
@@ -2187,7 +2199,7 @@ int register_gifconf(unsigned int family, gifconf_func_t * gifconf)
  *     match.  --pb
  */
 
-static int dev_ifname(struct ifreq __user *arg)
+static int dev_ifname(struct net *net, struct ifreq __user *arg)
 {
        struct net_device *dev;
        struct ifreq ifr;
@@ -2200,7 +2212,7 @@ static int dev_ifname(struct ifreq __user *arg)
                return -EFAULT;
 
        read_lock(&dev_base_lock);
-       dev = __dev_get_by_index(ifr.ifr_ifindex);
+       dev = __dev_get_by_index(net, ifr.ifr_ifindex);
        if (!dev) {
                read_unlock(&dev_base_lock);
                return -ENODEV;
@@ -2220,7 +2232,7 @@ static int dev_ifname(struct ifreq __user *arg)
  *     Thus we will need a 'compatibility mode'.
  */
 
-static int dev_ifconf(char __user *arg)
+static int dev_ifconf(struct net *net, char __user *arg)
 {
        struct ifconf ifc;
        struct net_device *dev;
@@ -2244,7 +2256,7 @@ static int dev_ifconf(char __user *arg)
         */
 
        total = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(net, dev) {
                for (i = 0; i < NPROTO; i++) {
                        if (gifconf_list[i]) {
                                int done;
@@ -2278,6 +2290,7 @@ static int dev_ifconf(char __user *arg)
  */
 void *dev_seq_start(struct seq_file *seq, loff_t *pos)
 {
+       struct net *net = seq->private;
        loff_t off;
        struct net_device *dev;
 
@@ -2286,7 +2299,7 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos)
                return SEQ_START_TOKEN;
 
        off = 1;
-       for_each_netdev(dev)
+       for_each_netdev(net, dev)
                if (off++ == *pos)
                        return dev;
 
@@ -2295,9 +2308,10 @@ void *dev_seq_start(struct seq_file *seq, loff_t *pos)
 
 void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
+       struct net *net = seq->private;
        ++*pos;
        return v == SEQ_START_TOKEN ?
-               first_net_device() : next_net_device((struct net_device *)v);
+               first_net_device(net) : next_net_device((struct net_device *)v);
 }
 
 void dev_seq_stop(struct seq_file *seq, void *v)
@@ -2393,7 +2407,22 @@ static const struct seq_operations dev_seq_ops = {
 
 static int dev_seq_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &dev_seq_ops);
+       struct seq_file *seq;
+       int res;
+       res =  seq_open(file, &dev_seq_ops);
+       if (!res) {
+               seq = file->private_data;
+               seq->private = get_net(PROC_NET(inode));
+       }
+       return res;
+}
+
+static int dev_seq_release(struct inode *inode, struct file *file)
+{
+       struct seq_file *seq = file->private_data;
+       struct net *net = seq->private;
+       put_net(net);
+       return seq_release(inode, file);
 }
 
 static const struct file_operations dev_seq_fops = {
@@ -2401,7 +2430,7 @@ static const struct file_operations dev_seq_fops = {
        .open    = dev_seq_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
-       .release = seq_release,
+       .release = dev_seq_release,
 };
 
 static const struct seq_operations softnet_seq_ops = {
@@ -2553,30 +2582,49 @@ static const struct file_operations ptype_seq_fops = {
 };
 
 
-static int __init dev_proc_init(void)
+static int dev_proc_net_init(struct net *net)
 {
        int rc = -ENOMEM;
 
-       if (!proc_net_fops_create(&init_net, "dev", S_IRUGO, &dev_seq_fops))
+       if (!proc_net_fops_create(net, "dev", S_IRUGO, &dev_seq_fops))
                goto out;
-       if (!proc_net_fops_create(&init_net, "softnet_stat", S_IRUGO, &softnet_seq_fops))
+       if (!proc_net_fops_create(net, "softnet_stat", S_IRUGO, &softnet_seq_fops))
                goto out_dev;
-       if (!proc_net_fops_create(&init_net, "ptype", S_IRUGO, &ptype_seq_fops))
+       if (!proc_net_fops_create(net, "ptype", S_IRUGO, &ptype_seq_fops))
                goto out_softnet;
 
-       if (wext_proc_init())
+       if (wext_proc_init(net))
                goto out_ptype;
        rc = 0;
 out:
        return rc;
 out_ptype:
-       proc_net_remove(&init_net, "ptype");
+       proc_net_remove(net, "ptype");
 out_softnet:
-       proc_net_remove(&init_net, "softnet_stat");
+       proc_net_remove(net, "softnet_stat");
 out_dev:
-       proc_net_remove(&init_net, "dev");
+       proc_net_remove(net, "dev");
        goto out;
 }
+
+static void dev_proc_net_exit(struct net *net)
+{
+       wext_proc_exit(net);
+
+       proc_net_remove(net, "ptype");
+       proc_net_remove(net, "softnet_stat");
+       proc_net_remove(net, "dev");
+}
+
+static struct pernet_operations dev_proc_ops = {
+       .init = dev_proc_net_init,
+       .exit = dev_proc_net_exit,
+};
+
+static int __init dev_proc_init(void)
+{
+       return register_pernet_subsys(&dev_proc_ops);
+}
 #else
 #define dev_proc_init() 0
 #endif /* CONFIG_PROC_FS */
@@ -3011,10 +3059,10 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
 /*
  *     Perform the SIOCxIFxxx calls.
  */
-static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)
+static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
 {
        int err;
-       struct net_device *dev = __dev_get_by_name(ifr->ifr_name);
+       struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
 
        if (!dev)
                return -ENODEV;
@@ -3167,7 +3215,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)
  *     positive or a negative errno code on error.
  */
 
-int dev_ioctl(unsigned int cmd, void __user *arg)
+int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 {
        struct ifreq ifr;
        int ret;
@@ -3180,12 +3228,12 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
 
        if (cmd == SIOCGIFCONF) {
                rtnl_lock();
-               ret = dev_ifconf((char __user *) arg);
+               ret = dev_ifconf(net, (char __user *) arg);
                rtnl_unlock();
                return ret;
        }
        if (cmd == SIOCGIFNAME)
-               return dev_ifname((struct ifreq __user *)arg);
+               return dev_ifname(net, (struct ifreq __user *)arg);
 
        if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
                return -EFAULT;
@@ -3215,9 +3263,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                case SIOCGIFMAP:
                case SIOCGIFINDEX:
                case SIOCGIFTXQLEN:
-                       dev_load(ifr.ifr_name);
+                       dev_load(net, ifr.ifr_name);
                        read_lock(&dev_base_lock);
-                       ret = dev_ifsioc(&ifr, cmd);
+                       ret = dev_ifsioc(net, &ifr, cmd);
                        read_unlock(&dev_base_lock);
                        if (!ret) {
                                if (colon)
@@ -3229,9 +3277,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                        return ret;
 
                case SIOCETHTOOL:
-                       dev_load(ifr.ifr_name);
+                       dev_load(net, ifr.ifr_name);
                        rtnl_lock();
-                       ret = dev_ethtool(&ifr);
+                       ret = dev_ethtool(net, &ifr);
                        rtnl_unlock();
                        if (!ret) {
                                if (colon)
@@ -3253,9 +3301,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                case SIOCSIFNAME:
                        if (!capable(CAP_NET_ADMIN))
                                return -EPERM;
-                       dev_load(ifr.ifr_name);
+                       dev_load(net, ifr.ifr_name);
                        rtnl_lock();
-                       ret = dev_ifsioc(&ifr, cmd);
+                       ret = dev_ifsioc(net, &ifr, cmd);
                        rtnl_unlock();
                        if (!ret) {
                                if (colon)
@@ -3294,9 +3342,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                        /* fall through */
                case SIOCBONDSLAVEINFOQUERY:
                case SIOCBONDINFOQUERY:
-                       dev_load(ifr.ifr_name);
+                       dev_load(net, ifr.ifr_name);
                        rtnl_lock();
-                       ret = dev_ifsioc(&ifr, cmd);
+                       ret = dev_ifsioc(net, &ifr, cmd);
                        rtnl_unlock();
                        return ret;
 
@@ -3316,9 +3364,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                        if (cmd == SIOCWANDEV ||
                            (cmd >= SIOCDEVPRIVATE &&
                             cmd <= SIOCDEVPRIVATE + 15)) {
-                               dev_load(ifr.ifr_name);
+                               dev_load(net, ifr.ifr_name);
                                rtnl_lock();
-                               ret = dev_ifsioc(&ifr, cmd);
+                               ret = dev_ifsioc(net, &ifr, cmd);
                                rtnl_unlock();
                                if (!ret && copy_to_user(arg, &ifr,
                                                         sizeof(struct ifreq)))
@@ -3327,7 +3375,7 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
                        }
                        /* Take care of Wireless Extensions */
                        if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
-                               return wext_handle_ioctl(&ifr, cmd, arg);
+                               return wext_handle_ioctl(net, &ifr, cmd, arg);
                        return -EINVAL;
        }
 }
@@ -3340,19 +3388,17 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
  *     number.  The caller must hold the rtnl semaphore or the
  *     dev_base_lock to be sure it remains unique.
  */
-static int dev_new_index(void)
+static int dev_new_index(struct net *net)
 {
        static int ifindex;
        for (;;) {
                if (++ifindex <= 0)
                        ifindex = 1;
-               if (!__dev_get_by_index(ifindex))
+               if (!__dev_get_by_index(net, ifindex))
                        return ifindex;
        }
 }
 
-static int dev_boot_phase = 1;
-
 /* Delayed registration/unregisteration */
 static DEFINE_SPINLOCK(net_todo_list_lock);
 static struct list_head net_todo_list = LIST_HEAD_INIT(net_todo_list);
@@ -3386,6 +3432,7 @@ int register_netdevice(struct net_device *dev)
        struct hlist_head *head;
        struct hlist_node *p;
        int ret;
+       struct net *net;
 
        BUG_ON(dev_boot_phase);
        ASSERT_RTNL();
@@ -3394,6 +3441,8 @@ int register_netdevice(struct net_device *dev)
 
        /* When net_device's are persistent, this will be fatal. */
        BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
+       BUG_ON(!dev->nd_net);
+       net = dev->nd_net;
 
        spin_lock_init(&dev->queue_lock);
        spin_lock_init(&dev->_xmit_lock);
@@ -3418,12 +3467,12 @@ int register_netdevice(struct net_device *dev)
                goto err_uninit;
        }
 
-       dev->ifindex = dev_new_index();
+       dev->ifindex = dev_new_index(net);
        if (dev->iflink == -1)
                dev->iflink = dev->ifindex;
 
        /* Check for existence of name */
-       head = dev_name_hash(dev->name);
+       head = dev_name_hash(net, dev->name);
        hlist_for_each(p, head) {
                struct net_device *d
                        = hlist_entry(p, struct net_device, name_hlist);
@@ -3501,9 +3550,9 @@ int register_netdevice(struct net_device *dev)
 
        dev_init_scheduler(dev);
        write_lock_bh(&dev_base_lock);
-       list_add_tail(&dev->dev_list, &dev_base_head);
+       list_add_tail(&dev->dev_list, &net->dev_base_head);
        hlist_add_head(&dev->name_hlist, head);
-       hlist_add_head(&dev->index_hlist, dev_index_hash(dev->ifindex));
+       hlist_add_head(&dev->index_hlist, dev_index_hash(net, dev->ifindex));
        dev_hold(dev);
        write_unlock_bh(&dev_base_lock);
 
@@ -4067,6 +4116,45 @@ int netdev_compute_features(unsigned long all, unsigned long one)
 }
 EXPORT_SYMBOL(netdev_compute_features);
 
+/* Initialize per network namespace state */
+static int netdev_init(struct net *net)
+{
+       int i;
+       INIT_LIST_HEAD(&net->dev_base_head);
+       rwlock_init(&dev_base_lock);
+
+       net->dev_name_head = kmalloc(
+               sizeof(*net->dev_name_head)*NETDEV_HASHENTRIES, GFP_KERNEL);
+       if (!net->dev_name_head)
+               return -ENOMEM;
+
+       net->dev_index_head = kmalloc(
+               sizeof(*net->dev_index_head)*NETDEV_HASHENTRIES, GFP_KERNEL);
+       if (!net->dev_index_head) {
+               kfree(net->dev_name_head);
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < NETDEV_HASHENTRIES; i++)
+               INIT_HLIST_HEAD(&net->dev_name_head[i]);
+
+       for (i = 0; i < NETDEV_HASHENTRIES; i++)
+               INIT_HLIST_HEAD(&net->dev_index_head[i]);
+
+       return 0;
+}
+
+static void netdev_exit(struct net *net)
+{
+       kfree(net->dev_name_head);
+       kfree(net->dev_index_head);
+}
+
+static struct pernet_operations netdev_net_ops = {
+       .init = netdev_init,
+       .exit = netdev_exit,
+};
+
 /*
  *     Initialize the DEV module. At boot time this walks the device list and
  *     unhooks any devices that fail to initialise (normally hardware not
@@ -4094,11 +4182,8 @@ static int __init net_dev_init(void)
        for (i = 0; i < 16; i++)
                INIT_LIST_HEAD(&ptype_base[i]);
 
-       for (i = 0; i < ARRAY_SIZE(dev_name_head); i++)
-               INIT_HLIST_HEAD(&dev_name_head[i]);
-
-       for (i = 0; i < ARRAY_SIZE(dev_index_head); i++)
-               INIT_HLIST_HEAD(&dev_index_head[i]);
+       if (register_pernet_subsys(&netdev_net_ops))
+               goto out;
 
        /*
         *      Initialise the packet receive queues.
index 8e069fc207cb9c5151df7f80f4979a94d6682559..1c4f6198459b80ea4cc5ef699fc1861aacc2b13e 100644 (file)
@@ -187,11 +187,12 @@ EXPORT_SYMBOL(dev_mc_unsync);
 #ifdef CONFIG_PROC_FS
 static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
 {
+       struct net *net = seq->private;
        struct net_device *dev;
        loff_t off = 0;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(net, dev) {
                if (off++ == *pos)
                        return dev;
        }
@@ -240,7 +241,22 @@ static const struct seq_operations dev_mc_seq_ops = {
 
 static int dev_mc_seq_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &dev_mc_seq_ops);
+       struct seq_file *seq;
+       int res;
+       res = seq_open(file, &dev_mc_seq_ops);
+       if (!res) {
+               seq = file->private_data;
+               seq->private = get_net(PROC_NET(inode));
+       }
+       return res;
+}
+
+static int dev_mc_seq_release(struct inode *inode, struct file *file)
+{
+       struct seq_file *seq = file->private_data;
+       struct net *net = seq->private;
+       put_net(net);
+       return seq_release(inode, file);
 }
 
 static const struct file_operations dev_mc_seq_fops = {
@@ -248,14 +264,31 @@ static const struct file_operations dev_mc_seq_fops = {
        .open    = dev_mc_seq_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
-       .release = seq_release,
+       .release = dev_mc_seq_release,
 };
 
 #endif
 
+static int dev_mc_net_init(struct net *net)
+{
+       if (!proc_net_fops_create(net, "dev_mcast", 0, &dev_mc_seq_fops))
+               return -ENOMEM;
+       return 0;
+}
+
+static void dev_mc_net_exit(struct net *net)
+{
+       proc_net_remove(net, "dev_mcast");
+}
+
+static struct pernet_operations dev_mc_net_ops = {
+       .init = dev_mc_net_init,
+       .exit = dev_mc_net_exit,
+};
+
 void __init dev_mcast_init(void)
 {
-       proc_net_fops_create(&init_net, "dev_mcast", 0, &dev_mc_seq_fops);
+       register_pernet_subsys(&dev_mc_net_ops);
 }
 
 EXPORT_SYMBOL(dev_mc_add);
index 7c43f032a7f9dae05a1b08f08d0a75077afe54ed..0d0b13cc1dd361e88b42ddd009868db9a006fd37 100644 (file)
@@ -779,9 +779,9 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
 
 /* The main entry point in this file.  Called from net/core/dev.c */
 
-int dev_ethtool(struct ifreq *ifr)
+int dev_ethtool(struct net *net, struct ifreq *ifr)
 {
-       struct net_device *dev = __dev_get_by_name(ifr->ifr_name);
+       struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
        void __user *useraddr = ifr->ifr_data;
        u32 ethcmd;
        int rc;
index 9eabe1ae01dc3ca147487558ce322ef4dc028129..1ba71baf87ef1a96754cd26e02f978d8e3378cb1 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <net/net_namespace.h>
+#include <net/sock.h>
 #include <net/fib_rules.h>
 
 static LIST_HEAD(rules_ops);
@@ -198,6 +199,7 @@ errout:
 
 static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct fib_rule_hdr *frh = nlmsg_data(nlh);
        struct fib_rules_ops *ops = NULL;
        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)
 
                rule->ifindex = -1;
                nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ);
-               dev = __dev_get_by_name(rule->ifname);
+               dev = __dev_get_by_name(net, rule->ifname);
                if (dev)
                        rule->ifindex = dev->ifindex;
        }
index 5f25f4f79b8ceff86be9bce0013d9cc31515acb6..2c6577c1eedd7947dbb5d0ae147dc759eba02710 100644 (file)
@@ -1441,6 +1441,7 @@ int neigh_table_clear(struct neigh_table *tbl)
 
 static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ndmsg *ndm;
        struct nlattr *dst_attr;
        struct neigh_table *tbl;
@@ -1456,7 +1457,7 @@ static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 
        ndm = nlmsg_data(nlh);
        if (ndm->ndm_ifindex) {
-               dev = dev_get_by_index(ndm->ndm_ifindex);
+               dev = dev_get_by_index(net, ndm->ndm_ifindex);
                if (dev == NULL) {
                        err = -ENODEV;
                        goto out;
@@ -1506,6 +1507,7 @@ out:
 
 static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ndmsg *ndm;
        struct nlattr *tb[NDA_MAX+1];
        struct neigh_table *tbl;
@@ -1522,7 +1524,7 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 
        ndm = nlmsg_data(nlh);
        if (ndm->ndm_ifindex) {
-               dev = dev_get_by_index(ndm->ndm_ifindex);
+               dev = dev_get_by_index(net, ndm->ndm_ifindex);
                if (dev == NULL) {
                        err = -ENODEV;
                        goto out;
index 0952f936b29283134fcd356ff52dd6acfbe24672..bb7523a5b4084145818d07a5929830393b8d1a4a 100644 (file)
@@ -653,7 +653,7 @@ int netpoll_setup(struct netpoll *np)
        int err;
 
        if (np->dev_name)
-               ndev = dev_get_by_name(np->dev_name);
+               ndev = dev_get_by_name(&init_net, np->dev_name);
        if (!ndev) {
                printk(KERN_ERR "%s: %s doesn't exist, aborting.\n",
                       np->name, np->dev_name);
index d7c30ce095a18ea02077495d6dd928975ec77b9e..94e42be16daaa00e24da84c786c00ffc3e751708 100644 (file)
@@ -2008,7 +2008,7 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname)
                pkt_dev->odev = NULL;
        }
 
-       odev = dev_get_by_name(ifname);
+       odev = dev_get_by_name(&init_net, ifname);
        if (!odev) {
                printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname);
                return -ENODEV;
index 416768d1e0cdc0cd890a4e46ae30769c2540a849..44f91bb1ae8d41f7adfcc180c97565af7949a1f7 100644 (file)
@@ -306,10 +306,13 @@ EXPORT_SYMBOL_GPL(rtnl_link_register);
 void __rtnl_link_unregister(struct rtnl_link_ops *ops)
 {
        struct net_device *dev, *n;
+       struct net *net;
 
-       for_each_netdev_safe(dev, n) {
-               if (dev->rtnl_link_ops == ops)
-                       ops->dellink(dev);
+       for_each_net(net) {
+               for_each_netdev_safe(net, dev, n) {
+                       if (dev->rtnl_link_ops == ops)
+                               ops->dellink(dev);
+               }
        }
        list_del(&ops->list);
 }
@@ -693,12 +696,13 @@ nla_put_failure:
 
 static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        int idx;
        int s_idx = cb->args[0];
        struct net_device *dev;
 
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(net, dev) {
                if (idx < s_idx)
                        goto cont;
                if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
@@ -858,6 +862,7 @@ errout:
 
 static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ifinfomsg *ifm;
        struct net_device *dev;
        int err;
@@ -876,9 +881,9 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
        err = -EINVAL;
        ifm = nlmsg_data(nlh);
        if (ifm->ifi_index > 0)
-               dev = dev_get_by_index(ifm->ifi_index);
+               dev = dev_get_by_index(net, ifm->ifi_index);
        else if (tb[IFLA_IFNAME])
-               dev = dev_get_by_name(ifname);
+               dev = dev_get_by_name(net, ifname);
        else
                goto errout;
 
@@ -904,6 +909,7 @@ errout:
 
 static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        const struct rtnl_link_ops *ops;
        struct net_device *dev;
        struct ifinfomsg *ifm;
@@ -920,9 +926,9 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 
        ifm = nlmsg_data(nlh);
        if (ifm->ifi_index > 0)
-               dev = __dev_get_by_index(ifm->ifi_index);
+               dev = __dev_get_by_index(net, ifm->ifi_index);
        else if (tb[IFLA_IFNAME])
-               dev = __dev_get_by_name(ifname);
+               dev = __dev_get_by_name(net, ifname);
        else
                return -EINVAL;
 
@@ -937,7 +943,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
        return 0;
 }
 
-struct net_device *rtnl_create_link(char *ifname,
+struct net_device *rtnl_create_link(struct net *net, char *ifname,
                const struct rtnl_link_ops *ops, struct nlattr *tb[])
 {
        int err;
@@ -954,6 +960,7 @@ struct net_device *rtnl_create_link(char *ifname,
                        goto err_free;
        }
 
+       dev->nd_net = net;
        dev->rtnl_link_ops = ops;
 
        if (tb[IFLA_MTU])
@@ -981,6 +988,7 @@ err:
 
 static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        const struct rtnl_link_ops *ops;
        struct net_device *dev;
        struct ifinfomsg *ifm;
@@ -1004,9 +1012,9 @@ replay:
 
        ifm = nlmsg_data(nlh);
        if (ifm->ifi_index > 0)
-               dev = __dev_get_by_index(ifm->ifi_index);
+               dev = __dev_get_by_index(net, ifm->ifi_index);
        else if (ifname[0])
-               dev = __dev_get_by_name(ifname);
+               dev = __dev_get_by_name(net, ifname);
        else
                dev = NULL;
 
@@ -1092,7 +1100,7 @@ replay:
                if (!ifname[0])
                        snprintf(ifname, IFNAMSIZ, "%s%%d", ops->kind);
 
-               dev = rtnl_create_link(ifname, ops, tb);
+               dev = rtnl_create_link(net, ifname, ops, tb);
 
                if (IS_ERR(dev))
                        err = PTR_ERR(dev);
@@ -1109,6 +1117,7 @@ replay:
 
 static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ifinfomsg *ifm;
        struct nlattr *tb[IFLA_MAX+1];
        struct net_device *dev = NULL;
@@ -1121,7 +1130,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 
        ifm = nlmsg_data(nlh);
        if (ifm->ifi_index > 0) {
-               dev = dev_get_by_index(ifm->ifi_index);
+               dev = dev_get_by_index(net, ifm->ifi_index);
                if (dev == NULL)
                        return -ENODEV;
        } else
index a31455dc702485b62f846dec01510d29d500ec7d..4ed9b507c1e78d519488088e0285785ad1460f9b 100644 (file)
@@ -367,6 +367,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
 {
        int ret = -ENOPROTOOPT;
 #ifdef CONFIG_NETDEVICES
+       struct net *net = sk->sk_net;
        char devname[IFNAMSIZ];
        int index;
 
@@ -395,7 +396,7 @@ static int sock_bindtodevice(struct sock *sk, char __user *optval, int optlen)
        if (devname[0] == '\0') {
                index = 0;
        } else {
-               struct net_device *dev = dev_get_by_name(devname);
+               struct net_device *dev = dev_get_by_name(net, devname);
 
                ret = -ENODEV;
                if (!dev)
index 83398da5d7636bd1455ac464f788c4efd3860a45..aabe98d9402f492bac411e111da9a0cc66a011f8 100644 (file)
@@ -751,7 +751,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                if (dn_ntohs(saddr->sdn_nodeaddrl)) {
                        read_lock(&dev_base_lock);
                        ldev = NULL;
-                       for_each_netdev(dev) {
+                       for_each_netdev(&init_net, dev) {
                                if (!dev->dn_ptr)
                                        continue;
                                if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) {
index 83cb0761336a723acc59253e3c03d2b848cedc1b..ddfd2aff44d8c06d36a252734364de8fc29f428f 100644 (file)
@@ -513,7 +513,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
        ifr->ifr_name[IFNAMSIZ-1] = 0;
 
 #ifdef CONFIG_KMOD
-       dev_load(ifr->ifr_name);
+       dev_load(&init_net, ifr->ifr_name);
 #endif
 
        switch(cmd) {
@@ -531,7 +531,7 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg)
 
        rtnl_lock();
 
-       if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL) {
+       if ((dev = __dev_get_by_name(&init_net, ifr->ifr_name)) == NULL) {
                ret = -ENODEV;
                goto done;
        }
@@ -629,7 +629,7 @@ static struct dn_dev *dn_dev_by_index(int ifindex)
 {
        struct net_device *dev;
        struct dn_dev *dn_dev = NULL;
-       dev = dev_get_by_index(ifindex);
+       dev = dev_get_by_index(&init_net, ifindex);
        if (dev) {
                dn_dev = dev->dn_ptr;
                dev_put(dev);
@@ -694,7 +694,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
                return -EINVAL;
 
        ifm = nlmsg_data(nlh);
-       if ((dev = __dev_get_by_index(ifm->ifa_index)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, ifm->ifa_index)) == NULL)
                return -ENODEV;
 
        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)
        skip_naddr = cb->args[1];
 
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < skip_ndevs)
                        goto cont;
                else if (idx > skip_ndevs) {
@@ -1297,7 +1297,7 @@ void dn_dev_devices_off(void)
        struct net_device *dev;
 
        rtnl_lock();
-       for_each_netdev(dev)
+       for_each_netdev(&init_net, dev)
                dn_dev_down(dev);
        rtnl_unlock();
 
@@ -1308,7 +1308,7 @@ void dn_dev_devices_on(void)
        struct net_device *dev;
 
        rtnl_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (dev->flags & IFF_UP)
                        dn_dev_up(dev);
        }
@@ -1342,7 +1342,7 @@ static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
                return SEQ_START_TOKEN;
 
        i = 1;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (!is_dn_dev(dev))
                        continue;
 
@@ -1361,9 +1361,9 @@ static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 
        dev = (struct net_device *)v;
        if (v == SEQ_START_TOKEN)
-               dev = net_device_entry(&dev_base_head);
+               dev = net_device_entry(&init_net.dev_base_head);
 
-       for_each_netdev_continue(dev) {
+       for_each_netdev_continue(&init_net, dev) {
                if (!is_dn_dev(dev))
                        continue;
 
index d2bc19d479506de64ca4bf9a9da803a1ea8586d6..3760a20d10d08b661d5b881164ab1b14cd2f20c5 100644 (file)
@@ -212,7 +212,7 @@ static int dn_fib_check_nh(const struct rtmsg *r, struct dn_fib_info *fi, struct
                                return -EINVAL;
                        if (dnet_addr_type(nh->nh_gw) != RTN_UNICAST)
                                return -EINVAL;
-                       if ((dev = __dev_get_by_index(nh->nh_oif)) == NULL)
+                       if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL)
                                return -ENODEV;
                        if (!(dev->flags&IFF_UP))
                                return -ENETDOWN;
@@ -255,7 +255,7 @@ out:
                if (nh->nh_flags&(RTNH_F_PERVASIVE|RTNH_F_ONLINK))
                        return -EINVAL;
 
-               dev = __dev_get_by_index(nh->nh_oif);
+               dev = __dev_get_by_index(&init_net, nh->nh_oif);
                if (dev == NULL || dev->dn_ptr == NULL)
                        return -ENODEV;
                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
                if (nhs != 1 || nh->nh_gw)
                        goto err_inval;
                nh->nh_scope = RT_SCOPE_NOWHERE;
-               nh->nh_dev = dev_get_by_index(fi->fib_nh->nh_oif);
+               nh->nh_dev = dev_get_by_index(&init_net, fi->fib_nh->nh_oif);
                err = -ENODEV;
                if (nh->nh_dev == NULL)
                        goto failure;
@@ -602,7 +602,7 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
 
        /* Scan device list */
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                dn_db = dev->dn_ptr;
                if (dn_db == NULL)
                        continue;
index 580e786d0c3862ccc6fea2e0d25c47f5646aa7f4..70b1c3fa00f3793c44ea54bff14278b5cee96998 100644 (file)
@@ -908,7 +908,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
 
        /* If we have an output interface, verify its a DECnet device */
        if (oldflp->oif) {
-               dev_out = dev_get_by_index(oldflp->oif);
+               dev_out = dev_get_by_index(&init_net, oldflp->oif);
                err = -ENODEV;
                if (dev_out && dev_out->dn_ptr == NULL) {
                        dev_put(dev_out);
@@ -929,7 +929,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
                        goto out;
                }
                read_lock(&dev_base_lock);
-               for_each_netdev(dev) {
+               for_each_netdev(&init_net, dev) {
                        if (!dev->dn_ptr)
                                continue;
                        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
 
        if (fl.iif) {
                struct net_device *dev;
-               if ((dev = dev_get_by_index(fl.iif)) == NULL) {
+               if ((dev = dev_get_by_index(&init_net, fl.iif)) == NULL) {
                        kfree_skb(skb);
                        return -ENODEV;
                }
index 52e40d7eb22d9f583c045175ae1d64aa4dde2e16..ae354a43fb97af91d7f8c0250585051e0aa2b186 100644 (file)
@@ -259,7 +259,7 @@ static int dn_def_dev_strategy(ctl_table *table, int __user *name, int nlen,
 
                devname[newlen] = 0;
 
-               dev = dev_get_by_name(devname);
+               dev = dev_get_by_name(&init_net, devname);
                if (dev == NULL)
                        return -ENODEV;
 
@@ -299,7 +299,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
                devname[*lenp] = 0;
                strip_it(devname);
 
-               dev = dev_get_by_name(devname);
+               dev = dev_get_by_name(&init_net, devname);
                if (dev == NULL)
                        return -ENODEV;
 
index f877f3b5c72529d635c277f3f04055545fbb0690..9938e76a8ff62a6f9854e61a169ea63fb316dd34 100644 (file)
@@ -662,7 +662,7 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg)
        if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
                return -EFAULT;
 
-       if ((dev = dev_get_by_name(ifr.ifr_name)) == NULL)
+       if ((dev = dev_get_by_name(&init_net, ifr.ifr_name)) == NULL)
                return -ENODEV;
 
        sec = (struct sockaddr_ec *)&ifr.ifr_addr;
index a11e7a5c1da4312ccebb28adf4e4f4cf93532394..3a683006d761ea10d64ca2d926b5b3c122b5f315 100644 (file)
@@ -981,7 +981,7 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev)
                if (mask && mask != htonl(0xFFFFFFFF))
                        return -EINVAL;
                if (!dev && (r->arp_flags & ATF_COM)) {
-                       dev = dev_getbyhwaddr(r->arp_ha.sa_family, r->arp_ha.sa_data);
+                       dev = dev_getbyhwaddr(&init_net, r->arp_ha.sa_family, r->arp_ha.sa_data);
                        if (!dev)
                                return -ENODEV;
                }
@@ -1169,7 +1169,7 @@ int arp_ioctl(unsigned int cmd, void __user *arg)
        rtnl_lock();
        if (r.arp_dev[0]) {
                err = -ENODEV;
-               if ((dev = __dev_get_by_name(r.arp_dev)) == NULL)
+               if ((dev = __dev_get_by_name(&init_net, r.arp_dev)) == NULL)
                        goto out;
 
                /* Mmmm... It is wrong... ARPHRD_NETROM==0 */
index c5eb1a29a5cfbbf1a3e9183fe46511890f549637..721b89b609631d144de02285c8397465b30c04ee 100644 (file)
@@ -420,7 +420,7 @@ struct in_device *inetdev_by_index(int ifindex)
        struct net_device *dev;
        struct in_device *in_dev = NULL;
        read_lock(&dev_base_lock);
-       dev = __dev_get_by_index(ifindex);
+       dev = __dev_get_by_index(&init_net, ifindex);
        if (dev)
                in_dev = in_dev_get(dev);
        read_unlock(&dev_base_lock);
@@ -506,7 +506,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh)
                goto errout;
        }
 
-       dev = __dev_get_by_index(ifm->ifa_index);
+       dev = __dev_get_by_index(&init_net, ifm->ifa_index);
        if (dev == NULL) {
                err = -ENODEV;
                goto errout;
@@ -628,7 +628,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
                *colon = 0;
 
 #ifdef CONFIG_KMOD
-       dev_load(ifr.ifr_name);
+       dev_load(&init_net, ifr.ifr_name);
 #endif
 
        switch (cmd) {
@@ -669,7 +669,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
        rtnl_lock();
 
        ret = -ENODEV;
-       if ((dev = __dev_get_by_name(ifr.ifr_name)) == NULL)
+       if ((dev = __dev_get_by_name(&init_net, ifr.ifr_name)) == NULL)
                goto done;
 
        if (colon)
@@ -909,7 +909,7 @@ no_in_dev:
         */
        read_lock(&dev_base_lock);
        rcu_read_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
                        continue;
 
@@ -988,7 +988,7 @@ __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local,
 
        read_lock(&dev_base_lock);
        rcu_read_lock();
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((in_dev = __in_dev_get_rcu(dev))) {
                        addr = confirm_addr_indev(in_dev, dst, local, scope);
                        if (addr)
@@ -1185,7 +1185,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 
        s_ip_idx = ip_idx = cb->args[1];
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < s_idx)
                        goto cont;
                if (idx > s_idx)
@@ -1244,7 +1244,7 @@ static void devinet_copy_dflt_conf(int i)
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                struct in_device *in_dev;
                rcu_read_lock();
                in_dev = __in_dev_get_rcu(dev);
@@ -1333,7 +1333,7 @@ void inet_forward_change(void)
        IPV4_DEVCONF_DFLT(FORWARDING) = on;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                struct in_device *in_dev;
                rcu_read_lock();
                in_dev = __in_dev_get_rcu(dev);
index 140bf7a8d8770c2bedd1bac0a23e4cc475d1950d..df17aab193b491d8f53eec28ca7d3de5883d5235 100644 (file)
@@ -334,7 +334,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
                colon = strchr(devname, ':');
                if (colon)
                        *colon = 0;
-               dev = __dev_get_by_name(devname);
+               dev = __dev_get_by_name(&init_net, devname);
                if (!dev)
                        return -ENODEV;
                cfg->fc_oif = dev->ifindex;
index c434119deb527d8e1754dbbdc9b81cb08987e8f7..d30fb68d5f4e88007256638750b10b46ae73f316 100644 (file)
@@ -533,7 +533,7 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
                                return -EINVAL;
                        if (inet_addr_type(nh->nh_gw) != RTN_UNICAST)
                                return -EINVAL;
-                       if ((dev = __dev_get_by_index(nh->nh_oif)) == NULL)
+                       if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL)
                                return -ENODEV;
                        if (!(dev->flags&IFF_UP))
                                return -ENETDOWN;
@@ -799,7 +799,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
                if (nhs != 1 || nh->nh_gw)
                        goto err_inval;
                nh->nh_scope = RT_SCOPE_NOWHERE;
-               nh->nh_dev = dev_get_by_index(fi->fib_nh->nh_oif);
+               nh->nh_dev = dev_get_by_index(&init_net, fi->fib_nh->nh_oif);
                err = -ENODEV;
                if (nh->nh_dev == NULL)
                        goto failure;
index 02a899bec1969fcb6511722d41fe20009b6f2dbc..68a22670f5978cc0d15d7c1473ae9a3e7509ef8d 100644 (file)
@@ -517,7 +517,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
                struct net_device *dev = NULL;
 
                if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr)
-                       dev = dev_get_by_index(rt->fl.iif);
+                       dev = dev_get_by_index(&init_net, rt->fl.iif);
 
                if (dev) {
                        saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK);
index d78599a9dbd5a2ebdeee1a2429cd2b243d341680..ad500a43b3592aa76562e822f8a3b80d40176fc3 100644 (file)
@@ -2292,7 +2292,7 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
        struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
 
        state->in_dev = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct in_device *in_dev;
                in_dev = in_dev_get(state->dev);
                if (!in_dev)
@@ -2454,7 +2454,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
 
        state->idev = NULL;
        state->im = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct in_device *idev;
                idev = in_dev_get(state->dev);
                if (unlikely(idev == NULL))
index 0231bdcb2ab7620b55c1aaeda45d256c5a0de2ef..fabb86db763b01efb6fde8d29178420e275f9dd7 100644 (file)
@@ -292,7 +292,7 @@ static void ip_expire(unsigned long arg)
        if ((qp->last_in&FIRST_IN) && qp->fragments != NULL) {
                struct sk_buff *head = qp->fragments;
                /* Send an ICMP "Fragment Reassembly Timeout" message. */
-               if ((head->dev = dev_get_by_index(qp->iif)) != NULL) {
+               if ((head->dev = dev_get_by_index(&init_net, qp->iif)) != NULL) {
                        icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0);
                        dev_put(head->dev);
                }
index 5c14ed63e56c97c8b53f188fd0bfd6997a3e8f8c..3106225c5e50a858cbc52729e34db09149479e91 100644 (file)
@@ -262,7 +262,7 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
                int i;
                for (i=1; i<100; i++) {
                        sprintf(name, "gre%d", i);
-                       if (__dev_get_by_name(name) == NULL)
+                       if (__dev_get_by_name(&init_net, name) == NULL)
                                break;
                }
                if (i==100)
@@ -1196,7 +1196,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
        }
 
        if (!tdev && tunnel->parms.link)
-               tdev = __dev_get_by_index(tunnel->parms.link);
+               tdev = __dev_get_by_index(&init_net, tunnel->parms.link);
 
        if (tdev) {
                hlen = tdev->hard_header_len;
index 6b420aedcdcf55a5578eed3a07c4f54f4ffdb7fd..b2b3053dfef75ebb214e7f2b111cc3b6eb54631a 100644 (file)
@@ -602,7 +602,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                                dev_put(dev);
                        }
                } else
-                       dev = __dev_get_by_index(mreq.imr_ifindex);
+                       dev = __dev_get_by_index(&init_net, mreq.imr_ifindex);
 
 
                err = -EADDRNOTAVAIL;
index 08ff623371f08252d24d261a55275794267fa948..4303851749f6a5642f674040df86765910921cba 100644 (file)
@@ -193,7 +193,7 @@ static int __init ic_open_devs(void)
        if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
                printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
 
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (dev == &loopback_dev)
                        continue;
                if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
index 396437242a1b36186db17ff5aaa1bf5d60a1734b..652bd86e33a38cf1ea689e127d8fb9138e1dcdc4 100644 (file)
@@ -225,7 +225,7 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
                int i;
                for (i=1; i<100; i++) {
                        sprintf(name, "tunl%d", i);
-                       if (__dev_get_by_name(name) == NULL)
+                       if (__dev_get_by_name(&init_net, name) == NULL)
                                break;
                }
                if (i==100)
@@ -822,7 +822,7 @@ static int ipip_tunnel_init(struct net_device *dev)
        }
 
        if (!tdev && tunnel->parms.link)
-               tdev = __dev_get_by_index(tunnel->parms.link);
+               tdev = __dev_get_by_index(&init_net, tunnel->parms.link);
 
        if (tdev) {
                dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr);
index 036598835c636ee6de233cbc09f235ea3f4ebe53..b8b4b497fb57309a3321960dd5d913542ed3e3cd 100644 (file)
@@ -125,7 +125,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
 {
        struct net_device  *dev;
 
-       dev = __dev_get_by_name("tunl0");
+       dev = __dev_get_by_name(&init_net, "tunl0");
 
        if (dev) {
                int err;
@@ -149,7 +149,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v)
 
                dev = NULL;
 
-               if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) {
+               if (err == 0 && (dev = __dev_get_by_name(&init_net, p.name)) != NULL) {
                        dev->flags |= IFF_MULTICAST;
 
                        in_dev = __in_dev_get_rtnl(dev);
index 356f067484e393634176357f193b9565cfdb2814..1960747f354c8c89966b920426d7487640476617 100644 (file)
@@ -387,7 +387,7 @@ static int set_mcast_if(struct sock *sk, char *ifname)
        struct net_device *dev;
        struct inet_sock *inet = inet_sk(sk);
 
-       if ((dev = __dev_get_by_name(ifname)) == NULL)
+       if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
                return -ENODEV;
 
        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)
        int num;
 
        if (sync_state == IP_VS_STATE_MASTER) {
-               if ((dev = __dev_get_by_name(ip_vs_master_mcast_ifn)) == NULL)
+               if ((dev = __dev_get_by_name(&init_net, ip_vs_master_mcast_ifn)) == NULL)
                        return -ENODEV;
 
                num = (dev->mtu - sizeof(struct iphdr) -
@@ -423,7 +423,7 @@ static int set_sync_mesg_maxlen(int sync_state)
                IP_VS_DBG(7, "setting the maximum length of sync sending "
                          "message %d.\n", sync_send_mesg_maxlen);
        } else if (sync_state == IP_VS_STATE_BACKUP) {
-               if ((dev = __dev_get_by_name(ip_vs_backup_mcast_ifn)) == NULL)
+               if ((dev = __dev_get_by_name(&init_net, ip_vs_backup_mcast_ifn)) == NULL)
                        return -ENODEV;
 
                sync_recv_mesg_maxlen = dev->mtu -
@@ -451,7 +451,7 @@ join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
        memset(&mreq, 0, sizeof(mreq));
        memcpy(&mreq.imr_multiaddr, addr, sizeof(struct in_addr));
 
-       if ((dev = __dev_get_by_name(ifname)) == NULL)
+       if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
                return -ENODEV;
        if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
                return -EINVAL;
@@ -472,7 +472,7 @@ static int bind_mcastif_addr(struct socket *sock, char *ifname)
        __be32 addr;
        struct sockaddr_in sin;
 
-       if ((dev = __dev_get_by_name(ifname)) == NULL)
+       if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
                return -ENODEV;
 
        addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
index 50fc9e009fe4443563a511fb1e1b5a6921a12102..27f14e1ebd8b342ff3a8f556c3d990cb665e6540 100644 (file)
@@ -401,7 +401,7 @@ checkentry(const char *tablename,
                                return false;
                        }
 
-                       dev = dev_get_by_name(e->ip.iniface);
+                       dev = dev_get_by_name(&init_net, e->ip.iniface);
                        if (!dev) {
                                printk(KERN_WARNING "CLUSTERIP: no such interface %s\n", e->ip.iniface);
                                return false;
index efd2a9202d68d6bd1655e9cffbc0eed8ed8fbcf9..396c631166a43e849d5cd8aee0fd0b65d2cd7a82 100644 (file)
@@ -2213,7 +2213,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
 
 
        if (oldflp->oif) {
-               dev_out = dev_get_by_index(oldflp->oif);
+               dev_out = dev_get_by_index(&init_net, oldflp->oif);
                err = -ENODEV;
                if (dev_out == NULL)
                        goto out;
@@ -2592,7 +2592,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
        if (iif) {
                struct net_device *dev;
 
-               dev = __dev_get_by_index(iif);
+               dev = __dev_get_by_index(&init_net, iif);
                if (dev == NULL) {
                        err = -ENODEV;
                        goto errout_free;
index 1a6783646520aa341c6d1e6b4d2d552711ed16cd..ee55be975407b113f72332d9b32c671b759d4666 100644 (file)
@@ -450,7 +450,7 @@ static void addrconf_forward_change(void)
        struct inet6_dev *idev;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                rcu_read_lock();
                idev = __in6_dev_get(dev);
                if (idev) {
@@ -912,7 +912,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
        read_lock(&dev_base_lock);
        rcu_read_lock();
 
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                struct inet6_dev *idev;
                struct inet6_ifaddr *ifa;
 
@@ -1858,7 +1858,7 @@ int addrconf_set_dstaddr(void __user *arg)
        if (copy_from_user(&ireq, arg, sizeof(struct in6_ifreq)))
                goto err_exit;
 
-       dev = __dev_get_by_index(ireq.ifr6_ifindex);
+       dev = __dev_get_by_index(&init_net, ireq.ifr6_ifindex);
 
        err = -ENODEV;
        if (dev == NULL)
@@ -1889,7 +1889,7 @@ int addrconf_set_dstaddr(void __user *arg)
 
                if (err == 0) {
                        err = -ENOBUFS;
-                       if ((dev = __dev_get_by_name(p.name)) == NULL)
+                       if ((dev = __dev_get_by_name(&init_net, p.name)) == NULL)
                                goto err_exit;
                        err = dev_open(dev);
                }
@@ -1919,7 +1919,7 @@ static int inet6_addr_add(int ifindex, struct in6_addr *pfx, int plen,
        if (!valid_lft || prefered_lft > valid_lft)
                return -EINVAL;
 
-       if ((dev = __dev_get_by_index(ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, ifindex)) == NULL)
                return -ENODEV;
 
        if ((idev = addrconf_add_dev(dev)) == NULL)
@@ -1970,7 +1970,7 @@ static int inet6_addr_del(int ifindex, struct in6_addr *pfx, int plen)
        struct inet6_dev *idev;
        struct net_device *dev;
 
-       if ((dev = __dev_get_by_index(ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, ifindex)) == NULL)
                return -ENODEV;
 
        if ((idev = __in6_dev_get(dev)) == NULL)
@@ -2065,7 +2065,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
                return;
        }
 
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                struct in_device * in_dev = __in_dev_get_rtnl(dev);
                if (in_dev && (dev->flags & IFF_UP)) {
                        struct in_ifaddr * ifa;
@@ -2221,12 +2221,12 @@ static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
 
        /* first try to inherit the link-local address from the link device */
        if (idev->dev->iflink &&
-           (link_dev = __dev_get_by_index(idev->dev->iflink))) {
+           (link_dev = __dev_get_by_index(&init_net, idev->dev->iflink))) {
                if (!ipv6_inherit_linklocal(idev, link_dev))
                        return;
        }
        /* then try to inherit it from any device */
-       for_each_netdev(link_dev) {
+       for_each_netdev(&init_net, link_dev) {
                if (!ipv6_inherit_linklocal(idev, link_dev))
                        return;
        }
@@ -3084,7 +3084,7 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
                valid_lft = INFINITY_LIFE_TIME;
        }
 
-       dev =  __dev_get_by_index(ifm->ifa_index);
+       dev =  __dev_get_by_index(&init_net, ifm->ifa_index);
        if (dev == NULL)
                return -ENODEV;
 
@@ -3268,7 +3268,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
        s_ip_idx = ip_idx = cb->args[1];
 
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < s_idx)
                        goto cont;
                if (idx > s_idx)
@@ -3377,7 +3377,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
 
        ifm = nlmsg_data(nlh);
        if (ifm->ifa_index)
-               dev = __dev_get_by_index(ifm->ifa_index);
+               dev = __dev_get_by_index(&init_net, ifm->ifa_index);
 
        if ((ifa = ipv6_get_ifaddr(addr, dev, 1)) == NULL) {
                err = -EADDRNOTAVAIL;
@@ -3589,7 +3589,7 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 
        read_lock(&dev_base_lock);
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < s_idx)
                        goto cont;
                if ((idev = in6_dev_get(dev)) == NULL)
@@ -4266,7 +4266,7 @@ void __exit addrconf_cleanup(void)
         *      clean dev list.
         */
 
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (__in6_dev_get(dev) == NULL)
                        continue;
                addrconf_ifdown(dev, 1);
index 21931c86e95b087571bfd342e99c54ea39d0b7d0..e5c5aad44bb15dee473cdaa5bbfd133f827ed43b 100644 (file)
@@ -302,7 +302,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                                        err = -EINVAL;
                                        goto out;
                                }
-                               dev = dev_get_by_index(sk->sk_bound_dev_if);
+                               dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
                                if (!dev) {
                                        err = -ENODEV;
                                        goto out;
index 0bd665498d06a076e5e3f73538c2afe9cf12caaa..d407992c1481b27248a3e1c31f7d8d35c72b8edb 100644 (file)
@@ -112,10 +112,10 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
                } else {
                        /* router, no matching interface: just pick one */
 
-                       dev = dev_get_by_flags(IFF_UP, IFF_UP|IFF_LOOPBACK);
+                       dev = dev_get_by_flags(&init_net, IFF_UP, IFF_UP|IFF_LOOPBACK);
                }
        } else
-               dev = dev_get_by_index(ifindex);
+               dev = dev_get_by_index(&init_net, ifindex);
 
        if (dev == NULL) {
                err = -ENODEV;
@@ -196,7 +196,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, struct in6_addr *addr)
 
        write_unlock_bh(&ipv6_sk_ac_lock);
 
-       dev = dev_get_by_index(pac->acl_ifindex);
+       dev = dev_get_by_index(&init_net, pac->acl_ifindex);
        if (dev) {
                ipv6_dev_ac_dec(dev, &pac->acl_addr);
                dev_put(dev);
@@ -224,7 +224,7 @@ void ipv6_sock_ac_close(struct sock *sk)
                if (pac->acl_ifindex != prev_index) {
                        if (dev)
                                dev_put(dev);
-                       dev = dev_get_by_index(pac->acl_ifindex);
+                       dev = dev_get_by_index(&init_net, pac->acl_ifindex);
                        prev_index = pac->acl_ifindex;
                }
                if (dev)
@@ -429,7 +429,7 @@ int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr)
        if (dev)
                return ipv6_chk_acast_dev(dev, addr);
        read_lock(&dev_base_lock);
-       for_each_netdev(dev)
+       for_each_netdev(&init_net, dev)
                if (ipv6_chk_acast_dev(dev, addr)) {
                        found = 1;
                        break;
@@ -453,7 +453,7 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
        struct ac6_iter_state *state = ac6_seq_private(seq);
 
        state->idev = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct inet6_dev *idev;
                idev = in6_dev_get(state->dev);
                if (!idev)
index fe0f49024a0a213a843cb854404ea428ebcca350..2ed689ac449ec67cd6e0519b1a4ddab4d156e43d 100644 (file)
@@ -544,7 +544,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                                if (!src_info->ipi6_ifindex)
                                        return -EINVAL;
                                else {
-                                       dev = dev_get_by_index(src_info->ipi6_ifindex);
+                                       dev = dev_get_by_index(&init_net, src_info->ipi6_ifindex);
                                        if (!dev)
                                                return -ENODEV;
                                }
index ca774d8e3be35e09c010db9aae493e7db6be997f..937625e577c12357e902b10d72c7e110e09fefa6 100644 (file)
@@ -235,7 +235,7 @@ static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
                int i;
                for (i = 1; i < IP6_TNL_MAX; i++) {
                        sprintf(name, "ip6tnl%d", i);
-                       if (__dev_get_by_name(name) == NULL)
+                       if (__dev_get_by_name(&init_net, name) == NULL)
                                break;
                }
                if (i == IP6_TNL_MAX)
@@ -650,7 +650,7 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
                struct net_device *ldev = NULL;
 
                if (p->link)
-                       ldev = dev_get_by_index(p->link);
+                       ldev = dev_get_by_index(&init_net, p->link);
 
                if ((ipv6_addr_is_multicast(&p->laddr) ||
                     likely(ipv6_chk_addr(&p->laddr, ldev, 0))) &&
@@ -786,7 +786,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
                struct net_device *ldev = NULL;
 
                if (p->link)
-                       ldev = dev_get_by_index(p->link);
+                       ldev = dev_get_by_index(&init_net, p->link);
 
                if (unlikely(!ipv6_chk_addr(&p->laddr, ldev, 0)))
                        printk(KERN_WARNING
index 74254fccbcc837f477d6cfac458367c5f6bfd062..eb330a44bacdf48d3fd03b720d4d33347bd3b016 100644 (file)
@@ -542,7 +542,7 @@ done:
                if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
                        goto e_inval;
 
-               if (__dev_get_by_index(val) == NULL) {
+               if (__dev_get_by_index(&init_net, val) == NULL) {
                        retv = -ENODEV;
                        break;
                }
index a41d5a0b50cc3e64c44b1e2bfe331046a67b9ac1..e2ab43c989d4d5f993731be026d1840938728dc5 100644 (file)
@@ -215,7 +215,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
                        dst_release(&rt->u.dst);
                }
        } else
-               dev = dev_get_by_index(ifindex);
+               dev = dev_get_by_index(&init_net, ifindex);
 
        if (dev == NULL) {
                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)
                        *lnk = mc_lst->next;
                        write_unlock_bh(&ipv6_sk_mc_lock);
 
-                       if ((dev = dev_get_by_index(mc_lst->ifindex)) != NULL) {
+                       if ((dev = dev_get_by_index(&init_net, mc_lst->ifindex)) != NULL) {
                                struct inet6_dev *idev = in6_dev_get(dev);
 
                                (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)
                        dst_release(&rt->u.dst);
                }
        } else
-               dev = dev_get_by_index(ifindex);
+               dev = dev_get_by_index(&init_net, ifindex);
 
        if (!dev)
                return NULL;
@@ -332,7 +332,7 @@ void ipv6_sock_mc_close(struct sock *sk)
                np->ipv6_mc_list = mc_lst->next;
                write_unlock_bh(&ipv6_sk_mc_lock);
 
-               dev = dev_get_by_index(mc_lst->ifindex);
+               dev = dev_get_by_index(&init_net, mc_lst->ifindex);
                if (dev) {
                        struct inet6_dev *idev = in6_dev_get(dev);
 
@@ -2333,7 +2333,7 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq)
        struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
 
        state->idev = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct inet6_dev *idev;
                idev = in6_dev_get(state->dev);
                if (!idev)
@@ -2477,7 +2477,7 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq)
 
        state->idev = NULL;
        state->im = NULL;
-       for_each_netdev(state->dev) {
+       for_each_netdev(&init_net, state->dev) {
                struct inet6_dev *idev;
                idev = in6_dev_get(state->dev);
                if (unlikely(idev == NULL))
index 38a3d21c2585a60800029e5f20cf9d1555c9376a..bdd0974e6775c6e0542369d9310a5cb10be4af2a 100644 (file)
@@ -283,7 +283,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                        if (!sk->sk_bound_dev_if)
                                goto out;
 
-                       dev = dev_get_by_index(sk->sk_bound_dev_if);
+                       dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
                        if (!dev) {
                                err = -ENODEV;
                                goto out;
index de795c04e34c1862723eb8100a8f376a5b375ebb..31601c99354107e6487cb4f9f161476a4a392cfb 100644 (file)
@@ -301,7 +301,7 @@ static void ip6_frag_expire(unsigned long data)
 
        fq_kill(fq);
 
-       dev = dev_get_by_index(fq->iif);
+       dev = dev_get_by_index(&init_net, fq->iif);
        if (!dev)
                goto out;
 
index f4f0c341e5c8999d7828f1eaadf7328e5d42a52a..5bdd9d4010fea7de5fbd9190ea3aa6254719e87d 100644 (file)
@@ -1130,7 +1130,7 @@ int ip6_route_add(struct fib6_config *cfg)
 #endif
        if (cfg->fc_ifindex) {
                err = -ENODEV;
-               dev = dev_get_by_index(cfg->fc_ifindex);
+               dev = dev_get_by_index(&init_net, cfg->fc_ifindex);
                if (!dev)
                        goto out;
                idev = in6_dev_get(dev);
@@ -2265,7 +2265,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
 
        if (iif) {
                struct net_device *dev;
-               dev = __dev_get_by_index(iif);
+               dev = __dev_get_by_index(&init_net, iif);
                if (!dev) {
                        err = -ENODEV;
                        goto errout;
index eb20bb690abd736e6699f1af7987cb8a1287d3c3..e79f419b1731e5e5bdc767be3ef65ea46bb8a52c 100644 (file)
@@ -167,7 +167,7 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int
                int i;
                for (i=1; i<100; i++) {
                        sprintf(name, "sit%d", i);
-                       if (__dev_get_by_name(name) == NULL)
+                       if (__dev_get_by_name(&init_net, name) == NULL)
                                break;
                }
                if (i==100)
@@ -761,7 +761,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
        }
 
        if (!tdev && tunnel->parms.link)
-               tdev = __dev_get_by_index(tunnel->parms.link);
+               tdev = __dev_get_by_index(&init_net, tunnel->parms.link);
 
        if (tdev) {
                dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr);
index 24921f12e9af21863fb7aa7144ae946f541d50a7..29b063d4312052cefd1a9bbdfd02b62d8b212211 100644 (file)
@@ -989,7 +989,7 @@ static int ipxitf_create(struct ipx_interface_definition *idef)
        if (intrfc)
                ipxitf_put(intrfc);
 
-       dev = dev_get_by_name(idef->ipx_device);
+       dev = dev_get_by_name(&init_net, idef->ipx_device);
        rc = -ENODEV;
        if (!dev)
                goto out;
@@ -1097,7 +1097,7 @@ static int ipxitf_delete(struct ipx_interface_definition *idef)
        if (!dlink_type)
                goto out;
 
-       dev = __dev_get_by_name(idef->ipx_device);
+       dev = __dev_get_by_name(&init_net, idef->ipx_device);
        rc = -ENODEV;
        if (!dev)
                goto out;
@@ -1192,7 +1192,7 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg)
                if (copy_from_user(&ifr, arg, sizeof(ifr)))
                        break;
                sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
-               dev  = __dev_get_by_name(ifr.ifr_name);
+               dev  = __dev_get_by_name(&init_net, ifr.ifr_name);
                rc   = -ENODEV;
                if (!dev)
                        break;
index 1e429c92973960fe4be164a62ef4e578f2cdc520..cd9ff176ecde7b81370f0891763fd1352ba240f2 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <linux/socket.h>
 #include <linux/irda.h>
+#include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/irda/irda.h>
 #include <net/irda/irlap.h>
@@ -30,7 +31,7 @@ static struct genl_family irda_nl_family = {
        .maxattr = IRDA_NL_CMD_MAX,
 };
 
-static struct net_device * ifname_to_netdev(struct genl_info *info)
+static struct net_device * ifname_to_netdev(struct net *net, struct genl_info *info)
 {
        char * ifname;
 
@@ -41,7 +42,7 @@ static struct net_device * ifname_to_netdev(struct genl_info *info)
 
        IRDA_DEBUG(5, "%s(): Looking for %s\n", __FUNCTION__, ifname);
 
-       return dev_get_by_name(ifname);
+       return dev_get_by_name(net, ifname);
 }
 
 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)
 
        IRDA_DEBUG(5, "%s(): Switching to mode: %d\n", __FUNCTION__, mode);
 
-       dev = ifname_to_netdev(info);
+       dev = ifname_to_netdev(&init_net, info);
        if (!dev)
                return -ENODEV;
 
@@ -82,7 +83,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info)
        void *hdr;
        int ret = -ENOBUFS;
 
-       dev = ifname_to_netdev(info);
+       dev = ifname_to_netdev(&init_net, info);
        if (!dev)
                return -ENODEV;
 
index b48244156e756ec4a396fea765eec7a8a71facd6..49eacba824df5bfdf1905c1df6e5503eaf15326d 100644 (file)
@@ -252,7 +252,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
        if (!sock_flag(sk, SOCK_ZAPPED))
                goto out;
        rc = -ENODEV;
-       llc->dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
+       llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd);
        if (!llc->dev)
                goto out;
        rc = -EUSERS;
@@ -303,7 +303,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
                goto out;
        rc = -ENODEV;
        rtnl_lock();
-       llc->dev = dev_getbyhwaddr(addr->sllc_arphrd, addr->sllc_mac);
+       llc->dev = dev_getbyhwaddr(&init_net, addr->sllc_arphrd, addr->sllc_mac);
        rtnl_unlock();
        if (!llc->dev)
                goto out;
index d4b13a031fd5e0375f3f76c74eb7c676c894fc4b..248b5903bb1348e07f594e5f54119963de82f365 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <net/net_namespace.h>
 #include <net/llc.h>
 
 LIST_HEAD(llc_sap_list);
@@ -162,7 +163,7 @@ static int __init llc_init(void)
 {
        struct net_device *dev;
 
-       dev = first_net_device();
+       dev = first_net_device(&init_net);
        if (dev != NULL)
                dev = next_net_device(dev);
 
index 73e314e33de2aec24556124f6e1a7a4e8f72d6e7..506cfa06b18415f01cfa5f118b092f73ded0e6e6 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/wireless.h>
 #include <linux/rtnetlink.h>
 #include <linux/bitmap.h>
+#include <net/net_namespace.h>
 #include <net/cfg80211.h>
 
 #include "ieee80211_common.h"
index 509096edb32463f7cae3720c93ad5e39b0c3a0fb..b1c13bc9c3ca29245e81e6a58cd5f38247026660 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/nl80211.h>
 #include <linux/rtnetlink.h>
+#include <net/net_namespace.h>
 #include <net/cfg80211.h>
 #include "ieee80211_i.h"
 #include "ieee80211_cfg.h"
@@ -50,7 +51,7 @@ static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
        if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
                return -ENODEV;
 
-       dev = dev_get_by_index(ifindex);
+       dev = dev_get_by_index(&init_net, ifindex);
        if (!dev)
                return 0;
 
index b65ff653624464f7817670fe10e0fc4540aadb77..9e952e37b7dfa12d554d2d2226740089494f2c6e 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/skbuff.h>
 #include <linux/etherdevice.h>
 #include <linux/bitmap.h>
+#include <net/net_namespace.h>
 #include <net/ieee80211_radiotap.h>
 #include <net/cfg80211.h>
 #include <net/mac80211.h>
@@ -1018,7 +1019,7 @@ static int inline ieee80211_tx_prepare(struct ieee80211_txrx_data *tx,
        struct net_device *dev;
 
        pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
-       dev = dev_get_by_index(pkt_data->ifindex);
+       dev = dev_get_by_index(&init_net, pkt_data->ifindex);
        if (unlikely(dev && !is_ieee80211_device(dev, mdev))) {
                dev_put(dev);
                dev = NULL;
@@ -1226,7 +1227,7 @@ int ieee80211_master_start_xmit(struct sk_buff *skb,
        memset(&control, 0, sizeof(struct ieee80211_tx_control));
 
        if (pkt_data->ifindex)
-               odev = dev_get_by_index(pkt_data->ifindex);
+               odev = dev_get_by_index(&init_net, pkt_data->ifindex);
        if (unlikely(odev && !is_ieee80211_device(odev, dev))) {
                dev_put(odev);
                odev = NULL;
@@ -1722,7 +1723,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id,
        u8 *b_head, *b_tail;
        int bh_len, bt_len;
 
-       bdev = dev_get_by_index(if_id);
+       bdev = dev_get_by_index(&init_net, if_id);
        if (bdev) {
                sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
                ap = &sdata->u.ap;
@@ -1836,7 +1837,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
        struct ieee80211_sub_if_data *sdata;
        struct ieee80211_if_ap *bss = NULL;
 
-       bdev = dev_get_by_index(if_id);
+       bdev = dev_get_by_index(&init_net, if_id);
        if (bdev) {
                sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
                bss = &sdata->u.ap;
index 07686bda26cdae55952ad4e55ae1329d3cb2fd83..c970996ba6f96ccb89acc3a1476bf55769ee9104 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/if_arp.h>
 #include <linux/wireless.h>
 #include <linux/bitmap.h>
+#include <net/net_namespace.h>
 #include <net/cfg80211.h>
 
 #include "ieee80211_i.h"
@@ -318,7 +319,7 @@ __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
                                        size_t frame_len, int rate)
 {
        struct ieee80211_local *local = hw_to_local(hw);
-       struct net_device *bdev = dev_get_by_index(if_id);
+       struct net_device *bdev = dev_get_by_index(&init_net, if_id);
        struct ieee80211_sub_if_data *sdata;
        u16 dur;
        int erp;
@@ -342,7 +343,7 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
 {
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_rate *rate;
-       struct net_device *bdev = dev_get_by_index(if_id);
+       struct net_device *bdev = dev_get_by_index(&init_net, if_id);
        struct ieee80211_sub_if_data *sdata;
        int short_preamble;
        int erp;
@@ -378,7 +379,7 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
 {
        struct ieee80211_local *local = hw_to_local(hw);
        struct ieee80211_rate *rate;
-       struct net_device *bdev = dev_get_by_index(if_id);
+       struct net_device *bdev = dev_get_by_index(&init_net, if_id);
        struct ieee80211_sub_if_data *sdata;
        int short_preamble;
        int erp;
index 24fe4a66d297d37ebc9600c3e15f263122a53d30..e943c16552a204badf0737b3550d11f6d85df663 100644 (file)
@@ -580,7 +580,7 @@ static struct net_device *nr_ax25_dev_get(char *devname)
 {
        struct net_device *dev;
 
-       if ((dev = dev_get_by_name(devname)) == NULL)
+       if ((dev = dev_get_by_name(&init_net, devname)) == NULL)
                return NULL;
 
        if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25)
@@ -598,7 +598,7 @@ struct net_device *nr_dev_first(void)
        struct net_device *dev, *first = NULL;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM)
                        if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
                                first = dev;
@@ -618,7 +618,7 @@ struct net_device *nr_dev_get(ax25_address *addr)
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) {
                        dev_hold(dev);
                        goto out;
index ad0052524e88574f33bbf6f537cfe4cc584f5215..745e2cb87c96a236b844f12f32f5c8e4fbd38d9e 100644 (file)
@@ -347,7 +347,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
         */
 
        saddr->spkt_device[13] = 0;
-       dev = dev_get_by_name(saddr->spkt_device);
+       dev = dev_get_by_name(&init_net, saddr->spkt_device);
        err = -ENODEV;
        if (dev == NULL)
                goto out_unlock;
@@ -742,7 +742,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
        }
 
 
-       dev = dev_get_by_index(ifindex);
+       dev = dev_get_by_index(&init_net, ifindex);
        err = -ENXIO;
        if (dev == NULL)
                goto out_unlock;
@@ -937,7 +937,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
                return -EINVAL;
        strlcpy(name,uaddr->sa_data,sizeof(name));
 
-       dev = dev_get_by_name(name);
+       dev = dev_get_by_name(&init_net, name);
        if (dev) {
                err = packet_do_bind(sk, dev, pkt_sk(sk)->num);
                dev_put(dev);
@@ -964,7 +964,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
 
        if (sll->sll_ifindex) {
                err = -ENODEV;
-               dev = dev_get_by_index(sll->sll_ifindex);
+               dev = dev_get_by_index(&init_net, sll->sll_ifindex);
                if (dev == NULL)
                        goto out;
        }
@@ -1161,7 +1161,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
                return -EOPNOTSUPP;
 
        uaddr->sa_family = AF_PACKET;
-       dev = dev_get_by_index(pkt_sk(sk)->ifindex);
+       dev = dev_get_by_index(&init_net, pkt_sk(sk)->ifindex);
        if (dev) {
                strlcpy(uaddr->sa_data, dev->name, 15);
                dev_put(dev);
@@ -1186,7 +1186,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
        sll->sll_family = AF_PACKET;
        sll->sll_ifindex = po->ifindex;
        sll->sll_protocol = po->num;
-       dev = dev_get_by_index(po->ifindex);
+       dev = dev_get_by_index(&init_net, po->ifindex);
        if (dev) {
                sll->sll_hatype = dev->type;
                sll->sll_halen = dev->addr_len;
@@ -1238,7 +1238,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
        rtnl_lock();
 
        err = -ENODEV;
-       dev = __dev_get_by_index(mreq->mr_ifindex);
+       dev = __dev_get_by_index(&init_net, mreq->mr_ifindex);
        if (!dev)
                goto done;
 
@@ -1292,7 +1292,7 @@ static int packet_mc_drop(struct sock *sk, struct packet_mreq_max *mreq)
                        if (--ml->count == 0) {
                                struct net_device *dev;
                                *mlp = ml->next;
-                               dev = dev_get_by_index(ml->ifindex);
+                               dev = dev_get_by_index(&init_net, ml->ifindex);
                                if (dev) {
                                        packet_dev_mc(dev, ml, -1);
                                        dev_put(dev);
@@ -1320,7 +1320,7 @@ static void packet_flush_mclist(struct sock *sk)
                struct net_device *dev;
 
                po->mclist = ml->next;
-               if ((dev = dev_get_by_index(ml->ifindex)) != NULL) {
+               if ((dev = dev_get_by_index(&init_net, ml->ifindex)) != NULL) {
                        packet_dev_mc(dev, ml, -1);
                        dev_put(dev);
                }
index 96f61a71b2527da33c900acf34c92e9fa014b055..540c0f26ffeeae0d5afb0caab156815deabbebaa 100644 (file)
@@ -583,7 +583,7 @@ static struct net_device *rose_ax25_dev_get(char *devname)
 {
        struct net_device *dev;
 
-       if ((dev = dev_get_by_name(devname)) == NULL)
+       if ((dev = dev_get_by_name(&init_net, devname)) == NULL)
                return NULL;
 
        if ((dev->flags & IFF_UP) && dev->type == ARPHRD_AX25)
@@ -601,7 +601,7 @@ struct net_device *rose_dev_first(void)
        struct net_device *dev, *first = NULL;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE)
                        if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
                                first = dev;
@@ -619,7 +619,7 @@ struct net_device *rose_dev_get(rose_address *addr)
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
                        dev_hold(dev);
                        goto out;
@@ -636,7 +636,7 @@ static int rose_dev_exists(rose_address *addr)
        struct net_device *dev;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)
                        goto out;
        }
index 579578944ae778b34c771ed73632cc50dd6b96b2..fd7bca4d5c208f173cc673b8753ff2dac4e14c51 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <net/net_namespace.h>
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <linux/tc_act/tc_mirred.h>
@@ -73,7 +74,7 @@ static int tcf_mirred_init(struct rtattr *rta, struct rtattr *est,
        parm = RTA_DATA(tb[TCA_MIRRED_PARMS-1]);
 
        if (parm->ifindex) {
-               dev = __dev_get_by_index(parm->ifindex);
+               dev = __dev_get_by_index(&init_net, parm->ifindex);
                if (dev == NULL)
                        return -ENODEV;
                switch (dev->type) {
index 5f0fbca7393ff73648129e8bad3b36081a525f44..03657976fd501f9715840750e51bf9029f1c631d 100644 (file)
@@ -154,7 +154,7 @@ replay:
        /* Find head of filter chain. */
 
        /* Find link */
-       if ((dev = __dev_get_by_index(t->tcm_ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, t->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        /* Find qdisc */
@@ -387,7 +387,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
 
        if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))
                return skb->len;
-       if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return skb->len;
 
        if (!tcm->tcm_parent)
index 650f09c8bd6a77b41f376f9213781547adb032c2..e9989610712ca2b8e68bc845623c28a5e78e8e5f 100644 (file)
@@ -291,7 +291,7 @@ META_COLLECTOR(var_sk_bound_if)
         } else  {
                struct net_device *dev;
 
-               dev = dev_get_by_index(skb->sk->sk_bound_dev_if);
+               dev = dev_get_by_index(&init_net, skb->sk->sk_bound_dev_if);
                *err = var_dev(dev, dst);
                if (dev)
                        dev_put(dev);
index efc383c58f1e4d8bd7b864b6b2d8d469ae87b5a2..39d32780c80bab626aea68fea07cdbec74d5c2a2 100644 (file)
@@ -607,7 +607,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        struct Qdisc *p = NULL;
        int err;
 
-       if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        if (clid) {
@@ -674,7 +674,7 @@ replay:
        clid = tcm->tcm_parent;
        q = p = NULL;
 
-       if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        if (clid) {
@@ -881,7 +881,7 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
        s_q_idx = q_idx = cb->args[1];
        read_lock(&dev_base_lock);
        idx = 0;
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                if (idx < s_idx)
                        goto cont;
                if (idx > s_idx)
@@ -932,7 +932,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
        u32 qid = TC_H_MAJ(clid);
        int err;
 
-       if ((dev = __dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = __dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return -ENODEV;
 
        /*
@@ -1115,7 +1115,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
 
        if (cb->nlh->nlmsg_len < NLMSG_LENGTH(sizeof(*tcm)))
                return 0;
-       if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL)
+       if ((dev = dev_get_by_index(&init_net, tcm->tcm_ifindex)) == NULL)
                return 0;
 
        s_t = cb->args[0];
index ddeb4882ec7519f0903929e4d4cbaa87f9d6bc96..9de3ddaa27685daf19d9795727c8d81d67fdc00c 100644 (file)
@@ -855,7 +855,7 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
                if (type & IPV6_ADDR_LINKLOCAL) {
                        if (!addr->v6.sin6_scope_id)
                                return 0;
-                       dev = dev_get_by_index(addr->v6.sin6_scope_id);
+                       dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id);
                        if (!dev)
                                return 0;
                        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)
                if (type & IPV6_ADDR_LINKLOCAL) {
                        if (!addr->v6.sin6_scope_id)
                                return 0;
-                       dev = dev_get_by_index(addr->v6.sin6_scope_id);
+                       dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id);
                        if (!dev)
                                return 0;
                        dev_put(dev);
index af67c839ef98410c55c5c6c8018ad41fc8f6ad64..54edcd978f75c4a8b737bd30cee760d56317aee0 100644 (file)
@@ -179,7 +179,7 @@ static void sctp_get_local_addr_list(void)
        struct sctp_af *af;
 
        read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
+       for_each_netdev(&init_net, dev) {
                __list_for_each(pos, &sctp_address_families) {
                        af = list_entry(pos, struct sctp_af, list);
                        af->copy_addrlist(&sctp_local_addr_list, dev);
index a714c6d4e4a16c798c8b83d849469ee092bf8e01..bc16eee4dc80b97041864f5805f7fbc57fa51b95 100644 (file)
@@ -791,9 +791,9 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
  */
 
 static DEFINE_MUTEX(br_ioctl_mutex);
-static int (*br_ioctl_hook) (unsigned int cmd, void __user *arg) = NULL;
+static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL;
 
-void brioctl_set(int (*hook) (unsigned int, void __user *))
+void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *))
 {
        mutex_lock(&br_ioctl_mutex);
        br_ioctl_hook = hook;
@@ -803,9 +803,9 @@ void brioctl_set(int (*hook) (unsigned int, void __user *))
 EXPORT_SYMBOL(brioctl_set);
 
 static DEFINE_MUTEX(vlan_ioctl_mutex);
-static int (*vlan_ioctl_hook) (void __user *arg);
+static int (*vlan_ioctl_hook) (struct net *, void __user *arg);
 
-void vlan_ioctl_set(int (*hook) (void __user *))
+void vlan_ioctl_set(int (*hook) (struct net *, void __user *))
 {
        mutex_lock(&vlan_ioctl_mutex);
        vlan_ioctl_hook = hook;
@@ -834,16 +834,20 @@ EXPORT_SYMBOL(dlci_ioctl_set);
 static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 {
        struct socket *sock;
+       struct sock *sk;
        void __user *argp = (void __user *)arg;
        int pid, err;
+       struct net *net;
 
        sock = file->private_data;
+       sk = sock->sk;
+       net = sk->sk_net;
        if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
-               err = dev_ioctl(cmd, argp);
+               err = dev_ioctl(net, cmd, argp);
        } else
 #ifdef CONFIG_WIRELESS_EXT
        if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
-               err = dev_ioctl(cmd, argp);
+               err = dev_ioctl(net, cmd, argp);
        } else
 #endif                         /* CONFIG_WIRELESS_EXT */
                switch (cmd) {
@@ -869,7 +873,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 
                        mutex_lock(&br_ioctl_mutex);
                        if (br_ioctl_hook)
-                               err = br_ioctl_hook(cmd, argp);
+                               err = br_ioctl_hook(net, cmd, argp);
                        mutex_unlock(&br_ioctl_mutex);
                        break;
                case SIOCGIFVLAN:
@@ -880,7 +884,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 
                        mutex_lock(&vlan_ioctl_mutex);
                        if (vlan_ioctl_hook)
-                               err = vlan_ioctl_hook(argp);
+                               err = vlan_ioctl_hook(net, argp);
                        mutex_unlock(&vlan_ioctl_mutex);
                        break;
                case SIOCADDDLCI:
@@ -903,7 +907,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
                         * to the NIC driver.
                         */
                        if (err == -ENOIOCTLCMD)
-                               err = dev_ioctl(cmd, argp);
+                               err = dev_ioctl(net, cmd, argp);
                        break;
                }
        return err;
index 406f0d26fa812a81d940e48826cbc00017745acc..d6fc0575816bd4a994ac70bd715487a7e3c3f397 100644 (file)
@@ -135,7 +135,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
 
        /* Find device with specified name */
 
-       for_each_netdev(pdev){
+       for_each_netdev(&init_net, pdev){
                if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) {
                        dev = pdev;
                        break;
index b8069afe0410b89777cb641fa6d883a0ceaa720a..e8b3409d6c8bac8e7ed1d76f569138ab9f87e75c 100644 (file)
@@ -673,7 +673,22 @@ static const struct seq_operations wireless_seq_ops = {
 
 static int wireless_seq_open(struct inode *inode, struct file *file)
 {
-       return seq_open(file, &wireless_seq_ops);
+       struct seq_file *seq;
+       int res;
+       res = seq_open(file, &wireless_seq_ops);
+       if (!res) {
+               seq = file->private_data;
+               seq->private = get_net(PROC_NET(inode));
+       }
+       return res;
+}
+
+static int wireless_seq_release(struct inode *inode, struct file *file)
+{
+       struct seq_file *seq = file->private_data;
+       struct net *net = seq->private;
+       put_net(net);
+       return seq_release(inode, file);
 }
 
 static const struct file_operations wireless_seq_fops = {
@@ -681,17 +696,22 @@ static const struct file_operations wireless_seq_fops = {
        .open    = wireless_seq_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
-       .release = seq_release,
+       .release = wireless_seq_release,
 };
 
-int __init wext_proc_init(void)
+int wext_proc_init(struct net *net)
 {
        /* Create /proc/net/wireless entry */
-       if (!proc_net_fops_create(&init_net, "wireless", S_IRUGO, &wireless_seq_fops))
+       if (!proc_net_fops_create(net, "wireless", S_IRUGO, &wireless_seq_fops))
                return -ENOMEM;
 
        return 0;
 }
+
+void wext_proc_exit(struct net *net)
+{
+       proc_net_remove(net, "wireless");
+}
 #endif /* CONFIG_PROC_FS */
 
 /************************** IOCTL SUPPORT **************************/
@@ -1011,7 +1031,7 @@ static int ioctl_private_call(struct net_device *dev, struct ifreq *ifr,
  * Main IOCTl dispatcher.
  * Check the type of IOCTL and call the appropriate wrapper...
  */
-static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
+static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd)
 {
        struct net_device *dev;
        iw_handler      handler;
@@ -1020,7 +1040,7 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
         * The copy_to/from_user() of ifr is also dealt with in there */
 
        /* Make sure the device exist */
-       if ((dev = __dev_get_by_name(ifr->ifr_name)) == NULL)
+       if ((dev = __dev_get_by_name(net, ifr->ifr_name)) == NULL)
                return -ENODEV;
 
        /* A bunch of special cases, then the generic case...
@@ -1054,7 +1074,7 @@ static int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
 }
 
 /* entry point from dev ioctl */
-int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
+int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
                      void __user *arg)
 {
        int ret;
@@ -1066,9 +1086,9 @@ int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd,
            && !capable(CAP_NET_ADMIN))
                return -EPERM;
 
-       dev_load(ifr->ifr_name);
+       dev_load(net, ifr->ifr_name);
        rtnl_lock();
-       ret = wireless_process_ioctl(ifr, cmd);
+       ret = wireless_process_ioctl(net, ifr, cmd);
        rtnl_unlock();
        if (IW_IS_GET(cmd) && copy_to_user(arg, ifr, sizeof(struct ifreq)))
                return -EFAULT;
index 060fcfaa2f47c3ec8465348336dd4a095546b22e..86b5b4da097c5c17065b17c87160555b2fa94ea0 100644 (file)
@@ -129,7 +129,7 @@ void x25_route_device_down(struct net_device *dev)
  */
 struct net_device *x25_dev_get(char *devname)
 {
-       struct net_device *dev = dev_get_by_name(devname);
+       struct net_device *dev = dev_get_by_name(&init_net, devname);
 
        if (dev &&
            (!(dev->flags & IFF_UP) || (dev->type != ARPHRD_X25