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

selftests: forwarding: use proto icmp for {gretap, ip6gretap}_mac testing

For tc ip_proto filter, when we extract the flow via __skb_flow_dissect()
without flag FLOW_DISSECTOR_F_STOP_AT_ENCAP, we will continue extract to
the inner proto.

So for GRE + ICMP messages, we should not track GRE proto, but inner ICMP
proto.

For test mirror_gre.sh, it may make user confused if we capture ICMP
message on $h3(since the flow is GRE message). So I move the capture
dev to h3-gt{4,6}, and only capture ICMP message.

Before the fix:
]# ./mirror_gre.sh
TEST: ingress mirror to gretap (skip_hw) [ OK ]
TEST: egress mirror to gretap (skip_hw) [ OK ]
TEST: ingress mirror to ip6gretap (skip_hw) [ OK ]
TEST: egress mirror to ip6gretap (skip_hw) [ OK ]
TEST: ingress mirror to gretap: envelope MAC (skip_hw) [FAIL]
Expected to capture 10 packets, got 0.
TEST: egress mirror to gretap: envelope MAC (skip_hw) [FAIL]
Expected to capture 10 packets, got 0.
TEST: ingress mirror to ip6gretap: envelope MAC (skip_hw) [FAIL]
Expected to capture 10 packets, got 0.
TEST: egress mirror to ip6gretap: envelope MAC (skip_hw) [FAIL]
Expected to capture 10 packets, got 0.
TEST: two simultaneously configured mirrors (skip_hw) [ OK ]
WARN: Could not test offloaded functionality

After fix:
]# ./mirror_gre.sh
TEST: ingress mirror to gretap (skip_hw) [ OK ]
TEST: egress mirror to gretap (skip_hw) [ OK ]
TEST: ingress mirror to ip6gretap (skip_hw) [ OK ]
TEST: egress mirror to ip6gretap (skip_hw) [ OK ]
TEST: ingress mirror to gretap: envelope MAC (skip_hw) [ OK ]
TEST: egress mirror to gretap: envelope MAC (skip_hw) [ OK ]
TEST: ingress mirror to ip6gretap: envelope MAC (skip_hw) [ OK ]
TEST: egress mirror to ip6gretap: envelope MAC (skip_hw) [ OK ]
TEST: two simultaneously configured mirrors (skip_hw) [ OK ]
WARN: Could not test offloaded functionality

Fixes: ba8d39871a10 ("selftests: forwarding: Add test for mirror to gretap")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Petr Machata <pmachata@gmail.com>
Tested-by: Petr Machata <pmachata@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Hangbin Liu and committed by
David S. Miller
e8023b03 2019fc96

+13 -12
+13 -12
tools/testing/selftests/net/forwarding/mirror_gre.sh
··· 63 63 { 64 64 local tundev=$1; shift 65 65 local direction=$1; shift 66 - local prot=$1; shift 67 66 local what=$1; shift 68 67 69 - local swp3mac=$(mac_get $swp3) 70 - local h3mac=$(mac_get $h3) 68 + case "$direction" in 69 + ingress) local src_mac=$(mac_get $h1); local dst_mac=$(mac_get $h2) 70 + ;; 71 + egress) local src_mac=$(mac_get $h2); local dst_mac=$(mac_get $h1) 72 + ;; 73 + esac 71 74 72 75 RET=0 73 76 74 77 mirror_install $swp1 $direction $tundev "matchall $tcflags" 75 - tc filter add dev $h3 ingress pref 77 prot $prot \ 76 - flower ip_proto 0x2f src_mac $swp3mac dst_mac $h3mac \ 77 - action pass 78 + icmp_capture_install h3-${tundev} "src_mac $src_mac dst_mac $dst_mac" 78 79 79 - mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10 80 + mirror_test v$h1 192.0.2.1 192.0.2.2 h3-${tundev} 100 10 80 81 81 - tc filter del dev $h3 ingress pref 77 82 + icmp_capture_uninstall h3-${tundev} 82 83 mirror_uninstall $swp1 $direction 83 84 84 85 log_test "$direction $what: envelope MAC ($tcflags)" ··· 121 120 122 121 test_gretap_mac() 123 122 { 124 - test_span_gre_mac gt4 ingress ip "mirror to gretap" 125 - test_span_gre_mac gt4 egress ip "mirror to gretap" 123 + test_span_gre_mac gt4 ingress "mirror to gretap" 124 + test_span_gre_mac gt4 egress "mirror to gretap" 126 125 } 127 126 128 127 test_ip6gretap_mac() 129 128 { 130 - test_span_gre_mac gt6 ingress ipv6 "mirror to ip6gretap" 131 - test_span_gre_mac gt6 egress ipv6 "mirror to ip6gretap" 129 + test_span_gre_mac gt6 ingress "mirror to ip6gretap" 130 + test_span_gre_mac gt6 egress "mirror to ip6gretap" 132 131 } 133 132 134 133 test_all()