]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/8021q/vlan.c
[NET]: Make the device list and device lookups per namespace.
[linux-2.6-omap-h63xx.git] / net / 8021q / vlan.c
index 39bdcc25c15053b053c7fe5d595569cfa1e7e9a1..a9ced0a6f4c083061cdd27f8b3f0a41b47756238 100644 (file)
@@ -31,6 +31,7 @@
 #include <net/arp.h>
 #include <linux/rtnetlink.h>
 #include <linux/notifier.h>
+#include <net/net_namespace.h>
 
 #include <linux/if_vlan.h>
 #include "vlan.h"
@@ -50,7 +51,7 @@ static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
 static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
 
 static int vlan_device_event(struct notifier_block *, unsigned long, void *);
-static int vlan_ioctl_handler(void __user *);
+static int vlan_ioctl_handler(struct net *net, void __user *);
 static int unregister_vlan_dev(struct net_device *, unsigned short );
 
 static struct notifier_block vlan_notifier_block = {
@@ -377,7 +378,7 @@ void vlan_setup(struct net_device *new_dev)
        new_dev->destructor = free_netdev;
        new_dev->do_ioctl = vlan_dev_ioctl;
 
-       memset(new_dev->broadcast, 0, sizeof(ETH_ALEN));
+       memset(new_dev->broadcast, 0, ETH_ALEN);
 }
 
 static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev)
@@ -562,8 +563,6 @@ static int register_vlan_device(struct net_device *real_dev,
        if (err < 0)
                goto out_free_newdev;
 
-       /* Account for reference in struct vlan_dev_info */
-       dev_hold(real_dev);
 #ifdef VLAN_DEBUG
        printk(VLAN_DBG "Allocated new device successfully, returning.\n");
 #endif
@@ -605,6 +604,9 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
        int i, flgs;
        struct net_device *vlandev;
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        if (!grp)
                goto out;
 
@@ -695,7 +697,7 @@ out:
  *     o execute requested action or pass command to the device driver
  *   arg is really a struct vlan_ioctl_args __user *.
  */
-static int vlan_ioctl_handler(void __user *arg)
+static int vlan_ioctl_handler(struct net *net, void __user *arg)
 {
        int err;
        unsigned short vid = 0;
@@ -724,7 +726,7 @@ static int vlan_ioctl_handler(void __user *arg)
        case GET_VLAN_REALDEV_NAME_CMD:
        case GET_VLAN_VID_CMD:
                err = -ENODEV;
-               dev = __dev_get_by_name(args.device1);
+               dev = __dev_get_by_name(&init_net, args.device1);
                if (!dev)
                        goto out;
 
@@ -810,6 +812,7 @@ static int vlan_ioctl_handler(void __user *arg)
                err = -EINVAL;
                break;
        case GET_VLAN_REALDEV_NAME_CMD:
+               err = 0;
                vlan_dev_get_realdev_name(dev, args.u.device2);
                if (copy_to_user(arg, &args,
                                 sizeof(struct vlan_ioctl_args))) {
@@ -818,6 +821,7 @@ static int vlan_ioctl_handler(void __user *arg)
                break;
 
        case GET_VLAN_VID_CMD:
+               err = 0;
                vlan_dev_get_vid(dev, &vid);
                args.u.VID = vid;
                if (copy_to_user(arg, &args,