aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-10-26 21:40:35 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-27 04:02:33 -0400
commit05423b241311c9380b7280179295bac7794281b6 (patch)
tree8a84aca48cbc30b142bdf143dbf11fdbab9cad67 /net/packet
parent9dbb58d867e90d2528752339751216c955523e62 (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 'net/packet')
-rw-r--r--net/packet/af_packet.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ff752c606413..33e68f20ec61 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -79,6 +79,7 @@
79#include <linux/module.h> 79#include <linux/module.h>
80#include <linux/init.h> 80#include <linux/init.h>
81#include <linux/mutex.h> 81#include <linux/mutex.h>
82#include <linux/if_vlan.h>
82 83
83#ifdef CONFIG_INET 84#ifdef CONFIG_INET
84#include <net/inet_common.h> 85#include <net/inet_common.h>
@@ -766,7 +767,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
766 getnstimeofday(&ts); 767 getnstimeofday(&ts);
767 h.h2->tp_sec = ts.tv_sec; 768 h.h2->tp_sec = ts.tv_sec;
768 h.h2->tp_nsec = ts.tv_nsec; 769 h.h2->tp_nsec = ts.tv_nsec;
769 h.h2->tp_vlan_tci = skb->vlan_tci; 770 h.h2->tp_vlan_tci = vlan_tx_tag_get(skb);
770 hdrlen = sizeof(*h.h2); 771 hdrlen = sizeof(*h.h2);
771 break; 772 break;
772 default: 773 default:
@@ -1493,7 +1494,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
1493 aux.tp_snaplen = skb->len; 1494 aux.tp_snaplen = skb->len;
1494 aux.tp_mac = 0; 1495 aux.tp_mac = 0;
1495 aux.tp_net = skb_network_offset(skb); 1496 aux.tp_net = skb_network_offset(skb);
1496 aux.tp_vlan_tci = skb->vlan_tci; 1497 aux.tp_vlan_tci = vlan_tx_tag_get(skb);
1497 1498
1498 put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); 1499 put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
1499 } 1500 }