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

selftests/net: convert test_vxlan_nolocalbypass.sh to run it in unique namespace

Here is the test result after conversion.

]# ./test_vxlan_nolocalbypass.sh
TEST: localbypass enabled [ OK ]
TEST: Packet received by local VXLAN device - localbypass [ OK ]
TEST: localbypass disabled [ OK ]
TEST: Packet not received by local VXLAN device - nolocalbypass [ OK ]
TEST: localbypass enabled [ OK ]
TEST: Packet received by local VXLAN device - localbypass [ OK ]

Tests passed: 6
Tests failed: 0

Acked-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Hangbin Liu and committed by
David S. Miller
d79e907b a8258e64

+23 -25
+23 -25
tools/testing/selftests/net/test_vxlan_nolocalbypass.sh
··· 9 9 # option and verifies that packets are no longer received by the second VXLAN 10 10 # device. 11 11 12 + source lib.sh 12 13 ret=0 13 - # Kselftest framework requirement - SKIP code is 4. 14 - ksft_skip=4 15 14 16 15 TESTS=" 17 16 nolocalbypass ··· 97 98 98 99 setup() 99 100 { 100 - ip netns add ns1 101 + setup_ns ns1 101 102 102 - ip -n ns1 link set dev lo up 103 - ip -n ns1 address add 192.0.2.1/32 dev lo 104 - ip -n ns1 address add 198.51.100.1/32 dev lo 103 + ip -n $ns1 address add 192.0.2.1/32 dev lo 104 + ip -n $ns1 address add 198.51.100.1/32 dev lo 105 105 106 - ip -n ns1 link add name vx0 up type vxlan id 100 local 198.51.100.1 \ 106 + ip -n $ns1 link add name vx0 up type vxlan id 100 local 198.51.100.1 \ 107 107 dstport 4789 nolearning 108 - ip -n ns1 link add name vx1 up type vxlan id 100 dstport 4790 108 + ip -n $ns1 link add name vx1 up type vxlan id 100 dstport 4790 109 109 } 110 110 111 111 cleanup() 112 112 { 113 - ip netns del ns1 &> /dev/null 113 + cleanup_ns $ns1 114 114 } 115 115 116 116 ################################################################################ ··· 120 122 local smac=00:01:02:03:04:05 121 123 local dmac=00:0a:0b:0c:0d:0e 122 124 123 - run_cmd "bridge -n ns1 fdb add $dmac dev vx0 self static dst 192.0.2.1 port 4790" 125 + run_cmd "bridge -n $ns1 fdb add $dmac dev vx0 self static dst 192.0.2.1 port 4790" 124 126 125 - run_cmd "tc -n ns1 qdisc add dev vx1 clsact" 126 - run_cmd "tc -n ns1 filter add dev vx1 ingress pref 1 handle 101 proto all flower src_mac $smac dst_mac $dmac action pass" 127 + run_cmd "tc -n $ns1 qdisc add dev vx1 clsact" 128 + run_cmd "tc -n $ns1 filter add dev vx1 ingress pref 1 handle 101 proto all flower src_mac $smac dst_mac $dmac action pass" 127 129 128 - run_cmd "tc -n ns1 qdisc add dev lo clsact" 129 - run_cmd "tc -n ns1 filter add dev lo ingress pref 1 handle 101 proto ip flower ip_proto udp dst_port 4790 action drop" 130 + run_cmd "tc -n $ns1 qdisc add dev lo clsact" 131 + run_cmd "tc -n $ns1 filter add dev lo ingress pref 1 handle 101 proto ip flower ip_proto udp dst_port 4790 action drop" 130 132 131 - run_cmd "ip -n ns1 -d -j link show dev vx0 | jq -e '.[][\"linkinfo\"][\"info_data\"][\"localbypass\"] == true'" 133 + run_cmd "ip -n $ns1 -d -j link show dev vx0 | jq -e '.[][\"linkinfo\"][\"info_data\"][\"localbypass\"] == true'" 132 134 log_test $? 0 "localbypass enabled" 133 135 134 - run_cmd "ip netns exec ns1 mausezahn vx0 -a $smac -b $dmac -c 1 -p 100 -q" 136 + run_cmd "ip netns exec $ns1 mausezahn vx0 -a $smac -b $dmac -c 1 -p 100 -q" 135 137 136 - tc_check_packets "ns1" "dev vx1 ingress" 101 1 138 + tc_check_packets "$ns1" "dev vx1 ingress" 101 1 137 139 log_test $? 0 "Packet received by local VXLAN device - localbypass" 138 140 139 - run_cmd "ip -n ns1 link set dev vx0 type vxlan nolocalbypass" 141 + run_cmd "ip -n $ns1 link set dev vx0 type vxlan nolocalbypass" 140 142 141 - run_cmd "ip -n ns1 -d -j link show dev vx0 | jq -e '.[][\"linkinfo\"][\"info_data\"][\"localbypass\"] == false'" 143 + run_cmd "ip -n $ns1 -d -j link show dev vx0 | jq -e '.[][\"linkinfo\"][\"info_data\"][\"localbypass\"] == false'" 142 144 log_test $? 0 "localbypass disabled" 143 145 144 - run_cmd "ip netns exec ns1 mausezahn vx0 -a $smac -b $dmac -c 1 -p 100 -q" 146 + run_cmd "ip netns exec $ns1 mausezahn vx0 -a $smac -b $dmac -c 1 -p 100 -q" 145 147 146 - tc_check_packets "ns1" "dev vx1 ingress" 101 1 148 + tc_check_packets "$ns1" "dev vx1 ingress" 101 1 147 149 log_test $? 0 "Packet not received by local VXLAN device - nolocalbypass" 148 150 149 - run_cmd "ip -n ns1 link set dev vx0 type vxlan localbypass" 151 + run_cmd "ip -n $ns1 link set dev vx0 type vxlan localbypass" 150 152 151 - run_cmd "ip -n ns1 -d -j link show dev vx0 | jq -e '.[][\"linkinfo\"][\"info_data\"][\"localbypass\"] == true'" 153 + run_cmd "ip -n $ns1 -d -j link show dev vx0 | jq -e '.[][\"linkinfo\"][\"info_data\"][\"localbypass\"] == true'" 152 154 log_test $? 0 "localbypass enabled" 153 155 154 - run_cmd "ip netns exec ns1 mausezahn vx0 -a $smac -b $dmac -c 1 -p 100 -q" 156 + run_cmd "ip netns exec $ns1 mausezahn vx0 -a $smac -b $dmac -c 1 -p 100 -q" 155 157 156 - tc_check_packets "ns1" "dev vx1 ingress" 101 2 158 + tc_check_packets "$ns1" "dev vx1 ingress" 101 2 157 159 log_test $? 0 "Packet received by local VXLAN device - localbypass" 158 160 } 159 161