]> git.proxmox.com Git - ovs.git/blame - tests/rstp.at
netdev-linux: Support for SFQ, FQ_CoDel and CoDel qdiscs.
[ovs.git] / tests / rstp.at
CommitLineData
9efd308e
DV
1AT_BANNER([Rapid Spanning Tree Protocol unit tests])
2
3AT_SETUP([RSTP Single bridge])
4AT_KEYWORDS([RSTP])
5AT_DATA([test-rstp-num1],
6[bridge 0 0x111 = a b
7run 1000
8check 0 = root
9])
10AT_CHECK([ovstest test-rstp test-rstp-num1], [0], [])
11AT_CLEANUP
12
13AT_SETUP([RSTP Link failure])
14AT_KEYWORDS([RSTP])
15AT_DATA([test-rstp-num2],
16[bridge 0 0x111 = a b
17bridge 1 0x222 = a c
18bridge 2 0x333 = b c
19run 1000
20check 0 = root
21check 1 = F:200000 F
22check 2 = F:200000 Di
23# Link b goes down
24bridge 2 = X c
25run 1000
26check 1 = F:200000 F
27check 2 = D F:400000
28])
29AT_CHECK([ovstest test-rstp test-rstp-num2], [0], [])
30AT_CLEANUP
31
32AT_SETUP([RSTP Double link Failure])
33AT_KEYWORDS([RSTP])
34AT_DATA([test-rstp-num3],
35[bridge 0 0x111 = a b
36bridge 1 0x222 = a c d
37bridge 2 0x333 = b c e
38bridge 3 0x444 = d f
39bridge 4 0x555 = e f
40run 1000
41check 0 = root
42check 1 = F:200000 F F
43check 2 = F:200000 Di F
44check 3 = F:400000 F
45check 4 = F:400000 Di
46# Link b goes down
47bridge 2 = X c e
48run 1000
49check 0 = root
50check 1 = F:200000 F F
51check 2 = D F:400000 F
52check 3 = F:400000 F
53check 4 = F:600000 Di
54# Link e goes down
55bridge 4 = X f
56run 1000
57check 0 = root
58check 1 = F:200000 F F
59check 2 = D F:400000 F
60check 3 = F:400000 F
61check 4 = D F:600000
62# Link f cost changes
63bridge 4 = X f:100000
64run 1000
65check 4 = D F:500000
66# Bridge 4 becomes root and
67bridge 4 ^ 31000
68run 1000
69check 4 = root
70])
71AT_CHECK([ovstest test-rstp test-rstp-num3], [0], [])
72AT_CLEANUP
73
74AT_SETUP([RSTP example from IEEE 802.1D-2004 figures 17.4 and 17.5])
75AT_KEYWORDS([RSTP])
76AT_DATA([test-rstp-ieee802.1d-2004-fig17.4],
77[bridge 0 0x111 = a b e c
78bridge 1 0x222 = a b d f
79bridge 2 0x333 = c d l j h g
80bridge 3 0x444 = e f n m k i
81bridge 4 0x555 = g i 0 0
82bridge 5 0x666 = h k 0 0
83bridge 6 0x777 = j m 0 0
84bridge 7 0x888 = l n 0 0
85run 1000
86check 0 = root
87check 1 = F:200000 Di F F
88check 2 = F:200000 Di F F F F
89check 3 = F:200000 Di F F F F
90check 4 = F:400000 Di F F
91check 5 = F:400000 Di F F
92check 6 = F:400000 Di F F
93check 7 = F:400000 Di F F
94
95# Now connect two ports of bridge 7 to the same LAN.
96bridge 7 = l n o o
97# Same results except for bridge 7:
98run 1000
99check 0 = root
100check 1 = F:200000 Di F F
101check 2 = F:200000 Di F F F F
102check 3 = F:200000 Di F F F F
103check 4 = F:400000 Di F F
104check 5 = F:400000 Di F F
105check 6 = F:400000 Di F F
106check 7 = F:400000 Di F Di
107])
108AT_CHECK([ovstest test-rstp test-rstp-ieee802.1d-2004-fig17.4], [0], [])
109AT_CLEANUP
110
111AT_SETUP([RSTP example from IEEE 802.1D-2004 figure 17.6])
112AT_KEYWORDS([RSTP])
113AT_DATA([test-rstp-ieee802.1d-2004-fig17.6],
114[bridge 0 0x111 = a b l
115bridge 1 0x222 = b c d
116bridge 2 0x333 = d e f
117bridge 3 0x444 = f g h
118bridge 4 0x555 = j h i
119bridge 5 0x666 = l j k
120run 1000
121check 0 = root
122check 1 = F:200000 F F
123check 2 = F:400000 F F
124check 3 = F:600000 F Di
125check 4 = F:400000 F F
126check 5 = F:200000 F F
127])
128AT_CHECK([ovstest test-rstp test-rstp-ieee802.1d-2004-fig17.6], [0], [])
129AT_CLEANUP
130
131AT_SETUP([RSTP example from IEEE 802.1D-2004 figure 17.7])
132AT_KEYWORDS([RSTP])
133AT_DATA([test-rstp-ieee802.1d-2004-fig17.7],
134[bridge 0 0x000 = b
135bridge 1 0x111 = a b d f h g e c
136bridge 2 0x222 = g h j l n m k i
137run 1000
138check 0 = root
139check 1 = F F:200000 F F F F F F
140check 2 = Di F:400000 F F F F F F
141# Link g priority increment
142bridge 1 = a b d f h g^112 e c
143run 1000
144check 0 = root
145check 1 = F F:200000 F F F F F F
146check 2 = F:400000 Di F F F F F F
147])
148AT_CHECK([ovstest test-rstp test-rstp-ieee802.1d-2004-fig17.7], [0], [])
149AT_CLEANUP
9a0bb428
JR
150
151# Strips out uninteresting parts of flow output, as well as parts
152# that vary from one run to another (e.g., timing and bond actions).
153m4_define([STRIP_USED], [[sed '
154 s/used:[0-9]*\.[0-9]*/used:0.0/
155 s/duration=[0-9.]*s*/duration=Xs/
156 s/idle_age=[0-9]*,/idle_age=X,/
157']])
158m4_define([FILTER_STP_TOPOLOGY], [[
159grep 'STP state changed' | sed '
160 s/.*ofproto_dpif|.*|//
161']])
162
163AT_SETUP([RSTP - dummy interface])
164# Create br0 with interfaces p1 and p7
165# and br1 with interfaces p2 and p8
166# with p1 and p2 connected via unix domain socket
167OVS_VSWITCHD_START(
168 [set port br0 other_config:rstp-enable=false -- \
169 set bridge br0 rstp_enable=true -- \
170 add-br br1 -- \
171 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
172 set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
173 fail-mode=secure -- \
174 set port br1 other_config:rstp-enable=false -- \
f025bcb7
JR
175 set bridge br1 rstp_enable=false -- \
176])
9a0bb428
JR
177
178AT_CHECK([ovs-vsctl add-port br0 p1 -- \
179 set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock ofport_request=1 -- \
180 set port p1 other_config:rstp-enable=true -- \
181])
182AT_CHECK([ovs-vsctl add-port br0 p7 -- \
183 set interface p7 ofport_request=7 type=dummy -- \
184 set port p7 other_config:rstp-enable=false -- \
185])
186AT_CHECK([ovs-vsctl add-port br1 p2 -- \
187 set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock ofport_request=2 -- \
f025bcb7 188 set port p2 other_config:rstp-enable=false -- \
9a0bb428
JR
189])
190AT_CHECK([ovs-vsctl add-port br1 p8 -- \
191 set interface p8 ofport_request=8 type=dummy -- \
192 set port p8 other_config:rstp-enable=false -- \
193])
194
f025bcb7
JR
195#
196# RSTP needs link to be in admin-state up, netdev-dummy is by default down
197#
198AT_CHECK([ovs-appctl netdev-dummy/set-admin-state p1 up], [], [dnl
199OK
200])
201
202#
203# Turn RSTP on in br1 after the ports have been added.
204#
205AT_CHECK([ovs-vsctl set bridge br1 rstp_enable=true])
206
9a0bb428
JR
207ovs-appctl time/stop
208
209AT_CHECK([ovs-ofctl add-flow br0 "in_port=7 icmp actions=1"])
210AT_CHECK([ovs-ofctl add-flow br0 "in_port=1 icmp actions=7"])
211AT_CHECK([ovs-ofctl add-flow br1 "in_port=8 icmp actions=2"])
212AT_CHECK([ovs-ofctl add-flow br1 "in_port=2 icmp actions=8"])
213
f025bcb7
JR
214AT_CHECK([ovs-vsctl set port p2 other_config:rstp-enable=true])
215
0b5d64f6 216OVS_WAIT_UNTIL([test `cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY | wc -l` -ge 2])
9a0bb428
JR
217AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl
218port p1: RSTP state changed from Disabled to Discarding
219port p2: RSTP state changed from Disabled to Discarding
220])
221
222AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(7),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' | grep STP], [0], [dnl
223RSTP not in forwarding state, skipping output
224])
225AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' | grep STP], [0], [dnl
226RSTP not in forwarding state, skipping output
227])
228
229#
230# RSTP needs link to be in admin-state up, netdev-dummy is by default down
231#
f025bcb7 232AT_CHECK([ovs-appctl netdev-dummy/set-admin-state p2 up], [], [dnl
9a0bb428
JR
233OK
234])
235
37a4efd1
JR
236# give time for RSTP to move initially
237
238ovs-appctl time/warp 1000
239ovs-appctl time/warp 1000
240
0b5d64f6 241OVS_WAIT_UNTIL([test `cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY | wc -l` -ge 4])
9a0bb428
JR
242AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl
243port p1: RSTP state changed from Disabled to Discarding
244port p2: RSTP state changed from Disabled to Discarding
245port p2: RSTP state changed from Discarding to Forwarding
246port p1: RSTP state changed from Discarding to Forwarding
247])
248
249AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(7),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' | grep Datapath], [0], [dnl
250Datapath actions: 1
251])
252AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(8),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' | grep Datapath], [0], [dnl
253Datapath actions: 2
254])
255
f025bcb7
JR
256AT_CHECK([ovs-vsctl del-br br1])
257
258AT_CHECK([ovs-vsctl del-port br0 p7])
259AT_CHECK([ovs-vsctl del-port br0 p1])
260
9a0bb428
JR
261OVS_VSWITCHD_STOP
262AT_CLEANUP