gamemann / XDP-Firewall

A firewall that utilizes the Linux kernel's XDP hook. The XDP hook allows for very fast network processing on Linux systems. This is great for dropping malicious traffic from a (D)DoS attack. IPv6 is supported with this firewall! I hope this helps network engineers/programmers interested in utilizing XDP!
https://deaconn.net/
MIT License
556 stars 91 forks source link

fix linker issue #42

Closed pettai closed 1 year ago

pettai commented 1 year ago

fix linker issue undefined reference to `zip_archive_open'

pettai commented 1 year ago

Resolve this issue during make:

[...]
mkdir -p build/
clang -L/usr/lib/x86_64-linux-gnu -lconfig -lelf -lz -I modules/xdp-tools/lib/libbpf/src -I /usr/include -I /usr/local/include -o build/xdpfw modules/xdp-tools/lib/libbpf/src/staticobjs/bpf_prog_linfo.o modules/xdp-tools/lib/libbpf/src/staticobjs/bpf.o modules/xdp-tools/lib/libbpf/src/staticobjs/btf_dump.o modules/xdp-tools/lib/libbpf/src/staticobjs/btf.o modules/xdp-tools/lib/libbpf/src/staticobjs/gen_loader.o   modules/xdp-tools/lib/libbpf/src/staticobjs/hashmap.o modules/xdp-tools/lib/libbpf/src/staticobjs/libbpf_errno.o modules/xdp-tools/lib/libbpf/src/staticobjs/libbpf_probes.o  modules/xdp-tools/lib/libbpf/src/staticobjs/libbpf.o modules/xdp-tools/lib/libbpf/src/staticobjs/linker.o modules/xdp-tools/lib/libbpf/src/staticobjs/netlink.o  modules/xdp-tools/lib/libbpf/src/staticobjs/nlattr.o modules/xdp-tools/lib/libbpf/src/staticobjs/relo_core.o modules/xdp-tools/lib/libbpf/src/staticobjs/ringbuf.o modules/xdp-tools/lib/libbpf/src/staticobjs/str_error.o modules/xdp-tools/lib/libbpf/src/staticobjs/strset.o modules/xdp-tools/lib/libbpf/src/staticobjs/usdt.o modules/xdp-tools/lib/libxdp/sharedobjs/xsk.o modules/xdp-tools/lib/libxdp/sharedobjs/libxdp.o build/config.o build/cmdline.o src/xdpfw.c
/usr/bin/ld: modules/xdp-tools/lib/libbpf/src/staticobjs/libbpf.o: in function `elf_find_func_offset_from_archive':
/home/ubuntu/XDP-Firewall/modules/xdp-tools/lib/libbpf/src/libbpf.c:10893: undefined reference to `zip_archive_open'
/usr/bin/ld: /home/ubuntu/XDP-Firewall/modules/xdp-tools/lib/libbpf/src/libbpf.c:10900: undefined reference to `zip_archive_find_entry'
/usr/bin/ld: /home/ubuntu/XDP-Firewall/modules/xdp-tools/lib/libbpf/src/libbpf.c:10934: undefined reference to `zip_archive_close'
/usr/bin/ld: /home/ubuntu/XDP-Firewall/modules/xdp-tools/lib/libbpf/src/libbpf.c:10934: undefined reference to `zip_archive_close'
/usr/bin/ld: /home/ubuntu/XDP-Firewall/modules/xdp-tools/lib/libbpf/src/libbpf.c:10934: undefined reference to `zip_archive_close'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:60: xdpfw] Error 1
gamemann commented 1 year ago

Hey, thanks for the PR! What Linux distro did you have this issue on along with kernel version? It causes a linking error on runtime since libxdp.so can't be found. I'm going to need to dig into this further when I have the time. I'm installing libxdp as well and running into the same issue.

pettai commented 1 year ago

Vanilla Ubuntu 22.04 running the latest kernel:

root@bygg-u2204:/home/pettai/XDP-Firewall# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy
root@bygg-u2204:/home/pettai/XDP-Firewall# uname -a
Linux bygg-u2204 5.15.0-86-generic #96-Ubuntu SMP Wed Sep 20 08:23:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

But after a git pull and doing a make libxdp; make the problem wasn't there anymore 👍