Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf/test_offload.py: Filter bpftool internal map when counting maps

A few of the tests in test_offload.py expects to see a certain number of
maps created, and checks this by counting the number of maps returned by
bpftool. There is already a filter that will remove any maps already there
at the beginning of the test, but bpftool now creates a map for the PID
iterator rodata on each invocation, which makes the map count wrong. Fix
this by also filtering the pid_iter.rodata map by name when counting.

Fixes: d53dee3fe013 ("tools/bpftool: Show info for processes holding BPF map/prog/link/btf FDs")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/bpf/160752226387.110217.9887866138149423444.stgit@toke.dk

authored by

Toke Høiland-Jørgensen and committed by
Daniel Borkmann
8158cad1 766e62b7

+4 -3
+4 -3
tools/testing/selftests/bpf/test_offload.py
··· 184 184 def bpftool_map_list(expected=None, ns=""): 185 185 _, maps = bpftool("map show", JSON=True, ns=ns, fail=True) 186 186 # Remove the base maps 187 - for m in base_maps: 188 - if m in maps: 189 - maps.remove(m) 187 + maps = [m for m in maps if m not in base_maps and m.get('name') not in base_map_names] 190 188 if expected is not None: 191 189 if len(maps) != expected: 192 190 fail(True, "%d BPF maps loaded, expected %d" % ··· 768 770 skip(ret != 0, "bpftool not installed") 769 771 base_progs = progs 770 772 _, base_maps = bpftool("map") 773 + base_map_names = [ 774 + 'pid_iter.rodata' # created on each bpftool invocation 775 + ] 771 776 772 777 # Check netdevsim 773 778 ret, out = cmd("modprobe netdevsim", fail=False)