lacp: Stop time to avoid dependency on real time in negotiation test.
[sliver-openvswitch.git] / tests / lacp.at
1 AT_BANNER([lacp])
2
3 AT_SETUP([lacp - config])
4 OVS_VSWITCHD_START([\
5         add-port br0 p1 --\
6         set Port p1 lacp=active --\
7         set Interface p1 type=dummy ])
8
9 AT_CHECK([ovs-appctl lacp/show], [0], [dnl
10 ---- p1 ----
11         status: active negotiated
12         sys_id: aa:55:aa:55:00:00
13         sys_priority: 65535
14         aggregation key: 1
15         lacp_time: slow
16
17 slave: p1: expired attached
18         port_id: 1
19         port_priority: 65535
20         may_enable: false
21
22         actor sys_id: aa:55:aa:55:00:00
23         actor sys_priority: 65535
24         actor port_id: 1
25         actor port_priority: 65535
26         actor key: 1
27         actor state: activity synchronized collecting distributing expired
28
29         partner sys_id: 00:00:00:00:00:00
30         partner sys_priority: 0
31         partner port_id: 0
32         partner port_priority: 0
33         partner key: 0
34         partner state: timeout
35 ])
36 AT_CHECK([ovs-appctl bond/show])
37 OVS_VSWITCHD_STOP
38 AT_CLEANUP
39
40 AT_SETUP([lacp - multi port config])
41 OVS_VSWITCHD_START([dnl
42         add-bond br0 bond p1 p2 --\
43         set Port bond lacp=active bond-mode=active-backup \
44             other_config:lacp-time="fast" \
45             other_config:lacp-system-id=11:22:33:44:55:66 \
46             other_config:lacp-system-priority=54321 --\
47         set Interface p1 type=dummy \
48             other_config:lacp-port-id=11 \
49             other_config:lacp-port-priority=111 \
50             other_config:lacp-aggregation-key=3333 --\
51         set Interface p2 type=dummy \
52             other_config:lacp-port-id=22 \
53             other_config:lacp-port-priority=222 \
54             other_config:lacp-aggregation-key=3333 ])
55
56 AT_CHECK([ovs-appctl lacp/show], [0], [stdout])
57 AT_CHECK([sed -e 's/aggregation key:.*/aggregation key: <omitted>/' < stdout], [0], [dnl
58 ---- bond ----
59         status: active negotiated
60         sys_id: 11:22:33:44:55:66
61         sys_priority: 54321
62         aggregation key: <omitted>
63         lacp_time: fast
64
65 slave: p1: expired attached
66         port_id: 11
67         port_priority: 111
68         may_enable: false
69
70         actor sys_id: 11:22:33:44:55:66
71         actor sys_priority: 54321
72         actor port_id: 11
73         actor port_priority: 111
74         actor key: 3333
75         actor state: activity timeout aggregation synchronized collecting distributing expired
76
77         partner sys_id: 00:00:00:00:00:00
78         partner sys_priority: 0
79         partner port_id: 0
80         partner port_priority: 0
81         partner key: 0
82         partner state: timeout
83
84 slave: p2: expired attached
85         port_id: 22
86         port_priority: 222
87         may_enable: false
88
89         actor sys_id: 11:22:33:44:55:66
90         actor sys_priority: 54321
91         actor port_id: 22
92         actor port_priority: 222
93         actor key: 3333
94         actor state: activity timeout aggregation synchronized collecting distributing expired
95
96         partner sys_id: 00:00:00:00:00:00
97         partner sys_priority: 0
98         partner port_id: 0
99         partner port_priority: 0
100         partner key: 0
101         partner state: timeout
102 ])
103 AT_CHECK([ovs-appctl bond/show], [0], [dnl
104 ---- bond ----
105 bond_mode: active-backup
106 bond-hash-basis: 0
107 updelay: 0 ms
108 downdelay: 0 ms
109 lacp_status: negotiated
110
111 slave p1: disabled
112         may_enable: false
113
114 slave p2: disabled
115         may_enable: false
116
117 ])
118 OVS_VSWITCHD_STOP
119 AT_CLEANUP
120
121 AT_SETUP([lacp - negotiation])
122 # Create bond0 on br0 with interfaces p0 and p1
123 #    and bond1 on br1 with interfaces p2 and p3
124 # with p0 patched to p2 and p1 patched to p3.
125 OVS_VSWITCHD_START(
126   [add-bond br0 bond0 p0 p1 bond_mode=balance-tcp lacp=active \
127                             other-config:lacp-time=fast \
128                             other-config:bond-rebalance-interval=0 -- \
129    set interface p0 type=patch options:peer=p2 ofport_request=1 -- \
130    set interface p1 type=patch options:peer=p3 ofport_request=2 -- \
131    add-br br1 -- \
132    set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
133    set bridge br1 datapath-type=dummy other-config:datapath-id=1234 \
134                   fail-mode=secure -- \
135    add-bond br1 bond1 p2 p3 bond_mode=balance-tcp lacp=active \
136                             other-config:lacp-time=fast \
137                             other-config:bond-rebalance-interval=0 -- \
138    set interface p2 type=patch options:peer=p0 ofport_request=3 -- \
139    set interface p3 type=patch options:peer=p1 ofport_request=4 --])
140
141 AT_CHECK([ovs-appctl netdev-dummy/set-admin-state up], 0, [OK
142 ])
143
144 ovs-appctl time/stop
145
146 # Wait for up to 5 (simulated) seconds, until LACP negotiation finishes.
147 i=0
148 while :; do
149     ovs-appctl lacp/show bond0 > bond0
150     AT_CAPTURE_FILE([bond0])
151     ovs-appctl lacp/show bond1 > bond1
152     AT_CAPTURE_FILE([bond1])
153     if grep negotiated bond0 && grep negotiated bond1; then
154         if grep expired bond0 || grep expired bond1; then
155             :
156         else
157             break
158         fi
159     fi
160     i=`expr $i + 1`
161     if test $i = 50; then
162         AT_FAIL_IF([:])
163     fi
164     ovs-appctl time/warp 100
165 done
166
167 # Now check the correctly negotiated configuration.
168 AT_CHECK(
169   [ovs-appctl lacp/show bond0
170 ovs-appctl lacp/show bond1
171 ovs-appctl bond/show bond0
172 ovs-appctl bond/show bond1], [0], [stdout])
173 AT_CHECK([sed '/active slave/d' stdout], [0], [dnl
174 ---- bond0 ----
175         status: active negotiated
176         sys_id: aa:55:aa:55:00:00
177         sys_priority: 65534
178         aggregation key: 2
179         lacp_time: fast
180
181 slave: p0: current attached
182         port_id: 1
183         port_priority: 65535
184         may_enable: true
185
186         actor sys_id: aa:55:aa:55:00:00
187         actor sys_priority: 65534
188         actor port_id: 1
189         actor port_priority: 65535
190         actor key: 2
191         actor state: activity timeout aggregation synchronized collecting distributing
192
193         partner sys_id: aa:66:aa:66:00:00
194         partner sys_priority: 65534
195         partner port_id: 3
196         partner port_priority: 65535
197         partner key: 4
198         partner state: activity timeout aggregation synchronized collecting distributing
199
200 slave: p1: current attached
201         port_id: 2
202         port_priority: 65535
203         may_enable: true
204
205         actor sys_id: aa:55:aa:55:00:00
206         actor sys_priority: 65534
207         actor port_id: 2
208         actor port_priority: 65535
209         actor key: 2
210         actor state: activity timeout aggregation synchronized collecting distributing
211
212         partner sys_id: aa:66:aa:66:00:00
213         partner sys_priority: 65534
214         partner port_id: 4
215         partner port_priority: 65535
216         partner key: 4
217         partner state: activity timeout aggregation synchronized collecting distributing
218 ---- bond1 ----
219         status: active negotiated
220         sys_id: aa:66:aa:66:00:00
221         sys_priority: 65534
222         aggregation key: 4
223         lacp_time: fast
224
225 slave: p2: current attached
226         port_id: 3
227         port_priority: 65535
228         may_enable: true
229
230         actor sys_id: aa:66:aa:66:00:00
231         actor sys_priority: 65534
232         actor port_id: 3
233         actor port_priority: 65535
234         actor key: 4
235         actor state: activity timeout aggregation synchronized collecting distributing
236
237         partner sys_id: aa:55:aa:55:00:00
238         partner sys_priority: 65534
239         partner port_id: 1
240         partner port_priority: 65535
241         partner key: 2
242         partner state: activity timeout aggregation synchronized collecting distributing
243
244 slave: p3: current attached
245         port_id: 4
246         port_priority: 65535
247         may_enable: true
248
249         actor sys_id: aa:66:aa:66:00:00
250         actor sys_priority: 65534
251         actor port_id: 4
252         actor port_priority: 65535
253         actor key: 4
254         actor state: activity timeout aggregation synchronized collecting distributing
255
256         partner sys_id: aa:55:aa:55:00:00
257         partner sys_priority: 65534
258         partner port_id: 2
259         partner port_priority: 65535
260         partner key: 2
261         partner state: activity timeout aggregation synchronized collecting distributing
262 ---- bond0 ----
263 bond_mode: balance-tcp
264 bond-hash-basis: 0
265 updelay: 0 ms
266 downdelay: 0 ms
267 lacp_status: negotiated
268
269 slave p0: enabled
270         may_enable: true
271
272 slave p1: enabled
273         may_enable: true
274
275 ---- bond1 ----
276 bond_mode: balance-tcp
277 bond-hash-basis: 0
278 updelay: 0 ms
279 downdelay: 0 ms
280 lacp_status: negotiated
281
282 slave p2: enabled
283         may_enable: true
284
285 slave p3: enabled
286         may_enable: true
287
288 ])
289 AT_CHECK([grep 'active slave' stdout], [0], [dnl
290         active slave
291         active slave
292 ])
293
294 # Redirect the patch link between p0 and p2 so that no packets get
295 # back and forth across them anymore.  Then wait 2.5 simulated
296 # seconds.  The LACP state should become "expired" for p0 and p2.
297 AT_CHECK([ovs-vsctl \
298 -- add-port br0 null0 -- set int null0 type=patch options:peer=p2 -- set int p2 options:peer=null0 \
299 -- add-port br1 null1 -- set int null1 type=patch options:peer=p0 -- set int p0 options:peer=null1])
300
301 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
302 AT_CHECK(
303   [ovs-appctl lacp/show bond0
304 ovs-appctl lacp/show bond1
305 ovs-appctl bond/show bond0
306 ovs-appctl bond/show bond1], [0], [dnl
307 ---- bond0 ----
308         status: active negotiated
309         sys_id: aa:55:aa:55:00:00
310         sys_priority: 65534
311         aggregation key: 2
312         lacp_time: fast
313
314 slave: p0: expired attached
315         port_id: 1
316         port_priority: 65535
317         may_enable: false
318
319         actor sys_id: aa:55:aa:55:00:00
320         actor sys_priority: 65534
321         actor port_id: 1
322         actor port_priority: 65535
323         actor key: 2
324         actor state: activity timeout aggregation synchronized collecting distributing expired
325
326         partner sys_id: aa:66:aa:66:00:00
327         partner sys_priority: 65534
328         partner port_id: 3
329         partner port_priority: 65535
330         partner key: 4
331         partner state: activity timeout aggregation collecting distributing
332
333 slave: p1: current attached
334         port_id: 2
335         port_priority: 65535
336         may_enable: true
337
338         actor sys_id: aa:55:aa:55:00:00
339         actor sys_priority: 65534
340         actor port_id: 2
341         actor port_priority: 65535
342         actor key: 2
343         actor state: activity timeout aggregation synchronized collecting distributing
344
345         partner sys_id: aa:66:aa:66:00:00
346         partner sys_priority: 65534
347         partner port_id: 4
348         partner port_priority: 65535
349         partner key: 4
350         partner state: activity timeout aggregation synchronized collecting distributing
351 ---- bond1 ----
352         status: active negotiated
353         sys_id: aa:66:aa:66:00:00
354         sys_priority: 65534
355         aggregation key: 4
356         lacp_time: fast
357
358 slave: p2: expired attached
359         port_id: 3
360         port_priority: 65535
361         may_enable: false
362
363         actor sys_id: aa:66:aa:66:00:00
364         actor sys_priority: 65534
365         actor port_id: 3
366         actor port_priority: 65535
367         actor key: 4
368         actor state: activity timeout aggregation synchronized collecting distributing expired
369
370         partner sys_id: aa:55:aa:55:00:00
371         partner sys_priority: 65534
372         partner port_id: 1
373         partner port_priority: 65535
374         partner key: 2
375         partner state: activity timeout aggregation collecting distributing
376
377 slave: p3: current attached
378         port_id: 4
379         port_priority: 65535
380         may_enable: true
381
382         actor sys_id: aa:66:aa:66:00:00
383         actor sys_priority: 65534
384         actor port_id: 4
385         actor port_priority: 65535
386         actor key: 4
387         actor state: activity timeout aggregation synchronized collecting distributing
388
389         partner sys_id: aa:55:aa:55:00:00
390         partner sys_priority: 65534
391         partner port_id: 2
392         partner port_priority: 65535
393         partner key: 2
394         partner state: activity timeout aggregation synchronized collecting distributing
395 ---- bond0 ----
396 bond_mode: balance-tcp
397 bond-hash-basis: 0
398 updelay: 0 ms
399 downdelay: 0 ms
400 lacp_status: negotiated
401
402 slave p0: disabled
403         may_enable: false
404
405 slave p1: enabled
406         active slave
407         may_enable: true
408
409 ---- bond1 ----
410 bond_mode: balance-tcp
411 bond-hash-basis: 0
412 updelay: 0 ms
413 downdelay: 0 ms
414 lacp_status: negotiated
415
416 slave p2: disabled
417         may_enable: false
418
419 slave p3: enabled
420         active slave
421         may_enable: true
422
423 ])
424
425 # Wait 4 more simulated seconds.  The LACP state should become
426 # "defaulted" for p0 and p2.
427 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
428 AT_CHECK(
429   [ovs-appctl lacp/show bond0
430 ovs-appctl lacp/show bond1
431 ovs-appctl bond/show bond0
432 ovs-appctl bond/show bond1], [0], [dnl
433 ---- bond0 ----
434         status: active negotiated
435         sys_id: aa:55:aa:55:00:00
436         sys_priority: 65534
437         aggregation key: 2
438         lacp_time: fast
439
440 slave: p0: defaulted detached
441         port_id: 1
442         port_priority: 65535
443         may_enable: false
444
445         actor sys_id: aa:55:aa:55:00:00
446         actor sys_priority: 65534
447         actor port_id: 1
448         actor port_priority: 65535
449         actor key: 2
450         actor state: activity timeout aggregation defaulted
451
452         partner sys_id: 00:00:00:00:00:00
453         partner sys_priority: 0
454         partner port_id: 0
455         partner port_priority: 0
456         partner key: 0
457         partner state:
458
459 slave: p1: current attached
460         port_id: 2
461         port_priority: 65535
462         may_enable: true
463
464         actor sys_id: aa:55:aa:55:00:00
465         actor sys_priority: 65534
466         actor port_id: 2
467         actor port_priority: 65535
468         actor key: 2
469         actor state: activity timeout aggregation synchronized collecting distributing
470
471         partner sys_id: aa:66:aa:66:00:00
472         partner sys_priority: 65534
473         partner port_id: 4
474         partner port_priority: 65535
475         partner key: 4
476         partner state: activity timeout aggregation synchronized collecting distributing
477 ---- bond1 ----
478         status: active negotiated
479         sys_id: aa:66:aa:66:00:00
480         sys_priority: 65534
481         aggregation key: 4
482         lacp_time: fast
483
484 slave: p2: defaulted detached
485         port_id: 3
486         port_priority: 65535
487         may_enable: false
488
489         actor sys_id: aa:66:aa:66:00:00
490         actor sys_priority: 65534
491         actor port_id: 3
492         actor port_priority: 65535
493         actor key: 4
494         actor state: activity timeout aggregation defaulted
495
496         partner sys_id: 00:00:00:00:00:00
497         partner sys_priority: 0
498         partner port_id: 0
499         partner port_priority: 0
500         partner key: 0
501         partner state:
502
503 slave: p3: current attached
504         port_id: 4
505         port_priority: 65535
506         may_enable: true
507
508         actor sys_id: aa:66:aa:66:00:00
509         actor sys_priority: 65534
510         actor port_id: 4
511         actor port_priority: 65535
512         actor key: 4
513         actor state: activity timeout aggregation synchronized collecting distributing
514
515         partner sys_id: aa:55:aa:55:00:00
516         partner sys_priority: 65534
517         partner port_id: 2
518         partner port_priority: 65535
519         partner key: 2
520         partner state: activity timeout aggregation synchronized collecting distributing
521 ---- bond0 ----
522 bond_mode: balance-tcp
523 bond-hash-basis: 0
524 updelay: 0 ms
525 downdelay: 0 ms
526 lacp_status: negotiated
527
528 slave p0: disabled
529         may_enable: false
530
531 slave p1: enabled
532         active slave
533         may_enable: true
534
535 ---- bond1 ----
536 bond_mode: balance-tcp
537 bond-hash-basis: 0
538 updelay: 0 ms
539 downdelay: 0 ms
540 lacp_status: negotiated
541
542 slave p2: disabled
543         may_enable: false
544
545 slave p3: enabled
546         active slave
547         may_enable: true
548
549 ])
550 OVS_VSWITCHD_STOP
551 AT_CLEANUP