[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AE5CAC6.4000604@gmail.com>
Date: Mon, 26 Oct 2009 17:13:58 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: unlisted-recipients:; (no To-header on input)
CC: Benny Amorsen <benny+usenet@...rsen.dk>,
Gertjan Hofman <gertjan_hofman@...oo.com>,
Matt Carlson <mcarlson@...adcom.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Patrick McHardy <kaber@...sh.net>,
"David S. Miller" <davem@...emloft.net>
Subject: [PATCH] vlan: allow VLAN ID 0 to be used
Eric Dumazet a écrit :
> VLAN id 0 is not usable on current kernel because we use 16 bits in skb to
> store vlan_tci, and vlan_tci = 0 means there is no VLAN tagging.
>
>
> We could use high order bit (0x8000) to tell if vlan tagging is set or not.
>
Here is the patch I cooked that permitted VLAN 0 to be used with tg3
(and other HW accelerated vlan nics I suppose)
[PATCH] vlan: allow VLAN ID 0 to be used
We currently use a 16 bit field (vlan_tci) to store VLAN ID on a skb.
0 value is used a special value, meaning VLAN ID not set.
This forbids use of VLAN ID 0
As VLAN ID is 12 bits, we can use high order bit as a flag, and
allow VLAN ID 0
Reported-by: Gertjan Hofman <gertjan_hofman@...oo.com>
Signed-off-by: Eric Dumazet <eric.dumazet@...il.com>
---
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 7ff9af1..7dfcdb5 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -105,8 +105,9 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
}
-#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci)
-#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci)
+#define VLAN_TAG_PRESENT 0x8000
+#define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
+#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & 0x7fff)
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
@@ -231,7 +232,7 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
u16 vlan_tci)
{
- skb->vlan_tci = vlan_tci;
+ skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci;
return skb;
}
@@ -284,7 +285,7 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
u16 *vlan_tci)
{
if (vlan_tx_tag_present(skb)) {
- *vlan_tci = skb->vlan_tci;
+ *vlan_tci = vlan_tx_tag_get(skb);
return 0;
} else {
*vlan_tci = 0;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists