Skip to contentSkip to conversation

selftests: net: fix error message in bpf_offload

PATCH Applied Jakub Kicinski 3 participants 5 messages Mar 4, 2025 – Mar 7, 2025

Subsystems (4)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/2 selftests: net: fix error message in bpf_offload

We hit a following exception on timeout, nmaps is never set:

Test bpftool bound info reporting (own ns)...
Traceback (most recent call last):
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 1128, in <module>
check_dev_info(False, "")
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 583, in check_dev_info
maps = bpftool_map_list_wait(expected=2, ns=ns)
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 215, in bpftool_map_list_wait
raise Exception("Time out waiting for map counts to stabilize want %d, have %d" % (expected, nmaps))
NameError: name 'nmaps' is not defined

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 tools/testing/selftests/net/bpf_offload.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/net/bpf_offload.py +3 -1
index fd0d959914e4..4a9be8c49561 100755
@@ -207,9 +207,11 @@ netns = [] # net namespaces to be removed
     raise Exception("Time out waiting for program counts to stabilize want %d, have %d" % (expected, nprogs))
 
 def bpftool_map_list_wait(expected=0, n_retry=20, ns=""):
+    nmaps = None
     for i in range(n_retry):
         maps = bpftool_map_list(ns=ns)
-        if len(maps) == expected:
+        nmaps = len(maps)
+        if nmaps == expected:
             return maps
         time.sleep(0.05)
     raise Exception("Time out waiting for map counts to stabilize want %d, have %d" % (expected, nmaps))
Signature · 1 line
2.48.1
author maintainer
#1 lore raw

PATCH 2/2 selftests: net: bpf_offload: add 'libbpf_global' to ignored maps

After installing pahole on the CI image we have a new map created by libbpf. Ignore it otherwise we see:

Exception: Time out waiting for map counts to stabilize want 2, have 3

---
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 tools/testing/selftests/net/bpf_offload.py | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/net/bpf_offload.py +1 -0
index 4a9be8c49561..b2c271b79240 100755
@@ -712,6 +712,7 @@ _, base_maps = bpftool("map")
 base_map_names = [
     'pid_iter.rodata', # created on each bpftool invocation
     'libbpf_det_bind', # created on each bpftool invocation
+    'libbpf_global',
 ]
 
 # Check netdevsim
Signature · 1 line
2.48.1
Acked-by on v1 1/2
#3 lore raw
In reply to Jakub Kicinski
Quoted 12 lines · Jakub Kicinski

We hit a following exception on timeout, nmaps is never set:

Test bpftool bound info reporting (own ns)...
Traceback (most recent call last):
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 1128, in <module>
check_dev_info(False, "")
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 583, in check_dev_info
maps = bpftool_map_list_wait(expected=2, ns=ns)
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 215, in bpftool_map_list_wait
raise Exception("Time out waiting for map counts to stabilize want %d, have %d" % (expected, nmaps))
NameError: name 'nmaps' is not defined

Quoted 1 line

I've seen this a couple of times myself but was too lazy to send out a fix :-[

#4 lore raw
In reply to Jakub Kicinski
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 12 lines · On Tue, 4 Mar 2025 15:32:03 -0800 you wrote:

We hit a following exception on timeout, nmaps is never set:

Test bpftool bound info reporting (own ns)...
Traceback (most recent call last):
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 1128, in <module>
check_dev_info(False, "")
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 583, in check_dev_info
maps = bpftool_map_list_wait(expected=2, ns=ns)
File "/home/virtme/testing-1/tools/testing/selftests/net/./bpf_offload.py", line 215, in bpftool_map_list_wait
raise Exception("Time out waiting for map counts to stabilize want %d, have %d" % (expected, nmaps))
NameError: name 'nmaps' is not defined

Quoted 1 line

[...]

Here is the summary with links:
- [net-next,1/2] selftests: net: fix error message in bpf_offload

    https://git.kernel.org/netdev/net-next/c/f9d2f5ddd47c
  - [net-next,2/2] selftests: net: bpf_offload: add 'libbpf_global' to ignored maps
    https://git.kernel.org/netdev/net-next/c/56a586961bf8

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html