Skip to contentSkip to conversation

802.1q vlan updates

PATCH In review Ben Greear 2 participants 3 messages Nov 6, 2003

Subsystems (2)
lore
Share & tools
lore

Ben Greear

author
#0 lore raw

PATCH 1/1 802.1q vlan updates

Here is a patch that is a cleaned up version of something I sent a while back. This adds the ability to query a device to see if it is a vlan device by asking for the vlan's parent device. One can deduce that a querried interface is not a VLAN by looking at the IOCTL error code.

Patch is against 2.4.22-pre9, compile tested and extracted from a run-time tested patch.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
net/8021q/vlan_dev.c +55 -1
@@ -1,4 +1,4 @@
-/*
+/* -*- linux-c -*-
  * INET		802.1Q VLAN
  *		Ethernet-type device handling.
  *
@@ -636,6 +636,60 @@
 	return -EINVAL;
 }
 
+
+int vlan_dev_get_realdev_name(const char *dev_name, char* result)
+{
+	struct net_device *dev = dev_get_by_name(dev_name);
+	int rv = 0;
+	
+	if (dev) {
+		if (dev->priv_flags & IFF_802_1Q_VLAN) {
+			strncpy(result, VLAN_DEV_INFO(dev)->real_dev->name, 23);
+			dev_put(dev);
+			rv = 0;
+		} else {
+			/*printk(KERN_ERR 
+			       "%s: %s is not a vlan device, priv_flags: %hX.\n",
+			       __FUNCTION__, dev->name, dev->priv_flags);*/
+			dev_put(dev);
+			rv = -EINVAL;
+		}
+	} else {
+		/* printk(KERN_ERR	 "%s: Could not find device: %s\n", 
+		   __FUNCTION__, dev_name); */
+		rv = -ENODEV;
+	}
+
+	return rv;
+}
+
+int vlan_dev_get_vid(const char *dev_name, unsigned short* result)
+{
+	struct net_device *dev = dev_get_by_name(dev_name);
+	int rv = 0;
+	
+	if (dev) {
+		if (dev->priv_flags & IFF_802_1Q_VLAN) {
+			*result = VLAN_DEV_INFO(dev)->vlan_id;
+			dev_put(dev);
+			rv = 0;
+		} else {
+			/*printk(KERN_ERR 
+			       "%s: %s is not a vlan device, priv_flags: %hX.\n",
+			       __FUNCTION__, dev->name, dev->priv_flags);*/
+			dev_put(dev);
+			rv = -EINVAL;
+		}
+	} else {
+		/* printk(KERN_ERR	 "%s: Could not find device: %s\n", 
+		   __FUNCTION__, dev_name);*/
+		rv = -ENODEV;
+	}
+
+	return rv;
+}
+
+
 int vlan_dev_set_mac_address(struct net_device *dev, void *addr_struct_p)
 {
 	struct sockaddr *addr = (struct sockaddr *)(addr_struct_p);
net/8021q/vlan.c +54 -18

126 lines not on this page · raw message

include/linux/if_vlan.h +3 -1
@@ -213,7 +213,9 @@
 	GET_VLAN_INGRESS_PRIORITY_CMD,
 	GET_VLAN_EGRESS_PRIORITY_CMD,
 	SET_VLAN_NAME_TYPE_CMD,
-	SET_VLAN_FLAG_CMD
+	SET_VLAN_FLAG_CMD,
+        GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */
+        GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */
 };
 
 enum vlan_name_types {
#1 lore raw
Quoted 8 lines · On Wed, 05 Nov 2003 20:24:43 -0800 Ben Greear <[email protected]> wrote:

Here is a patch that is a cleaned up version of something I sent a while back. This adds the ability to query a device to see if it is a vlan device by asking for the vlan's parent device. One can deduce that a querried interface is not a VLAN by looking at the IOCTL error code.

Patch is against 2.4.22-pre9, compile tested and extracted from a run-time tested patch.

I'll push this to Marcelo for 2.4.24, thanks.

If you could cook up and test a 2.6.x version, I'll push that in for 2.6.1

author
#2 lore raw
Quoted 10 lines · David S. Miller
Quoted 6 lines · On Wed, 05 Nov 2003 20:24:43 -0800 Ben Greear <[email protected]> wrote:

Here is a patch that is a cleaned up version of something I sent a while back. This adds the ability to query a device to see if it is a vlan device by asking for the vlan's parent device. One can deduce that a querried interface is not a VLAN by looking at the IOCTL error code.

Quoted 8 lines
Quoted 2 lines

Patch is against 2.4.22-pre9, compile tested and extracted from a run-time tested patch.

I'll push this to Marcelo for 2.4.24, thanks.

If you could cook up and test a 2.6.x version, I'll push that in for 2.6.1

I have yet to start using 2.6, but I'll get a test system up as soon as 2.6.0 comes out and will send a patch shortly there-after.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com