]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/8021q/vlan.c
[NET]: Make device event notification network namespace safe
[linux-2.6-omap-h63xx.git] / net / 8021q / vlan.c
index abb9900edb3f189a923315f71ec5991f7d34d079..d0d36fdedbe988123e5458c5271351b98ba55498 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"
@@ -373,10 +374,11 @@ void vlan_setup(struct net_device *new_dev)
        new_dev->open = vlan_dev_open;
        new_dev->stop = vlan_dev_stop;
        new_dev->set_multicast_list = vlan_dev_set_multicast_list;
+       new_dev->change_rx_flags = vlan_change_rx_flags;
        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)
@@ -561,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
@@ -604,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;
 
@@ -809,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))) {
@@ -817,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,