From 9660ee0e246d5e9c6fa4e599cb7019e21c862c55 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 9 Apr 2017 13:44:27 +0200 Subject: compat: careful with destructors --- src/compat/udp_tunnel/udp_tunnel.c | 8 ++++---- src/compat/udp_tunnel/udp_tunnel_partial_compat.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/compat/udp_tunnel') 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 #include -#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 -- cgit v1.2.3-59-g8ed1b