0

I have a test case similar to code in https://github.com/xdp-project/xdp-tutorial/ which maintains a statistic map in a per-cpu array, and user-space code which displays the statistics periodically.

When I run this, the user space code always displays zeros. I have instrumented my eBPF kernel code with bpf_trace_printk and it appears to be putting the correct values into the map. The user code is iterating over all possible CPUs, but is always finding zeros in the per-cpu array slots.

Can anybody tell me what is going wrong ?

My test case is here ; af_xdp_kern.c is the eBPF code, af_xdp_user.c is the userspace code which drives the eBPF code, and filter-xdp_stats.c is the code which should display the statistics. It all builds with 'make' in that directory, and there is a run script which I use with

tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter/netperf-namespace$ sudo FILTER=af_xdp_kern ./run.sh

to run the user code and eBPF code with data being transferred between 2 network namespaces on the machine. While it is running,

tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter$ sudo ./filter-xdp_stats

should display statistics, but in fact displays zeros.

My test case is coded to the '1.0' BPF interface, where the code in xdp-tutorial is coded to the pre-release BPF interface.

I am running Ubuntu 22.04 with uname -a giving

tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter$ uname -a
Linux r28b29-n10 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
tjcw@r28b29-n10:~/workspace/bpf-examples/AF_XDP-filter$

Thanks for all the help you can give !

1 Answer 1

1

It is necessary to run the statistics display application in the same network namespace as the user and eBPF application; even in the same instance of ip netns exec.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .