4cc67a72a6d710735bd56076de5eceb05f4f0039
[openwrt/staging/mans0n.git] /
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
5 AF_PACKET
6
7 commit 01a4967c71c004f8ecad4ab57021348636502fa9 upstream.
8
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:
12
13 packet_sendmsg -> packet_snd -> packet_parse_headers ->
14 dev_parse_header_protocol -> parse_protocol
15
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.
19
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>
24 ---
25 drivers/net/wireguard/device.c | 1 +
26 1 file changed, 1 insertion(+)
27
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));
32
33 dev->netdev_ops = &netdev_ops;
34 + dev->header_ops = &ip_tunnel_header_ops;
35 dev->hard_header_len = 0;
36 dev->addr_len = 0;
37 dev->needed_headroom = DATA_PACKET_HEAD_ROOM;