1 From cf413ab742788eeb47e789934d492bb546aa4aa8 Mon Sep 17 00:00:00 2001
2 From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3 Date: Mon, 29 Jun 2020 19:06:20 -0600
4 Subject: [PATCH 111/124] wireguard: implement header_ops->parse_protocol for
7 commit 01a4967c71c004f8ecad4ab57021348636502fa9 upstream.
9 WireGuard uses skb->protocol to determine packet type, and bails out if
10 it's not set or set to something it's not expecting. For AF_PACKET
11 injection, we need to support its call chain of:
13 packet_sendmsg -> packet_snd -> packet_parse_headers ->
14 dev_parse_header_protocol -> parse_protocol
16 Without a valid parse_protocol, this returns zero, and wireguard then
17 rejects the skb. So, this wires up the ip_tunnel handler for layer 3
18 packets for that case.
20 Reported-by: Hans Wippel <ndev@hwipl.net>
21 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
22 Signed-off-by: David S. Miller <davem@davemloft.net>
23 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
25 drivers/net/wireguard/device.c | 1 +
26 1 file changed, 1 insertion(+)
28 --- a/drivers/net/wireguard/device.c
29 +++ b/drivers/net/wireguard/device.c
30 @@ -262,6 +262,7 @@ static void wg_setup(struct net_device *
31 max(sizeof(struct ipv6hdr), sizeof(struct iphdr));
33 dev->netdev_ops = &netdev_ops;
34 + dev->header_ops = &ip_tunnel_header_ops;
35 dev->hard_header_len = 0;
37 dev->needed_headroom = DATA_PACKET_HEAD_ROOM;