gamemann / IPIPDirect-TC

Sends outgoing IPIP packets back to the client directly instead of back through the IPIP tunnel/forwarding server. Uses TC egress filter for fast packet processing.
https://moddingcommunity.com/
17 stars 1 forks source link

update #3

Open dedimark opened 4 months ago

dedimark commented 4 months ago

uname -a 6.1.0-20-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11) x86_64 GNU/Linux

lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm

/usr/bin/IPIPDirect_loader eth0 libbpf: elf: legacy map definitions in 'maps' section are not supported by libbpf v1.0+ ERROR: opening BPF object file failed Unable to load program Error attaching TC egress filter. TC cannot attach to filter. Command => tc filter add dev eth0 egress prio 1 handle 1 bpf da obj /etc/IPIPDirect/IPIPDirect_filter.o sec egress and Return Error Number => 1.

https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#drop-support-for-legacy-bpf-map-declaration-syntax

can you help recompile on newest OS?

gamemann commented 4 months ago

Hey, are you using the correct version of LibBPF that I used with this project? You should have the following commit checked out under src/include/libbpf.

https://github.com/libbpf/libbpf/tree/97ada10bd834950b1856c7f9efacc9ee83f824cf

In regards to porting this project to the latest version of LibBPF, I might do that in the future, but I'm not sure when I'll have the time.

dedimark commented 4 months ago

yes, libbpf correct version.

git clone --recursive https://github.com/gamemann/IPIPDirect-TC.git Cloning into 'IPIPDirect-TC'... remote: Enumerating objects: 85, done. remote: Counting objects: 100% (85/85), done. remote: Compressing objects: 100% (59/59), done. remote: Total 85 (delta 39), reused 70 (delta 24), pack-reused 0 Receiving objects: 100% (85/85), 271.87 KiB | 3.02 MiB/s, done. Resolving deltas: 100% (39/39), done. Submodule 'src/include/libbpf' (https://github.com/libbpf/libbpf.git) registered for path 'src/include/libbpf' Cloning into '/root/IPIPDirect-TC/src/include/libbpf'... remote: Enumerating objects: 12184, done. remote: Counting objects: 100% (3393/3393), done. remote: Compressing objects: 100% (858/858), done. remote: Total 12184 (delta 2539), reused 2622 (delta 2450), pack-reused 8791 Receiving objects: 100% (12184/12184), 9.21 MiB | 18.67 MiB/s, done. Resolving deltas: 100% (8197/8197), done. Submodule path 'src/include/libbpf': checked out '97ada10bd834950b1856c7f9efacc9ee83f824cf'

dedimark commented 2 months ago

Hey,any news?

gamemann commented 2 months ago

Hi, I've pushed an update to the project that should work with the latest version of LibBPF.

I wasn't able to test the TC program's functionality itself since I no longer run this in production, but confirmed attaching/detaching from the TC egress filter works.

# TC filter egress programs loaded.
christian@dev-debian12:~$ sudo tc filter show dev enp1s0 egress
filter protocol all pref 49152 bpf chain 0 
filter protocol all pref 49152 bpf chain 0 handle 0x1 tc_egress:[399] direct-action not_in_hw id 399 name tc_egress tag 245416d498d264d0 jited 

# Ensuring mac_map is populated meaning new map pinning works.
christian@dev-debian12:~$ sudo bpftool map dump name mac_map
[{
        "key": 0,
        "value": 156300082273574
    }
]

Please let me know how it goes and ensure you update LibBPF to the latest version when pulling the new changes.

dedimark commented 1 month ago

git clone --recursive https://github.com/gamemann/IPIPDirect-TC.git

