You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to set an entry in a hash map that is declared in an XDP program loaded by a C program.
However, the entry set is ineffective: the entry is not visible to the XDP program or bpftool; gobpfld cannot see the entry if the map is closed then re-opened.
Environment
Ubuntu 18.04
Linux kernel 5.4.0-100-generic, installed via linux-generic-hwe-18.04 package
Run the Go program to set an entry in the hash map:
$ sudo ./main -map 62
IterA 858993459 0
IterA end
IterB end
View the hash map via bpftool:
$ sudo bpftool map dump id 62
[]
Expected Behavior
The Go program should print IterB 858993459 0, which means the entry is presented after the map is closed and reopened.
bpftool should print the entry.
If the network interface receives traffic, it should be visible to tcpdump on the network interface, because there's no XSK socket attached so that the XDP program would return XDP_PASS after finding an entry in the map.
Actual Behavior
The Go program output suggests that the entry is absent after the map is closed and reopened. Note that the XDP program has a reference to the map, so that closing the map in the Go program should not cause the kernel to free the map.
bpftool shows the hash map is empty.
If the network interface receives traffic, it is dropped, which means the XDP program cannot find an entry in the map so that it returns XDP_DROP.
Also, bpftool map update command could successfully create an entry in this map.
The text was updated successfully, but these errors were encountered:
I'm trying to set an entry in a hash map that is declared in an XDP program loaded by a C program.
However, the entry set is ineffective: the entry is not visible to the XDP program or
bpftool
; gobpfld cannot see the entry if the map is closed then re-opened.Environment
linux-generic-hwe-18.04
package971bb03
(2022-02-28)Source Code
Each file must be placed in a separate directory.
xdp.c
loader.c
main.go
Steps to Reproduce
Compile the programs:
clang-11 -g -O2 -target bpf -c xdp.c -o xdp.o clang-11 -g -O2 loader.c -o loader $(pkg-config --cflags --libs libxdp) go build main.go
Load the XDP program to a network interface:
Find the id of the hash map:
Run the Go program to set an entry in the hash map:
View the hash map via
bpftool
:Expected Behavior
IterB 858993459 0
, which means the entry is presented after the map is closed and reopened.bpftool
should print the entry.tcpdump
on the network interface, because there's no XSK socket attached so that the XDP program would returnXDP_PASS
after finding an entry in the map.Actual Behavior
bpftool
shows the hash map is empty.XDP_DROP
.bpftool map update
command could successfully create an entry in this map.The text was updated successfully, but these errors were encountered: