aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat/udp_tunnel
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-04-09 13:44:27 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-04-09 14:24:12 +0200
commit9660ee0e246d5e9c6fa4e599cb7019e21c862c55 (patch)
tree1681250e6c1627e4dd0d5e65581339818f960fb0 /src/compat/udp_tunnel
parentcompat: support 3.10 (diff)
downloadwireguard-monolithic-historical-9660ee0e246d5e9c6fa4e599cb7019e21c862c55.tar.xz
wireguard-monolithic-historical-9660ee0e246d5e9c6fa4e599cb7019e21c862c55.zip
compat: careful with destructors
Diffstat (limited to 'src/compat/udp_tunnel')
-rw-r--r--src/compat/udp_tunnel/udp_tunnel.c8
-rw-r--r--src/compat/udp_tunnel/udp_tunnel_partial_compat.h6
2 files changed, 7 insertions, 7 deletions
diff --git a/src/compat/udp_tunnel/udp_tunnel.c b/src/compat/udp_tunnel/udp_tunnel.c
index 2c60681..d1286c0 100644
--- a/src/compat/udp_tunnel/udp_tunnel.c
+++ b/src/compat/udp_tunnel/udp_tunnel.c
@@ -193,10 +193,10 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb
udp_set_csum(nocheck, skb, src, dst, skb->len);
- if (!skb->sk) {
+ if (!skb->sk)
skb->sk = sk;
+ if (!skb->destructor)
skb->destructor = fake_destructor;
- }
iptunnel_xmit(
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
@@ -366,10 +366,10 @@ int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
ip6h->daddr = *daddr;
ip6h->saddr = *saddr;
- if (!skb->sk) {
+ if (!skb->sk)
skb->sk = sk;
+ if (!skb->destructor)
skb->destructor = fake_destructor;
- }
ip6tunnel_xmit(skb, dev);
return 0;
diff --git a/src/compat/udp_tunnel/udp_tunnel_partial_compat.h b/src/compat/udp_tunnel/udp_tunnel_partial_compat.h
index 53ee6c3..c927628 100644
--- a/src/compat/udp_tunnel/udp_tunnel_partial_compat.h
+++ b/src/compat/udp_tunnel/udp_tunnel_partial_compat.h
@@ -116,14 +116,14 @@ static inline int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *ds
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
#include <linux/if.h>
#include <net/udp_tunnel.h>
-#if LINUX_VERISON_CODE >= KERNEL_VERSION(3, 18, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
static inline void fake_destructor(struct sk_buff *skb)
{
}
#endif
-#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)
+#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__; if (!(c)->destructor) (c)->destructor = fake_destructor; if (!(c)->sk) (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)
+#define udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { if (!(c)->destructor) (c)->destructor = fake_destructor; if (!(c)->sk) (c)->sk = (b); udp_tunnel6_xmit_skb(a, c, d, e, f, g, h, j, k, l); } while(0)
#endif
#else