Commit 393e52e3 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

packet: deliver VLAN TCI to userspace

Store the VLAN tag in the auxillary data/tpacket2_hdr so userspace can
properly deal with hardware VLAN tagging/stripping.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bbd6ef87
...@@ -59,6 +59,7 @@ struct tpacket_auxdata ...@@ -59,6 +59,7 @@ struct tpacket_auxdata
__u32 tp_snaplen; __u32 tp_snaplen;
__u16 tp_mac; __u16 tp_mac;
__u16 tp_net; __u16 tp_net;
__u16 tp_vlan_tci;
}; };
struct tpacket_hdr struct tpacket_hdr
...@@ -90,6 +91,7 @@ struct tpacket2_hdr ...@@ -90,6 +91,7 @@ struct tpacket2_hdr
__u16 tp_net; __u16 tp_net;
__u32 tp_sec; __u32 tp_sec;
__u32 tp_nsec; __u32 tp_nsec;
__u16 tp_vlan_tci;
}; };
#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll)) #define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
......
...@@ -702,6 +702,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe ...@@ -702,6 +702,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
getnstimeofday(&ts); getnstimeofday(&ts);
h.h2->tp_sec = ts.tv_sec; h.h2->tp_sec = ts.tv_sec;
h.h2->tp_nsec = ts.tv_nsec; h.h2->tp_nsec = ts.tv_nsec;
h.h2->tp_vlan_tci = skb->vlan_tci;
hdrlen = sizeof(*h.h2); hdrlen = sizeof(*h.h2);
break; break;
default: default:
...@@ -1172,6 +1173,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1172,6 +1173,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
aux.tp_snaplen = skb->len; aux.tp_snaplen = skb->len;
aux.tp_mac = 0; aux.tp_mac = 0;
aux.tp_net = skb_network_offset(skb); aux.tp_net = skb_network_offset(skb);
aux.tp_vlan_tci = skb->vlan_tci;
put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment