Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # Various combinations of VRF with xfrms and qdisc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) # Kselftest framework requirement - SKIP code is 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) ksft_skip=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) PAUSE_ON_FAIL=no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) VERBOSE=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) ret=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) HOST1_4=192.168.1.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) HOST2_4=192.168.1.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) HOST1_6=2001:db8:1::1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) HOST2_6=2001:db8:1::2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) XFRM1_4=10.0.1.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) XFRM2_4=10.0.1.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) XFRM1_6=fc00:1000::1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) XFRM2_6=fc00:1000::2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) IF_ID=123
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) VRF=red
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) TABLE=300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) AUTH_1=0xd94fcfea65fddf21dc6e0d24a0253508
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) AUTH_2=0xdc6e0d24a0253508d94fcfea65fddf21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) ENC_1=0xfc46c20f8048be9725930ff3fb07ac2a91f0347dffeacf62
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) ENC_2=0x3fb07ac2a91f0347dffeacf62fc46c20f8048be9725930ff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) SPI_1=0x02122b77
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) SPI_2=0x2b770212
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) ################################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) log_test()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	local rc=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	local expected=$2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	local msg="$3"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	if [ ${rc} -eq ${expected} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		printf "TEST: %-60s  [ OK ]\n" "${msg}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		nsuccess=$((nsuccess+1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		ret=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		nfail=$((nfail+1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		printf "TEST: %-60s  [FAIL]\n" "${msg}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			echo "hit enter to continue, 'q' to quit"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 			read a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 			[ "$a" = "q" ] && exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) run_cmd_host1()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	local cmd="$*"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	local out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	local rc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if [ "$VERBOSE" = "1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		printf "    COMMAND: $cmd\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	out=$(eval ip netns exec host1 $cmd 2>&1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	rc=$?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if [ "$VERBOSE" = "1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		if [ -n "$out" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			echo "    $out"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	return $rc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) ################################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) # create namespaces for hosts and sws
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) create_vrf()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	local ns=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	local vrf=$2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	local table=$3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if [ -n "${ns}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		ns="-netns ${ns}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	ip ${ns} link add ${vrf} type vrf table ${table}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ip ${ns} link set ${vrf} up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	ip ${ns} route add vrf ${vrf} unreachable default metric 8192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	ip ${ns} -6 route add vrf ${vrf} unreachable default metric 8192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	ip ${ns} addr add 127.0.0.1/8 dev ${vrf}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	ip ${ns} -6 addr add ::1 dev ${vrf} nodad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	ip ${ns} ru del pref 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	ip ${ns} ru add pref 32765 from all lookup local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	ip ${ns} -6 ru del pref 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	ip ${ns} -6 ru add pref 32765 from all lookup local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) create_ns()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	local ns=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	local addr=$2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	local addr6=$3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	[ -z "${addr}" ] && addr="-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	[ -z "${addr6}" ] && addr6="-"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	ip netns add ${ns}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	ip -netns ${ns} link set lo up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	if [ "${addr}" != "-" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		ip -netns ${ns} addr add dev lo ${addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if [ "${addr6}" != "-" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		ip -netns ${ns} -6 addr add dev lo ${addr6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	ip -netns ${ns} ro add unreachable default metric 8192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	ip -netns ${ns} -6 ro add unreachable default metric 8192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	ip netns exec ${ns} sysctl -qw net.ipv4.ip_forward=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	ip netns exec ${ns} sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	ip netns exec ${ns} sysctl -qw net.ipv6.conf.all.forwarding=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	ip netns exec ${ns} sysctl -qw net.ipv6.conf.default.forwarding=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	ip netns exec ${ns} sysctl -qw net.ipv6.conf.default.accept_dad=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) # create veth pair to connect namespaces and apply addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) connect_ns()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	local ns1=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	local ns1_dev=$2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	local ns1_addr=$3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	local ns1_addr6=$4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	local ns2=$5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	local ns2_dev=$6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	local ns2_addr=$7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	local ns2_addr6=$8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	local ns1arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	local ns2arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if [ -n "${ns1}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		ns1arg="-netns ${ns1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if [ -n "${ns2}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		ns2arg="-netns ${ns2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	ip ${ns1arg} li add ${ns1_dev} type veth peer name tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	ip ${ns1arg} li set ${ns1_dev} up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	ip ${ns1arg} li set tmp netns ${ns2} name ${ns2_dev}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	ip ${ns2arg} li set ${ns2_dev} up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	if [ "${ns1_addr}" != "-" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		ip ${ns1arg} addr add dev ${ns1_dev} ${ns1_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		ip ${ns2arg} addr add dev ${ns2_dev} ${ns2_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if [ "${ns1_addr6}" != "-" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		ip ${ns1arg} addr add dev ${ns1_dev} ${ns1_addr6} nodad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		ip ${ns2arg} addr add dev ${ns2_dev} ${ns2_addr6} nodad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ################################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) cleanup()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	ip netns del host1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	ip netns del host2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) setup()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	create_ns "host1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	create_ns "host2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	connect_ns "host1" eth0 ${HOST1_4}/24 ${HOST1_6}/64 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	           "host2" eth0 ${HOST2_4}/24 ${HOST2_6}/64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	create_vrf "host1" ${VRF} ${TABLE}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	ip -netns host1 link set dev eth0 master ${VRF}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) cleanup_xfrm()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	for ns in host1 host2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		for x in state policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			ip -netns ${ns} xfrm ${x} flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			ip -6 -netns ${ns} xfrm ${x} flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) setup_xfrm()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	local h1_4=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	local h2_4=$2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	local h1_6=$3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	local h2_6=$4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	local devarg="$5"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	# policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	# host1 - IPv4 out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	ip -netns host1 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	  src ${h1_4} dst ${h2_4} ${devarg} dir out \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	  tmpl src ${HOST1_4} dst ${HOST2_4} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	# host2 - IPv4 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	ip -netns host2 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	  src ${h1_4} dst ${h2_4} dir in \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	  tmpl src ${HOST1_4} dst ${HOST2_4} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	# host1 - IPv4 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	ip -netns host1 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	  src ${h2_4} dst ${h1_4} ${devarg} dir in \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	  tmpl src ${HOST2_4} dst ${HOST1_4} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	# host2 - IPv4 out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	ip -netns host2 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	  src ${h2_4} dst ${h1_4} dir out \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	  tmpl src ${HOST2_4} dst ${HOST1_4} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	# host1 - IPv6 out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	ip -6 -netns host1 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	  src ${h1_6} dst ${h2_6} ${devarg} dir out \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	  tmpl src ${HOST1_6} dst ${HOST2_6} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	# host2 - IPv6 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	ip -6 -netns host2 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	  src ${h1_6} dst ${h2_6} dir in \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	  tmpl src ${HOST1_6} dst ${HOST2_6} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	# host1 - IPv6 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	ip -6 -netns host1 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	  src ${h2_6} dst ${h1_6} ${devarg} dir in \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	  tmpl src ${HOST2_6} dst ${HOST1_6} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	# host2 - IPv6 out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	ip -6 -netns host2 xfrm policy add \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	  src ${h2_6} dst ${h1_6} dir out \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	  tmpl src ${HOST2_6} dst ${HOST1_6} proto esp mode tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	# state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	ip -netns host1 xfrm state add src ${HOST1_4} dst ${HOST2_4} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	    proto esp spi ${SPI_1} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	    auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	    enc 'cbc(des3_ede)' ${ENC_1} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	    sel src ${h1_4} dst ${h2_4} ${devarg}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	ip -netns host2 xfrm state add src ${HOST1_4} dst ${HOST2_4} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	    proto esp spi ${SPI_1} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	    auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	    enc 'cbc(des3_ede)' ${ENC_1} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	    sel src ${h1_4} dst ${h2_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	ip -netns host1 xfrm state add src ${HOST2_4} dst ${HOST1_4} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	    proto esp spi ${SPI_2} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	    auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	    enc 'cbc(des3_ede)' ${ENC_2} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	    sel src ${h2_4} dst ${h1_4} ${devarg}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	ip -netns host2 xfrm state add src ${HOST2_4} dst ${HOST1_4} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	    proto esp spi ${SPI_2} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	    auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	    enc 'cbc(des3_ede)' ${ENC_2} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	    sel src ${h2_4} dst ${h1_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	ip -6 -netns host1 xfrm state add src ${HOST1_6} dst ${HOST2_6} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	    proto esp spi ${SPI_1} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	    auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	    enc 'cbc(des3_ede)' ${ENC_1} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	    sel src ${h1_6} dst ${h2_6} ${devarg}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	ip -6 -netns host2 xfrm state add src ${HOST1_6} dst ${HOST2_6} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	    proto esp spi ${SPI_1} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	    auth-trunc 'hmac(md5)' ${AUTH_1} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	    enc 'cbc(des3_ede)' ${ENC_1} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	    sel src ${h1_6} dst ${h2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	ip -6 -netns host1 xfrm state add src ${HOST2_6} dst ${HOST1_6} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	    proto esp spi ${SPI_2} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	    auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	    enc 'cbc(des3_ede)' ${ENC_2} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	    sel src ${h2_6} dst ${h1_6} ${devarg}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	ip -6 -netns host2 xfrm state add src ${HOST2_6} dst ${HOST1_6} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	    proto esp spi ${SPI_2} reqid 0 mode tunnel \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	    replay-window 4 replay-oseq 0x4 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	    auth-trunc 'hmac(md5)' ${AUTH_2} 96 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	    enc 'cbc(des3_ede)' ${ENC_2} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	    sel src ${h2_6} dst ${h1_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) cleanup_xfrm_dev()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	ip -netns host1 li del xfrm0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	ip -netns host2 addr del ${XFRM2_4}/24 dev eth0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	ip -netns host2 addr del ${XFRM2_6}/64 dev eth0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) setup_xfrm_dev()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	local vrfarg="vrf ${VRF}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	ip -netns host1 li add type xfrm dev eth0 if_id ${IF_ID}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	ip -netns host1 li set xfrm0 ${vrfarg} up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	ip -netns host1 addr add ${XFRM1_4}/24 dev xfrm0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	ip -netns host1 addr add ${XFRM1_6}/64 dev xfrm0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	ip -netns host2 addr add ${XFRM2_4}/24 dev eth0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	ip -netns host2 addr add ${XFRM2_6}/64 dev eth0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	setup_xfrm ${XFRM1_4} ${XFRM2_4} ${XFRM1_6} ${XFRM2_6} "if_id ${IF_ID}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) run_tests()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	cleanup_xfrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	# no IPsec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	run_cmd_host1 ip vrf exec ${VRF} ping -c1 -w1 ${HOST2_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	log_test $? 0 "IPv4 no xfrm policy"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	run_cmd_host1 ip vrf exec ${VRF} ${ping6} -c1 -w1 ${HOST2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	log_test $? 0 "IPv6 no xfrm policy"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	# xfrm without VRF in sel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	setup_xfrm ${HOST1_4} ${HOST2_4} ${HOST1_6} ${HOST2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	run_cmd_host1 ip vrf exec ${VRF} ping -c1 -w1 ${HOST2_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	log_test $? 0 "IPv4 xfrm policy based on address"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	run_cmd_host1 ip vrf exec ${VRF} ${ping6} -c1 -w1 ${HOST2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	log_test $? 0 "IPv6 xfrm policy based on address"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	cleanup_xfrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	# xfrm with VRF in sel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	# Known failure: ipv4 resets the flow oif after the lookup. Fix is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	# not straightforward.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	# setup_xfrm ${HOST1_4} ${HOST2_4} ${HOST1_6} ${HOST2_6} "dev ${VRF}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	# run_cmd_host1 ip vrf exec ${VRF} ping -c1 -w1 ${HOST2_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	# log_test $? 0 "IPv4 xfrm policy with VRF in selector"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	run_cmd_host1 ip vrf exec ${VRF} ${ping6} -c1 -w1 ${HOST2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	log_test $? 0 "IPv6 xfrm policy with VRF in selector"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	cleanup_xfrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	# xfrm with enslaved device in sel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	# Known failures: combined with the above, __xfrm{4,6}_selector_match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	# needs to consider both l3mdev and enslaved device index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	# setup_xfrm ${HOST1_4} ${HOST2_4} ${HOST1_6} ${HOST2_6} "dev eth0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	# run_cmd_host1 ip vrf exec ${VRF} ping -c1 -w1 ${HOST2_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	# log_test $? 0 "IPv4 xfrm policy with enslaved device in selector"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	# run_cmd_host1 ip vrf exec ${VRF} ${ping6} -c1 -w1 ${HOST2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	# log_test $? 0 "IPv6 xfrm policy with enslaved device in selector"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	# cleanup_xfrm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	# xfrm device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	setup_xfrm_dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	run_cmd_host1 ip vrf exec ${VRF} ping -c1 -w1 ${XFRM2_4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	log_test $? 0 "IPv4 xfrm policy with xfrm device"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	run_cmd_host1 ip vrf exec ${VRF} ${ping6} -c1 -w1 ${XFRM2_6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	log_test $? 0 "IPv6 xfrm policy with xfrm device"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	cleanup_xfrm_dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) ################################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) # usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) usage()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)         cat <<EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) usage: ${0##*/} OPTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)         -p          Pause on fail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)         -v          verbose mode (show commands and output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) ################################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) # main
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) while getopts :pv o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	case $o in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		p) PAUSE_ON_FAIL=yes;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		v) VERBOSE=$(($VERBOSE + 1));;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		h) usage; exit 0;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		*) usage; exit 1;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) cleanup 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) echo "No qdisc on VRF device"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) run_tests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) run_cmd_host1 tc qdisc add dev ${VRF} root netem delay 100ms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) echo "netem qdisc on VRF device"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) run_tests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) printf "\nTests passed: %3d\n" ${nsuccess}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) printf "Tests failed: %3d\n"   ${nfail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) exit $ret