[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTimg9hAq_ZeCLV1sM830z8T_yZ_-+cVUnYBEfk+M@mail.gmail.com>
Date: Thu, 24 Mar 2011 14:11:30 -0500
From: Andrew Strohman <astrohman@...plexinvestments.com>
To: netdev@...r.kernel.org
Subject: vlan_get_tag()
Hello,
Lately, I was messing around with the linux kernel code, and I wanted
to look up the Vlan ID for a given sk_buff. Instead of manually
pulling the ID out of the sk_buff object, I used this in
linux/include/linux/if_vlan.h
/**
327 * vlan_get_tag - get the VLAN ID from the skb
328 * @skb: skbuff to query
329 * @vlan_tci: buffer to store vlaue
330 *
331 * Returns error if the skb is not VLAN tagged
332 */
333static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
334{
335 if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
336 return __vlan_hwaccel_get_tag(skb, vlan_tci);
337 } else {
338 return __vlan_get_tag(skb, vlan_tci);
339 }
340}
Everything worked fine until I change the CoS value of my packets, and
then all the sudden the VLAN IDs that where returned from this
function were wrong. I believe I see why:
/**
306 * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
307 * @skb: skbuff to query
308 * @vlan_tci: buffer to store vlaue
309 *
310 * Returns error if @skb->vlan_tci is not set correctly
311 */
312static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
313 u16 *vlan_tci)
314{
315 if (vlan_tx_tag_present(skb)) {
316 *vlan_tci = vlan_tx_tag_get(skb);
317 return 0;
318 } else {
319 *vlan_tci = 0;
320 return -EINVAL;
321 }
322}
#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
#define VLAN_TAG_PRESENT VLAN_CFI_MASK
#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator */
So, to me it seems like this function really returns the entire tci
with the CFI bit zeroed out, not the VLAN ID. Perhaps, instead of
doing: ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT), it should do
((__skb)->vlan_tci & VLAN_VID_MASK)?
Andy
--
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