]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/netfilter/ip_queue.c
[NET]: Support multiple network namespaces with netlink
[linux-2.6-omap-h63xx.git] / net / ipv4 / netfilter / ip_queue.c
index 702d94db19b9f5edb12d0a8c77379014ace18211..82fda92e6b97b106d0dad050a7f63774d0551483 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/proc_fs.h>
 #include <linux/security.h>
 #include <linux/mutex.h>
+#include <net/net_namespace.h>
 #include <net/sock.h>
 #include <net/route.h>
 
@@ -556,6 +557,9 @@ ipq_rcv_dev_event(struct notifier_block *this,
 {
        struct net_device *dev = ptr;
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        /* Drop any packets associated with the downed device */
        if (event == NETDEV_DOWN)
                ipq_dev_drop(dev->ifindex);
@@ -575,7 +579,7 @@ ipq_rcv_nl_event(struct notifier_block *this,
        if (event == NETLINK_URELEASE &&
            n->protocol == NETLINK_FIREWALL && n->pid) {
                write_lock_bh(&queue_lock);
-               if (n->pid == peer_pid)
+               if ((n->net == &init_net) && (n->pid == peer_pid))
                        __ipq_reset();
                write_unlock_bh(&queue_lock);
        }
@@ -667,14 +671,14 @@ static int __init ip_queue_init(void)
        struct proc_dir_entry *proc;
 
        netlink_register_notifier(&ipq_nl_notifier);
-       ipqnl = netlink_kernel_create(NETLINK_FIREWALL, 0, ipq_rcv_sk,
-                                     NULL, THIS_MODULE);
+       ipqnl = netlink_kernel_create(&init_net, NETLINK_FIREWALL, 0,
+                                     ipq_rcv_sk, NULL, THIS_MODULE);
        if (ipqnl == NULL) {
                printk(KERN_ERR "ip_queue: failed to create netlink socket\n");
                goto cleanup_netlink_notifier;
        }
 
-       proc = proc_net_create(IPQ_PROC_FS_NAME, 0, ipq_get_info);
+       proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info);
        if (proc)
                proc->owner = THIS_MODULE;
        else {
@@ -695,8 +699,7 @@ static int __init ip_queue_init(void)
 cleanup_sysctl:
        unregister_sysctl_table(ipq_sysctl_header);
        unregister_netdevice_notifier(&ipq_dev_notifier);
-       proc_net_remove(IPQ_PROC_FS_NAME);
-
+       proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
 cleanup_ipqnl:
        sock_release(ipqnl->sk_socket);
        mutex_lock(&ipqnl_mutex);
@@ -715,7 +718,7 @@ static void __exit ip_queue_fini(void)
 
        unregister_sysctl_table(ipq_sysctl_header);
        unregister_netdevice_notifier(&ipq_dev_notifier);
-       proc_net_remove(IPQ_PROC_FS_NAME);
+       proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
 
        sock_release(ipqnl->sk_socket);
        mutex_lock(&ipqnl_mutex);