linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / 8021q / vlan.c
index 87b2115..fa76220 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <asm/uaccess.h> /* for copy_from_user */
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/skbuff.h>
@@ -40,7 +41,7 @@
 /* Global VLAN variables */
 
 /* Our listing of VLAN group(s) */
-struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
+static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
 #define vlan_grp_hashfn(IDX)   ((((IDX) >> VLAN_GRP_HASH_SHIFT) ^ (IDX)) & VLAN_GRP_HASH_MASK)
 
 static char vlan_fullname[] = "802.1Q VLAN Support";
@@ -52,7 +53,7 @@ static int vlan_device_event(struct notifier_block *, unsigned long, void *);
 static int vlan_ioctl_handler(void __user *);
 static int unregister_vlan_dev(struct net_device *, unsigned short );
 
-struct notifier_block vlan_notifier_block = {
+static struct notifier_block vlan_notifier_block = {
        .notifier_call = vlan_device_event,
 };
 
@@ -61,9 +62,6 @@ struct notifier_block vlan_notifier_block = {
 /* Determines interface naming scheme. */
 unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
 
-/* DO reorder the header by default */
-unsigned short vlan_default_dev_flags = 1;
-
 static struct packet_type vlan_packet_type = {
        .type = __constant_htons(ETH_P_8021Q),
        .func = vlan_skb_recv, /* VLAN receive method */
@@ -490,7 +488,7 @@ static struct net_device *register_vlan_device(const char *eth_IF_name,
        VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
        VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
        VLAN_DEV_INFO(new_dev)->dent = NULL;
-       VLAN_DEV_INFO(new_dev)->flags = vlan_default_dev_flags;
+       VLAN_DEV_INFO(new_dev)->flags = 1;
 
 #ifdef VLAN_DEBUG
        printk(VLAN_DBG "About to go find the group for idx: %i\n",
@@ -581,6 +579,14 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
                        if (!vlandev)
                                continue;
 
+                       if (netif_carrier_ok(dev)) {
+                               if (!netif_carrier_ok(vlandev))
+                                       netif_carrier_on(vlandev);
+                       } else {
+                               if (netif_carrier_ok(vlandev))
+                                       netif_carrier_off(vlandev);
+                       }
+
                        if ((vlandev->state & VLAN_LINK_STATE_MASK) != flgs) {
                                vlandev->state = (vlandev->state &~ VLAN_LINK_STATE_MASK) 
                                        | flgs;
@@ -748,6 +754,8 @@ static int vlan_ioctl_handler(void __user *arg)
                break;
        case GET_VLAN_REALDEV_NAME_CMD:
                err = vlan_dev_get_realdev_name(args.device1, args.u.device2);
+               if (err)
+                       goto out;
                if (copy_to_user(arg, &args,
                                 sizeof(struct vlan_ioctl_args))) {
                        err = -EFAULT;
@@ -756,6 +764,8 @@ static int vlan_ioctl_handler(void __user *arg)
 
        case GET_VLAN_VID_CMD:
                err = vlan_dev_get_vid(args.device1, &vid);
+               if (err)
+                       goto out;
                args.u.VID = vid;
                if (copy_to_user(arg, &args,
                                 sizeof(struct vlan_ioctl_args))) {
@@ -769,7 +779,7 @@ static int vlan_ioctl_handler(void __user *arg)
                        __FUNCTION__, args.cmd);
                return -EINVAL;
        };
-
+out:
        return err;
 }