selftests/bpf/test_tcp_check_syncookie: use temp netns for testing
authorHangbin Liu <liuhangbin@gmail.com>
Tue, 25 Jan 2022 08:17:15 +0000 (16:17 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 28 Jan 2022 03:21:28 +0000 (19:21 -0800)
Use temp netns instead of hard code name for testing in case the
netns already exists.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Lorenz Bauer <lmb@cloudflare.com>
Link: https://lore.kernel.org/r/20220125081717.1260849-6-liuhangbin@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/test_tcp_check_syncookie.sh

index 6413c14725546067e8fd252e493d7f282384bb1a..102e6588e2fed4ced79560842e51c620154f7878 100755 (executable)
@@ -4,6 +4,7 @@
 # Copyright (c) 2019 Cloudflare
 
 set -eu
+readonly NS1="ns1-$(mktemp -u XXXXXX)"
 
 wait_for_ip()
 {
@@ -28,12 +29,12 @@ get_prog_id()
 
 ns1_exec()
 {
-       ip netns exec ns1 "$@"
+       ip netns exec ${NS1} "$@"
 }
 
 setup()
 {
-       ip netns add ns1
+       ip netns add ${NS1}
        ns1_exec ip link set lo up
 
        ns1_exec sysctl -w net.ipv4.tcp_syncookies=2