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

Merge branch 'net-selftests-mirroring-cleanup' into main

Petr Machata says:

====================
selftest: Clean-up and stabilize mirroring tests

The mirroring selftests work by sending ICMP traffic between two hosts.
Along the way, this traffic is mirrored to a gretap netdevice, and counter
taps are then installed strategically along the path of the mirrored
traffic to verify the mirroring took place.

The problem with this is that besides mirroring the primary traffic, any
other service traffic is mirrored as well. At the same time, because the
tests need to work in HW-offloaded scenarios, the ability of the device to
do arbitrary packet inspection should not be taken for granted. Most tests
therefore simply use matchall, one uses flower to match on IP address.
As a result, the selftests are noisy.

mirror_test() accommodated this noisiness by giving the counters an
allowance of several packets. But that only works up to a point, and on
busy systems won't be always enough.

In this patch set, clean up and stabilize the mirroring selftests. The
original intention was to port the tests over to UDP, but the logic of
ICMP ends up being so entangled in the mirroring selftests that the
changes feel overly invasive. Instead, ICMP is kept, but where possible,
we match on ICMP message type, thus filtering out hits by other ICMP
messages.

Where this is not practical (where the counter tap is put on a device
that carries encapsulated packets), switch the counter condition to _at
least_ X observed packets. This is less robust, but barely so --
probably the only scenario that this would not catch is something like
erroneous packet duplication, which would hopefully get caught by the
numerous other tests in this extensive suite.

- Patches #1 to #3 clean up parameters at various helpers.

- Patches #4 to #6 stabilize the mirroring selftests as described above.

- Mirroring tests currently allow testing SW datapath even on HW
netdevices by trapping traffic to the SW datapath. This complicates
the tests a bit without a good reason: to test SW datapath, just run
the selftests on the veth topology. Thus in patch #7, drop support for
this dual SW/HW testing.

- At this point, some cleanups were either made possible by the previous
patches, or were always possible. In patches #8 to #11, realize these
cleanups.

