summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
blob: 20078cc55f24bc6eede738d9fc41c55ee3206793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# SPDX-License-Identifier: GPL-2.0

source "$net_forwarding_dir/mirror_lib.sh"

quick_test_span_gre_dir_ips()
{
	local tundev=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift

	do_test_span_dir_ips 10 h3-$tundev "$ip1" "$ip2" \
			     "$forward_type" "$backward_type"
}

fail_test_span_gre_dir_ips()
{
	local tundev=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift

	do_test_span_dir_ips 0 h3-$tundev "$ip1" "$ip2"
}

test_span_gre_dir_ips()
{
	local tundev=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift

	test_span_dir_ips h3-$tundev "$forward_type" \
			  "$backward_type" "$ip1" "$ip2"
}

full_test_span_gre_dir_ips()
{
	local tundev=$1; shift
	local direction=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local what=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift

	RET=0

	mirror_install $swp1 $direction $tundev "matchall"
	test_span_dir_ips "h3-$tundev" "$forward_type" \
			  "$backward_type" "$ip1" "$ip2"
	mirror_uninstall $swp1 $direction

	log_test "$direction $what"
}

full_test_span_gre_dir_vlan_ips()
{
	local tundev=$1; shift
	local direction=$1; shift
	local vlan_match=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local what=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift

	RET=0

	mirror_install $swp1 $direction $tundev "matchall"

	test_span_dir_ips "h3-$tundev" "$forward_type" \
			  "$backward_type" "$ip1" "$ip2"

	tc filter add dev $h3 ingress pref 77 prot 802.1q \
		flower $vlan_match \
		action pass
	mirror_test v$h1 $ip1 $ip2 $h3 77 '>= 10'
	tc filter del dev $h3 ingress pref 77

	mirror_uninstall $swp1 $direction

	log_test "$direction $what"
}

quick_test_span_gre_dir()
{
	local tundev=$1; shift
	local forward_type=${1-8}; shift
	local backward_type=${1-0}; shift

	quick_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2 \
				    "$forward_type" "$backward_type"
}

fail_test_span_gre_dir()
{
	local tundev=$1; shift

	fail_test_span_gre_dir_ips "$tundev" 192.0.2.1 192.0.2.2
}

full_test_span_gre_dir()
{
	local tundev=$1; shift
	local direction=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local what=$1; shift

	full_test_span_gre_dir_ips "$tundev" "$direction" "$forward_type" \
				   "$backward_type" "$what" 192.0.2.1 192.0.2.2
}

full_test_span_gre_dir_vlan()
{
	local tundev=$1; shift
	local direction=$1; shift
	local vlan_match=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local what=$1; shift

	full_test_span_gre_dir_vlan_ips "$tundev" "$direction" "$vlan_match" \
					"$forward_type" "$backward_type" \
					"$what" 192.0.2.1 192.0.2.2
}

full_test_span_gre_stp_ips()
{
	local tundev=$1; shift
	local nbpdev=$1; shift
	local what=$1; shift
	local ip1=$1; shift
	local ip2=$1; shift
	local forward_type=$1; shift
	local backward_type=$1; shift
	local h3mac=$(mac_get $h3)

	RET=0

	mirror_install $swp1 ingress $tundev "matchall"
	quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \
				    "$forward_type" "$backward_type"

	bridge link set dev $nbpdev state disabled
	sleep 1
	fail_test_span_gre_dir_ips $tundev $ip1 $ip2

	bridge link set dev $nbpdev state forwarding
	sleep 1
	quick_test_span_gre_dir_ips $tundev $ip1 $ip2 \
				    "$forward_type" "$backward_type"

	mirror_uninstall $swp1 ingress

	log_test "$what: STP state"
}

full_test_span_gre_stp()
{
	local tundev=$1; shift
	local nbpdev=$1; shift
	local what=$1; shift
	local forward_type=${1-8}; shift
	local backward_type=${1-0}; shift

	full_test_span_gre_stp_ips "$tundev" "$nbpdev" "$what" \
				   192.0.2.1 192.0.2.2 \
				   "$forward_type" "$backward_type"
}