Chion82 / netfilter-full-cone-nat

A kernel module to turn MASQUERADE into full cone SNAT
GNU General Public License v2.0
427 stars 121 forks source link

Kernel 4.18 编译错误 #17

Closed love4taylor closed 6 years ago

love4taylor commented 6 years ago
DKMS make.log for netfilter-full-cone-nat-0.1 for kernel 4.18.0-trunk-amd64 (x86_64)
Mon Sep  3 09:15:53 CST 2018
make[1]: Entering directory '/var/lib/dkms/netfilter-full-cone-nat/0.1/build'
make -C ipt
make[2]: Entering directory '/var/lib/dkms/netfilter-full-cone-nat/0.1/build/ipt'
cc -I../src -fPIC   -c -o libipt_FULLCONENAT.o libipt_FULLCONENAT.c
cc -shared -o libipt_FULLCONENAT.so libipt_FULLCONENAT.o;
rm libipt_FULLCONENAT.o
make[2]: Leaving directory '/var/lib/dkms/netfilter-full-cone-nat/0.1/build/ipt'
make -C src
make[2]: Entering directory '/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src'
make -C /lib/modules/4.18.0-trunk-amd64/build SUBDIRS=/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src modules
make[3]: Entering directory '/usr/src/linux-headers-4.18.0-trunk-amd64'
  CC [M]  /var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.o
/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.c: In function ‘fullconenat_tg’:
/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.c:540:35: error: passing argument 2 of ‘nf_nat_setup_info’ from incompatible pointer type [-Werror=incompatible-pointer-types]
       ret = nf_nat_setup_info(ct, &newrange, HOOK2MANIP(xt_hooknum(par)));
                                   ^
In file included from /var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.c:24:0:
/usr/src/linux-headers-4.18.0-trunk-common/include/net/netfilter/nf_nat.h:41:14: note: expected ‘const struct nf_nat_range2 *’ but argument is of type ‘struct nf_nat_range *’
 unsigned int nf_nat_setup_info(struct nf_conn *ct,
              ^~~~~~~~~~~~~~~~~
/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.c:594:33: error: passing argument 2 of ‘nf_nat_setup_info’ from incompatible pointer type [-Werror=incompatible-pointer-types]
     ret = nf_nat_setup_info(ct, &newrange, HOOK2MANIP(xt_hooknum(par)));
                                 ^
In file included from /var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.c:24:0:
/usr/src/linux-headers-4.18.0-trunk-common/include/net/netfilter/nf_nat.h:41:14: note: expected ‘const struct nf_nat_range2 *’ but argument is of type ‘struct nf_nat_range *’
 unsigned int nf_nat_setup_info(struct nf_conn *ct,
              ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[6]: *** [/usr/src/linux-headers-4.18.0-trunk-common/scripts/Makefile.build:329: /var/lib/dkms/netfilter-full-cone-nat/0.1/build/src/xt_FULLCONENAT.o] Error 1
make[5]: *** [/usr/src/linux-headers-4.18.0-trunk-common/Makefile:1514: _module_/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src] Error 2
make[4]: *** [Makefile:146: sub-make] Error 2
make[3]: *** [Makefile:8: all] Error 2
make[3]: Leaving directory '/usr/src/linux-headers-4.18.0-trunk-amd64'
make[2]: *** [Makefile:9: default] Error 2
make[2]: Leaving directory '/var/lib/dkms/netfilter-full-cone-nat/0.1/build/src'
make[1]: *** [Makefile:7: all] Error 2
make[1]: Leaving directory '/var/lib/dkms/netfilter-full-cone-nat/0.1/build'
edward-p commented 6 years ago

@Love4Taylor 高版本内核不再使用nf_nat_range, 而使用nf_nat_range2 打一下下面这个补丁就好了

--- a/xt_FULLCONENAT.c
+++ b/xt_FULLCONENAT.c
@@ -472,7 +472,7 @@ static unsigned int fullconenat_tg(struct sk_buff *skb, const struct xt_action_p

   struct nat_mapping *mapping, *src_mapping;
   unsigned int ret;
-  struct nf_nat_range newrange;
+  struct nf_nat_range2 newrange;

   __be32 new_ip, ip;
   uint16_t port, original_port, want_port;
love4taylor commented 6 years ago

@edward-p get!

Chion82 commented 6 years ago

https://github.com/Chion82/netfilter-full-cone-nat/commit/bc3fb32f3ff8facebad65dfbd12a64bf9b9276f4 fixed

tinnlux commented 4 years ago

@Love4Taylor 高版本内核不再使用nf_nat_range, 而使用nf_nat_range2 打一下下面这个补丁就好了

--- a/xt_FULLCONENAT.c
+++ b/xt_FULLCONENAT.c
@@ -472,7 +472,7 @@ static unsigned int fullconenat_tg(struct sk_buff *skb, const struct xt_action_p

   struct nat_mapping *mapping, *src_mapping;
   unsigned int ret;
-  struct nf_nat_range newrange;
+  struct nf_nat_range2 newrange;

   __be32 new_ip, ip;
   uint16_t port, original_port, want_port;

大佬,求教现在最新的openwrt是5.4内核的,编译出错如下: CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh DESCEND objtool LINK /home/ubuntu/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.22/tools/objtool/objtool /usr/bin/ld: warning: libc.so, needed by /home/ubuntu/openwrt/staging_dir/target-x86_64_musl/usr/lib/libelf.so, not found (try using -rpath or -rpath-link) /usr/bin/ld: /home/ubuntu/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.22/tools/objtool/objtool: hidden symbol `fstat' in /usr/lib/x86_64-linux-gnu/libc_nonshared.a(fstat.oS) is referenced by DSO /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status make[5]: [Makefile:50: /home/ubuntu/openwrt/build_dir/target-x86_64_musl/linux-x86_64/linux-5.4.22/tools/objtool/objtool] Error 1 make[4]: [Makefile:67: objtool] Error 2 这个应该怎么解决啊。万分感谢!