Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/net: convert cmsg tests to make them run in unique namespace

Here is the test result after conversion.

]# ./cmsg_ipv6.sh
OK
]# ./cmsg_so_mark.sh
OK
]# ./cmsg_time.sh
OK

Acked-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Hangbin Liu and committed by
Paolo Abeni
7c16d485 3a0f3367

+12 -12
+4 -6
tools/testing/selftests/net/cmsg_ipv6.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - ksft_skip=4 4 + source lib.sh 5 5 6 - NS=ns 7 6 IP6=2001:db8:1::1/64 8 7 TGT6=2001:db8:1::2 9 8 TMPF=$(mktemp --suffix ".pcap") ··· 10 11 cleanup() 11 12 { 12 13 rm -f $TMPF 13 - ip netns del $NS 14 + cleanup_ns $NS 14 15 } 15 16 16 17 trap cleanup EXIT 17 - 18 - NSEXE="ip netns exec $NS" 19 18 20 19 tcpdump -h | grep immediate-mode >> /dev/null 21 20 if [ $? -ne 0 ]; then ··· 22 25 fi 23 26 24 27 # Namespaces 25 - ip netns add $NS 28 + setup_ns NS 29 + NSEXE="ip netns exec $NS" 26 30 27 31 $NSEXE sysctl -w net.ipv4.ping_group_range='0 2147483647' > /dev/null 28 32
+4 -3
tools/testing/selftests/net/cmsg_so_mark.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - NS=ns 4 + source lib.sh 5 + 5 6 IP4=172.16.0.1/24 6 7 TGT4=172.16.0.2 7 8 IP6=2001:db8:1::1/64 ··· 11 10 12 11 cleanup() 13 12 { 14 - ip netns del $NS 13 + cleanup_ns $NS 15 14 } 16 15 17 16 trap cleanup EXIT 18 17 19 18 # Namespaces 20 - ip netns add $NS 19 + setup_ns NS 21 20 22 21 ip netns exec $NS sysctl -w net.ipv4.ping_group_range='0 2147483647' > /dev/null 23 22
+4 -3
tools/testing/selftests/net/cmsg_time.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - NS=ns 4 + source lib.sh 5 + 5 6 IP4=172.16.0.1/24 6 7 TGT4=172.16.0.2 7 8 IP6=2001:db8:1::1/64 ··· 10 9 11 10 cleanup() 12 11 { 13 - ip netns del $NS 12 + cleanup_ns $NS 14 13 } 15 14 16 15 trap cleanup EXIT 17 16 18 17 # Namespaces 19 - ip netns add $NS 18 + setup_ns NS 20 19 21 20 ip netns exec $NS sysctl -w net.ipv4.ping_group_range='0 2147483647' > /dev/null 22 21