]> Gentwo Git Trees - linux/.git/commit
selftests/bpf: Add checks in tc_tunnel when entering net namespaces
authorAlexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Fri, 31 Oct 2025 09:01:42 +0000 (10:01 +0100)
committerMartin KaFai Lau <martin.lau@kernel.org>
Fri, 31 Oct 2025 22:00:30 +0000 (15:00 -0700)
commite6e10c51fb17e8d0b565921a077dd878fc80aa18
treef1a19b7bec86fd1c87389ceaaf00008d20fd5d2c
parentc076fd5bb4d70b1f9de7aaf6cc6165891f190ba9
selftests/bpf: Add checks in tc_tunnel when entering net namespaces

test_tc_tunnel is missing checks on any open_netns. Add those checks
anytime we try to enter a net namespace, and skip the related operations
if we fail. While at it, reduce the number of open_netns/close_netns for
cases involving operations in two distinct namespaces: the test
currently does the following:

  nstoken = open_netns("foo")
  do_operation();
  close(nstoken);
  nstoken = open_netns("bar")
  do_another_operation();
  close(nstoken);

As already stated in reviews for the initial test, we don't need to go
back to the root net namespace to enter a second namespace, so just do:

  ntoken_client = open_netns("foo")
  do_operation();
  nstoken_server = open_netns("bar")
  do_another_operation();
  close(nstoken_server);
  close(nstoken_client);

Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20251031-tc_tunnel_improv-v1-2-0ffe44d27eda@bootlin.com
tools/testing/selftests/bpf/prog_tests/test_tc_tunnel.c