File Index
Files and directories
Sign in
FILE

mirror_gre_lib.sh

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh BASH
  1# SPDX-License-Identifier: GPL-2.0
  2
  3source "$net_forwarding_dir/mirror_lib.sh"
  4
  5quick_test_span_gre_dir_ips()
  6{
  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
 12
 13	do_test_span_dir_ips 10 h3-$tundev "$ip1" "$ip2" \
 14			     "$forward_type" "$backward_type"
 15}
 16
 17fail_test_span_gre_dir_ips()
 18{
 19	local tundev=$1; shift
 20	local ip1=$1; shift
 21	local ip2=$1; shift
 22
 23	do_test_span_dir_ips 0 h3-$tundev "$ip1" "$ip2"
 24}
 25
 26test_span_gre_dir_ips()
 27{
 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
 33
 34	test_span_dir_ips h3-$tundev "$forward_type" \
 35			  "$backward_type" "$ip1" "$ip2"
 36}
 37
 38full_test_span_gre_dir_ips()
 39{
 40	local tundev=$1; shift
 41	local direction=$1; shift
 42	local forward_type=$1; shift
 43	local backward_type=$1; shift
 44	local what=$1; shift
 45	local ip1=$1; shift
 46	local ip2=$1; shift
 47
 48	RET=0
 49
 50	mirror_install $swp1 $direction $tundev "matchall"
 51	test_span_dir_ips "h3-$tundev" "$forward_type" \
 52			  "$backward_type" "$ip1" "$ip2"
 53	mirror_uninstall $swp1 $direction
 54
 55	log_test "$direction $what"
 56}
 57
 58full_test_span_gre_dir_vlan_ips()
 59{
 60	local tundev=$1; shift
 61	local direction=$1; shift
 62	local vlan_match=$1; shift
 63	local forward_type=$1; shift
 64	local backward_type=$1; shift
 65	local what=$1; shift
 66	local ip1=$1; shift
 67	local ip2=$1; shift
 68
 69	RET=0
 70
 71	mirror_install $swp1 $direction $tundev "matchall"
 72
 73	test_span_dir_ips "h3-$tundev" "$forward_type" \
 74			  "$backward_type" "$ip1" "$ip2"
 75
 76	tc filter add dev $h3 ingress pref 77 prot 802.1q \
 77		flower $vlan_match \
 78		action pass
 79	mirror_test v$h1 $ip1 $ip2 $h3 77 '>= 10'
 80	tc filter del dev $h3 ingress pref 77
 81
 82	mirror_uninstall $swp1 $direction
 83
 84	log_test "$direction $what"
 85}
 86
 87quick_test_span_gre_dir()
 88{
 89	local tundev=$1; shift
 90	local forward_type=${1-8}; shift
 91	local backward_type=${1-0}; shift
 92
 93	quick_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2 \
 94				    "$forward_type" "$backward_type"
 95}
 96
 97fail_test_span_gre_dir()
 98{
 99	local tundev=$1; shift
100
101	fail_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2
102}
103
104full_test_span_gre_dir()
105{
106	local tundev=$1; shift
107	local direction=$1; shift
108	local forward_type=$1; shift
109	local backward_type=$1; shift
110	local what=$1; shift
111
112	full_test_span_gre_dir_ips "$tundev" "$direction" "$forward_type" \
113				   "$backward_type" "$what" 192.0.2.1 192.0.2.2
114}
115
116full_test_span_gre_dir_vlan()
117{
118	local tundev=$1; shift
119	local direction=$1; shift
120	local vlan_match=$1; shift
121	local forward_type=$1; shift
122	local backward_type=$1; shift
123	local what=$1; shift
124
125	full_test_span_gre_dir_vlan_ips "$tundev" "$direction" "$vlan_match" \
126					"$forward_type" "$backward_type" \
127					"$what" 192.0.2.1 192.0.2.2
128}
129
130full_test_span_gre_stp_ips()
131{
132	local tundev=$1; shift
133	local nbpdev=$1; shift
134	local what=$1; shift
135	local ip1=$1; shift
136	local ip2=$1; shift
137	local forward_type=$1; shift
138	local backward_type=$1; shift
139	local h3mac=$(mac_get $h3)
140
141	RET=0
142
143	mirror_install $swp1 ingress $tundev "matchall"
144	quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \
145				    "$forward_type" "$backward_type"
146
147	bridge link set dev $nbpdev state disabled
148	sleep 1
149	fail_test_span_gre_dir_ips $tundev $ip1 $ip2
150
151	bridge link set dev $nbpdev state forwarding
152	sleep 1
153	quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \
154				    "$forward_type" "$backward_type"
155
156	mirror_uninstall $swp1 ingress
157
158	log_test "$what: STP state"
159}
160
161full_test_span_gre_stp()
162{
163	local tundev=$1; shift
164	local nbpdev=$1; shift
165	local what=$1; shift
166	local forward_type=${1-8}; shift
167	local backward_type=${1-0}; shift
168
169	full_test_span_gre_stp_ips "$tundev" "$nbpdev" "$what" \
170				   192.0.2.1 192.0.2.2 \
171				   "$forward_type" "$backward_type"
172}
~/ Read-only file preview.