2021-03-02 08:24:45 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
kernel: 5.4: import wireguard backport
Rather than using the clunky, old, slower wireguard-linux-compat out of
tree module, this commit does a patch-by-patch backport of upstream's
wireguard to 5.4. This specific backport is in widespread use, being
part of SUSE's enterprise kernel, Oracle's enterprise kernel, Google's
Android kernel, Gentoo's distro kernel, and probably more I've forgotten
about. It's definately the "more proper" way of adding wireguard to a
kernel than the ugly compat.h hell of the wireguard-linux-compat repo.
And most importantly for OpenWRT, it allows using the same module
configuration code for 5.10 as for 5.4, with no need for bifurcation.
These patches are from the backport tree which is maintained in the
open here: https://git.zx2c4.com/wireguard-linux/log/?h=backport-5.4.y
I'll be sending PRs to update this as needed.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-19 13:29:04 +00:00
|
|
|
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
|
|
|
Date: Mon, 29 Jun 2020 19:06:18 -0600
|
2021-03-02 08:24:45 +00:00
|
|
|
Subject: [PATCH] net: ip_tunnel: add header_ops for layer 3 devices
|
kernel: 5.4: import wireguard backport
Rather than using the clunky, old, slower wireguard-linux-compat out of
tree module, this commit does a patch-by-patch backport of upstream's
wireguard to 5.4. This specific backport is in widespread use, being
part of SUSE's enterprise kernel, Oracle's enterprise kernel, Google's
Android kernel, Gentoo's distro kernel, and probably more I've forgotten
about. It's definately the "more proper" way of adding wireguard to a
kernel than the ugly compat.h hell of the wireguard-linux-compat repo.
And most importantly for OpenWRT, it allows using the same module
configuration code for 5.10 as for 5.4, with no need for bifurcation.
These patches are from the backport tree which is maintained in the
open here: https://git.zx2c4.com/wireguard-linux/log/?h=backport-5.4.y
I'll be sending PRs to update this as needed.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-19 13:29:04 +00:00
|
|
|
|
|
|
|
commit 2606aff916854b61234bf85001be9777bab2d5f8 upstream.
|
|
|
|
|
|
|
|
Some devices that take straight up layer 3 packets benefit from having a
|
|
|
|
shared header_ops so that AF_PACKET sockets can inject packets that are
|
|
|
|
recognized. This shared infrastructure will be used by other drivers
|
|
|
|
that currently can't inject packets using AF_PACKET. It also exposes the
|
|
|
|
parser function, as it is useful in standalone form too.
|
|
|
|
|
|
|
|
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
|
|
|
Acked-by: Willem de Bruijn <willemb@google.com>
|
|
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
|
|
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
|
|
|
---
|
|
|
|
include/net/ip_tunnels.h | 3 +++
|
|
|
|
net/ipv4/ip_tunnel_core.c | 18 ++++++++++++++++++
|
|
|
|
2 files changed, 21 insertions(+)
|
|
|
|
|
|
|
|
--- a/include/net/ip_tunnels.h
|
|
|
|
+++ b/include/net/ip_tunnels.h
|
|
|
|
@@ -289,6 +289,9 @@ int ip_tunnel_newlink(struct net_device
|
|
|
|
struct ip_tunnel_parm *p, __u32 fwmark);
|
|
|
|
void ip_tunnel_setup(struct net_device *dev, unsigned int net_id);
|
|
|
|
|
|
|
|
+extern const struct header_ops ip_tunnel_header_ops;
|
|
|
|
+__be16 ip_tunnel_parse_protocol(const struct sk_buff *skb);
|
|
|
|
+
|
|
|
|
struct ip_tunnel_encap_ops {
|
|
|
|
size_t (*encap_hlen)(struct ip_tunnel_encap *e);
|
|
|
|
int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e,
|
|
|
|
--- a/net/ipv4/ip_tunnel_core.c
|
|
|
|
+++ b/net/ipv4/ip_tunnel_core.c
|
|
|
|
@@ -446,3 +446,21 @@ void ip_tunnel_unneed_metadata(void)
|
|
|
|
static_branch_dec(&ip_tunnel_metadata_cnt);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(ip_tunnel_unneed_metadata);
|
|
|
|
+
|
|
|
|
+/* Returns either the correct skb->protocol value, or 0 if invalid. */
|
|
|
|
+__be16 ip_tunnel_parse_protocol(const struct sk_buff *skb)
|
|
|
|
+{
|
|
|
|
+ if (skb_network_header(skb) >= skb->head &&
|
|
|
|
+ (skb_network_header(skb) + sizeof(struct iphdr)) <= skb_tail_pointer(skb) &&
|
|
|
|
+ ip_hdr(skb)->version == 4)
|
|
|
|
+ return htons(ETH_P_IP);
|
|
|
|
+ if (skb_network_header(skb) >= skb->head &&
|
|
|
|
+ (skb_network_header(skb) + sizeof(struct ipv6hdr)) <= skb_tail_pointer(skb) &&
|
|
|
|
+ ipv6_hdr(skb)->version == 6)
|
|
|
|
+ return htons(ETH_P_IPV6);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(ip_tunnel_parse_protocol);
|
|
|
|
+
|
|
|
|
+const struct header_ops ip_tunnel_header_ops = { .parse_protocol = ip_tunnel_parse_protocol };
|
|
|
|
+EXPORT_SYMBOL(ip_tunnel_header_ops);
|