[NET]: Make the device list and device lookups per namespace.
[pandora-kernel.git] / net / decnet / dn_route.c
index 82622fb..70b1c3f 100644 (file)
@@ -77,6 +77,7 @@
 #include <linux/rcupdate.h>
 #include <linux/times.h>
 #include <asm/errno.h>
+#include <net/net_namespace.h>
 #include <net/netlink.h>
 #include <net/neighbour.h>
 #include <net/dst.h>
@@ -583,6 +584,9 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
        struct dn_dev *dn = (struct dn_dev *)dev->dn_ptr;
        unsigned char padlen = 0;
 
+       if (dev->nd_net != &init_net)
+               goto dump_it;
+
        if (dn == NULL)
                goto dump_it;
 
@@ -904,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);
@@ -925,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))
@@ -1552,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;
                }
@@ -1737,8 +1741,9 @@ static int dn_rt_cache_seq_open(struct inode *inode, struct file *file)
 {
        struct seq_file *seq;
        int rc = -ENOMEM;
-       struct dn_rt_cache_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
+       struct dn_rt_cache_iter_state *s;
 
+       s = kzalloc(sizeof(*s), GFP_KERNEL);
        if (!s)
                goto out;
        rc = seq_open(file, &dn_rt_cache_seq_ops);
@@ -1746,7 +1751,6 @@ static int dn_rt_cache_seq_open(struct inode *inode, struct file *file)
                goto out_kfree;
        seq             = file->private_data;
        seq->private    = s;
-       memset(s, 0, sizeof(*s));
 out:
        return rc;
 out_kfree:
@@ -1770,7 +1774,7 @@ void __init dn_route_init(void)
 
        dn_dst_ops.kmem_cachep =
                kmem_cache_create("dn_dst_cache", sizeof(struct dn_route), 0,
-                                 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
+                                 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
        init_timer(&dn_route_timer);
        dn_route_timer.function = dn_dst_check_expire;
        dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ;
@@ -1814,7 +1818,7 @@ void __init dn_route_init(void)
 
        dn_dst_ops.gc_thresh = (dn_rt_hash_mask + 1);
 
-       proc_net_fops_create("decnet_cache", S_IRUGO, &dn_rt_cache_seq_fops);
+       proc_net_fops_create(&init_net, "decnet_cache", S_IRUGO, &dn_rt_cache_seq_fops);
 
 #ifdef CONFIG_DECNET_ROUTER
        rtnl_register(PF_DECnet, RTM_GETROUTE, dn_cache_getroute, dn_fib_dump);
@@ -1829,6 +1833,6 @@ void __exit dn_route_cleanup(void)
        del_timer(&dn_route_timer);
        dn_run_flush(0);
 
-       proc_net_remove("decnet_cache");
+       proc_net_remove(&init_net, "decnet_cache");
 }