Skip to contentSkip to conversation

VLAN patch try 2, tabs instead of spaces

PATCH Ben Greear 2 participants 2 messages Aug 6, 2003 – Aug 31, 2003

Subsystems (2)
lore
Share & tools
lore

Ben Greear

author
#0 lore raw

Same as last time, but now using tabs instead of spaces.

net/8021q/vlan_dev.c +76 -23
@@ -1,18 +1,18 @@
-/*
+/* -*- linux-c -*-
  * INET		802.1Q VLAN
  *		Ethernet-type device handling.
  *
  * Authors:	Ben Greear <[email protected]>
- *              Please send support related email to: [email protected]
- *              VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
+ *		Please send support related email to: [email protected]
+ *		VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
  *
- * Fixes:       Mar 22 2001: Martin Bokaemper <[email protected]>
- *                - reset skb->pkt_type on incoming packets when MAC was changed
- *                - see that changed MAC is saddr for outgoing packets
- *              Oct 20, 2001:  Ard van Breeman:
- *                - Fix MC-list, finally.
- *                - Flush MC-list on VLAN destroy.
- *
+ * Fixes:	Mar 22 2001: Martin Bokaemper <[email protected]>
+ *		  - reset skb->pkt_type on incoming packets when MAC was changed
+ *		  - see that changed MAC is saddr for outgoing packets
+ *		Oct 20, 2001:  Ard van Breeman:
+ *		  - Fix MC-list, finally.
+ *		  - Flush MC-list on VLAN destroy.
+ *		
  *
  *		This program is free software; you can redistribute it and/or
  *		modify it under the terms of the GNU General Public License
@@ -99,18 +99,18 @@
  *  NOTE:  Should be similar to ethernet/eth.c.
  *
  *  SANITY NOTE:  This method is called when a packet is moving up the stack
- *                towards userland.  To get here, it would have already passed
- *                through the ethernet/eth.c eth_type_trans() method.
+ *		  towards userland.  To get here, it would have already passed
+ *		  through the ethernet/eth.c eth_type_trans() method.
  *  SANITY NOTE 2: We are referencing to the VLAN_HDR frields, which MAY be
- *                 stored UNALIGNED in the memory.  RISC systems don't like
- *                 such cases very much...
+ *		   stored UNALIGNED in the memory.  RISC systems don't like
+ *		   such cases very much...
  *  SANITY NOTE 2a:  According to Dave Miller & Alexey, it will always be aligned,
- *                 so there doesn't need to be any of the unaligned stuff.  It has
- *                 been commented out now...  --Ben
+ *		   so there doesn't need to be any of the unaligned stuff.  It has
+ *		   been commented out now...  --Ben
  *
  */
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
-                  struct packet_type* ptype)
+		  struct packet_type* ptype)
 {
 	unsigned char *rawp = NULL;
 	struct vlan_hdr *vhdr = (struct vlan_hdr *)(skb->data);
@@ -170,7 +170,7 @@
 		spin_unlock_bh(&vlan_group_lock);
 
 #ifdef VLAN_DEBUG
-		printk(VLAN_DBG "%s: dropping skb: %p because came in on wrong device, dev: %s  real_dev: %s, skb_dev: %s\n",
+		printk(VLAN_DBG "%s: dropping skb: %p because came in on wrong device, dev: %s	real_dev: %s, skb_dev: %s\n",
 			__FUNCTION__ skb, dev->name,
 			VLAN_DEV_INFO(skb->dev)->real_dev->name,
 			skb->dev->name);
@@ -324,8 +324,8 @@
  *  physical devices.
  */
 int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-                         unsigned short type, void *daddr, void *saddr,
-                         unsigned len)
+			 unsigned short type, void *daddr, void *saddr,
+			 unsigned len)
 {
 	struct vlan_hdr *vhdr;
 	unsigned short veth_TCI = 0;
@@ -613,7 +613,7 @@
 				dev_put(dev);
 				return 0;
 			} else {
-				printk(KERN_ERR  "%s: flag %i is not valid.\n",
+				printk(KERN_ERR	 "%s: flag %i is not valid.\n",
 					__FUNCTION__, (int)(flag));
 				dev_put(dev);
 				return -EINVAL;
@@ -625,13 +625,66 @@
 			dev_put(dev);
 		}
 	} else {
-		printk(KERN_ERR  "%s: Could not find device: %s\n",
+		printk(KERN_ERR	 "%s: Could not find device: %s\n",
 			__FUNCTION__, dev_name);
 	}
 
 	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);
@@ -671,7 +724,7 @@
 }
 
 static inline int vlan_dmi_equals(struct dev_mc_list *dmi1,
-                                  struct dev_mc_list *dmi2)
+				  struct dev_mc_list *dmi2)
 {
 	return ((dmi1->dmi_addrlen == dmi2->dmi_addrlen) &&
 		(memcmp(dmi1->dmi_addr, dmi2->dmi_addr, dmi1->dmi_addrlen) == 0));
net/8021q/vlan.c +60 -22

164 lines not on this page · raw message

net/8021q/vlan.h +2 -0
@@ -72,6 +72,8 @@
 int vlan_dev_set_ingress_priority(char* dev_name, __u32 skb_prio, short vlan_prio);
 int vlan_dev_set_egress_priority(char* dev_name, __u32 skb_prio, short vlan_prio);
 int vlan_dev_set_vlan_flag(char* dev_name, __u32 flag, short flag_val);
+int vlan_dev_get_realdev_name(const char* dev_name, char* result);
+int vlan_dev_get_vid(const char* dev_name, unsigned short* result);
 void vlan_dev_set_multicast_list(struct net_device *vlan_dev);
 
 #endif /* !(__BEN_VLAN_802_1Q_INC__) */
include/linux/if_vlan.h +3 -1
@@ -212,7 +212,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 {
Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#1 lore raw
Quoted 1 line · On Tue, 05 Aug 2003 21:15:00 -0700 Ben Greear <[email protected]> wrote:

Same as last time, but now using tabs instead of spaces.

I was about to apply this, then I noticed that you whitespace fixed the entire file.

Please don't do that, I want just your change not your change + whitespace cleanups. That makes it hard to figure out exactly what your patch actually does amongst all the whitespace changes.