Skip to content

Commit 393e52e

Browse files
kaberdavem330
authored andcommitted
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: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bbd6ef8 commit 393e52e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

include/linux/if_packet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct tpacket_auxdata
5959
__u32 tp_snaplen;
6060
__u16 tp_mac;
6161
__u16 tp_net;
62+
__u16 tp_vlan_tci;
6263
};
6364

6465
struct tpacket_hdr
@@ -90,6 +91,7 @@ struct tpacket2_hdr
9091
__u16 tp_net;
9192
__u32 tp_sec;
9293
__u32 tp_nsec;
94+
__u16 tp_vlan_tci;
9395
};
9496

9597
#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))

net/packet/af_packet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
702702
getnstimeofday(&ts);
703703
h.h2->tp_sec = ts.tv_sec;
704704
h.h2->tp_nsec = ts.tv_nsec;
705+
h.h2->tp_vlan_tci = skb->vlan_tci;
705706
hdrlen = sizeof(*h.h2);
706707
break;
707708
default:
@@ -1172,6 +1173,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
11721173
aux.tp_snaplen = skb->len;
11731174
aux.tp_mac = 0;
11741175
aux.tp_net = skb_network_offset(skb);
1176+
aux.tp_vlan_tci = skb->vlan_tci;
11751177

11761178
put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux);
11771179
}

0 commit comments

Comments
 (0)