Score:0

Where is my eBPF per-cpu-array data going?

US flag

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 !

Score:1
US flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.