hoang-tranviet / tcp-options-bpf

Linux kernel: eBPF support for user-defined TCP options
Other
28 stars 11 forks source link

error in "sudo ./test_tcp_user bpf_tcp_cc_kern.o" #5

Open JustinTiezhu opened 2 years ago

JustinTiezhu commented 2 years ago

Dear Viet-Hoang Tran,

I would like to run tcp-options-bpf (https://github.com/hoang-tranviet/tcp-options-bpf) on my own PC to better understand your work. I have put this set of source code in Ubuntu 18 04, got kernel 4.17-rc5 after compilation. However, when I execute the "sudo ./test_tcp_user bpf_tcp_cc_kern.o" instruction, it always report an error. I tried to google this error but found nothing helpful. Could you give me some hints about this error? The details:

loading bpf program: bpf_tcp_cc_kern.o system(echo**** 53709 >> /tmp/cgroupv2/foo/cgroup.procs) PASS! libbpf: bpf_tcp_cc_kern.o doesn't provide kernel version FAILED: load_bpf_file failed for: bpf_tcp_cc_kern.o

I will be very happy if you offered me an answer to this problem.

hoang-tranviet commented 2 years ago

Hi Justin,

I have not worked on the topic since then, but from your error message, it is probably that the libbpf/kernel headers of your host Linux are too new and there is incompatibility with the target eBPF binary builds. As I see, libbpf has been changed frequently over the time.

Could you try to downgrade your libbpf to the matched version with kernel 4.16-4.17, or better to compile and run the host OS with that kernel version?

JustinTiezhu commented 2 years ago

Thank you for your reply ,I'll have a try

JustinTiezhu commented 2 years ago

Sorry to bother you again. What version of libbpf did you use at that time?

hoang-tranviet commented 2 years ago

Sorry I don't remember, and whether if the build process use libbpf in the host or in the source tree. But these patchsets seem to be a good starting point to solve that problem: https://lore.kernel.org/bpf/20191004030058.2248514-2-andriin@fb.com/ https://patchwork.ozlabs.org/project/netdev/patch/20180510172443.17238-7-jakub.kicinski@netronome.com/

One direction is to apply the code changes from the first link.

JustinTiezhu commented 2 years ago

Sorry to bother you again.First,thank you very much for your direction,I read the two links you gave me carefully. After analysis, I found that the error of "don't provide kernel version" is due to the "libbpf.c" in my own kernel source code: static int bpf_object__validate(struct bpf_object *obj) { if (obj->kern_version == 0) { pr_ warning("%s doesn't provide kernel version\n", obj->path); return -LIBBPF_ ERRNO__ KVERSION; } return 0; } Therefore, I commented it out and tried to skip this step to solve the problem, but then it reported another error: libbpf: object file doesn't contain BPF program Failed: load_bpf_file failed for: bpf_tcp_cc_kern. o Therefore, I guess there is a problem with the "bpf_tcp_cc_kern. o" file generated during compilation. Is it because there is a problem with the compiled ebpf environment, so I'd like to continue to ask you about the details of the ebpf environment at the time of your compilation.Or do you have any other ideas? Thank you very much for your guidance.

hoang-tranviet commented 2 years ago

Thanks for updating the issue.

From the new error, it might be an issue with the llvm compiling/linking process.

Also I don't know why there is a space in the name of bpf object "bpf_tcp_cc_kern. o" What is the size of this object file? Do you get the same error when compiling other bpf program, e.g. bpf_tcp_iw.o?

Further, could you try to inspect the bpf object, e.g. with this way: https://sysdig.com/blog/the-art-of-writing-ebpf-programs-a-primer/ ?

hoang-tranviet commented 2 years ago

FYI, two other sources that could be useful for debugging the ebpf build: https://qmo.fr/docs/talk_20200202_debugging_ebpf.pdf https://qmonnet.github.io/whirl-offload/2021/09/23/bpftool-features-thread/

JustinTiezhu commented 2 years ago

Thank you for your reply.

Sorry, I accidentally entered that space. There is no problem running other BPF programs under the kernel directory, such as "socket". And the size of "bpf_tcp_cc_kern.o" file is 368 bytes.

I will carefully read the links you sent me. Thank you again for your reply.

RandyLambert commented 2 years ago

Hi JustinTiezhu, have you finally resolved this issue?

BDXGD commented 1 year ago

Hi JustinTiezhu, are you still paying attention to this problem ? @JustinTiezhu

RandyLambert commented 1 year ago

Hi JustinTiezhu, are you still paying attention to this problem ? @JustinTiezhu This code is now merged into the master kernel branch, like this https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/bpf.h#L6478

BDXGD commented 1 year ago

Hi JustinTiezhu, are you still paying attention to this problem ? @JustinTiezhu This code is now merged into the master kernel branch, like this https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/bpf.h#L6478

Thanks for reply, I know but I just don't know how to build the envirment like tcp-options-bpf