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

selftests: forwarding: Fix packet matching in mirroring selftests

In commit 6de6e46d27ef ("cls_flower: Fix inability to match GRE/IPIP
packets"), cls_flower was fixed to match an outer packet of a tunneled
packet as would be expected, rather than dissecting to the inner packet and
matching on that.

This fix uncovered several issues in packet matching in mirroring
selftests:

- in mirror_gre_bridge_1d_vlan.sh and mirror_gre_vlan_bridge_1q.sh, the
vlan_ethtype match is copied around as "ip", even as some of the tests
are running over ip6gretap. This is fixed by using an "ipv6" for
vlan_ethtype in the ip6gretap tests.

- in mirror_gre_changes.sh, a filter to count GRE packets is set up to
match TTL of 50. This used to trigger in the offloaded datapath, where
the envelope TTL was matched, but not in the software datapath, which
considered TTL of the inner packet. Now that both match consistently, all
the packets were double-counted. This is fixed by marking the filter as
skip_hw, leaving only the SW datapath component active.

Fixes: 6de6e46d27ef ("cls_flower: Fix inability to match GRE/IPIP packets")
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Machata and committed by
David S. Miller
af0a5111 c7cd82b9

+13 -11
+1 -1
tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh
··· 80 80 81 81 test_ip6gretap() 82 82 { 83 - test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \ 83 + test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ipv6' \ 84 84 "mirror to ip6gretap" 85 85 } 86 86
+1 -1
tools/testing/selftests/net/forwarding/mirror_gre_changes.sh
··· 74 74 75 75 mirror_install $swp1 ingress $tundev "matchall $tcflags" 76 76 tc filter add dev $h3 ingress pref 77 prot $prot \ 77 - flower ip_ttl 50 action pass 77 + flower skip_hw ip_ttl 50 action pass 78 78 79 79 mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 0 80 80
+7 -6
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
··· 141 141 142 142 test_ip6gretap() 143 143 { 144 - test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \ 144 + test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ipv6' \ 145 145 "mirror to ip6gretap" 146 146 } 147 147 ··· 218 218 test_span_gre_untagged_egress() 219 219 { 220 220 local tundev=$1; shift 221 + local ul_proto=$1; shift 221 222 local what=$1; shift 222 223 223 224 RET=0 ··· 226 225 mirror_install $swp1 ingress $tundev "matchall $tcflags" 227 226 228 227 quick_test_span_gre_dir $tundev ingress 229 - quick_test_span_vlan_dir $h3 555 ingress 228 + quick_test_span_vlan_dir $h3 555 ingress "$ul_proto" 230 229 231 230 h3_addr_add_del del $h3.555 232 231 bridge vlan add dev $swp3 vid 555 pvid untagged ··· 234 233 sleep 5 235 234 236 235 quick_test_span_gre_dir $tundev ingress 237 - fail_test_span_vlan_dir $h3 555 ingress 236 + fail_test_span_vlan_dir $h3 555 ingress "$ul_proto" 238 237 239 238 h3_addr_add_del del $h3 240 239 bridge vlan add dev $swp3 vid 555 ··· 242 241 sleep 5 243 242 244 243 quick_test_span_gre_dir $tundev ingress 245 - quick_test_span_vlan_dir $h3 555 ingress 244 + quick_test_span_vlan_dir $h3 555 ingress "$ul_proto" 246 245 247 246 mirror_uninstall $swp1 ingress 248 247 ··· 251 250 252 251 test_gretap_untagged_egress() 253 252 { 254 - test_span_gre_untagged_egress gt4 "mirror to gretap" 253 + test_span_gre_untagged_egress gt4 ip "mirror to gretap" 255 254 } 256 255 257 256 test_ip6gretap_untagged_egress() 258 257 { 259 - test_span_gre_untagged_egress gt6 "mirror to ip6gretap" 258 + test_span_gre_untagged_egress gt6 ipv6 "mirror to ip6gretap" 260 259 } 261 260 262 261 test_span_gre_fdb_roaming()
+2 -1
tools/testing/selftests/net/forwarding/mirror_lib.sh
··· 115 115 local dev=$1; shift 116 116 local vid=$1; shift 117 117 local direction=$1; shift 118 + local ul_proto=$1; shift 118 119 local ip1=$1; shift 119 120 local ip2=$1; shift 120 121 121 122 # Install the capture as skip_hw to avoid double-counting of packets. 122 123 # The traffic is meant for local box anyway, so will be trapped to 123 124 # kernel. 124 - vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype ip" 125 + vlan_capture_install $dev "skip_hw vlan_id $vid vlan_ethtype $ul_proto" 125 126 mirror_test v$h1 $ip1 $ip2 $dev 100 $expect 126 127 mirror_test v$h2 $ip2 $ip1 $dev 100 $expect 127 128 vlan_capture_uninstall $dev
+2 -2
tools/testing/selftests/net/forwarding/mirror_vlan.sh
··· 85 85 RET=0 86 86 87 87 mirror_install $swp1 $direction $swp3.555 "matchall $tcflags" 88 - do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" \ 88 + do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" ip \ 89 89 192.0.2.17 192.0.2.18 90 - do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" \ 90 + do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" ip \ 91 91 192.0.2.17 192.0.2.18 92 92 mirror_uninstall $swp1 $direction 93 93