Cloning into 'IPIPDirect-TC'... remote: Enumerating objects: 119, done. remote: Counting objects: 100% (119/119), done. remote: Compressing objects: 100% (77/77), done. remote: Total 119 (delta 57), reused 100 (delta 38), pack-reused 0 Receiving objects: 100% (119/119), 277.08 KiB | 3.96 MiB/s, done. Resolving deltas: 100% (57/57), done. Submodule 'src/include/libbpf' (https://github.com/libbpf/libbpf.git) registered for path 'src/include/libbpf' Cloning into '/root/IPIPDirect-TC/src/include/libbpf'... remote: Enumerating objects: 12602, done. remote: Counting objects: 100% (3811/3811), done. remote: Compressing objects: 100% (985/985), done. remote: Total 12602 (delta 2838), reused 2949 (delta 2720), pack-reused 8791 Receiving objects: 100% (12602/12602), 9.60 MiB | 16.75 MiB/s, done. Resolving deltas: 100% (8496/8496), done. Submodule path 'src/include/libbpf': checked out 'c1a6c770c46c6e78ad6755bf596c23a4e6f6b216'

root@vultr:~/IPIPDirect-TC# make

make[1]: Leaving directory '/root/IPIPDirect-TC/src/include/libbpf/src' clang -lelf -lz -o build/IPIPDirect_loader src/include/libbpf/src/staticobjs/bpf_prog_linfo.o src/include/libbpf/src/staticobjs/bpf.o src/include/libbpf/src/staticobjs/btf_dump.o src/include/libbpf/src/staticobjs/btf_iter.o src/include/libbpf/src/staticobjs/btf_relocate.o src/include/libbpf/src/staticobjs/btf.o src/include/libbpf/src/staticobjs/elf.o src/include/libbpf/src/staticobjs/features.o src/include/libbpf/src/staticobjs/gen_loader.o src/include/libbpf/src/staticobjs/hashmap.o src/include/libbpf/src/staticobjs/libbpf_errno.o src/include/libbpf/src/staticobjs/libbpf_probes.o src/include/libbpf/src/staticobjs/libbpf.o src/include/libbpf/src/staticobjs/linker.o src/include/libbpf/src/staticobjs/netlink.o src/include/libbpf/src/staticobjs/nlattr.o src/include/libbpf/src/staticobjs/relo_core.o src/include/libbpf/src/staticobjs/ringbuf.o src/include/libbpf/src/staticobjs/str_error.o src/include/libbpf/src/staticobjs/strset.o src/include/libbpf/src/staticobjs/usdt.o src/include/libbpf/src/staticobjs/zip.o src/IPIPDirect_loader.c clang -O2 --target=bpf -g -c src/IPIPDirect_kern.c -o build/IPIPDirect_filter.o In file included from src/IPIPDirect_kern.c:14: src/include/bpf_helpers.h:4:10: fatal error: 'bpf/bpf_helpers.h' file not found

include <bpf/bpf_helpers.h>

     ^~~~~~~~~~~~~~~~~~~

1 error generated. make: *** [Makefile:22: kern] Error 1

I can't compile

src/include/bpf_helpers.h:4:10: fatal error: 'bpf/bpf_helpers.h' file not found

include <bpf/bpf_helpers.h>

gamemann commented 1 month ago

I'll look into this later. It likely works on my VM because I've installed xdp-tools on the system. You could try installing that along with LibBPF to see if it corrects the error you're getting in the meantime.

dedimark commented 1 month ago

uname -a Linux vultr 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64 GNU/Linux

apt-get install xdp-tools Reading package lists... Done Building dependency tree... Done Reading state information... Done xdp-tools is already the newest version (1.3.1-1).

--

make make -C src/include/libbpf/src make[1]: Entering directory '/root/IPIPDirect-TC/src/include/libbpf/src' make[1]: Leaving directory '/root/IPIPDirect-TC/src/include/libbpf/src' clang -lelf -lz -o build/IPIPDirect_loader src/include/libbpf/src/staticobjs/bpf_prog_linfo.o src/include/libbpf/src/staticobjs/bpf.o src/include/libbpf/src/staticobjs/btf_dump.o src/include/libbpf/src/staticobjs/btf_iter.o src/include/libbpf/src/staticobjs/btf_relocate.o src/include/libbpf/src/staticobjs/btf.o src/include/libbpf/src/staticobjs/elf.o src/include/libbpf/src/staticobjs/features.o src/include/libbpf/src/staticobjs/gen_loader.o src/include/libbpf/src/staticobjs/hashmap.o src/include/libbpf/src/staticobjs/libbpf_errno.o src/include/libbpf/src/staticobjs/libbpf_probes.o src/include/libbpf/src/staticobjs/libbpf.o src/include/libbpf/src/staticobjs/linker.o src/include/libbpf/src/staticobjs/netlink.o src/include/libbpf/src/staticobjs/nlattr.o src/include/libbpf/src/staticobjs/relo_core.o src/include/libbpf/src/staticobjs/ringbuf.o src/include/libbpf/src/staticobjs/str_error.o src/include/libbpf/src/staticobjs/strset.o src/include/libbpf/src/staticobjs/usdt.o src/include/libbpf/src/staticobjs/zip.o src/IPIPDirect_loader.c clang -O2 --target=bpf -g -c src/IPIPDirect_kern.c -o build/IPIPDirect_filter.o In file included from src/IPIPDirect_kern.c:14: src/include/bpf_helpers.h:4:10: fatal error: 'bpf/bpf_helpers.h' file not found

include <bpf/bpf_helpers.h>

     ^~~~~~~~~~~~~~~~~~~

1 error generated. make: *** [Makefile:22: kern] Error 1

same.