aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-06-29 19:06:22 -0600
committerDavid S. Miller <davem@davemloft.net>2020-06-30 12:29:39 -0700
commitb9815eb1d13f0dc088ee8afb6e6d0683ea551098 (patch)
treed6ec34f6b210969a919d03f8312fa3d814629f3c /drivers/net/tun.c
parentwireguard: queueing: make use of ip_tunnel_parse_protocol (diff)
downloadwireguard-linux-b9815eb1d13f0dc088ee8afb6e6d0683ea551098.tar.xz
wireguard-linux-b9815eb1d13f0dc088ee8afb6e6d0683ea551098.zip
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>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 858b012074bd..7adeb91bd368 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -62,6 +62,7 @@
#include <net/rtnetlink.h>
#include <net/sock.h>
#include <net/xdp.h>
+#include <net/ip_tunnels.h>
#include <linux/seq_file.h>
#include <linux/uio.h>
#include <linux/skb_array.h>
@@ -1351,6 +1352,7 @@ static void tun_net_init(struct net_device *dev)
switch (tun->flags & TUN_TYPE_MASK) {
case IFF_TUN:
dev->netdev_ops = &tun_netdev_ops;
+ dev->header_ops = &ip_tunnel_header_ops;
/* Point-to-Point TUN Device */
dev->hard_header_len = 0;