]> git.proxmox.com Git - mirror_ovs.git/blame - tests/stp.at
ovn: Rename "nd" action to "nd_na".
[mirror_ovs.git] / tests / stp.at
CommitLineData
829a7d02
JP
1AT_BANNER([Spanning Tree Protocol unit tests])
2
3AT_SETUP([STP example from IEEE 802.1D-1998])
4AT_KEYWORDS([STP])
5AT_DATA([test-stp-ieee802.1d-1998],
6[bridge 0 0x42 = a b
7bridge 1 0x97 = c:5 a d:5
8bridge 2 0x45 = b e
9bridge 3 0x57 = b:5 e:5
10bridge 4 0x83 = a:5 e:5
11run 1000
12check 0 = root
13check 1 = F F:10 F
14check 2 = F:10 B
15check 3 = F:5 F
16check 4 = F:5 B
17])
eadd1644 18AT_CHECK([ovstest test-stp test-stp-ieee802.1d-1998], [0], [], [dnl
634408e0
EJ
19stp|INFO|stp42: detected topology change.
20stp|INFO|stp42: detected topology change.
21stp|INFO|stp97: detected topology change.
22stp|INFO|stp97: detected topology change.
23stp|INFO|stp97: detected topology change.
24])
829a7d02
JP
25AT_CLEANUP
26
27AT_SETUP([STP example from IEEE 802.1D-2004 figures 17.4 and 17.5])
28AT_KEYWORDS([STP])
29AT_DATA([test-stp-ieee802.1d-2004-fig17.4],
30[bridge 0 0x111 = a b e c
31bridge 1 0x222 = a b d f
32bridge 2 0x333 = c d l j h g
33bridge 3 0x444 = e f n m k i
34bridge 4 0x555 = g i 0 0
35bridge 5 0x666 = h k 0 0
36bridge 6 0x777 = j m 0 0
37bridge 7 0x888 = l n 0 0
38run 1000
39check 0 = root
40check 1 = F:10 B F F
41check 2 = F:10 B F F F F
42check 3 = F:10 B F F F F
43check 4 = F:20 B F F
44check 5 = F:20 B F F
45check 6 = F:20 B F F
46check 7 = F:20 B F F
47
48# Now connect two ports of bridge 7 to the same LAN.
49bridge 7 = l n o o
50# Same results except for bridge 7:
51run 1000
52check 0 = root
53check 1 = F:10 B F F
54check 2 = F:10 B F F F F
55check 3 = F:10 B F F F F
56check 4 = F:20 B F F
57check 5 = F:20 B F F
58check 6 = F:20 B F F
59check 7 = F:20 B F B
60])
eadd1644 61AT_CHECK([ovstest test-stp test-stp-ieee802.1d-2004-fig17.4], [0], [], [dnl
634408e0
EJ
62stp|INFO|stp111: detected topology change.
63stp|INFO|stp111: detected topology change.
64stp|INFO|stp111: detected topology change.
65stp|INFO|stp111: detected topology change.
66stp|INFO|stp222: detected topology change.
67])
829a7d02
JP
68AT_CLEANUP
69
70AT_SETUP([STP example from IEEE 802.1D-2004 figure 17.6])
71AT_KEYWORDS([STP])
72AT_DATA([test-stp-ieee802.1d-2004-fig17.6],
73[bridge 0 0x111 = a b l
74bridge 1 0x222 = b c d
75bridge 2 0x333 = d e f
76bridge 3 0x444 = f g h
77bridge 4 0x555 = j h i
78bridge 5 0x666 = l j k
79run 1000
80check 0 = root
81check 1 = F:10 F F
82check 2 = F:20 F F
83check 3 = F:30 F B
84check 4 = F:20 F F
85check 5 = F:10 F F
86])
eadd1644 87AT_CHECK([ovstest test-stp test-stp-ieee802.1d-2004-fig17.6], [0], [], [dnl
634408e0
EJ
88stp|INFO|stp111: detected topology change.
89stp|INFO|stp111: detected topology change.
90stp|INFO|stp111: detected topology change.
91stp|INFO|stp222: detected topology change.
92stp|INFO|stp222: detected topology change.
93])
829a7d02
JP
94AT_CLEANUP
95
96AT_SETUP([STP example from IEEE 802.1D-2004 figure 17.7])
97AT_KEYWORDS([STP])
98AT_DATA([test-stp-ieee802.1d-2004-fig17.7],
99[bridge 0 0xaa = b
100bridge 1 0x111 = a b d f h g e c
101bridge 2 0x222 = g h j l n m k i
102run 1000
103check 0 = root
104check 1 = F F:10 F F F F F F
105check 2 = B F:20 F F F F F F
106
107# This is not the port priority change described in that figure,
108# but I don't understand what port priority change would cause
109# that change.
110bridge 2 = g X j l n m k i
111run 1000
112check 0 = root
113check 1 = F F:10 F F F F F F
114check 2 = F:20 D F F F F F F
115])
eadd1644 116AT_CHECK([ovstest test-stp test-stp-ieee802.1d-2004-fig17.7], [0], [], [dnl
634408e0
EJ
117stp|INFO|stpaa: detected topology change.
118stp|INFO|stp111: detected topology change.
119stp|INFO|stp111: detected topology change.
120stp|INFO|stp111: detected topology change.
121stp|INFO|stp111: detected topology change.
122])
829a7d02
JP
123AT_CLEANUP
124
125AT_SETUP([STP.io.1.1: Link Failure])
126AT_KEYWORDS([STP])
127AT_DATA([test-stp-iol-io-1.1],
128[# This test file approximates the following test from "Bridge
129# Functions Consortium Spanning Tree Interoperability Test Suite
130# Version 1.5":
131#
132# STP.io.1.1: Link Failure
133bridge 0 0x111 = a b c
134bridge 1 0x222 = a b c
135run 1000
136check 0 = root
137check 1 = F:10 B B
138bridge 1 = 0 _ _
139run 1000
140check 0 = root
141check 1 = F F:10 B
142bridge 1 = X _ _
143run 1000
144check 0 = root
145check 1 = D F:10 B
146bridge 1 = _ 0 _
147run 1000
148check 0 = root
149check 1 = D F F:10
150bridge 1 = _ X _
151run 1000
152check 0 = root
153check 1 = D D F:10
154])
eadd1644 155AT_CHECK([ovstest test-stp test-stp-iol-io-1.1], [0], [], [dnl
634408e0
EJ
156stp|INFO|stp111: detected topology change.
157stp|INFO|stp111: detected topology change.
158stp|INFO|stp111: detected topology change.
159stp|INFO|stp222: detected topology change.
160stp|INFO|stp111: detected topology change.
161])
829a7d02
JP
162AT_CLEANUP
163
164AT_SETUP([STP.io.1.2: Repeated Network])
165AT_KEYWORDS([STP])
166AT_DATA([test-stp-iol-io-1.2],
167[# This test file approximates the following test from "Bridge
168# Functions Consortium Spanning Tree Interoperability Test Suite
169# Version 1.5":
170# STP.io.1.2: Repeated Network
171bridge 0 0x111 = a a
172bridge 1 0x222 = a a
173run 1000
174check 0 = rootid:0x111 F B
175check 1 = rootid:0x111 F:10 B
176bridge 1 = a^0x90 _
177run 1000
178check 0 = rootid:0x111 F B
179check 1 = rootid:0x111 B F:10
180])
eadd1644 181AT_CHECK([ovstest test-stp test-stp-iol-io-1.2], [0], [], [dnl
634408e0
EJ
182stp|INFO|stp111: detected topology change.
183stp|INFO|stp222: detected topology change.
184stp|INFO|stp111: detected topology change.
185])
829a7d02
JP
186AT_CLEANUP
187
188AT_SETUP([STP.io.1.4: Network Initialization])
189AT_KEYWORDS([STP])
190AT_DATA([test-stp-iol-io-1.4],
191[# This test file approximates the following test from "Bridge
192# Functions Consortium Spanning Tree Interoperability Test Suite
193# Version 1.5":
194# STP.io.1.4: Network Initialization
195bridge 0 0x111 = a b c
196bridge 1 0x222 = b d e
197bridge 2 0x333 = a d f
198bridge 3 0x444 = c e f
199run 1000
200check 0 = root
201check 1 = F:10 F F
202check 2 = F:10 B F
203check 3 = F:10 B B
204])
eadd1644 205AT_CHECK([ovstest test-stp test-stp-iol-io-1.4], [0], [], [dnl
634408e0
EJ
206stp|INFO|stp111: detected topology change.
207stp|INFO|stp111: detected topology change.
208stp|INFO|stp111: detected topology change.
209stp|INFO|stp222: detected topology change.
210stp|INFO|stp222: detected topology change.
211])
829a7d02
JP
212AT_CLEANUP
213
214AT_SETUP([STP.io.1.5: Topology Change])
215AT_KEYWORDS([STP])
216AT_DATA([test-stp-iol-io-1.5],
217[# This test file approximates the following test from "Bridge
218# Functions Consortium Spanning Tree Interoperability Test Suite
219# Version 1.5":
220# STP.io.1.5: Topology Change
221bridge 0 0x111 = a b d c
222bridge 1 0x222 = a b f e
223bridge 2 0x333 = c d g h
224bridge 3 0x444 = e f g h
225run 1000
226check 0 = root
227check 1 = F:10 B F F
228check 2 = B F:10 F F
229check 3 = B F:20 B B
230bridge 1^0x7000
231run 1000
232check 0 = F:10 B F F
233check 1 = root
234check 2 = B F:20 B B
235check 3 = B F:10 F F
236bridge 2^0x6000
237run 1000
238check 0 = F F B F:10
239check 1 = F:20 B B B
240check 2 = root
241check 3 = F F F:10 B
242bridge 3^0x5000
243run 1000
244check 0 = B B B F:20
245check 1 = F F B F:10
246check 2 = F F F:10 B
247check 3 = root
248bridge 0^0x4000
249bridge 1^0x4001
250bridge 2^0x4002
251bridge 3^0x4003
252run 1000
253check 0 = root
254check 1 = F:10 B F F
255check 2 = B F:10 F F
256check 3 = B F:20 B B
257])
eadd1644 258AT_CHECK([ovstest test-stp test-stp-iol-io-1.5], [0], [], [dnl
634408e0
EJ
259stp|INFO|stp111: detected topology change.
260stp|INFO|stp111: detected topology change.
261stp|INFO|stp111: detected topology change.
262stp|INFO|stp111: detected topology change.
263stp|INFO|stp222: detected topology change.
264])
829a7d02
JP
265AT_CLEANUP
266
267AT_SETUP([STP.op.1.1 and STP.op.1.2])
268AT_KEYWORDS([STP])
269AT_DATA([test-stp-iol-op-1.1],
270[# This test file approximates the following tests from "Bridge
271# Functions Consortium Spanning Tree Protocol Operations Test Suite
272# Version 2.3":
273# Test STP.op.1.1: Root ID Initialized to Bridge ID
274# Test STP.op.1.2: Root Path Cost Initialized to Zero
275bridge 0 0x123 =
276check 0 = root
277])
eadd1644 278AT_CHECK([ovstest test-stp test-stp-iol-op-1.1])
829a7d02
JP
279AT_CLEANUP
280
281AT_SETUP([STP.op.1.4: All Ports Initialized to Designated Ports])
282AT_KEYWORDS([STP])
283AT_DATA([test-stp-iol-op-1.4],
284[# This test file approximates the following test from "Bridge
285# Functions Consortium Spanning Tree Protocol Operations Test Suite
286# Version 2.3":
287# Test STP.op.1.4: All Ports Initialized to Designated Ports
288bridge 0 0x123 = a b c d e f
289check 0 = Li Li Li Li Li Li
290run 1000
291check 0 = F F F F F F
292])
eadd1644 293AT_CHECK([ovstest test-stp test-stp-iol-op-1.4], [0], [], [dnl
634408e0
EJ
294stp|INFO|stp123: detected topology change.
295stp|INFO|stp123: detected topology change.
296stp|INFO|stp123: detected topology change.
297stp|INFO|stp123: detected topology change.
298stp|INFO|stp123: detected topology change.
299])
829a7d02
JP
300AT_CLEANUP
301
302AT_SETUP([STP.op.3.1: Root Bridge Selection: Root ID Values])
303AT_KEYWORDS([STP])
304AT_DATA([test-stp-iol-op-3.1],
305[# This test file approximates the following test from "Bridge
306# Functions Consortium Spanning Tree Protocol Operations Test Suite
307# Version 2.3":
308# Test STP.op.3.1: Root Bridge Selection: Root ID Values
309bridge 0 0x111 = a
310bridge 1 0x222 = a
311check 0 = rootid:0x111 Li
312check 1 = rootid:0x222 Li
313run 1000
314check 0 = rootid:0x111 root
315check 1 = rootid:0x111 F:10
316])
eadd1644 317AT_CHECK([ovstest test-stp test-stp-iol-op-3.1], [0], [], [dnl
634408e0
EJ
318stp|INFO|stp111: detected topology change.
319])
829a7d02
JP
320AT_CLEANUP
321
322AT_SETUP([STP.op.3.3: Root Bridge Selection: Bridge ID Values])
323AT_KEYWORDS([STP])
324AT_DATA([test-stp-iol-op-3.3],
325[# This test file approximates the following test from "Bridge
326# Functions Consortium Spanning Tree Protocol Operations Test Suite
327# Version 2.3":
328# Test STP.op.3.3: Root Bridge Selection: Bridge ID Values
329bridge 0 0x333^0x6000 = a
330bridge 1 0x222^0x7000 = b
331bridge 2 0x111 = a b
332run 1000
333check 0 = rootid:0x333^0x6000 root
334check 1 = rootid:0x333^0x6000 F:20
335check 2 = rootid:0x333^0x6000 F:10 F
336])
eadd1644 337AT_CHECK([ovstest test-stp test-stp-iol-op-3.3], [0], [], [dnl
634408e0
EJ
338stp|INFO|stp333: detected topology change.
339stp|INFO|stp111: detected topology change.
340stp|INFO|stp111: detected topology change.
341stp|INFO|stp333: detected topology change.
342])
829a7d02
JP
343AT_CLEANUP
344
345AT_SETUP([STP.op.3.3: Root Bridge Selection: Bridge ID Values])
346AT_KEYWORDS([STP])
347AT_DATA([test-stp-iol-op-3.4],
348[# This test file approximates the following test from "Bridge
349# Functions Consortium Spanning Tree Protocol Operations Test Suite
350# Version 2.3":
351# Test STP.op.3.3: Root Bridge Selection: Bridge ID Values
352bridge 0 0x333^0x6000 = a
353bridge 1 0x222^0x7000 = b
354bridge 2 0x111 = a b
355run 1000
356check 0 = rootid:0x333^0x6000 root
357check 1 = rootid:0x333^0x6000 F:20
358check 2 = rootid:0x333^0x6000 F:10 F
359])
eadd1644 360AT_CHECK([ovstest test-stp test-stp-iol-op-3.4], [0], [], [dnl
634408e0
EJ
361stp|INFO|stp333: detected topology change.
362stp|INFO|stp111: detected topology change.
363stp|INFO|stp111: detected topology change.
364stp|INFO|stp333: detected topology change.
365])
829a7d02 366AT_CLEANUP
9a0bb428
JR
367
368# Strips out uninteresting parts of flow output, as well as parts
369# that vary from one run to another (e.g., timing and bond actions).
370m4_define([STRIP_USED], [[sed '
371 s/used:[0-9]*\.[0-9]*/used:0.0/
372 s/duration=[0-9.]*s*/duration=Xs/
373 s/idle_age=[0-9]*,/idle_age=X,/
374']])
375m4_define([FILTER_STP_TOPOLOGY], [[
376grep 'STP state change' | sed '
377 s/.*ofproto_dpif|.*|//
378']])
379
380AT_SETUP([STP - dummy interface])
381# Create br0 with interfaces p1 and p7
382# and br1 with interfaces p2 and p8
383# with p1 and p2 connected via unix domain socket
384OVS_VSWITCHD_START(
385 [set port br0 other_config:stp-enable=false -- \
386 set bridge br0 stp_enable=true -- \
387 add-br br1 -- \
388 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
389 set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
390 fail-mode=secure -- \
391 set port br1 other_config:stp-enable=false -- \
392 set bridge br1 stp_enable=true --])
393
394AT_CHECK([ovs-appctl vlog/set ofproto_dpif:dbg])
395
396AT_CHECK([ovs-vsctl add-port br0 p1 -- \
397 set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock ofport_request=1 -- \
398 set port p1 other_config:stp-enable=true -- \
399])
400AT_CHECK([ovs-vsctl add-port br0 p7 -- \
401 set interface p7 ofport_request=7 type=dummy -- \
402 set port p7 other_config:stp-enable=false -- \
403])
404AT_CHECK([ovs-vsctl add-port br1 p2 -- \
405 set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock ofport_request=2 -- \
406 set port p2 other_config:stp-enable=true -- \
407])
408AT_CHECK([ovs-vsctl add-port br1 p8 -- \
409 set interface p8 ofport_request=8 type=dummy -- \
410 set port p8 other_config:stp-enable=false -- \
411])
412
413ovs-appctl time/stop
414
415AT_CHECK([ovs-ofctl add-flow br0 "in_port=7 icmp actions=1"])
416AT_CHECK([ovs-ofctl add-flow br0 "in_port=1 icmp actions=7"])
417AT_CHECK([ovs-ofctl add-flow br1 "in_port=8 icmp actions=2"])
418AT_CHECK([ovs-ofctl add-flow br1 "in_port=2 icmp actions=8"])
419
420# give time for STP to move initially
421
422ovs-appctl time/warp 3000
423ovs-appctl time/warp 3000
424
425AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl
426port p1: STP state changed from disabled to listening
427port p2: STP state changed from disabled to listening
428])
429
430AT_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
431STP not in forwarding state, skipping output
432])
433AT_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
434STP not in forwarding state, skipping output
435])
436
437# give time for STP to synchronize
438
439ovs-appctl time/warp 3000
440ovs-appctl time/warp 3000
441ovs-appctl time/warp 3000
442ovs-appctl time/warp 3000
443ovs-appctl time/warp 3000
444ovs-appctl time/warp 3000
445ovs-appctl time/warp 3000
446ovs-appctl time/warp 3000
447ovs-appctl time/warp 3000
448
449AT_CHECK([cat ovs-vswitchd.log | FILTER_STP_TOPOLOGY], [0], [dnl
450port p1: STP state changed from disabled to listening
451port p2: STP state changed from disabled to listening
452port p1: STP state changed from listening to learning
453port p2: STP state changed from listening to learning
454port p1: STP state changed from learning to forwarding
455port p2: STP state changed from learning to forwarding
456])
457
458AT_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
459Datapath actions: 1
460])
461AT_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
462Datapath actions: 2
463])
464
465OVS_VSWITCHD_STOP
466AT_CLEANUP