diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-10-26 21:40:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-27 04:02:33 -0400 |
commit | 05423b241311c9380b7280179295bac7794281b6 (patch) | |
tree | 8a84aca48cbc30b142bdf143dbf11fdbab9cad67 /include/linux/if_vlan.h | |
parent | 9dbb58d867e90d2528752339751216c955523e62 (diff) |
vlan: allow null VLAN ID to be used
We currently use a 16 bit field (vlan_tci) to store VLAN ID/PRIO on a skb.
Null value is used as a special value, meaning vlan tagging not enabled.
This forbids use of null vlan ID.
As pointed by David, some drivers use the 3 high order bits (PRIO)
As VLAN ID is 12 bits, we can use the remaining bit (CFI) as a flag, and
allow null VLAN ID.
In case future code really wants to use VLAN_CFI_MASK, we'll have to use
a bit outside of vlan_tci.
#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */
#define VLAN_PRIO_SHIFT 13
#define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator */
#define VLAN_TAG_PRESENT VLAN_CFI_MASK
#define VLAN_VID_MASK 0x0fff /* VLAN Identifier */
Reported-by: Gertjan Hofman <gertjan_hofman@yahoo.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/if_vlan.h')
-rw-r--r-- | include/linux/if_vlan.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 7ff9af1d0f05..8898cbebcf34 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h | |||
@@ -63,7 +63,11 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb) | |||
63 | return (struct vlan_ethhdr *)skb_mac_header(skb); | 63 | return (struct vlan_ethhdr *)skb_mac_header(skb); |
64 | } | 64 | } |
65 | 65 | ||
66 | #define VLAN_VID_MASK 0xfff | 66 | #define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */ |
67 | #define VLAN_PRIO_SHIFT 13 | ||
68 | #define VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator */ | ||
69 | #define VLAN_TAG_PRESENT VLAN_CFI_MASK | ||
70 | #define VLAN_VID_MASK 0x0fff /* VLAN Identifier */ | ||
67 | 71 | ||
68 | /* found in socket.c */ | 72 | /* found in socket.c */ |
69 | extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); | 73 | extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); |
@@ -105,8 +109,8 @@ static inline void vlan_group_set_device(struct vlan_group *vg, | |||
105 | array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; | 109 | array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; |
106 | } | 110 | } |
107 | 111 | ||
108 | #define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci) | 112 | #define vlan_tx_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) |
109 | #define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci) | 113 | #define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) |
110 | 114 | ||
111 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 115 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
112 | extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); | 116 | extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); |
@@ -231,7 +235,7 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) | |||
231 | static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, | 235 | static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, |
232 | u16 vlan_tci) | 236 | u16 vlan_tci) |
233 | { | 237 | { |
234 | skb->vlan_tci = vlan_tci; | 238 | skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci; |
235 | return skb; | 239 | return skb; |
236 | } | 240 | } |
237 | 241 | ||
@@ -284,7 +288,7 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb, | |||
284 | u16 *vlan_tci) | 288 | u16 *vlan_tci) |
285 | { | 289 | { |
286 | if (vlan_tx_tag_present(skb)) { | 290 | if (vlan_tx_tag_present(skb)) { |
287 | *vlan_tci = skb->vlan_tci; | 291 | *vlan_tci = vlan_tx_tag_get(skb); |
288 | return 0; | 292 | return 0; |
289 | } else { | 293 | } else { |
290 | *vlan_tci = 0; | 294 | *vlan_tci = 0; |