]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/dev_mcast.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
[linux-2.6-omap-h63xx.git] / net / core / dev_mcast.c
index 99aece1aeccff9aa950c3b8bb08385b8dd2b2b25..cec582563e0dcdbfcf15aa535115b62d35d29041 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/init.h>
+#include <net/net_namespace.h>
 #include <net/ip.h>
 #include <net/route.h>
 #include <linux/skbuff.h>
@@ -112,29 +113,15 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
  *     locked by netif_tx_lock_bh.
  *
  *     This function is intended to be called from the dev->set_multicast_list
- *     function of layered software devices.
+ *     or dev->set_rx_mode function of layered software devices.
  */
 int dev_mc_sync(struct net_device *to, struct net_device *from)
 {
-       struct dev_addr_list *da;
        int err = 0;
 
        netif_tx_lock_bh(to);
-       for (da = from->mc_list; da != NULL; da = da->next) {
-               if (!da->da_synced) {
-                       err = __dev_addr_add(&to->mc_list, &to->mc_count,
-                                            da->da_addr, da->da_addrlen, 0);
-                       if (err < 0)
-                               break;
-                       da->da_synced = 1;
-                       da->da_users++;
-               } else if (da->da_users == 1) {
-                       __dev_addr_delete(&to->mc_list, &to->mc_count,
-                                         da->da_addr, da->da_addrlen, 0);
-                       __dev_addr_delete(&from->mc_list, &from->mc_count,
-                                         da->da_addr, da->da_addrlen, 0);
-               }
-       }
+       err = __dev_addr_sync(&to->mc_list, &to->mc_count,
+                             &from->mc_list, &from->mc_count);
        if (!err)
                __dev_set_rx_mode(to);
        netif_tx_unlock_bh(to);
@@ -156,20 +143,11 @@ EXPORT_SYMBOL(dev_mc_sync);
  */
 void dev_mc_unsync(struct net_device *to, struct net_device *from)
 {
-       struct dev_addr_list *da;
-
        netif_tx_lock_bh(from);
        netif_tx_lock_bh(to);
 
-       for (da = from->mc_list; da != NULL; da = da->next) {
-               if (!da->da_synced)
-                       continue;
-               __dev_addr_delete(&to->mc_list, &to->mc_count,
-                                 da->da_addr, da->da_addrlen, 0);
-               da->da_synced = 0;
-               __dev_addr_delete(&from->mc_list, &from->mc_count,
-                                 da->da_addr, da->da_addrlen, 0);
-       }
+       __dev_addr_unsync(&to->mc_list, &to->mc_count,
+                         &from->mc_list, &from->mc_count);
        __dev_set_rx_mode(to);
 
        netif_tx_unlock_bh(to);
@@ -179,12 +157,14 @@ EXPORT_SYMBOL(dev_mc_unsync);
 
 #ifdef CONFIG_PROC_FS
 static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
+       __acquires(dev_base_lock)
 {
+       struct net *net = seq_file_net(seq);
        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;
        }
@@ -198,6 +178,7 @@ static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 }
 
 static void dev_mc_seq_stop(struct seq_file *seq, void *v)
+       __releases(dev_base_lock)
 {
        read_unlock(&dev_base_lock);
 }
@@ -233,7 +214,8 @@ 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);
+       return seq_open_net(inode, file, &dev_mc_seq_ops,
+                           sizeof(struct seq_net_private));
 }
 
 static const struct file_operations dev_mc_seq_fops = {
@@ -241,14 +223,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 = seq_release_net,
 };
 
 #endif
 
+static int __net_init 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 __net_exit dev_mc_net_exit(struct net *net)
+{
+       proc_net_remove(net, "dev_mcast");
+}
+
+static struct pernet_operations __net_initdata dev_mc_net_ops = {
+       .init = dev_mc_net_init,
+       .exit = dev_mc_net_exit,
+};
+
 void __init dev_mcast_init(void)
 {
-       proc_net_fops_create("dev_mcast", 0, &dev_mc_seq_fops);
+       register_pernet_subsys(&dev_mc_net_ops);
 }
 
 EXPORT_SYMBOL(dev_mc_add);