1 # SPDX-License-Identifier: GPL-2.0
5 local from_dev
=$1; shift
6 local direction
=$1; shift
10 tc filter add dev
$from_dev $direction \
12 action mirred egress mirror dev
$to_dev
17 local from_dev
=$1; shift
18 local direction
=$1; shift
20 tc filter del dev
$swp1 $direction pref
1000
27 [[ -z ${addr//[0-9a-fA-F:]/} ]]
32 local vrf_name
=$1; shift
37 local expect
=$1; shift
41 local type="icmp6 type=128" # Echo request.
44 local type="icmp echoreq"
47 if [[ -z ${expect//[[:digit:]]/} ]]; then
51 local t0
=$
(tc_rule_stats_get
$dev $pref)
52 $MZ $proto $vrf_name ${sip:+-A $sip} -B $dip -a own
-b bc -q \
53 -c 10 -d 100msec
-t $type
55 local t1
=$
(tc_rule_stats_get
$dev $pref)
56 local delta
=$
((t1
- t0
))
58 check_err $?
"Expected to capture $expect packets, got $delta."
61 do_test_span_dir_ips
()
63 local expect
=$1; shift
67 local forward_type
=${1-8}; shift
68 local backward_type
=${1-0}; shift
70 icmp_capture_install
$dev "type $forward_type"
71 mirror_test v
$h1 $ip1 $ip2 $dev 100 $expect
72 icmp_capture_uninstall
$dev
74 icmp_capture_install
$dev "type $backward_type"
75 mirror_test v
$h2 $ip2 $ip1 $dev 100 $expect
76 icmp_capture_uninstall
$dev
79 quick_test_span_dir_ips
()
84 local forward_type
=${1-8}; shift
85 local backward_type
=${1-0}; shift
87 do_test_span_dir_ips
10 "$dev" "$ip1" "$ip2" \
88 "$forward_type" "$backward_type"
94 local forward_type
=$1; shift
95 local backward_type
=$1; shift
99 quick_test_span_dir_ips
"$dev" "$ip1" "$ip2" \
100 "$forward_type" "$backward_type"
102 icmp_capture_install
$dev "type $forward_type"
103 mirror_test v
$h1 $ip1 $ip2 $dev 100 10
104 icmp_capture_uninstall
$dev
106 icmp_capture_install
$dev "type $backward_type"
107 mirror_test v
$h2 $ip2 $ip1 $dev 100 10
108 icmp_capture_uninstall
$dev
114 local forward_type
=$1; shift
115 local backward_type
=$1; shift
117 test_span_dir_ips
"$dev" "$forward_type" "$backward_type" \
121 do_test_span_vlan_dir_ips
()
123 local expect
=$1; shift
126 local ul_proto
=$1; shift
130 # Install the capture as skip_hw to avoid double-counting of packets.
131 # The traffic is meant for local box anyway, so will be trapped to
133 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"
136 vlan_capture_uninstall
$dev
139 quick_test_span_vlan_dir_ips
()
143 local ul_proto
=$1; shift
147 do_test_span_vlan_dir_ips
'>= 10' "$dev" "$vid" "$ul_proto" \
151 fail_test_span_vlan_dir_ips
()
155 local ul_proto
=$1; shift
159 do_test_span_vlan_dir_ips
0 "$dev" "$vid" "$ul_proto" "$ip1" "$ip2"
162 quick_test_span_vlan_dir
()
166 local ul_proto
=$1; shift
168 quick_test_span_vlan_dir_ips
"$dev" "$vid" "$ul_proto" \
172 fail_test_span_vlan_dir
()
176 local ul_proto
=$1; shift
178 fail_test_span_vlan_dir_ips
"$dev" "$vid" "$ul_proto" \