diff options
author | David Ahern <dsahern@gmail.com> | 2019-02-28 14:22:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-28 16:02:43 -0500 |
commit | be9cefe796f3abfbef02e66fbe3bff766b93b867 (patch) | |
tree | 4acfd4895706f9441158ff9f0388ac878f7f7bc3 | |
parent | b9f2c028709d158c57e7b8d76d4eadff3d9c69a6 (diff) |
selftests: rtnetlink: use internal netns switch for ip commands
'ip' can switch network namespaces internally and then run a given
command relative to that namespace without the need to fork and exec
another ip instance. Update all references of the form:
ip netns exec "$testns" ip ...
to
ip -netns "$testns" ...
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rwxr-xr-x | tools/testing/selftests/net/rtnetlink.sh | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh index 5baf35aab7f8..b447803f3f8a 100755 --- a/tools/testing/selftests/net/rtnetlink.sh +++ b/tools/testing/selftests/net/rtnetlink.sh | |||
@@ -391,7 +391,7 @@ kci_test_encap_vxlan() | |||
391 | vlan="test-vlan0" | 391 | vlan="test-vlan0" |
392 | testns="$1" | 392 | testns="$1" |
393 | 393 | ||
394 | ip netns exec "$testns" ip link add "$vxlan" type vxlan id 42 group 239.1.1.1 \ | 394 | ip -netns "$testns" link add "$vxlan" type vxlan id 42 group 239.1.1.1 \ |
395 | dev "$devdummy" dstport 4789 2>/dev/null | 395 | dev "$devdummy" dstport 4789 2>/dev/null |
396 | if [ $? -ne 0 ]; then | 396 | if [ $? -ne 0 ]; then |
397 | echo "FAIL: can't add vxlan interface, skipping test" | 397 | echo "FAIL: can't add vxlan interface, skipping test" |
@@ -399,68 +399,68 @@ kci_test_encap_vxlan() | |||
399 | fi | 399 | fi |
400 | check_err $? | 400 | check_err $? |
401 | 401 | ||
402 | ip netns exec "$testns" ip addr add 10.2.11.49/24 dev "$vxlan" | 402 | ip -netns "$testns" addr add 10.2.11.49/24 dev "$vxlan" |
403 | check_err $? | 403 | check_err $? |
404 | 404 | ||
405 | ip netns exec "$testns" ip link set up dev "$vxlan" | 405 | ip -netns "$testns" link set up dev "$vxlan" |
406 | check_err $? | 406 | check_err $? |
407 | 407 | ||
408 | ip netns exec "$testns" ip link add link "$vxlan" name "$vlan" type vlan id 1 | 408 | ip -netns "$testns" link add link "$vxlan" name "$vlan" type vlan id 1 |
409 | check_err $? | 409 | check_err $? |
410 | 410 | ||
411 | # changelink testcases | 411 | # changelink testcases |
412 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan vni 43 2>/dev/null | 412 | ip -netns "$testns" link set dev "$vxlan" type vxlan vni 43 2>/dev/null |
413 | check_fail $? | 413 | check_fail $? |
414 | 414 | ||
415 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan group ffe5::5 dev "$devdummy" 2>/dev/null | 415 | ip -netns "$testns" link set dev "$vxlan" type vxlan group ffe5::5 dev "$devdummy" 2>/dev/null |
416 | check_fail $? | 416 | check_fail $? |
417 | 417 | ||
418 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan ttl inherit 2>/dev/null | 418 | ip -netns "$testns" link set dev "$vxlan" type vxlan ttl inherit 2>/dev/null |
419 | check_fail $? | 419 | check_fail $? |
420 | 420 | ||
421 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan ttl 64 | 421 | ip -netns "$testns" link set dev "$vxlan" type vxlan ttl 64 |
422 | check_err $? | 422 | check_err $? |
423 | 423 | ||
424 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan nolearning | 424 | ip -netns "$testns" link set dev "$vxlan" type vxlan nolearning |
425 | check_err $? | 425 | check_err $? |
426 | 426 | ||
427 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan proxy 2>/dev/null | 427 | ip -netns "$testns" link set dev "$vxlan" type vxlan proxy 2>/dev/null |
428 | check_fail $? | 428 | check_fail $? |
429 | 429 | ||
430 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan norsc 2>/dev/null | 430 | ip -netns "$testns" link set dev "$vxlan" type vxlan norsc 2>/dev/null |
431 | check_fail $? | 431 | check_fail $? |
432 | 432 | ||
433 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan l2miss 2>/dev/null | 433 | ip -netns "$testns" link set dev "$vxlan" type vxlan l2miss 2>/dev/null |
434 | check_fail $? | 434 | check_fail $? |
435 | 435 | ||
436 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan l3miss 2>/dev/null | 436 | ip -netns "$testns" link set dev "$vxlan" type vxlan l3miss 2>/dev/null |
437 | check_fail $? | 437 | check_fail $? |
438 | 438 | ||
439 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan external 2>/dev/null | 439 | ip -netns "$testns" link set dev "$vxlan" type vxlan external 2>/dev/null |
440 | check_fail $? | 440 | check_fail $? |
441 | 441 | ||
442 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan udpcsum 2>/dev/null | 442 | ip -netns "$testns" link set dev "$vxlan" type vxlan udpcsum 2>/dev/null |
443 | check_fail $? | 443 | check_fail $? |
444 | 444 | ||
445 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan udp6zerocsumtx 2>/dev/null | 445 | ip -netns "$testns" link set dev "$vxlan" type vxlan udp6zerocsumtx 2>/dev/null |
446 | check_fail $? | 446 | check_fail $? |
447 | 447 | ||
448 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan udp6zerocsumrx 2>/dev/null | 448 | ip -netns "$testns" link set dev "$vxlan" type vxlan udp6zerocsumrx 2>/dev/null |
449 | check_fail $? | 449 | check_fail $? |
450 | 450 | ||
451 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan remcsumtx 2>/dev/null | 451 | ip -netns "$testns" link set dev "$vxlan" type vxlan remcsumtx 2>/dev/null |
452 | check_fail $? | 452 | check_fail $? |
453 | 453 | ||
454 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan remcsumrx 2>/dev/null | 454 | ip -netns "$testns" link set dev "$vxlan" type vxlan remcsumrx 2>/dev/null |
455 | check_fail $? | 455 | check_fail $? |
456 | 456 | ||
457 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan gbp 2>/dev/null | 457 | ip -netns "$testns" link set dev "$vxlan" type vxlan gbp 2>/dev/null |
458 | check_fail $? | 458 | check_fail $? |
459 | 459 | ||
460 | ip netns exec "$testns" ip link set dev "$vxlan" type vxlan gpe 2>/dev/null | 460 | ip -netns "$testns" link set dev "$vxlan" type vxlan gpe 2>/dev/null |
461 | check_fail $? | 461 | check_fail $? |
462 | 462 | ||
463 | ip netns exec "$testns" ip link del "$vxlan" | 463 | ip -netns "$testns" link del "$vxlan" |
464 | check_err $? | 464 | check_err $? |
465 | 465 | ||
466 | if [ $ret -ne 0 ]; then | 466 | if [ $ret -ne 0 ]; then |
@@ -482,19 +482,19 @@ kci_test_encap_fou() | |||
482 | return $ksft_skip | 482 | return $ksft_skip |
483 | fi | 483 | fi |
484 | 484 | ||
485 | ip netns exec "$testns" ip fou add port 7777 ipproto 47 2>/dev/null | 485 | ip -netns "$testns" fou add port 7777 ipproto 47 2>/dev/null |
486 | if [ $? -ne 0 ];then | 486 | if [ $? -ne 0 ];then |
487 | echo "FAIL: can't add fou port 7777, skipping test" | 487 | echo "FAIL: can't add fou port 7777, skipping test" |
488 | return 1 | 488 | return 1 |
489 | fi | 489 | fi |
490 | 490 | ||
491 | ip netns exec "$testns" ip fou add port 8888 ipproto 4 | 491 | ip -netns "$testns" fou add port 8888 ipproto 4 |
492 | check_err $? | 492 | check_err $? |
493 | 493 | ||
494 | ip netns exec "$testns" ip fou del port 9999 2>/dev/null | 494 | ip -netns "$testns" fou del port 9999 2>/dev/null |
495 | check_fail $? | 495 | check_fail $? |
496 | 496 | ||
497 | ip netns exec "$testns" ip fou del port 7777 | 497 | ip -netns "$testns" fou del port 7777 |
498 | check_err $? | 498 | check_err $? |
499 | 499 | ||
500 | if [ $ret -ne 0 ]; then | 500 | if [ $ret -ne 0 ]; then |
@@ -517,12 +517,12 @@ kci_test_encap() | |||
517 | return $ksft_skip | 517 | return $ksft_skip |
518 | fi | 518 | fi |
519 | 519 | ||
520 | ip netns exec "$testns" ip link set lo up | 520 | ip -netns "$testns" link set lo up |
521 | check_err $? | 521 | check_err $? |
522 | 522 | ||
523 | ip netns exec "$testns" ip link add name "$devdummy" type dummy | 523 | ip -netns "$testns" link add name "$devdummy" type dummy |
524 | check_err $? | 524 | check_err $? |
525 | ip netns exec "$testns" ip link set "$devdummy" up | 525 | ip -netns "$testns" link set "$devdummy" up |
526 | check_err $? | 526 | check_err $? |
527 | 527 | ||
528 | kci_test_encap_vxlan "$testns" | 528 | kci_test_encap_vxlan "$testns" |
@@ -811,24 +811,24 @@ kci_test_gretap() | |||
811 | fi | 811 | fi |
812 | 812 | ||
813 | # test native tunnel | 813 | # test native tunnel |
814 | ip netns exec "$testns" ip link add dev "$DEV_NS" type gretap seq \ | 814 | ip -netns "$testns" link add dev "$DEV_NS" type gretap seq \ |
815 | key 102 local 172.16.1.100 remote 172.16.1.200 | 815 | key 102 local 172.16.1.100 remote 172.16.1.200 |
816 | check_err $? | 816 | check_err $? |
817 | 817 | ||
818 | ip netns exec "$testns" ip addr add dev "$DEV_NS" 10.1.1.100/24 | 818 | ip -netns "$testns" addr add dev "$DEV_NS" 10.1.1.100/24 |
819 | check_err $? | 819 | check_err $? |
820 | 820 | ||
821 | ip netns exec "$testns" ip link set dev $DEV_NS up | 821 | ip -netns "$testns" link set dev $DEV_NS up |
822 | check_err $? | 822 | check_err $? |
823 | 823 | ||
824 | ip netns exec "$testns" ip link del "$DEV_NS" | 824 | ip -netns "$testns" link del "$DEV_NS" |
825 | check_err $? | 825 | check_err $? |
826 | 826 | ||
827 | # test external mode | 827 | # test external mode |
828 | ip netns exec "$testns" ip link add dev "$DEV_NS" type gretap external | 828 | ip -netns "$testns" link add dev "$DEV_NS" type gretap external |
829 | check_err $? | 829 | check_err $? |
830 | 830 | ||
831 | ip netns exec "$testns" ip link del "$DEV_NS" | 831 | ip -netns "$testns" link del "$DEV_NS" |
832 | check_err $? | 832 | check_err $? |
833 | 833 | ||
834 | if [ $ret -ne 0 ]; then | 834 | if [ $ret -ne 0 ]; then |
@@ -861,24 +861,24 @@ kci_test_ip6gretap() | |||
861 | fi | 861 | fi |
862 | 862 | ||
863 | # test native tunnel | 863 | # test native tunnel |
864 | ip netns exec "$testns" ip link add dev "$DEV_NS" type ip6gretap seq \ | 864 | ip -netns "$testns" link add dev "$DEV_NS" type ip6gretap seq \ |
865 | key 102 local fc00:100::1 remote fc00:100::2 | 865 | key 102 local fc00:100::1 remote fc00:100::2 |
866 | check_err $? | 866 | check_err $? |
867 | 867 | ||
868 | ip netns exec "$testns" ip addr add dev "$DEV_NS" fc00:200::1/96 | 868 | ip -netns "$testns" addr add dev "$DEV_NS" fc00:200::1/96 |
869 | check_err $? | 869 | check_err $? |
870 | 870 | ||
871 | ip netns exec "$testns" ip link set dev $DEV_NS up | 871 | ip -netns "$testns" link set dev $DEV_NS up |
872 | check_err $? | 872 | check_err $? |
873 | 873 | ||
874 | ip netns exec "$testns" ip link del "$DEV_NS" | 874 | ip -netns "$testns" link del "$DEV_NS" |
875 | check_err $? | 875 | check_err $? |
876 | 876 | ||
877 | # test external mode | 877 | # test external mode |
878 | ip netns exec "$testns" ip link add dev "$DEV_NS" type ip6gretap external | 878 | ip -netns "$testns" link add dev "$DEV_NS" type ip6gretap external |
879 | check_err $? | 879 | check_err $? |
880 | 880 | ||
881 | ip netns exec "$testns" ip link del "$DEV_NS" | 881 | ip -netns "$testns" link del "$DEV_NS" |
882 | check_err $? | 882 | check_err $? |
883 | 883 | ||
884 | if [ $ret -ne 0 ]; then | 884 | if [ $ret -ne 0 ]; then |
@@ -910,40 +910,40 @@ kci_test_erspan() | |||
910 | fi | 910 | fi |
911 | 911 | ||
912 | # test native tunnel erspan v1 | 912 | # test native tunnel erspan v1 |
913 | ip netns exec "$testns" ip link add dev "$DEV_NS" type erspan seq \ | 913 | ip -netns "$testns" link add dev "$DEV_NS" type erspan seq \ |
914 | key 102 local 172.16.1.100 remote 172.16.1.200 \ | 914 | key 102 local 172.16.1.100 remote 172.16.1.200 \ |
915 | erspan_ver 1 erspan 488 | 915 | erspan_ver 1 erspan 488 |
916 | check_err $? | 916 | check_err $? |
917 | 917 | ||
918 | ip netns exec "$testns" ip addr add dev "$DEV_NS" 10.1.1.100/24 | 918 | ip -netns "$testns" addr add dev "$DEV_NS" 10.1.1.100/24 |
919 | check_err $? | 919 | check_err $? |
920 | 920 | ||
921 | ip netns exec "$testns" ip link set dev $DEV_NS up | 921 | ip -netns "$testns" link set dev $DEV_NS up |
922 | check_err $? | 922 | check_err $? |
923 | 923 | ||
924 | ip netns exec "$testns" ip link del "$DEV_NS" | 924 | ip -netns "$testns" link del "$DEV_NS" |
925 | check_err $? | 925 | check_err $? |
926 | 926 | ||
927 | # test native tunnel erspan v2 | 927 | # test native tunnel erspan v2 |
928 | ip netns exec "$testns" ip link add dev "$DEV_NS" type erspan seq \ | 928 | ip -netns "$testns" link add dev "$DEV_NS" type erspan seq \ |
929 | key 102 local 172.16.1.100 remote 172.16.1.200 \ | 929 | key 102 local 172.16.1.100 remote 172.16.1.200 \ |
930 | erspan_ver 2 erspan_dir ingress erspan_hwid 7 | 930 | erspan_ver 2 erspan_dir ingress erspan_hwid 7 |
931 | check_err $? | 931 | check_err $? |
932 | 932 | ||
933 | ip netns exec "$testns" ip addr add dev "$DEV_NS" 10.1.1.100/24 | 933 | ip -netns "$testns" addr add dev "$DEV_NS" 10.1.1.100/24 |
934 | check_err $? | 934 | check_err $? |
935 | 935 | ||
936 | ip netns exec "$testns" ip link set dev $DEV_NS up | 936 | ip -netns "$testns" link set dev $DEV_NS up |
937 | check_err $? | 937 | check_err $? |
938 | 938 | ||
939 | ip netns exec "$testns" ip link del "$DEV_NS" | 939 | ip -netns "$testns" link del "$DEV_NS" |
940 | check_err $? | 940 | check_err $? |
941 | 941 | ||
942 | # test external mode | 942 | # test external mode |
943 | ip netns exec "$testns" ip link add dev "$DEV_NS" type erspan external | 943 | ip -netns "$testns" link add dev "$DEV_NS" type erspan external |
944 | check_err $? | 944 | check_err $? |
945 | 945 | ||
946 | ip netns exec "$testns" ip link del "$DEV_NS" | 946 | ip -netns "$testns" link del "$DEV_NS" |
947 | check_err $? | 947 | check_err $? |
948 | 948 | ||
949 | if [ $ret -ne 0 ]; then | 949 | if [ $ret -ne 0 ]; then |
@@ -975,41 +975,41 @@ kci_test_ip6erspan() | |||
975 | fi | 975 | fi |
976 | 976 | ||
977 | # test native tunnel ip6erspan v1 | 977 | # test native tunnel ip6erspan v1 |
978 | ip netns exec "$testns" ip link add dev "$DEV_NS" type ip6erspan seq \ | 978 | ip -netns "$testns" link add dev "$DEV_NS" type ip6erspan seq \ |
979 | key 102 local fc00:100::1 remote fc00:100::2 \ | 979 | key 102 local fc00:100::1 remote fc00:100::2 \ |
980 | erspan_ver 1 erspan 488 | 980 | erspan_ver 1 erspan 488 |
981 | check_err $? | 981 | check_err $? |
982 | 982 | ||
983 | ip netns exec "$testns" ip addr add dev "$DEV_NS" 10.1.1.100/24 | 983 | ip -netns "$testns" addr add dev "$DEV_NS" 10.1.1.100/24 |
984 | check_err $? | 984 | check_err $? |
985 | 985 | ||
986 | ip netns exec "$testns" ip link set dev $DEV_NS up | 986 | ip -netns "$testns" link set dev $DEV_NS up |
987 | check_err $? | 987 | check_err $? |
988 | 988 | ||
989 | ip netns exec "$testns" ip link del "$DEV_NS" | 989 | ip -netns "$testns" link del "$DEV_NS" |
990 | check_err $? | 990 | check_err $? |
991 | 991 | ||
992 | # test native tunnel ip6erspan v2 | 992 | # test native tunnel ip6erspan v2 |
993 | ip netns exec "$testns" ip link add dev "$DEV_NS" type ip6erspan seq \ | 993 | ip -netns "$testns" link add dev "$DEV_NS" type ip6erspan seq \ |
994 | key 102 local fc00:100::1 remote fc00:100::2 \ | 994 | key 102 local fc00:100::1 remote fc00:100::2 \ |
995 | erspan_ver 2 erspan_dir ingress erspan_hwid 7 | 995 | erspan_ver 2 erspan_dir ingress erspan_hwid 7 |
996 | check_err $? | 996 | check_err $? |
997 | 997 | ||
998 | ip netns exec "$testns" ip addr add dev "$DEV_NS" 10.1.1.100/24 | 998 | ip -netns "$testns" addr add dev "$DEV_NS" 10.1.1.100/24 |
999 | check_err $? | 999 | check_err $? |
1000 | 1000 | ||
1001 | ip netns exec "$testns" ip link set dev $DEV_NS up | 1001 | ip -netns "$testns" link set dev $DEV_NS up |
1002 | check_err $? | 1002 | check_err $? |
1003 | 1003 | ||
1004 | ip netns exec "$testns" ip link del "$DEV_NS" | 1004 | ip -netns "$testns" link del "$DEV_NS" |
1005 | check_err $? | 1005 | check_err $? |
1006 | 1006 | ||
1007 | # test external mode | 1007 | # test external mode |
1008 | ip netns exec "$testns" ip link add dev "$DEV_NS" \ | 1008 | ip -netns "$testns" link add dev "$DEV_NS" \ |
1009 | type ip6erspan external | 1009 | type ip6erspan external |
1010 | check_err $? | 1010 | check_err $? |
1011 | 1011 | ||
1012 | ip netns exec "$testns" ip link del "$DEV_NS" | 1012 | ip -netns "$testns" link del "$DEV_NS" |
1013 | check_err $? | 1013 | check_err $? |
1014 | 1014 | ||
1015 | if [ $ret -ne 0 ]; then | 1015 | if [ $ret -ne 0 ]; then |