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>
This commit is contained in:

committed by
David S. Miller

parent
9dbb58d867
commit
05423b2413
@@ -79,6 +79,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/if_vlan.h>
|
||||
|
||||
#ifdef CONFIG_INET
|
||||
#include <net/inet_common.h>
|
||||
@@ -766,7 +767,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
getnstimeofday(&ts);
|
||||
h.h2->tp_sec = ts.tv_sec;
|
||||
h.h2->tp_nsec = ts.tv_nsec;
|
||||
h.h2->tp_vlan_tci = skb->vlan_tci;
|
||||
h.h2->tp_vlan_tci = vlan_tx_tag_get(skb);
|
||||
hdrlen = sizeof(*h.h2);
|
||||
break;
|
||||
default:
|
||||
@@ -1493,7 +1494,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
|
||||
aux.tp_snaplen = skb->len;
|
||||
aux.tp_mac = 0;
|
||||
aux.tp_net = skb_network_offset(skb);
|
||||
aux.tp_vlan_tci = skb->vlan_tci;
|
||||
aux.tp_vlan_tci = vlan_tx_tag_get(skb);
|
||||
|
||||
put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
|
||||
}
|
||||
|
Reference in New Issue
Block a user