summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-12-26 16:34:53 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-12-26 19:32:30 +0100
commit5b5f6d8686eee808dd15009a04b2e9ab25b92096 (patch)
tree2c115fa7aeccf633d50611d8cf8edc27fd5a9cc4
parentblake2s: cleanup (diff)
downloadwireguard-monolithic-historical-5b5f6d8686eee808dd15009a04b2e9ab25b92096.tar.xz
wireguard-monolithic-historical-5b5f6d8686eee808dd15009a04b2e9ab25b92096.zip
compat: support 3.18, 3.19, 4.0
-rw-r--r--src/compat.h31
-rw-r--r--src/dkms.conf4
-rwxr-xr-xsrc/tests/netns.sh2
-rw-r--r--src/tests/qemu/Makefile4
4 files changed, 33 insertions, 8 deletions
diff --git a/src/compat.h b/src/compat.h
index eb4f31b..ca180e0 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -7,8 +7,8 @@
#include <linux/version.h>
#include <linux/types.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-#error "WireGuard requires Linux >= 4.1"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
+#error "WireGuard requires Linux >= 3.18"
#endif
/* These conditionals can't be enforced by an out of tree module very easily,
@@ -29,6 +29,29 @@
#define RCU_LOCKDEP_WARN(cond, message) rcu_lockdep_assert(!(cond), message)
#endif
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 6)) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 12)
+#define dev_recursion_level() 0
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
+#include <linux/if.h>
+#include <net/udp_tunnel.h>
+#define udp_tunnel_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { struct net_device *dev__ = (c)->dev; int ret__; ret__ = udp_tunnel_xmit_skb((b)->sk_socket, a, c, d, e, f, g, h, i, j, k); iptunnel_xmit_stats(ret__, &dev__->stats, dev__->tstats); } while (0)
+#if IS_ENABLED(CONFIG_IPV6)
+#define udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) udp_tunnel6_xmit_skb((b)->sk_socket, a, c, d, e, f, g, h, j, k);
+#endif
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
+#include <linux/if.h>
+#include <net/udp_tunnel.h>
+static inline void fake_destructor(struct sk_buff *skb)
+{
+}
+#define udp_tunnel_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { struct net_device *dev__ = (c)->dev; int ret__; (c)->destructor = fake_destructor; (c)->sk = (b); ret__ = udp_tunnel_xmit_skb(a, c, d, e, f, g, h, i, j, k, l); iptunnel_xmit_stats(ret__, &dev__->stats, dev__->tstats); } while (0)
+#if IS_ENABLED(CONFIG_IPV6)
+#define udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { (c)->destructor = fake_destructor; (c)->sk = (b); udp_tunnel6_xmit_skb(a, c, d, e, f, g, h, j, k, l); } while(0)
+#endif
+#else
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
#include <linux/if.h>
#include <net/udp_tunnel.h>
@@ -41,6 +64,8 @@
#define udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, j, k, l)
#endif
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
#include <linux/if.h>
#include <net/udp_tunnel.h>
@@ -117,7 +142,7 @@ __attribute__((unused)) static inline int udp_sock_create_new(struct net *net, s
#define ipv6_dst_lookup(a, b, c, d) ipv6_dst_lookup(b, c, d)
#endif
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 5) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 17)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 5) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 17) && LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 27)
#define IP6_ECN_set_ce(a, b) IP6_ECN_set_ce(b)
#endif
diff --git a/src/dkms.conf b/src/dkms.conf
index d8a27c5..5a500be 100644
--- a/src/dkms.conf
+++ b/src/dkms.conf
@@ -5,5 +5,5 @@ AUTOINSTALL=yes
BUILT_MODULE_NAME="wireguard"
DEST_MODULE_LOCATION="/kernel/net"
-# requires kernel 4.1 or greater:
-BUILD_EXCLUSIVE_KERNEL="^(4\.[^0]|[5-9])"
+# requires kernel 3.18 or greater:
+BUILD_EXCLUSIVE_KERNEL="^(([^1230]\.)|(3\.18)|(3\.19))"
diff --git a/src/tests/netns.sh b/src/tests/netns.sh
index f17a3ef..6d20c1b 100755
--- a/src/tests/netns.sh
+++ b/src/tests/netns.sh
@@ -39,7 +39,7 @@ ip2() { pretty 2 "ip $*"; ip -n $netns2 "$@"; }
sleep() { read -t "$1" -N 0 || true; }
waitiperf() { pretty "${1//*-}" "wait for iperf:5201"; while [[ $(ss -N "$1" -tlp 'sport = 5201') != *iperf3* ]]; do sleep 0.1; done; }
waitncatudp() { pretty "${1//*-}" "wait for udp:1111"; while [[ $(ss -N "$1" -ulp 'sport = 1111') != *ncat* ]]; do sleep 0.1; done; }
-waitiface() { pretty "${1//*-}" "wait for $2 to come up"; ip netns exec "$1" bash -c "while [[ \$(< \"/sys/class/net/$2/operstate\") != up ]]; do read -t .1 -N 0; done;"; }
+waitiface() { pretty "${1//*-}" "wait for $2 to come up"; ip netns exec "$1" bash -c "while [[ \$(< \"/sys/class/net/$2/operstate\") != up ]]; do read -t .1 -N 0 || true; done;"; }
cleanup() {
set +e
diff --git a/src/tests/qemu/Makefile b/src/tests/qemu/Makefile
index 140def6..aad4557 100644
--- a/src/tests/qemu/Makefile
+++ b/src/tests/qemu/Makefile
@@ -35,9 +35,9 @@ $(DISTFILES_PATH)/$(1):
endef
ifeq ($(findstring -rc,$(KERNEL_VERSION)),)
-KERNEL_URL_DIRECTORY := https://cdn.kernel.org/pub/linux/kernel/v4.x/
+KERNEL_URL_DIRECTORY := https://cdn.kernel.org/pub/linux/kernel/v$(firstword $(subst ., ,$(KERNEL_VERSION))).x/
else
-KERNEL_URL_DIRECTORY := https://cdn.kernel.org/pub/linux/kernel/v4.x/testing/
+KERNEL_URL_DIRECTORY := https://cdn.kernel.org/pub/linux/kernel/v$(firstword $(subst ., ,$(KERNEL_VERSION))).x/testing/
endif
$(eval $(call tar_download,KERNEL,linux,$(KERNEL_VERSION),.tar.xz,$(KERNEL_URL_DIRECTORY)))