From 48406ee5a12baf6c66c941c725ac60d796f3c66c Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 26 Apr 2018 09:33:17 +0200 Subject: [PATCH 1/7] fix xt_* calls on ubuntu 18.04 / linux 4.15 --- src/compat_xtables.h | 2 +- src/ts3init_match.c | 2 +- src/ts3init_target.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compat_xtables.h b/src/compat_xtables.h index 0972086..bfba112 100644 --- a/src/compat_xtables.h +++ b/src/compat_xtables.h @@ -90,7 +90,7 @@ static inline void proc_remove(struct proc_dir_entry *de) static inline struct net *par_net(const struct xt_action_param *par) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) - return par->net; + return xt_net(par); #else return dev_net((par->in != NULL) ? par->in : par->out); #endif diff --git a/src/ts3init_match.c b/src/ts3init_match.c index b17a513..87d35cc 100644 --- a/src/ts3init_match.c +++ b/src/ts3init_match.c @@ -141,7 +141,7 @@ static inline __u8* get_payload(const struct sk_buff *skb, const struct xt_actio static int calculate_cookie(const struct sk_buff *skb, const struct xt_action_param *par, struct udphdr *udp, __u64 k0, __u64 k1, __u64* out) { - switch (par->family) + switch (xt_family(par)) { case NFPROTO_IPV4: { diff --git a/src/ts3init_target.c b/src/ts3init_target.c index 88fe607..b66b861 100644 --- a/src/ts3init_target.c +++ b/src/ts3init_target.c @@ -47,7 +47,7 @@ ts3init_send_ipv6_reply(struct sk_buff *oldskb, const struct xt_action_param *pa struct udphdr *udp; struct flowi6 fl; struct dst_entry *dst = NULL; - struct net *net = dev_net((par->in != NULL) ? par->in : par->out); + struct net *net = dev_net((xt_in(par) != NULL) ? xt_in(par) : xt_out(par)); skb = alloc_skb(LL_MAX_HEADER + sizeof(*ip) + sizeof(*udp) + payload_size, GFP_ATOMIC); From 3624c9f26808881aa8c18b01ae26e49faaf8f685 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 26 Apr 2018 09:33:58 +0200 Subject: [PATCH 2/7] fix install on ubuntu 18.04 --- src/Makefile.xtables | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Makefile.xtables b/src/Makefile.xtables index e8babb8..d83a1eb 100644 --- a/src/Makefile.xtables +++ b/src/Makefile.xtables @@ -6,7 +6,11 @@ clean: rm -f $(LIBS) install: - install -g root -o root -m 644 $(LIBS) /lib/xtables/ + if [ -d /usr/lib/x86_64-linux-gnu/xtables ]; then \ + install -g root -o root -m 644 $(LIBS) /usr/lib/x86_64-linux-gnu/xtables; \ + else \ + install -g root -o root -m 644 $(LIBS) /lib/xtables/ ; \ + fi lib%.so: lib%.o gcc -shared -fPIC -o $@ $^; From 8ac7ef3a5f16b23e4a2eab4603ec2d476570c9d6 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 3 May 2018 10:13:14 +0200 Subject: [PATCH 3/7] fix installpath on stretch+bionic --- src/Makefile.xtables | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Makefile.xtables b/src/Makefile.xtables index d83a1eb..56a6e18 100644 --- a/src/Makefile.xtables +++ b/src/Makefile.xtables @@ -6,11 +6,16 @@ clean: rm -f $(LIBS) install: - if [ -d /usr/lib/x86_64-linux-gnu/xtables ]; then \ - install -g root -o root -m 644 $(LIBS) /usr/lib/x86_64-linux-gnu/xtables; \ - else \ - install -g root -o root -m 644 $(LIBS) /lib/xtables/ ; \ - fi + if [ -d /lib/xtables ]; then \ + install -g root -o root -m 644 $(LIBS) /lib/xtables/ ; \ + elif [ -d /usr/lib/x86_64-linux-gnu/xtables ]; then \ + install -g root -o root -m 644 $(LIBS) /usr/lib/x86_64-linux-gnu/xtables; \ + elif [ -d /usr/lib/i386-linux-gnu/xtables ]; then \ + install -g root -o root -m 644 $(LIBS) /usr/lib/i386-linux-gnu/xtables; \ + else \ + echo "Unable to find xtables modules path!" + exit 1 + fi lib%.so: lib%.o gcc -shared -fPIC -o $@ $^; From c1f62b56bd1fc0ed7d08b4ffed5de46844efd1c7 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 3 May 2018 10:19:16 +0200 Subject: [PATCH 4/7] wrap fixes for 4.10 in indef --- src/compat_xtables.h | 4 +++- src/ts3init_match.c | 4 ++++ src/ts3init_target.c | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compat_xtables.h b/src/compat_xtables.h index bfba112..0e86727 100644 --- a/src/compat_xtables.h +++ b/src/compat_xtables.h @@ -89,8 +89,10 @@ static inline void proc_remove(struct proc_dir_entry *de) static inline struct net *par_net(const struct xt_action_param *par) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) return xt_net(par); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) + return par->net; #else return dev_net((par->in != NULL) ? par->in : par->out); #endif diff --git a/src/ts3init_match.c b/src/ts3init_match.c index 87d35cc..1428f5e 100644 --- a/src/ts3init_match.c +++ b/src/ts3init_match.c @@ -141,7 +141,11 @@ static inline __u8* get_payload(const struct sk_buff *skb, const struct xt_actio static int calculate_cookie(const struct sk_buff *skb, const struct xt_action_param *par, struct udphdr *udp, __u64 k0, __u64 k1, __u64* out) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) switch (xt_family(par)) +#else + switch (par->family) +#endif { case NFPROTO_IPV4: { diff --git a/src/ts3init_target.c b/src/ts3init_target.c index b66b861..7f48371 100644 --- a/src/ts3init_target.c +++ b/src/ts3init_target.c @@ -47,7 +47,12 @@ ts3init_send_ipv6_reply(struct sk_buff *oldskb, const struct xt_action_param *pa struct udphdr *udp; struct flowi6 fl; struct dst_entry *dst = NULL; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0) struct net *net = dev_net((xt_in(par) != NULL) ? xt_in(par) : xt_out(par)); +#else + struct net *net = dev_net((par->in != NULL) ? par->in : par->out); +#endif skb = alloc_skb(LL_MAX_HEADER + sizeof(*ip) + sizeof(*udp) + payload_size, GFP_ATOMIC); From ecfa748fc654f4e1eb8fec2b942deced2d1ec187 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 3 May 2018 10:27:14 +0200 Subject: [PATCH 5/7] add include to support version check --- src/ts3init_target.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ts3init_target.c b/src/ts3init_target.c index 7f48371..674d140 100644 --- a/src/ts3init_target.c +++ b/src/ts3init_target.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include From 8cfe32f62490fe70f222d13d4de5f711c512d472 Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 3 May 2018 10:28:24 +0200 Subject: [PATCH 6/7] fix if as single command --- src/Makefile.xtables | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.xtables b/src/Makefile.xtables index 56a6e18..1d66a71 100644 --- a/src/Makefile.xtables +++ b/src/Makefile.xtables @@ -13,8 +13,8 @@ install: elif [ -d /usr/lib/i386-linux-gnu/xtables ]; then \ install -g root -o root -m 644 $(LIBS) /usr/lib/i386-linux-gnu/xtables; \ else \ - echo "Unable to find xtables modules path!" - exit 1 + echo "Unable to find xtables modules path!"; \ + exit 1; \ fi lib%.so: lib%.o From 5e0389f227f822930a232a41e71cd53dfd0b9edb Mon Sep 17 00:00:00 2001 From: Stefan Schwarz Date: Thu, 3 May 2018 11:03:36 +0200 Subject: [PATCH 7/7] add include to support version check --- src/ts3init_match.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ts3init_match.c b/src/ts3init_match.c index 1428f5e..cec6bb2 100644 --- a/src/ts3init_match.c +++ b/src/ts3init_match.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include