]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/core/dev_mcast.c
Merge branch 'bkl-removal' into next
[linux-2.6-omap-h63xx.git] / net / core / dev_mcast.c
index 235a2a8a0d05b0b2163c180001f918274720a785..f8a3455f4493f7276fe614af6dbd7c26f4f04cb8 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);
@@ -177,49 +155,15 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
 }
 EXPORT_SYMBOL(dev_mc_unsync);
 
-/*
- *     Discard multicast list when a device is downed
- */
-
-void dev_mc_discard(struct net_device *dev)
-{
-       netif_tx_lock_bh(dev);
-       __dev_addr_discard(&dev->mc_list);
-       dev->mc_count = 0;
-       netif_tx_unlock_bh(dev);
-}
-
 #ifdef CONFIG_PROC_FS
-static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
-{
-       struct net_device *dev;
-       loff_t off = 0;
-
-       read_lock(&dev_base_lock);
-       for_each_netdev(dev) {
-               if (off++ == *pos)
-                       return dev;
-       }
-       return NULL;
-}
-
-static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-{
-       ++*pos;
-       return next_net_device((struct net_device *)v);
-}
-
-static void dev_mc_seq_stop(struct seq_file *seq, void *v)
-{
-       read_unlock(&dev_base_lock);
-}
-
-
 static int dev_mc_seq_show(struct seq_file *seq, void *v)
 {
        struct dev_addr_list *m;
        struct net_device *dev = v;
 
+       if (v == SEQ_START_TOKEN)
+               return 0;
+
        netif_tx_lock_bh(dev);
        for (m = dev->mc_list; m; m = m->next) {
                int i;
@@ -237,15 +181,16 @@ static int dev_mc_seq_show(struct seq_file *seq, void *v)
 }
 
 static const struct seq_operations dev_mc_seq_ops = {
-       .start = dev_mc_seq_start,
-       .next  = dev_mc_seq_next,
-       .stop  = dev_mc_seq_stop,
+       .start = dev_seq_start,
+       .next  = dev_seq_next,
+       .stop  = dev_seq_stop,
        .show  = dev_mc_seq_show,
 };
 
 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 = {
@@ -253,14 +198,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);