]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/bpf: ensure proper root namespace cleanup when test fail
authorAlexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Thu, 28 Nov 2024 14:38:43 +0000 (15:38 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 2 Dec 2024 19:04:35 +0000 (11:04 -0800)
commitc721d8f8b196285a59ed5c940e856bce9890523f
treeee63d4b2ff314c80455ba31f4507d2f362e15724
parent3bfb49d73fc281f06c0d976db898debebc8223e3
selftests/bpf: ensure proper root namespace cleanup when test fail

serial_test_flow_dissector_namespace manipulates both the root net
namespace and a dedicated non-root net namespace. If for some reason a
program attach on root namespace succeeds while it was expected to
fail, the unexpected program will remain attached to the root namespace,
possibly affecting other runs or even other tests in the same run.

Fix undesired test failure side effect by explicitly detaching programs
on failing tests expecting attach to fail. As a side effect of this
change, do not test errno value if the tested operation do not fail.

Fixes: 284ed00a59dd ("selftests/bpf: migrate flow_dissector namespace exclusivity test")
Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://lore.kernel.org/r/20241128-small_flow_test_fix-v1-1-c12d45c98c59@bootlin.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/flow_dissector.c