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

selftests/net: convert fcnal-test.sh to run it in unique namespace

Here is the test result after conversion. There are some failures, but it
also exists on my system without this patch. So it's not affectec by
this patch and I will check the reason later.

]# time ./fcnal-test.sh
/usr/bin/which: no nettest in (/root/.local/bin:/root/bin:/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)

###########################################################################
IPv4 ping
###########################################################################

#################################################################
No VRF

SYSCTL: net.ipv4.raw_l3mdev_accept=0

TEST: ping out - ns-B IP [ OK ]
TEST: ping out, device bind - ns-B IP [ OK ]
TEST: ping out, address bind - ns-B IP [ OK ]
...

#################################################################
SNAT on VRF

TEST: IPv4 TCP connection over VRF with SNAT [ OK ]
TEST: IPv6 TCP connection over VRF with SNAT [ OK ]

Tests passed: 893
Tests failed: 21

real 52m48.178s
user 0m34.158s
sys 1m42.976s

BTW, this test needs a really long time. So expand the timeout to 1h.

Acked-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://lore.kernel.org/r/20231213060856.4030084-6-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Hangbin Liu and committed by
Jakub Kicinski
779283b7 792cd1db

+14 -18
+13 -17
tools/testing/selftests/net/fcnal-test.sh
··· 37 37 # 38 38 # server / client nomenclature relative to ns-A 39 39 40 - # Kselftest framework requirement - SKIP code is 4. 41 - ksft_skip=4 42 - 40 + source lib.sh 43 41 VERBOSE=0 44 42 45 43 NSA_DEV=eth1 ··· 79 81 # set after namespace create 80 82 NSA_LINKIP6= 81 83 NSB_LINKIP6= 82 - 83 - NSA=ns-A 84 - NSB=ns-B 85 - NSC=ns-C 86 - 87 - NSA_CMD="ip netns exec ${NSA}" 88 - NSB_CMD="ip netns exec ${NSB}" 89 - NSC_CMD="ip netns exec ${NSC}" 90 84 91 85 which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping) 92 86 ··· 396 406 local addr=$2 397 407 local addr6=$3 398 408 399 - ip netns add ${ns} 400 - 401 - ip -netns ${ns} link set lo up 402 409 if [ "${addr}" != "-" ]; then 403 410 ip -netns ${ns} addr add dev lo ${addr} 404 411 fi ··· 454 467 ip -netns ${NSA} link del dev ${NSA_DEV} 455 468 456 469 ip netns pids ${NSA} | xargs kill 2>/dev/null 457 - ip netns del ${NSA} 470 + cleanup_ns ${NSA} 458 471 fi 459 472 460 473 ip netns pids ${NSB} | xargs kill 2>/dev/null 461 - ip netns del ${NSB} 462 474 ip netns pids ${NSC} | xargs kill 2>/dev/null 463 - ip netns del ${NSC} >/dev/null 2>&1 475 + cleanup_ns ${NSB} ${NSC} 464 476 } 465 477 466 478 cleanup_vrf_dup() ··· 473 487 { 474 488 # some VRF tests use ns-C which has the same config as 475 489 # ns-B but for a device NOT in the VRF 490 + setup_ns NSC 491 + NSC_CMD="ip netns exec ${NSC}" 476 492 create_ns ${NSC} "-" "-" 477 493 connect_ns ${NSA} ${NSA_DEV2} ${NSA_IP}/24 ${NSA_IP6}/64 \ 478 494 ${NSC} ${NSC_DEV} ${NSB_IP}/24 ${NSB_IP6}/64 ··· 490 502 491 503 log_debug "Configuring network namespaces" 492 504 set -e 505 + 506 + setup_ns NSA NSB 507 + NSA_CMD="ip netns exec ${NSA}" 508 + NSB_CMD="ip netns exec ${NSB}" 493 509 494 510 create_ns ${NSA} ${NSA_LO_IP}/32 ${NSA_LO_IP6}/128 495 511 create_ns ${NSB} ${NSB_LO_IP}/32 ${NSB_LO_IP6}/128 ··· 537 545 log_debug "Configuring network namespaces" 538 546 set -e 539 547 548 + setup_ns NSA NSB NSC 549 + NSA_CMD="ip netns exec ${NSA}" 550 + NSB_CMD="ip netns exec ${NSB}" 551 + NSC_CMD="ip netns exec ${NSC}" 540 552 create_ns ${NSA} "-" "-" 541 553 create_ns ${NSB} "-" "-" 542 554 create_ns ${NSC} "-" "-"
+1 -1
tools/testing/selftests/net/settings
··· 1 - timeout=1500 1 + timeout=3600