Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Error, Debian/12 #26

Closed
manchelsi opened this issue Mar 24, 2023 · 2 comments
Closed

Compilation Error, Debian/12 #26

manchelsi opened this issue Mar 24, 2023 · 2 comments

Comments

@manchelsi
Copy link

Distr: Debian Bookworm
Kernel: 6.1.0

Compilation Error:

make -C /lib/modules/6.1.0-7-amd64/build/ M=/usr/local/src/ipt-ratelimit modules
make[1]: Entering directory '/usr/src/linux-headers-6.1.0-7-amd64'
  CC [M]  /usr/local/src/ipt-ratelimit/xt_ratelimit.o
/usr/local/src/ipt-ratelimit/xt_ratelimit.c: In function ‘parse_rule’:
/usr/local/src/ipt-ratelimit/xt_ratelimit.c:530:37: warning: this statement may fall through [-Wimplicit-fallthrough=]
  530 |                                 val = val / 8 + (val / 8 / 2);
      |                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/src/ipt-ratelimit/xt_ratelimit.c:532:25: note: here
  532 |                         case 1:
      |                         ^~~~
/usr/local/src/ipt-ratelimit/xt_ratelimit.c:534:37: warning: this statement may fall through [-Wimplicit-fallthrough=]
  534 |                                 val *= 2;
      |                                 ~~~~^~~~
/usr/local/src/ipt-ratelimit/xt_ratelimit.c:536:25: note: here
  536 |                         case 2:
      |                         ^~~~
  MODPOST /usr/local/src/ipt-ratelimit/Module.symvers
  CC [M]  /usr/local/src/ipt-ratelimit/xt_ratelimit.mod.o
  LD [M]  /usr/local/src/ipt-ratelimit/xt_ratelimit.ko
  BTF [M] /usr/local/src/ipt-ratelimit/xt_ratelimit.ko
Skipping BTF generation for /usr/local/src/ipt-ratelimit/xt_ratelimit.ko due to unavailability of vmlinux
make[1]: Leaving directory '/usr/src/linux-headers-6.1.0-7-amd64'
sync
gcc -O2 -Wall -Wunused -fPIC   -o libxt_ratelimit_sh.o -c libxt_ratelimit.c
gcc -shared -o libxt_ratelimit.so libxt_ratelimit_sh.o
/usr/bin/ld: libxt_ratelimit_sh.o: in function `_init':
libxt_ratelimit.c:(.text+0x210): multiple definition of `_init'; /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:19: libxt_ratelimit.so] Error 1
rm libxt_ratelimit_sh.o
@manchelsi
Copy link
Author

Fix builds on iptables version 1.8.9 or newer
Ever since iptables commit ef108943f69a6e20533d58823740d3f0534ea8ec,
the _init macro has become guarded by XTABLES_INTERNAL, thus breaking
this extension.

Explicitly specify the constructor attribute on the initialization
function, which works on all versions.

diff --git a/libxt_ratelimit.c b/libxt_ratelimit.c                                                                                           
index d1a03d7..f3ecd6d 100644                                                                                                                
--- a/libxt_ratelimit.c                                                                                                                      
+++ b/libxt_ratelimit.c                                                                                                                      
@@ -153,7 +153,7 @@ static struct xtables_match ratelimit_mt_reg[] = {                                                                       
        },
 };

-void _init(void)                                                                                                                            
+static void __attribute__((constructor)) _init(void)                                                                                        
 {
        xtables_register_matches(ratelimit_mt_reg, ARRAY_SIZE(ratelimit_mt_reg));
 }

@manchelsi
Copy link
Author

#27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant