[NET]: Make the device list and device lookups per namespace.
[deliverable/linux.git] / drivers / net / bonding / bond_main.c
index 070b78d959cc1f3f87dc709aecbc4d5d06f3e286..559fe9437e0b6ed2937d0056853d8255cfcc570f 100644 (file)
@@ -75,6 +75,7 @@
 #include <linux/if_vlan.h>
 #include <linux/if_bonding.h>
 #include <net/route.h>
+#include <net/net_namespace.h>
 #include "bonding.h"
 #include "bond_3ad.h"
 #include "bond_alb.h"
@@ -1202,43 +1203,35 @@ static int bond_sethwaddr(struct net_device *bond_dev,
        return 0;
 }
 
-#define BOND_INTERSECT_FEATURES \
-       (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_TSO | NETIF_F_UFO)
+#define BOND_VLAN_FEATURES \
+       (NETIF_F_VLAN_CHALLENGED | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | \
+        NETIF_F_HW_VLAN_FILTER)
 
 /* 
  * Compute the common dev->feature set available to all slaves.  Some
- * feature bits are managed elsewhere, so preserve feature bits set on
- * master device that are not part of the examined set.
+ * feature bits are managed elsewhere, so preserve those feature bits
+ * on the master device.
  */
 static int bond_compute_features(struct bonding *bond)
 {
-       unsigned long features = BOND_INTERSECT_FEATURES;
        struct slave *slave;
        struct net_device *bond_dev = bond->dev;
+       unsigned long features = bond_dev->features;
        unsigned short max_hard_header_len = ETH_HLEN;
        int i;
 
+       features &= ~(NETIF_F_ALL_CSUM | BOND_VLAN_FEATURES);
+       features |= NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
+                   NETIF_F_GSO_MASK | NETIF_F_NO_CSUM;
+
        bond_for_each_slave(bond, slave, i) {
-               features &= (slave->dev->features & BOND_INTERSECT_FEATURES);
+               features = netdev_compute_features(features,
+                                                  slave->dev->features);
                if (slave->dev->hard_header_len > max_hard_header_len)
                        max_hard_header_len = slave->dev->hard_header_len;
        }
 
-       if ((features & NETIF_F_SG) && 
-           !(features & NETIF_F_ALL_CSUM))
-               features &= ~NETIF_F_SG;
-
-       /* 
-        * features will include NETIF_F_TSO (NETIF_F_UFO) iff all 
-        * slave devices support NETIF_F_TSO (NETIF_F_UFO), which 
-        * implies that all slaves also support scatter-gather 
-        * (NETIF_F_SG), which implies that features also includes 
-        * NETIF_F_SG. So no need to check whether we have an  
-        * illegal combination of NETIF_F_{TSO,UFO} and 
-        * !NETIF_F_SG 
-        */
-
-       features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES);
+       features |= (bond_dev->features & BOND_VLAN_FEATURES);
        bond_dev->features = features;
        bond_dev->hard_header_len = max_hard_header_len;
 
@@ -2465,6 +2458,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
        unsigned char *arp_ptr;
        u32 sip, tip;
 
+       if (dev->nd_net != &init_net)
+               goto out;
+
        if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER))
                goto out;
 
@@ -3152,7 +3148,7 @@ static void bond_create_proc_dir(void)
 {
        int len = strlen(DRV_NAME);
 
-       for (bond_proc_dir = proc_net->subdir; bond_proc_dir;
+       for (bond_proc_dir = init_net.proc_net->subdir; bond_proc_dir;
             bond_proc_dir = bond_proc_dir->next) {
                if ((bond_proc_dir->namelen == len) &&
                    !memcmp(bond_proc_dir->name, DRV_NAME, len)) {
@@ -3161,7 +3157,7 @@ static void bond_create_proc_dir(void)
        }
 
        if (!bond_proc_dir) {
-               bond_proc_dir = proc_mkdir(DRV_NAME, proc_net);
+               bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net);
                if (bond_proc_dir) {
                        bond_proc_dir->owner = THIS_MODULE;
                } else {
@@ -3196,7 +3192,7 @@ static void bond_destroy_proc_dir(void)
                        bond_proc_dir->owner = NULL;
                }
        } else {
-               remove_proc_entry(DRV_NAME, proc_net);
+               remove_proc_entry(DRV_NAME, init_net.proc_net);
                bond_proc_dir = NULL;
        }
 }
@@ -3303,6 +3299,9 @@ static int bond_netdev_event(struct notifier_block *this, unsigned long event, v
 {
        struct net_device *event_dev = (struct net_device *)ptr;
 
+       if (event_dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        dprintk("event_dev: %s, event: %lx\n",
                (event_dev ? event_dev->name : "None"),
                event);
@@ -3720,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);
 
This page took 0.029048 seconds and 5 git commands to generate.