aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-06-26 23:46:15 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-06-26 23:49:14 -0600
commit40c24fd379edc1668087111506ed3d0928052fe0 (patch)
treea48fd5f3fffd18c296e42458b554ff65e5afb38f
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (diff)
downloadwireguard-linux-jd/skbprotocol-no-headerops.tar.xz
wireguard-linux-jd/skbprotocol-no-headerops.zip
wireguard: device: fill in skb->protocol for zero casejd/skbprotocol-no-headerops
One way to handle AF_PACKET would be to implement header_ops->parse_protocol, which AF_PACKET calls via: packet_sendmsg -> packet_snd -> packet_parse_headers -> dev_parse_header_protocol -> parse_protocol This works, but it seems like various other behavior changes simply on the basis of whether or not dev->header_ops == NULL or not. It's easier, therefore, to just fill in skb->protocol when it's zero inside the xmit function, and not change the packet flow otherwise. So this commit checks for skb->protocol==0, and sets it in that case. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--drivers/net/wireguard/device.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c
index a8f151b1b5fa..e3777bfc7dc3 100644
--- a/drivers/net/wireguard/device.c
+++ b/drivers/net/wireguard/device.c
@@ -123,6 +123,8 @@ static netdev_tx_t wg_xmit(struct sk_buff *skb, struct net_device *dev)
u32 mtu;
int ret;
+ if (unlikely(!skb->protocol))
+ skb->protocol = wg_examine_packet_protocol(skb);
if (unlikely(!wg_check_packet_protocol(skb))) {
ret = -EPROTONOSUPPORT;
net_dbg_ratelimited("%s: Invalid IP packet\n", dev->name);