Commit d8b5e76a authored by Toke Høiland-Jørgensen's avatar Toke Høiland-Jørgensen Committed by Daniel Borkmann

selftests/bpf/test_offload.py: Only check verifier log on verification fails

Since commit 6f8a57cc ("bpf: Make verifier log more relevant by
default"), the verifier discards log messages for successfully-verified
programs. This broke test_offload.py which is looking for a verification
message from the driver callback. Change test_offload.py to use the toggle
in netdevsim to make the verification fail before looking for the
verification message.

Fixes: 6f8a57cc ("bpf: Make verifier log more relevant by default")
Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/bpf/160752226069.110217.12370824996153348073.stgit@toke.dk
parent e4ff5aa4
...@@ -911,11 +911,18 @@ try: ...@@ -911,11 +911,18 @@ try:
sim.tc_flush_filters() sim.tc_flush_filters()
start_test("Test TC offloads failure...")
sim.dfs["dev/bpf_bind_verifier_accept"] = 0
ret, _, err = sim.cls_bpf_add_filter(obj, verbose=True, skip_sw=True,
fail=False, include_stderr=True)
fail(ret == 0, "TC filter did not reject with TC offloads enabled")
check_verifier_log(err, "[netdevsim] Hello from netdevsim!")
sim.dfs["dev/bpf_bind_verifier_accept"] = 1
start_test("Test TC offloads work...") start_test("Test TC offloads work...")
ret, _, err = sim.cls_bpf_add_filter(obj, verbose=True, skip_sw=True, ret, _, err = sim.cls_bpf_add_filter(obj, verbose=True, skip_sw=True,
fail=False, include_stderr=True) fail=False, include_stderr=True)
fail(ret != 0, "TC filter did not load with TC offloads enabled") fail(ret != 0, "TC filter did not load with TC offloads enabled")
check_verifier_log(err, "[netdevsim] Hello from netdevsim!")
start_test("Test TC offload basics...") start_test("Test TC offload basics...")
dfs = simdev.dfs_get_bound_progs(expected=1) dfs = simdev.dfs_get_bound_progs(expected=1)
...@@ -1032,6 +1039,15 @@ try: ...@@ -1032,6 +1039,15 @@ try:
rm("/sys/fs/bpf/offload") rm("/sys/fs/bpf/offload")
sim.wait_for_flush() sim.wait_for_flush()
start_test("Test XDP load failure...")
sim.dfs["dev/bpf_bind_verifier_accept"] = 0
ret, _, err = bpftool_prog_load("sample_ret0.o", "/sys/fs/bpf/offload",
dev=sim['ifname'], fail=False, include_stderr=True)
fail(ret == 0, "verifier should fail on load")
check_verifier_log(err, "[netdevsim] Hello from netdevsim!")
sim.dfs["dev/bpf_bind_verifier_accept"] = 1
sim.wait_for_flush()
start_test("Test XDP offload...") start_test("Test XDP offload...")
_, _, err = sim.set_xdp(obj, "offload", verbose=True, include_stderr=True) _, _, err = sim.set_xdp(obj, "offload", verbose=True, include_stderr=True)
ipl = sim.ip_link_show(xdp=True) ipl = sim.ip_link_show(xdp=True)
...@@ -1039,7 +1055,6 @@ try: ...@@ -1039,7 +1055,6 @@ try:
progs = bpftool_prog_list(expected=1) progs = bpftool_prog_list(expected=1)
prog = progs[0] prog = progs[0]
fail(link_xdp["id"] != prog["id"], "Loaded program has wrong ID") fail(link_xdp["id"] != prog["id"], "Loaded program has wrong ID")
check_verifier_log(err, "[netdevsim] Hello from netdevsim!")
start_test("Test XDP offload is device bound...") start_test("Test XDP offload is device bound...")
dfs = simdev.dfs_get_bound_progs(expected=1) dfs = simdev.dfs_get_bound_progs(expected=1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment