Subject: Transmit VLAN with AF_PACKET

From: Stephen Hemminger <[email-masked]>
Date: Wed, 12 Jun 2019 08:10:07 -0700

Sending VLAN packets through AF_PACKET over Hyper-V netvsc driver doesn't work now.
The question is what is best option for fixing it?

AF_PACKET handles VLAN stripping on receive, but there currently is no mechanism
for VLAN offload on transmit. Instead an application may form a raw packet with
a VLAN header and inject it into the kernel. This works fine for most drivers.

The problem is that in order to send a VLAN packet through Hyper-V, the VLAN
tag must be stripped and placed in the NDIS meta data. If the VLAN header is
inline in the packet it gets dropped by the vswitch rules as an invalid packet.

There a several options for fixing this and would like some consensus.

Option #1: Add code in netvsc transmit to look at packet and do a
VLAN pop if necessary before doing the normal VLAN tag handling on
transmit.

Option #2: Do a generic solution in AF_PACKET so that if application
sends a packet with VLAN header, it gets popped and inserted into skb.

Option #3: Add new tpacket header on transmit to match the Rx VLAN
tag strip on receive.