tun: implement header_ops->parse_protocol for AF_PACKET
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 30 Jun 2020 01:06:22 +0000 (19:06 -0600)
committerDavid S. Miller <davem@davemloft.net>
Tue, 30 Jun 2020 19:29:39 +0000 (12:29 -0700)
commitb9815eb1d13f0dc088ee8afb6e6d0683ea551098
treed6ec34f6b210969a919d03f8312fa3d814629f3c
parent1a574074ae7d1d745c16f7710655f38a53174c27
tun: implement header_ops->parse_protocol for AF_PACKET

The tun driver passes up skb->protocol to userspace in the form of PI headers.
For AF_PACKET injection, we need to support its call chain of:

    packet_sendmsg -> packet_snd -> packet_parse_headers ->
      dev_parse_header_protocol -> parse_protocol

Without a valid parse_protocol, this returns zero, and the tun driver
then gives userspace bogus values that it can't deal with.

Note that this isn't the case with tap, because tap already benefits
from the shared infrastructure for ethernet headers. But with tun,
there's nothing.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c