- In patch #12, fix mlxsw mirror_gre selftest to respect setting TESTS.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+355 -538
+28 -43
tools/testing/selftests/drivers/net/mlxsw/mirror_gre.sh
··· 15 15 source $lib_dir/mirror_gre_lib.sh 16 16 source $lib_dir/mirror_gre_topo_lib.sh 17 17 18 + ALL_TESTS=" 19 + test_keyful 20 + test_soft 21 + test_tos_fixed 22 + test_ttl_inherit 23 + " 24 + 18 25 setup_keyful() 19 26 { 20 27 tunnel_create gt6-key ip6gretap 2001:db8:3::1 2001:db8:3::2 \ ··· 125 118 RET=0 126 119 127 120 ip link set dev $tundev type $type ttl inherit 128 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 129 - fail_test_span_gre_dir $tundev ingress 121 + mirror_install $swp1 ingress $tundev "matchall" 122 + fail_test_span_gre_dir $tundev 130 123 131 124 ip link set dev $tundev type $type ttl 100 132 125 133 - quick_test_span_gre_dir $tundev ingress 126 + quick_test_span_gre_dir $tundev 134 127 mirror_uninstall $swp1 ingress 135 128 136 - log_test "$what: no offload on TTL of inherit ($tcflags)" 129 + log_test "$what: no offload on TTL of inherit" 137 130 } 138 131 139 132 test_span_gre_tos_fixed() ··· 145 138 RET=0 146 139 147 140 ip link set dev $tundev type $type tos 0x10 148 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 149 - fail_test_span_gre_dir $tundev ingress 141 + mirror_install $swp1 ingress $tundev "matchall" 142 + fail_test_span_gre_dir $tundev 150 143 151 144 ip link set dev $tundev type $type tos inherit 152 - quick_test_span_gre_dir $tundev ingress 145 + quick_test_span_gre_dir $tundev 153 146 mirror_uninstall $swp1 ingress 154 147 155 - log_test "$what: no offload on a fixed TOS ($tcflags)" 148 + log_test "$what: no offload on a fixed TOS" 156 149 } 157 150 158 151 test_span_failable() 159 152 { 160 - local should_fail=$1; shift 161 153 local tundev=$1; shift 162 154 local what=$1; shift 163 155 164 156 RET=0 165 157 166 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 167 - if ((should_fail)); then 168 - fail_test_span_gre_dir $tundev ingress 169 - else 170 - quick_test_span_gre_dir $tundev ingress 171 - fi 158 + mirror_install $swp1 ingress $tundev "matchall" 159 + fail_test_span_gre_dir $tundev 172 160 mirror_uninstall $swp1 ingress 173 161 174 - log_test "$what: should_fail=$should_fail ($tcflags)" 162 + log_test "fail $what" 175 163 } 176 164 177 - test_failable() 165 + test_keyful() 178 166 { 179 - local should_fail=$1; shift 180 - 181 - test_span_failable $should_fail gt6-key "mirror to keyful gretap" 182 - test_span_failable $should_fail gt6-soft "mirror to gretap w/ soft underlay" 167 + test_span_failable gt6-key "mirror to keyful gretap" 183 168 } 184 169 185 - test_sw() 170 + test_soft() 186 171 { 187 - slow_path_trap_install $swp1 ingress 188 - slow_path_trap_install $swp1 egress 189 - 190 - test_failable 0 191 - 192 - slow_path_trap_uninstall $swp1 egress 193 - slow_path_trap_uninstall $swp1 ingress 172 + test_span_failable gt6-soft "mirror to gretap w/ soft underlay" 194 173 } 195 174 196 - test_hw() 175 + test_tos_fixed() 197 176 { 198 - test_failable 1 199 - 200 177 test_span_gre_tos_fixed gt4 gretap "mirror to gretap" 201 178 test_span_gre_tos_fixed gt6 ip6gretap "mirror to ip6gretap" 179 + } 202 180 181 + 182 + test_ttl_inherit() 183 + { 203 184 test_span_gre_ttl_inherit gt4 gretap "mirror to gretap" 204 185 test_span_gre_ttl_inherit gt6 ip6gretap "mirror to ip6gretap" 205 186 } ··· 197 202 setup_prepare 198 203 setup_wait 199 204 200 - if ! tc_offload_check; then 201 - check_err 1 "Could not test offloaded functionality" 202 - log_test "mlxsw-specific tests for mirror to gretap" 203 - exit 204 - fi 205 - 206 - tcflags="skip_hw" 207 - test_sw 208 - 209 - tcflags="skip_sw" 210 - test_hw 205 + tests_run 211 206 212 207 exit $EXIT_STATUS
+2 -16
tools/testing/selftests/drivers/net/mlxsw/mirror_gre_scale.sh
··· 79 79 cat >> $MIRROR_GRE_BATCH_FILE <<-EOF 80 80 filter add dev $swp1 ingress pref 1000 \ 81 81 protocol ipv6 \ 82 - flower $tcflags dst_ip $match_dip \ 82 + flower skip_sw dst_ip $match_dip \ 83 83 action mirred egress mirror dev $tun 84 84 EOF 85 85 done ··· 107 107 done 108 108 } 109 109 110 - __mirror_gre_test() 110 + mirror_gre_test() 111 111 { 112 112 local count=$1; shift 113 113 local should_fail=$1; shift ··· 129 129 mirror_test v$h1 $sip $dip $htun 100 10 130 130 icmp6_capture_uninstall $htun 131 131 done 132 - } 133 - 134 - mirror_gre_test() 135 - { 136 - local count=$1; shift 137 - local should_fail=$1; shift 138 - 139 - if ! tc_offload_check $TC_FLOWER_NUM_NETIFS; then 140 - check_err 1 "Could not test offloaded functionality" 141 - return 142 - fi 143 - 144 - tcflags="skip_sw" 145 - __mirror_gre_test $count $should_fail 146 132 } 147 133 148 134 mirror_gre_setup_prepare()
+56 -27
tools/testing/selftests/net/forwarding/lib.sh
··· 1225 1225 tc filter del dev $dev $direction pref 1 flower 1226 1226 } 1227 1227 1228 - slow_path_trap_install() 1229 - { 1230 - # For slow-path testing, we need to install a trap to get to 1231 - # slow path the packets that would otherwise be switched in HW. 1232 - if [ "${tcflags/skip_hw}" != "$tcflags" ]; then 1233 - trap_install "$@" 1234 - fi 1235 - } 1236 - 1237 - slow_path_trap_uninstall() 1238 - { 1239 - if [ "${tcflags/skip_hw}" != "$tcflags" ]; then 1240 - trap_uninstall "$@" 1241 - fi 1242 - } 1243 - 1244 1228 __icmp_capture_add_del() 1245 1229 { 1246 1230 local add_del=$1; shift ··· 1241 1257 1242 1258 icmp_capture_install() 1243 1259 { 1244 - __icmp_capture_add_del add 100 "" "$@" 1260 + local tundev=$1; shift 1261 + local filter=$1; shift 1262 + 1263 + __icmp_capture_add_del add 100 "" "$tundev" "$filter" 1245 1264 } 1246 1265 1247 1266 icmp_capture_uninstall() 1248 1267 { 1249 - __icmp_capture_add_del del 100 "" "$@" 1268 + local tundev=$1; shift 1269 + local filter=$1; shift 1270 + 1271 + __icmp_capture_add_del del 100 "" "$tundev" "$filter" 1250 1272 } 1251 1273 1252 1274 icmp6_capture_install() 1253 1275 { 1254 - __icmp_capture_add_del add 100 v6 "$@" 1276 + local tundev=$1; shift 1277 + local filter=$1; shift 1278 + 1279 + __icmp_capture_add_del add 100 v6 "$tundev" "$filter" 1255 1280 } 1256 1281 1257 1282 icmp6_capture_uninstall() 1258 1283 { 1259 - __icmp_capture_add_del del 100 v6 "$@" 1284 + local tundev=$1; shift 1285 + local filter=$1; shift 1286 + 1287 + __icmp_capture_add_del del 100 v6 "$tundev" "$filter" 1260 1288 } 1261 1289 1262 1290 __vlan_capture_add_del() ··· 1286 1290 1287 1291 vlan_capture_install() 1288 1292 { 1289 - __vlan_capture_add_del add 100 "$@" 1293 + local dev=$1; shift 1294 + local filter=$1; shift 1295 + 1296 + __vlan_capture_add_del add 100 "$dev" "$filter" 1290 1297 } 1291 1298 1292 1299 vlan_capture_uninstall() 1293 1300 { 1294 - __vlan_capture_add_del del 100 "$@" 1301 + local dev=$1; shift 1302 + local filter=$1; shift 1303 + 1304 + __vlan_capture_add_del del 100 "$dev" "$filter" 1295 1305 } 1296 1306 1297 1307 __dscp_capture_add_del() ··· 1657 1655 local sip=$1; shift 1658 1656 local dip=$1; shift 1659 1657 local dmac=$1; shift 1658 + local -a mz_args=("$@") 1660 1659 1661 1660 $MZ $h_in -p $pktsize -A $sip -B $dip -c 0 \ 1662 - -a own -b $dmac -t "$proto" -q "$@" & 1661 + -a own -b $dmac -t "$proto" -q "${mz_args[@]}" & 1663 1662 sleep 1 1664 1663 } 1665 1664 1666 1665 start_traffic_pktsize() 1667 1666 { 1668 1667 local pktsize=$1; shift 1668 + local h_in=$1; shift 1669 + local sip=$1; shift 1670 + local dip=$1; shift 1671 + local dmac=$1; shift 1672 + local -a mz_args=("$@") 1669 1673 1670 - __start_traffic $pktsize udp "$@" 1674 + __start_traffic $pktsize udp "$h_in" "$sip" "$dip" "$dmac" \ 1675 + "${mz_args[@]}" 1671 1676 } 1672 1677 1673 1678 start_tcp_traffic_pktsize() 1674 1679 { 1675 1680 local pktsize=$1; shift 1681 + local h_in=$1; shift 1682 + local sip=$1; shift 1683 + local dip=$1; shift 1684 + local dmac=$1; shift 1685 + local -a mz_args=("$@") 1676 1686 1677 - __start_traffic $pktsize tcp "$@" 1687 + __start_traffic $pktsize tcp "$h_in" "$sip" "$dip" "$dmac" \ 1688 + "${mz_args[@]}" 1678 1689 } 1679 1690 1680 1691 start_traffic() 1681 1692 { 1682 - start_traffic_pktsize 8000 "$@" 1693 + local h_in=$1; shift 1694 + local sip=$1; shift 1695 + local dip=$1; shift 1696 + local dmac=$1; shift 1697 + local -a mz_args=("$@") 1698 + 1699 + start_traffic_pktsize 8000 "$h_in" "$sip" "$dip" "$dmac" \ 1700 + "${mz_args[@]}" 1683 1701 } 1684 1702 1685 1703 start_tcp_traffic() 1686 1704 { 1687 - start_tcp_traffic_pktsize 8000 "$@" 1705 + local h_in=$1; shift 1706 + local sip=$1; shift 1707 + local dip=$1; shift 1708 + local dmac=$1; shift 1709 + local -a mz_args=("$@") 1710 + 1711 + start_tcp_traffic_pktsize 8000 "$h_in" "$sip" "$dip" "$dmac" \ 1712 + "${mz_args[@]}" 1688 1713 } 1689 1714 1690 1715 stop_traffic()
+13 -32
tools/testing/selftests/net/forwarding/mirror_gre.sh
··· 74 74 75 75 RET=0 76 76 77 - mirror_install $swp1 $direction $tundev "matchall $tcflags" 77 + mirror_install $swp1 $direction $tundev "matchall" 78 78 icmp_capture_install h3-${tundev} "src_mac $src_mac dst_mac $dst_mac" 79 79 80 80 mirror_test v$h1 192.0.2.1 192.0.2.2 h3-${tundev} 100 10 ··· 82 82 icmp_capture_uninstall h3-${tundev} 83 83 mirror_uninstall $swp1 $direction 84 84 85 - log_test "$direction $what: envelope MAC ($tcflags)" 85 + log_test "$direction $what: envelope MAC" 86 86 } 87 87 88 88 test_two_spans() 89 89 { 90 90 RET=0 91 91 92 - mirror_install $swp1 ingress gt4 "matchall $tcflags" 93 - mirror_install $swp1 egress gt6 "matchall $tcflags" 94 - quick_test_span_gre_dir gt4 ingress 95 - quick_test_span_gre_dir gt6 egress 92 + mirror_install $swp1 ingress gt4 "matchall" 93 + mirror_install $swp1 egress gt6 "matchall" 94 + quick_test_span_gre_dir gt4 8 0 95 + quick_test_span_gre_dir gt6 0 8 96 96 97 97 mirror_uninstall $swp1 ingress 98 - fail_test_span_gre_dir gt4 ingress 99 - quick_test_span_gre_dir gt6 egress 98 + fail_test_span_gre_dir gt4 8 0 99 + quick_test_span_gre_dir gt6 0 8 100 100 101 - mirror_install $swp1 ingress gt4 "matchall $tcflags" 101 + mirror_install $swp1 ingress gt4 "matchall" 102 102 mirror_uninstall $swp1 egress 103 - quick_test_span_gre_dir gt4 ingress 104 - fail_test_span_gre_dir gt6 egress 103 + quick_test_span_gre_dir gt4 8 0 104 + fail_test_span_gre_dir gt6 0 8 105 105 106 106 mirror_uninstall $swp1 ingress 107 - log_test "two simultaneously configured mirrors ($tcflags)" 107 + log_test "two simultaneously configured mirrors" 108 108 } 109 109 110 110 test_gretap() ··· 131 131 test_span_gre_mac gt6 egress "mirror to ip6gretap" 132 132 } 133 133 134 - test_all() 135 - { 136 - slow_path_trap_install $swp1 ingress 137 - slow_path_trap_install $swp1 egress 138 - 139 - tests_run 140 - 141 - slow_path_trap_uninstall $swp1 egress 142 - slow_path_trap_uninstall $swp1 ingress 143 - } 144 - 145 134 trap cleanup EXIT 146 135 147 136 setup_prepare 148 137 setup_wait 149 138 150 - tcflags="skip_hw" 151 - test_all 152 - 153 - if ! tc_offload_check; then 154 - echo "WARN: Could not test offloaded functionality" 155 - else 156 - tcflags="skip_sw" 157 - test_all 158 - fi 139 + tests_run 159 140 160 141 exit $EXIT_STATUS
+1 -22
tools/testing/selftests/net/forwarding/mirror_gre_bound.sh
··· 196 196 full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap w/ UL" 197 197 } 198 198 199 - test_all() 200 - { 201 - RET=0 202 - 203 - slow_path_trap_install $swp1 ingress 204 - slow_path_trap_install $swp1 egress 205 - 206 - tests_run 207 - 208 - slow_path_trap_uninstall $swp1 egress 209 - slow_path_trap_uninstall $swp1 ingress 210 - } 211 - 212 199 trap cleanup EXIT 213 200 214 201 setup_prepare 215 202 setup_wait 216 203 217 - tcflags="skip_hw" 218 - test_all 219 - 220 - if ! tc_offload_check; then 221 - echo "WARN: Could not test offloaded functionality" 222 - else 223 - tcflags="skip_sw" 224 - test_all 225 - fi 204 + tests_run 226 205 227 206 exit $EXIT_STATUS
+1 -20
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d.sh
··· 108 108 full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap" 109 109 } 110 110 111 - test_all() 112 - { 113 - slow_path_trap_install $swp1 ingress 114 - slow_path_trap_install $swp1 egress 115 - 116 - tests_run 117 - 118 - slow_path_trap_uninstall $swp1 egress 119 - slow_path_trap_uninstall $swp1 ingress 120 - } 121 - 122 111 trap cleanup EXIT 123 112 124 113 setup_prepare 125 114 setup_wait 126 115 127 - tcflags="skip_hw" 128 - test_all 129 - 130 - if ! tc_offload_check; then 131 - echo "WARN: Could not test offloaded functionality" 132 - else 133 - tcflags="skip_sw" 134 - test_all 135 - fi 116 + tests_run 136 117 137 118 exit $EXIT_STATUS
+1 -20
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
··· 104 104 full_test_span_gre_stp gt6 $swp3.555 "mirror to ip6gretap" 105 105 } 106 106 107 - test_all() 108 - { 109 - slow_path_trap_install $swp1 ingress 110 - slow_path_trap_install $swp1 egress 111 - 112 - tests_run 113 - 114 - slow_path_trap_uninstall $swp1 egress 115 - slow_path_trap_uninstall $swp1 ingress 116 - } 117 - 118 107 trap cleanup EXIT 119 108 120 109 setup_prepare 121 110 setup_wait 122 111 123 - tcflags="skip_hw" 124 - test_all 125 - 126 - if ! tc_offload_check; then 127 - echo "WARN: Could not test offloaded functionality" 128 - else 129 - tcflags="skip_sw" 130 - test_all 131 - fi 112 + tests_run 132 113 133 114 exit $EXIT_STATUS
+1 -20
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1q.sh
··· 104 104 full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap" 105 105 } 106 106 107 - tests() 108 - { 109 - slow_path_trap_install $swp1 ingress 110 - slow_path_trap_install $swp1 egress 111 - 112 - tests_run 113 - 114 - slow_path_trap_uninstall $swp1 egress 115 - slow_path_trap_uninstall $swp1 ingress 116 - } 117 - 118 107 trap cleanup EXIT 119 108 120 109 setup_prepare 121 110 setup_wait 122 111 123 - tcflags="skip_hw" 124 - tests 125 - 126 - if ! tc_offload_check; then 127 - echo "WARN: Could not test offloaded functionality" 128 - else 129 - tcflags="skip_sw" 130 - tests 131 - fi 112 + tests_run 132 113 133 114 exit $EXIT_STATUS
+5 -24
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1q_lag.sh
··· 227 227 RET=0 228 228 229 229 tc filter add dev $swp1 ingress pref 999 \ 230 - proto 802.1q flower vlan_ethtype arp $tcflags \ 230 + proto 802.1q flower vlan_ethtype arp \ 231 231 action pass 232 232 mirror_install $swp1 ingress gt4 \ 233 - "proto 802.1q flower vlan_id 333 $tcflags" 233 + "proto 802.1q flower vlan_id 333" 234 234 235 235 # Test connectivity through $up_dev when $down_dev is set down. 236 236 ip link set dev $down_dev down ··· 239 239 setup_wait_dev $host_dev 240 240 $ARPING -I br1 192.0.2.130 -qfc 1 241 241 sleep 2 242 - mirror_test vrf-h1 192.0.2.1 192.0.2.18 $host_dev 1 10 242 + mirror_test vrf-h1 192.0.2.1 192.0.2.18 $host_dev 1 ">= 10" 243 243 244 244 # Test lack of connectivity when both slaves are down. 245 245 ip link set dev $up_dev down ··· 252 252 mirror_uninstall $swp1 ingress 253 253 tc filter del dev $swp1 ingress pref 999 254 254 255 - log_test "$what ($tcflags)" 255 + log_test "$what" 256 256 } 257 257 258 258 test_mirror_gretap_first() ··· 265 265 test_lag_slave $h4 $swp4 $swp3 "mirror to gretap: LAG second slave" 266 266 } 267 267 268 - test_all() 269 - { 270 - slow_path_trap_install $swp1 ingress 271 - slow_path_trap_install $swp1 egress 272 - 273 - tests_run 274 - 275 - slow_path_trap_uninstall $swp1 egress 276 - slow_path_trap_uninstall $swp1 ingress 277 - } 278 - 279 268 trap cleanup EXIT 280 269 281 270 setup_prepare 282 271 setup_wait 283 272 284 - tcflags="skip_hw" 285 - test_all 286 - 287 - if ! tc_offload_check; then 288 - echo "WARN: Could not test offloaded functionality" 289 - else 290 - tcflags="skip_sw" 291 - test_all 292 - fi 273 + tests_run 293 274 294 275 exit $EXIT_STATUS
+27 -46
tools/testing/selftests/net/forwarding/mirror_gre_changes.sh
··· 73 73 RET=0 74 74 75 75 mirror_install $swp1 ingress $tundev \ 76 - "prot ip flower $tcflags ip_prot icmp" 76 + "prot ip flower ip_prot icmp" 77 77 tc filter add dev $h3 ingress pref 77 prot $prot \ 78 78 flower skip_hw ip_ttl 50 action pass 79 79 ··· 81 81 82 82 ip link set dev $tundev type $type ttl 50 83 83 sleep 2 84 - mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10 84 + mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 ">= 10" 85 85 86 86 ip link set dev $tundev type $type ttl 100 87 87 tc filter del dev $h3 ingress pref 77 88 88 mirror_uninstall $swp1 ingress 89 89 90 - log_test "$what: TTL change ($tcflags)" 90 + log_test "$what: TTL change" 91 91 } 92 92 93 93 test_span_gre_tun_up() ··· 98 98 RET=0 99 99 100 100 ip link set dev $tundev down 101 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 102 - fail_test_span_gre_dir $tundev ingress 101 + mirror_install $swp1 ingress $tundev "matchall" 102 + fail_test_span_gre_dir $tundev 103 103 104 104 ip link set dev $tundev up 105 105 106 - quick_test_span_gre_dir $tundev ingress 106 + quick_test_span_gre_dir $tundev 107 107 mirror_uninstall $swp1 ingress 108 108 109 - log_test "$what: tunnel down/up ($tcflags)" 109 + log_test "$what: tunnel down/up" 110 110 } 111 111 112 112 test_span_gre_egress_up() ··· 118 118 RET=0 119 119 120 120 ip link set dev $swp3 down 121 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 122 - fail_test_span_gre_dir $tundev ingress 121 + mirror_install $swp1 ingress $tundev "matchall" 122 + fail_test_span_gre_dir $tundev 123 123 124 124 # After setting the device up, wait for neighbor to get resolved so that 125 125 # we can expect mirroring to work. ··· 127 127 setup_wait_dev $swp3 128 128 ping -c 1 -I $swp3 $remote_ip &>/dev/null 129 129 130 - quick_test_span_gre_dir $tundev ingress 130 + quick_test_span_gre_dir $tundev 131 131 mirror_uninstall $swp1 ingress 132 132 133 - log_test "$what: egress down/up ($tcflags)" 133 + log_test "$what: egress down/up" 134 134 } 135 135 136 136 test_span_gre_remote_ip() ··· 144 144 RET=0 145 145 146 146 ip link set dev $tundev type $type remote $wrong_ip 147 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 148 - fail_test_span_gre_dir $tundev ingress 147 + mirror_install $swp1 ingress $tundev "matchall" 148 + fail_test_span_gre_dir $tundev 149 149 150 150 ip link set dev $tundev type $type remote $correct_ip 151 - quick_test_span_gre_dir $tundev ingress 151 + quick_test_span_gre_dir $tundev 152 152 mirror_uninstall $swp1 ingress 153 153 154 - log_test "$what: remote address change ($tcflags)" 154 + log_test "$what: remote address change" 155 155 } 156 156 157 157 test_span_gre_tun_del() ··· 165 165 166 166 RET=0 167 167 168 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 169 - quick_test_span_gre_dir $tundev ingress 168 + mirror_install $swp1 ingress $tundev "matchall" 169 + quick_test_span_gre_dir $tundev 170 170 ip link del dev $tundev 171 - fail_test_span_gre_dir $tundev ingress 171 + fail_test_span_gre_dir $tundev 172 172 173 173 tunnel_create $tundev $type $local_ip $remote_ip \ 174 174 ttl 100 tos inherit $flags ··· 176 176 # Recreating the tunnel doesn't reestablish mirroring, so reinstall it 177 177 # and verify it works for the follow-up tests. 178 178 mirror_uninstall $swp1 ingress 179 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 180 - quick_test_span_gre_dir $tundev ingress 179 + mirror_install $swp1 ingress $tundev "matchall" 180 + quick_test_span_gre_dir $tundev 181 181 mirror_uninstall $swp1 ingress 182 182 183 - log_test "$what: tunnel deleted ($tcflags)" 183 + log_test "$what: tunnel deleted" 184 184 } 185 185 186 186 test_span_gre_route_del() ··· 192 192 193 193 RET=0 194 194 195 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 196 - quick_test_span_gre_dir $tundev ingress 195 + mirror_install $swp1 ingress $tundev "matchall" 196 + quick_test_span_gre_dir $tundev 197 197 198 198 ip route del $route dev $edev 199 - fail_test_span_gre_dir $tundev ingress 199 + fail_test_span_gre_dir $tundev 200 200 201 201 ip route add $route dev $edev 202 - quick_test_span_gre_dir $tundev ingress 202 + quick_test_span_gre_dir $tundev 203 203 204 204 mirror_uninstall $swp1 ingress 205 205 206 - log_test "$what: underlay route removal ($tcflags)" 206 + log_test "$what: underlay route removal" 207 207 } 208 208 209 209 test_ttl() ··· 244 244 test_span_gre_route_del gt6 $swp3 2001:db8:2::/64 "mirror to ip6gretap" 245 245 } 246 246 247 - test_all() 248 - { 249 - slow_path_trap_install $swp1 ingress 250 - slow_path_trap_install $swp1 egress 251 - 252 - tests_run 253 - 254 - slow_path_trap_uninstall $swp1 egress 255 - slow_path_trap_uninstall $swp1 ingress 256 - } 257 - 258 247 trap cleanup EXIT 259 248 260 249 setup_prepare 261 250 setup_wait 262 251 263 - tcflags="skip_hw" 264 - test_all 265 - 266 - if ! tc_offload_check; then 267 - echo "WARN: Could not test offloaded functionality" 268 - else 269 - tcflags="skip_sw" 270 - test_all 271 - fi 252 + tests_run 272 253 273 254 exit $EXIT_STATUS
+15 -28
tools/testing/selftests/net/forwarding/mirror_gre_flower.sh
··· 64 64 65 65 test_span_gre_dir_acl() 66 66 { 67 - test_span_gre_dir_ips "$@" 192.0.2.3 192.0.2.4 67 + local tundev=$1; shift 68 + local forward_type=$1; shift 69 + local backward_type=$1; shift 70 + 71 + test_span_gre_dir_ips "$tundev" "$forward_type" \ 72 + "$backward_type" 192.0.2.3 192.0.2.4 68 73 } 69 74 70 75 fail_test_span_gre_dir_acl() 71 76 { 72 - fail_test_span_gre_dir_ips "$@" 192.0.2.3 192.0.2.4 77 + local tundev=$1; shift 78 + 79 + fail_test_span_gre_dir_ips "$tundev" 192.0.2.3 192.0.2.4 73 80 } 74 81 75 82 full_test_span_gre_dir_acl() ··· 91 84 RET=0 92 85 93 86 mirror_install $swp1 $direction $tundev \ 94 - "protocol ip flower $tcflags dst_ip $match_dip" 95 - fail_test_span_gre_dir $tundev $direction 96 - test_span_gre_dir_acl "$tundev" "$direction" \ 97 - "$forward_type" "$backward_type" 87 + "protocol ip flower dst_ip $match_dip" 88 + fail_test_span_gre_dir $tundev 89 + test_span_gre_dir_acl "$tundev" "$forward_type" "$backward_type" 98 90 mirror_uninstall $swp1 $direction 99 91 100 92 # Test lack of mirroring after ACL mirror is uninstalled. 101 - fail_test_span_gre_dir_acl "$tundev" "$direction" 93 + fail_test_span_gre_dir_acl "$tundev" 102 94 103 - log_test "$direction $what ($tcflags)" 95 + log_test "$direction $what" 104 96 } 105 97 106 98 test_gretap() ··· 114 108 full_test_span_gre_dir_acl gt6 egress 0 8 192.0.2.3 "ACL mirror to ip6gretap" 115 109 } 116 110 117 - test_all() 118 - { 119 - slow_path_trap_install $swp1 ingress 120 - slow_path_trap_install $swp1 egress 121 - 122 - tests_run 123 - 124 - slow_path_trap_uninstall $swp1 egress 125 - slow_path_trap_uninstall $swp1 ingress 126 - } 127 - 128 111 trap cleanup EXIT 129 112 130 113 setup_prepare 131 114 setup_wait 132 115 133 - tcflags="skip_hw" 134 - test_all 135 - 136 - if ! tc_offload_check; then 137 - echo "WARN: Could not test offloaded functionality" 138 - else 139 - tcflags="skip_sw" 140 - test_all 141 - fi 116 + tests_run 142 117 143 118 exit $EXIT_STATUS
+25 -40
tools/testing/selftests/net/forwarding/mirror_gre_lag_lacp.sh
··· 37 37 # | \ / | 38 38 # | \____________________________________________/ | 39 39 # | | | 40 - # | + lag2 (team) | 41 - # | 192.0.2.130/28 | 40 + # | + lag2 (team) ------> + gt4-dst (gretap) | 41 + # | 192.0.2.130/28 loc=192.0.2.130 | 42 + # | rem=192.0.2.129 | 43 + # | ttl=100 | 44 + # | tos=inherit | 45 + # | | 46 + # | | 47 + # | | 42 48 # | | 43 49 # +---------------------------------------------------------------------------+ 44 50 ··· 56 50 NUM_NETIFS=6 57 51 source lib.sh 58 52 source mirror_lib.sh 59 - source mirror_gre_lib.sh 60 - 61 - require_command $ARPING 62 53 63 54 vlan_host_create() 64 55 { ··· 125 122 { 126 123 vrf_create vrf-h3 127 124 ip link set dev vrf-h3 up 128 - tc qdisc add dev $h3 clsact 129 - tc qdisc add dev $h4 clsact 130 125 h3_create_team 126 + 127 + tunnel_create gt4-dst gretap 192.0.2.130 192.0.2.129 \ 128 + ttl 100 tos inherit 129 + ip link set dev gt4-dst master vrf-h3 130 + tc qdisc add dev gt4-dst clsact 131 131 } 132 132 133 133 h3_destroy() 134 134 { 135 + tc qdisc del dev gt4-dst clsact 136 + ip link set dev gt4-dst nomaster 137 + tunnel_destroy gt4-dst 138 + 135 139 h3_destroy_team 136 - tc qdisc del dev $h4 clsact 137 - tc qdisc del dev $h3 clsact 138 140 ip link set dev vrf-h3 down 139 141 vrf_destroy vrf-h3 140 142 } ··· 196 188 h2_create 197 189 h3_create 198 190 switch_create 199 - 200 - trap_install $h3 ingress 201 - trap_install $h4 ingress 202 191 } 203 192 204 193 cleanup() 205 194 { 206 195 pre_cleanup 207 - 208 - trap_uninstall $h4 ingress 209 - trap_uninstall $h3 ingress 210 196 211 197 switch_destroy 212 198 h3_destroy ··· 220 218 RET=0 221 219 222 220 mirror_install $swp1 ingress gt4 \ 223 - "proto 802.1q flower vlan_id 333 $tcflags" 221 + "proto 802.1q flower vlan_id 333" 222 + vlan_capture_install gt4-dst "vlan_ethtype ipv4 ip_proto icmp type 8" 224 223 225 224 # Move $down_dev away from the team. That will prompt change in 226 225 # txability of the connected device, without changing its upness. The ··· 229 226 # other slave. 230 227 ip link set dev $down_dev nomaster 231 228 sleep 2 232 - mirror_test vrf-h1 192.0.2.1 192.0.2.18 $up_dev 1 10 229 + mirror_test vrf-h1 192.0.2.1 192.0.2.18 gt4-dst 100 10 233 230 234 231 # Test lack of connectivity when neither slave is txable. 235 232 ip link set dev $up_dev nomaster 236 233 sleep 2 237 - mirror_test vrf-h1 192.0.2.1 192.0.2.18 $h3 1 0 238 - mirror_test vrf-h1 192.0.2.1 192.0.2.18 $h4 1 0 234 + mirror_test vrf-h1 192.0.2.1 192.0.2.18 gt4-dst 100 0 235 + 236 + vlan_capture_uninstall gt4-dst 239 237 mirror_uninstall $swp1 ingress 240 238 241 239 # Recreate H3's team device, because mlxsw, which this test is ··· 247 243 # Wait for ${h,swp}{3,4}. 248 244 setup_wait 249 245 250 - log_test "$what ($tcflags)" 246 + log_test "$what" 251 247 } 252 248 253 249 test_mirror_gretap_first() ··· 260 256 test_lag_slave $h4 $h3 "mirror to gretap: LAG second slave" 261 257 } 262 258 263 - test_all() 264 - { 265 - slow_path_trap_install $swp1 ingress 266 - slow_path_trap_install $swp1 egress 267 - 268 - tests_run 269 - 270 - slow_path_trap_uninstall $swp1 egress 271 - slow_path_trap_uninstall $swp1 ingress 272 - } 273 - 274 259 trap cleanup EXIT 275 260 276 261 setup_prepare 277 262 setup_wait 278 263 279 - tcflags="skip_hw" 280 - test_all 281 - 282 - if ! tc_offload_check; then 283 - echo "WARN: Could not test offloaded functionality" 284 - else 285 - tcflags="skip_sw" 286 - test_all 287 - fi 264 + tests_run 288 265 289 266 exit $EXIT_STATUS
+66 -24
tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
··· 5 5 quick_test_span_gre_dir_ips() 6 6 { 7 7 local tundev=$1; shift 8 + local ip1=$1; shift 9 + local ip2=$1; shift 10 + local forward_type=$1; shift 11 + local backward_type=$1; shift 8 12 9 - do_test_span_dir_ips 10 h3-$tundev "$@" 13 + do_test_span_dir_ips 10 h3-$tundev "$ip1" "$ip2" \ 14 + "$forward_type" "$backward_type" 10 15 } 11 16 12 17 fail_test_span_gre_dir_ips() 13 18 { 14 19 local tundev=$1; shift 20 + local ip1=$1; shift 21 + local ip2=$1; shift 15 22 16 - do_test_span_dir_ips 0 h3-$tundev "$@" 23 + do_test_span_dir_ips 0 h3-$tundev "$ip1" "$ip2" 17 24 } 18 25 19 26 test_span_gre_dir_ips() 20 27 { 21 28 local tundev=$1; shift 29 + local forward_type=$1; shift 30 + local backward_type=$1; shift 31 + local ip1=$1; shift 32 + local ip2=$1; shift 22 33 23 - test_span_dir_ips h3-$tundev "$@" 34 + test_span_dir_ips h3-$tundev "$forward_type" \ 35 + "$backward_type" "$ip1" "$ip2" 24 36 } 25 37 26 38 full_test_span_gre_dir_ips() ··· 47 35 48 36 RET=0 49 37 50 - mirror_install $swp1 $direction $tundev "matchall $tcflags" 51 - test_span_dir_ips "h3-$tundev" "$direction" "$forward_type" \ 38 + mirror_install $swp1 $direction $tundev "matchall" 39 + test_span_dir_ips "h3-$tundev" "$forward_type" \ 52 40 "$backward_type" "$ip1" "$ip2" 53 41 mirror_uninstall $swp1 $direction 54 42 55 - log_test "$direction $what ($tcflags)" 43 + log_test "$direction $what" 56 44 } 57 45 58 46 full_test_span_gre_dir_vlan_ips() ··· 68 56 69 57 RET=0 70 58 71 - mirror_install $swp1 $direction $tundev "matchall $tcflags" 59 + mirror_install $swp1 $direction $tundev "matchall" 72 60 73 - test_span_dir_ips "h3-$tundev" "$direction" "$forward_type" \ 61 + test_span_dir_ips "h3-$tundev" "$forward_type" \ 74 62 "$backward_type" "$ip1" "$ip2" 75 63 76 64 tc filter add dev $h3 ingress pref 77 prot 802.1q \ 77 65 flower $vlan_match \ 78 66 action pass 79 - mirror_test v$h1 $ip1 $ip2 $h3 77 10 67 + mirror_test v$h1 $ip1 $ip2 $h3 77 '>= 10' 80 68 tc filter del dev $h3 ingress pref 77 81 69 82 70 mirror_uninstall $swp1 $direction 83 71 84 - log_test "$direction $what ($tcflags)" 72 + log_test "$direction $what" 85 73 } 86 74 87 75 quick_test_span_gre_dir() 88 76 { 89 - quick_test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2 77 + local tundev=$1; shift 78 + local forward_type=${1-8}; shift 79 + local backward_type=${1-0}; shift 80 + 81 + quick_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2 \ 82 + "$forward_type" "$backward_type" 90 83 } 91 84 92 85 fail_test_span_gre_dir() 93 86 { 94 - fail_test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2 95 - } 87 + local tundev=$1; shift 96 88 97 - test_span_gre_dir() 98 - { 99 - test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2 89 + fail_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2 100 90 } 101 91 102 92 full_test_span_gre_dir() 103 93 { 104 - full_test_span_gre_dir_ips "$@" 192.0.2.1 192.0.2.2 94 + local tundev=$1; shift 95 + local direction=$1; shift 96 + local forward_type=$1; shift 97 + local backward_type=$1; shift 98 + local what=$1; shift 99 + 100 + full_test_span_gre_dir_ips "$tundev" "$direction" "$forward_type" \ 101 + "$backward_type" "$what" 192.0.2.1 192.0.2.2 105 102 } 106 103 107 104 full_test_span_gre_dir_vlan() 108 105 { 109 - full_test_span_gre_dir_vlan_ips "$@" 192.0.2.1 192.0.2.2 106 + local tundev=$1; shift 107 + local direction=$1; shift 108 + local vlan_match=$1; shift 109 + local forward_type=$1; shift 110 + local backward_type=$1; shift 111 + local what=$1; shift 112 + 113 + full_test_span_gre_dir_vlan_ips "$tundev" "$direction" "$vlan_match" \ 114 + "$forward_type" "$backward_type" \ 115 + "$what" 192.0.2.1 192.0.2.2 110 116 } 111 117 112 118 full_test_span_gre_stp_ips() ··· 134 104 local what=$1; shift 135 105 local ip1=$1; shift 136 106 local ip2=$1; shift 107 + local forward_type=$1; shift 108 + local backward_type=$1; shift 137 109 local h3mac=$(mac_get $h3) 138 110 139 111 RET=0 140 112 141 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 142 - quick_test_span_gre_dir_ips $tundev ingress $ip1 $ip2 113 + mirror_install $swp1 ingress $tundev "matchall" 114 + quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \ 115 + "$forward_type" "$backward_type" 143 116 144 117 bridge link set dev $nbpdev state disabled 145 118 sleep 1 146 - fail_test_span_gre_dir_ips $tundev ingress $ip1 $ip2 119 + fail_test_span_gre_dir_ips $tundev $ip1 $ip2 147 120 148 121 bridge link set dev $nbpdev state forwarding 149 122 sleep 1 150 - quick_test_span_gre_dir_ips $tundev ingress $ip1 $ip2 123 + quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \ 124 + "$forward_type" "$backward_type" 151 125 152 126 mirror_uninstall $swp1 ingress 153 127 154 - log_test "$what: STP state ($tcflags)" 128 + log_test "$what: STP state" 155 129 } 156 130 157 131 full_test_span_gre_stp() 158 132 { 159 - full_test_span_gre_stp_ips "$@" 192.0.2.1 192.0.2.2 133 + local tundev=$1; shift 134 + local nbpdev=$1; shift 135 + local what=$1; shift 136 + local forward_type=${1-8}; shift 137 + local backward_type=${1-0}; shift 138 + 139 + full_test_span_gre_stp_ips "$tundev" "$nbpdev" "$what" \ 140 + 192.0.2.1 192.0.2.2 \ 141 + "$forward_type" "$backward_type" 160 142 }
+11 -28
tools/testing/selftests/net/forwarding/mirror_gre_neigh.sh
··· 60 60 local addr=$1; shift 61 61 local tundev=$1; shift 62 62 local direction=$1; shift 63 + local forward_type=$1; shift 64 + local backward_type=$1; shift 63 65 local what=$1; shift 64 66 65 67 RET=0 66 68 67 69 ip neigh replace dev $swp3 $addr lladdr 00:11:22:33:44:55 68 - mirror_install $swp1 $direction $tundev "matchall $tcflags" 69 - fail_test_span_gre_dir $tundev ingress 70 + mirror_install $swp1 $direction $tundev "matchall" 71 + fail_test_span_gre_dir $tundev "$forward_type" "$backward_type" 70 72 ip neigh del dev $swp3 $addr 71 - quick_test_span_gre_dir $tundev ingress 73 + quick_test_span_gre_dir $tundev "$forward_type" "$backward_type" 72 74 mirror_uninstall $swp1 $direction 73 75 74 - log_test "$direction $what: neighbor change ($tcflags)" 76 + log_test "$direction $what: neighbor change" 75 77 } 76 78 77 79 test_gretap() 78 80 { 79 - test_span_gre_neigh 192.0.2.130 gt4 ingress "mirror to gretap" 80 - test_span_gre_neigh 192.0.2.130 gt4 egress "mirror to gretap" 81 + test_span_gre_neigh 192.0.2.130 gt4 ingress 8 0 "mirror to gretap" 82 + test_span_gre_neigh 192.0.2.130 gt4 egress 0 8 "mirror to gretap" 81 83 } 82 84 83 85 test_ip6gretap() 84 86 { 85 - test_span_gre_neigh 2001:db8:2::2 gt6 ingress "mirror to ip6gretap" 86 - test_span_gre_neigh 2001:db8:2::2 gt6 egress "mirror to ip6gretap" 87 - } 88 - 89 - test_all() 90 - { 91 - slow_path_trap_install $swp1 ingress 92 - slow_path_trap_install $swp1 egress 93 - 94 - tests_run 95 - 96 - slow_path_trap_uninstall $swp1 egress 97 - slow_path_trap_uninstall $swp1 ingress 87 + test_span_gre_neigh 2001:db8:2::2 gt6 ingress 8 0 "mirror to ip6gretap" 88 + test_span_gre_neigh 2001:db8:2::2 gt6 egress 0 8 "mirror to ip6gretap" 98 89 } 99 90 100 91 trap cleanup EXIT ··· 93 102 setup_prepare 94 103 setup_wait 95 104 96 - tcflags="skip_hw" 97 - test_all 98 - 99 - if ! tc_offload_check; then 100 - echo "WARN: Could not test offloaded functionality" 101 - else 102 - tcflags="skip_sw" 103 - test_all 104 - fi 105 + tests_run 105 106 106 107 exit $EXIT_STATUS
+8 -27
tools/testing/selftests/net/forwarding/mirror_gre_nh.sh
··· 75 75 test_gretap() 76 76 { 77 77 RET=0 78 - mirror_install $swp1 ingress gt4 "matchall $tcflags" 78 + mirror_install $swp1 ingress gt4 "matchall" 79 79 80 80 # For IPv4, test that there's no mirroring without the route directing 81 81 # the traffic to tunnel remote address. Then add it and test that 82 82 # mirroring starts. For IPv6 we can't test this due to the limitation 83 83 # that routes for locally-specified IPv6 addresses can't be added. 84 - fail_test_span_gre_dir gt4 ingress 84 + fail_test_span_gre_dir gt4 85 85 86 86 ip route add 192.0.2.130/32 via 192.0.2.162 87 - quick_test_span_gre_dir gt4 ingress 87 + quick_test_span_gre_dir gt4 88 88 ip route del 192.0.2.130/32 via 192.0.2.162 89 89 90 90 mirror_uninstall $swp1 ingress 91 - log_test "mirror to gre with next-hop remote ($tcflags)" 91 + log_test "mirror to gre with next-hop remote" 92 92 } 93 93 94 94 test_ip6gretap() 95 95 { 96 96 RET=0 97 97 98 - mirror_install $swp1 ingress gt6 "matchall $tcflags" 99 - quick_test_span_gre_dir gt6 ingress 98 + mirror_install $swp1 ingress gt6 "matchall" 99 + quick_test_span_gre_dir gt6 100 100 mirror_uninstall $swp1 ingress 101 101 102 - log_test "mirror to ip6gre with next-hop remote ($tcflags)" 103 - } 104 - 105 - test_all() 106 - { 107 - slow_path_trap_install $swp1 ingress 108 - slow_path_trap_install $swp1 egress 109 - 110 - tests_run 111 - 112 - slow_path_trap_uninstall $swp1 egress 113 - slow_path_trap_uninstall $swp1 ingress 102 + log_test "mirror to ip6gre with next-hop remote" 114 103 } 115 104 116 105 trap cleanup EXIT ··· 107 118 setup_prepare 108 119 setup_wait 109 120 110 - tcflags="skip_hw" 111 - test_all 112 - 113 - if ! tc_offload_check; then 114 - echo "WARN: Could not test offloaded functionality" 115 - else 116 - tcflags="skip_sw" 117 - test_all 118 - fi 121 + tests_run 119 122 120 123 exit $EXIT_STATUS
+1 -20
tools/testing/selftests/net/forwarding/mirror_gre_vlan.sh
··· 63 63 full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap" 64 64 } 65 65 66 - test_all() 67 - { 68 - slow_path_trap_install $swp1 ingress 69 - slow_path_trap_install $swp1 egress 70 - 71 - tests_run 72 - 73 - slow_path_trap_uninstall $swp1 egress 74 - slow_path_trap_uninstall $swp1 ingress 75 - } 76 - 77 66 trap cleanup EXIT 78 67 79 68 setup_prepare 80 69 setup_wait 81 70 82 - tcflags="skip_hw" 83 - test_all 84 - 85 - if ! tc_offload_check; then 86 - echo "WARN: Could not test offloaded functionality" 87 - else 88 - tcflags="skip_sw" 89 - test_all 90 - fi 71 + tests_run 91 72 92 73 exit $EXIT_STATUS
+25 -44
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
··· 153 153 RET=0 154 154 155 155 # Run the pass-test first, to prime neighbor table. 156 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 157 - quick_test_span_gre_dir $tundev ingress 156 + mirror_install $swp1 ingress $tundev "matchall" 157 + quick_test_span_gre_dir $tundev 158 158 159 159 # Now forbid the VLAN at the bridge and see it fail. 160 160 bridge vlan del dev br1 vid 555 self 161 161 sleep 1 162 - fail_test_span_gre_dir $tundev ingress 162 + fail_test_span_gre_dir $tundev 163 163 164 164 bridge vlan add dev br1 vid 555 self 165 165 sleep 1 166 - quick_test_span_gre_dir $tundev ingress 166 + quick_test_span_gre_dir $tundev 167 167 168 168 mirror_uninstall $swp1 ingress 169 169 170 - log_test "$what: vlan forbidden at a bridge ($tcflags)" 170 + log_test "$what: vlan forbidden at a bridge" 171 171 } 172 172 173 173 test_gretap_forbidden_cpu() ··· 187 187 188 188 RET=0 189 189 190 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 191 - quick_test_span_gre_dir $tundev ingress 190 + mirror_install $swp1 ingress $tundev "matchall" 191 + quick_test_span_gre_dir $tundev 192 192 193 193 bridge vlan del dev $swp3 vid 555 194 194 sleep 1 195 - fail_test_span_gre_dir $tundev ingress 195 + fail_test_span_gre_dir $tundev 196 196 197 197 bridge vlan add dev $swp3 vid 555 198 198 # Re-prime FDB 199 199 $ARPING -I br1.555 192.0.2.130 -fqc 1 200 200 sleep 1 201 - quick_test_span_gre_dir $tundev ingress 201 + quick_test_span_gre_dir $tundev 202 202 203 203 mirror_uninstall $swp1 ingress 204 204 205 - log_test "$what: vlan forbidden at a bridge egress ($tcflags)" 205 + log_test "$what: vlan forbidden at a bridge egress" 206 206 } 207 207 208 208 test_gretap_forbidden_egress() ··· 223 223 224 224 RET=0 225 225 226 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 226 + mirror_install $swp1 ingress $tundev "matchall" 227 227 228 - quick_test_span_gre_dir $tundev ingress 229 - quick_test_span_vlan_dir $h3 555 ingress "$ul_proto" 228 + quick_test_span_gre_dir $tundev 229 + quick_test_span_vlan_dir $h3 555 "$ul_proto" 230 230 231 231 h3_addr_add_del del $h3.555 232 232 bridge vlan add dev $swp3 vid 555 pvid untagged 233 233 h3_addr_add_del add $h3 234 234 sleep 5 235 235 236 - quick_test_span_gre_dir $tundev ingress 237 - fail_test_span_vlan_dir $h3 555 ingress "$ul_proto" 236 + quick_test_span_gre_dir $tundev 237 + fail_test_span_vlan_dir $h3 555 "$ul_proto" 238 238 239 239 h3_addr_add_del del $h3 240 240 bridge vlan add dev $swp3 vid 555 241 241 h3_addr_add_del add $h3.555 242 242 sleep 5 243 243 244 - quick_test_span_gre_dir $tundev ingress 245 - quick_test_span_vlan_dir $h3 555 ingress "$ul_proto" 244 + quick_test_span_gre_dir $tundev 245 + quick_test_span_vlan_dir $h3 555 "$ul_proto" 246 246 247 247 mirror_uninstall $swp1 ingress 248 248 249 - log_test "$what: vlan untagged at a bridge egress ($tcflags)" 249 + log_test "$what: vlan untagged at a bridge egress" 250 250 } 251 251 252 252 test_gretap_untagged_egress() ··· 267 267 268 268 RET=0 269 269 270 - mirror_install $swp1 ingress $tundev "matchall $tcflags" 271 - quick_test_span_gre_dir $tundev ingress 270 + mirror_install $swp1 ingress $tundev "matchall" 271 + quick_test_span_gre_dir $tundev 272 272 273 273 while ((RET == 0)); do 274 274 bridge fdb del dev $swp3 $h3mac vlan 555 master 2>/dev/null 275 275 bridge fdb add dev $swp2 $h3mac vlan 555 master static 276 276 sleep 1 277 - fail_test_span_gre_dir $tundev ingress 277 + fail_test_span_gre_dir $tundev 278 278 279 279 if ! bridge fdb sh dev $swp2 vlan 555 master \ 280 280 | grep -q $h3mac; then 281 281 printf "TEST: %-60s [RETRY]\n" \ 282 - "$what: MAC roaming ($tcflags)" 282 + "$what: MAC roaming" 283 283 # ARP or ND probably reprimed the FDB while the test 284 284 # was running. We would get a spurious failure. 285 285 RET=0 ··· 292 292 # Re-prime FDB 293 293 $ARPING -I br1.555 192.0.2.130 -fqc 1 294 294 sleep 1 295 - quick_test_span_gre_dir $tundev ingress 295 + quick_test_span_gre_dir $tundev 296 296 297 297 mirror_uninstall $swp1 ingress 298 298 299 - log_test "$what: MAC roaming ($tcflags)" 299 + log_test "$what: MAC roaming" 300 300 } 301 301 302 302 test_gretap_fdb_roaming() ··· 319 319 full_test_span_gre_stp gt6 $swp3 "mirror to ip6gretap" 320 320 } 321 321 322 - test_all() 323 - { 324 - slow_path_trap_install $swp1 ingress 325 - slow_path_trap_install $swp1 egress 326 - 327 - tests_run 328 - 329 - slow_path_trap_uninstall $swp1 egress 330 - slow_path_trap_uninstall $swp1 ingress 331 - } 332 - 333 322 trap cleanup EXIT 334 323 335 324 setup_prepare 336 325 setup_wait 337 326 338 - tcflags="skip_hw" 339 - test_all 340 - 341 - if ! tc_offload_check; then 342 - echo "WARN: Could not test offloaded functionality" 343 - else 344 - tcflags="skip_sw" 345 - test_all 346 - fi 327 + tests_run 347 328 348 329 exit $EXIT_STATUS
+55 -24
tools/testing/selftests/net/forwarding/mirror_lib.sh
··· 44 44 local type="icmp echoreq" 45 45 fi 46 46 47 + if [[ -z ${expect//[[:digit:]]/} ]]; then 48 + expect="== $expect" 49 + fi 50 + 47 51 local t0=$(tc_rule_stats_get $dev $pref) 48 52 $MZ $proto $vrf_name ${sip:+-A $sip} -B $dip -a own -b bc -q \ 49 53 -c 10 -d 100msec -t $type 50 54 sleep 0.5 51 55 local t1=$(tc_rule_stats_get $dev $pref) 52 56 local delta=$((t1 - t0)) 53 - # Tolerate a couple stray extra packets. 54 - ((expect <= delta && delta <= expect + 2)) 57 + ((delta $expect)) 55 58 check_err $? "Expected to capture $expect packets, got $delta." 56 59 } 57 60 ··· 62 59 { 63 60 local expect=$1; shift 64 61 local dev=$1; shift 65 - local direction=$1; shift 66 62 local ip1=$1; shift 67 63 local ip2=$1; shift 64 + local forward_type=${1-8}; shift 65 + local backward_type=${1-0}; shift 68 66 69 - icmp_capture_install $dev 67 + icmp_capture_install $dev "type $forward_type" 70 68 mirror_test v$h1 $ip1 $ip2 $dev 100 $expect 69 + icmp_capture_uninstall $dev 70 + 71 + icmp_capture_install $dev "type $backward_type" 71 72 mirror_test v$h2 $ip2 $ip1 $dev 100 $expect 72 73 icmp_capture_uninstall $dev 73 74 } 74 75 75 76 quick_test_span_dir_ips() 76 77 { 77 - do_test_span_dir_ips 10 "$@" 78 - } 78 + local dev=$1; shift 79 + local ip1=$1; shift 80 + local ip2=$1; shift 81 + local forward_type=${1-8}; shift 82 + local backward_type=${1-0}; shift 79 83 80 - fail_test_span_dir_ips() 81 - { 82 - do_test_span_dir_ips 0 "$@" 84 + do_test_span_dir_ips 10 "$dev" "$ip1" "$ip2" \ 85 + "$forward_type" "$backward_type" 83 86 } 84 87 85 88 test_span_dir_ips() 86 89 { 87 90 local dev=$1; shift 88 - local direction=$1; shift 89 91 local forward_type=$1; shift 90 92 local backward_type=$1; shift 91 93 local ip1=$1; shift 92 94 local ip2=$1; shift 93 95 94 - quick_test_span_dir_ips "$dev" "$direction" "$ip1" "$ip2" 96 + quick_test_span_dir_ips "$dev" "$ip1" "$ip2" \ 97 + "$forward_type" "$backward_type" 95 98 96 99 icmp_capture_install $dev "type $forward_type" 97 100 mirror_test v$h1 $ip1 $ip2 $dev 100 10 ··· 108 99 icmp_capture_uninstall $dev 109 100 } 110 101 111 - fail_test_span_dir() 112 - { 113 - fail_test_span_dir_ips "$@" 192.0.2.1 192.0.2.2 114 - } 115 - 116 102 test_span_dir() 117 103 { 118 - test_span_dir_ips "$@" 192.0.2.1 192.0.2.2 104 + local dev=$1; shift 105 + local forward_type=$1; shift 106 + local backward_type=$1; shift 107 + 108 + test_span_dir_ips "$dev" "$forward_type" "$backward_type" \ 109 + 192.0.2.1 192.0.2.2 119 110 } 120 111 121 112 do_test_span_vlan_dir_ips() ··· 123 114 local expect=$1; shift 124 115 local dev=$1; shift 125 116 local vid=$1; shift 126 - local direction=$1; shift 127 117 local ul_proto=$1; shift 128 118 local ip1=$1; shift 129 119 local ip2=$1; shift ··· 131 123 # The traffic is meant for local box anyway, so will be trapped to 132 124 # kernel. 133 125 vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype $ul_proto" 134 - mirror_test v$h1 $ip1 $ip2 $dev 100 $expect 135 - mirror_test v$h2 $ip2 $ip1 $dev 100 $expect 126 + mirror_test v$h1 $ip1 $ip2 $dev 100 "$expect" 127 + mirror_test v$h2 $ip2 $ip1 $dev 100 "$expect" 136 128 vlan_capture_uninstall $dev 137 129 } 138 130 139 131 quick_test_span_vlan_dir_ips() 140 132 { 141 - do_test_span_vlan_dir_ips 10 "$@" 133 + local dev=$1; shift 134 + local vid=$1; shift 135 + local ul_proto=$1; shift 136 + local ip1=$1; shift 137 + local ip2=$1; shift 138 + 139 + do_test_span_vlan_dir_ips '>= 10' "$dev" "$vid" "$ul_proto" \ 140 + "$ip1" "$ip2" 142 141 } 143 142 144 143 fail_test_span_vlan_dir_ips() 145 144 { 146 - do_test_span_vlan_dir_ips 0 "$@" 145 + local dev=$1; shift 146 + local vid=$1; shift 147 + local ul_proto=$1; shift 148 + local ip1=$1; shift 149 + local ip2=$1; shift 150 + 151 + do_test_span_vlan_dir_ips 0 "$dev" "$vid" "$ul_proto" "$ip1" "$ip2" 147 152 } 148 153 149 154 quick_test_span_vlan_dir() 150 155 { 151 - quick_test_span_vlan_dir_ips "$@" 192.0.2.1 192.0.2.2 156 + local dev=$1; shift 157 + local vid=$1; shift 158 + local ul_proto=$1; shift 159 + 160 + quick_test_span_vlan_dir_ips "$dev" "$vid" "$ul_proto" \ 161 + 192.0.2.1 192.0.2.2 152 162 } 153 163 154 164 fail_test_span_vlan_dir() 155 165 { 156 - fail_test_span_vlan_dir_ips "$@" 192.0.2.1 192.0.2.2 166 + local dev=$1; shift 167 + local vid=$1; shift 168 + local ul_proto=$1; shift 169 + 170 + fail_test_span_vlan_dir_ips "$dev" "$vid" "$ul_proto" \ 171 + 192.0.2.1 192.0.2.2 157 172 }
+12 -31
tools/testing/selftests/net/forwarding/mirror_vlan.sh
··· 40 40 41 41 vlan_create $h2 111 v$h2 192.0.2.18/28 42 42 bridge vlan add dev $swp2 vid 111 43 + 44 + trap_install $h3 ingress 43 45 } 44 46 45 47 cleanup() 46 48 { 47 49 pre_cleanup 50 + 51 + trap_uninstall $h3 ingress 48 52 49 53 vlan_destroy $h2 111 50 54 vlan_destroy $h1 111 ··· 67 63 68 64 RET=0 69 65 70 - mirror_install $swp1 $direction $swp3.555 "matchall $tcflags" 71 - test_span_dir "$h3.555" "$direction" "$forward_type" "$backward_type" 66 + mirror_install $swp1 $direction $swp3.555 "matchall" 67 + test_span_dir "$h3.555" "$forward_type" "$backward_type" 72 68 mirror_uninstall $swp1 $direction 73 69 74 - log_test "$direction mirror to vlan ($tcflags)" 70 + log_test "$direction mirror to vlan" 75 71 } 76 72 77 73 test_vlan() ··· 88 84 89 85 RET=0 90 86 91 - mirror_install $swp1 $direction $swp3.555 "matchall $tcflags" 92 - do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" ip \ 93 - 192.0.2.17 192.0.2.18 94 - do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" ip \ 95 - 192.0.2.17 192.0.2.18 87 + mirror_install $swp1 $direction $swp3.555 "matchall" 88 + do_test_span_vlan_dir_ips '>= 10' "$h3.555" 111 ip 192.0.2.17 192.0.2.18 89 + do_test_span_vlan_dir_ips 0 "$h3.555" 555 ip 192.0.2.17 192.0.2.18 96 90 mirror_uninstall $swp1 $direction 97 91 98 - log_test "$direction mirror tagged to vlan ($tcflags)" 92 + log_test "$direction mirror tagged to vlan" 99 93 } 100 94 101 95 test_tagged_vlan() ··· 102 100 test_tagged_vlan_dir egress 0 8 103 101 } 104 102 105 - test_all() 106 - { 107 - slow_path_trap_install $swp1 ingress 108 - slow_path_trap_install $swp1 egress 109 - trap_install $h3 ingress 110 - 111 - tests_run 112 - 113 - trap_uninstall $h3 ingress 114 - slow_path_trap_uninstall $swp1 egress 115 - slow_path_trap_uninstall $swp1 ingress 116 - } 117 - 118 103 trap cleanup EXIT 119 104 120 105 setup_prepare 121 106 setup_wait 122 107 123 - tcflags="skip_hw" 124 - test_all 125 - 126 - if ! tc_offload_check; then 127 - echo "WARN: Could not test offloaded functionality" 128 - else 129 - tcflags="skip_sw" 130 - test_all 131 - fi 108 + tests_run 132 109 133 110 exit $EXIT_STATUS
+2 -2
tools/testing/selftests/net/lib.sh
··· 199 199 { 200 200 local dev=$1; shift 201 201 local pref=$1; shift 202 - local dir=$1; shift 202 + local dir=${1:-ingress}; shift 203 203 local selector=${1:-.packets}; shift 204 204 205 - tc -j -s filter show dev $dev ${dir:-ingress} pref $pref \ 205 + tc -j -s filter show dev $dev $dir pref $pref \ 206 206 | jq ".[1].options.actions[].stats$selector" 207 207 } 208 208