Skip to content

Commit 2fb89a3

Browse files
Jakub Kicinskidavem330
authored andcommitted
selftests/bpf: check for spurious extacks from the driver
Drivers should not report errors when offload is not forced. Check stdout and stderr for familiar messages when with no skip flags and with skip_hw. Check for add, replace, and destroy. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 15f4edb commit 2fb89a3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tools/testing/selftests/bpf/test_offload.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,29 @@ def check_extack(output, reference, args):
543543
def check_extack_nsim(output, reference, args):
544544
check_extack(output, "Error: netdevsim: " + reference, args)
545545

546+
def check_no_extack(res, needle):
547+
fail((res[1] + res[2]).count(needle) or (res[1] + res[2]).count("Warning:"),
548+
"Found '%s' in command output, leaky extack?" % (needle))
549+
546550
def check_verifier_log(output, reference):
547551
lines = output.split("\n")
548552
for l in reversed(lines):
549553
if l == reference:
550554
return
551555
fail(True, "Missing or incorrect message from netdevsim in verifier log")
552556

557+
def test_spurios_extack(sim, obj, skip_hw, needle):
558+
res = sim.cls_bpf_add_filter(obj, prio=1, handle=1, skip_hw=skip_hw,
559+
include_stderr=True)
560+
check_no_extack(res, needle)
561+
res = sim.cls_bpf_add_filter(obj, op="replace", prio=1, handle=1,
562+
skip_hw=skip_hw, include_stderr=True)
563+
check_no_extack(res, needle)
564+
res = sim.cls_filter_op(op="delete", prio=1, handle=1, cls="bpf",
565+
include_stderr=True)
566+
check_no_extack(res, needle)
567+
568+
553569
# Parse command line
554570
parser = argparse.ArgumentParser()
555571
parser.add_argument("--log", help="output verbose log to given file")
@@ -687,6 +703,17 @@ def check_verifier_log(output, reference):
687703
(j))
688704
sim.cls_filter_op(op="delete", prio=1, handle=1, cls="bpf")
689705

706+
start_test("Test spurious extack from the driver...")
707+
test_spurios_extack(sim, obj, False, "netdevsim")
708+
test_spurios_extack(sim, obj, True, "netdevsim")
709+
710+
sim.set_ethtool_tc_offloads(False)
711+
712+
test_spurios_extack(sim, obj, False, "TC offload is disabled")
713+
test_spurios_extack(sim, obj, True, "TC offload is disabled")
714+
715+
sim.set_ethtool_tc_offloads(True)
716+
690717
sim.tc_flush_filters()
691718

692719
start_test("Test TC offloads work...")

0 commit comments

Comments
 (0)