lacp.at: Change timing of lacp - 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 # Wait for up to 5 (simulated) seconds, until LACP negotiation finishes.
145 i=0
146 while :; do
147     ovs-appctl lacp/show bond0 > bond0
148     AT_CAPTURE_FILE([bond0])
149     ovs-appctl lacp/show bond1 > bond1
150     AT_CAPTURE_FILE([bond1])
151     if grep negotiated bond0 && grep negotiated bond1; then
152         if grep expired bond0 || grep expired bond1; then
153             :
154         else
155             break
156         fi
157     fi
158     i=`expr $i + 1`
159     if test $i = 50; then
160         AT_FAIL_IF([:])
161     fi
162     ovs-appctl time/warp 100
163 done
164
165 # Now check the correctly negotiated configuration.
166 AT_CHECK(
167   [ovs-appctl lacp/show bond0
168 ovs-appctl lacp/show bond1
169 ovs-appctl bond/show bond0
170 ovs-appctl bond/show bond1], [0], [stdout])
171 AT_CHECK([sed '/active slave/d' stdout], [0], [dnl
172 ---- bond0 ----
173         status: active negotiated
174         sys_id: aa:55:aa:55:00:00
175         sys_priority: 65534
176         aggregation key: 2
177         lacp_time: fast
178
179 slave: p0: current attached
180         port_id: 1
181         port_priority: 65535
182         may_enable: true
183
184         actor sys_id: aa:55:aa:55:00:00
185         actor sys_priority: 65534
186         actor port_id: 1
187         actor port_priority: 65535
188         actor key: 2
189         actor state: activity timeout aggregation synchronized collecting distributing
190
191         partner sys_id: aa:66:aa:66:00:00
192         partner sys_priority: 65534
193         partner port_id: 3
194         partner port_priority: 65535
195         partner key: 4
196         partner state: activity timeout aggregation synchronized collecting distributing
197
198 slave: p1: current attached
199         port_id: 2
200         port_priority: 65535
201         may_enable: true
202
203         actor sys_id: aa:55:aa:55:00:00
204         actor sys_priority: 65534
205         actor port_id: 2
206         actor port_priority: 65535
207         actor key: 2
208         actor state: activity timeout aggregation synchronized collecting distributing
209
210         partner sys_id: aa:66:aa:66:00:00
211         partner sys_priority: 65534
212         partner port_id: 4
213         partner port_priority: 65535
214         partner key: 4
215         partner state: activity timeout aggregation synchronized collecting distributing
216 ---- bond1 ----
217         status: active negotiated
218         sys_id: aa:66:aa:66:00:00
219         sys_priority: 65534
220         aggregation key: 4
221         lacp_time: fast
222
223 slave: p2: current attached
224         port_id: 3
225         port_priority: 65535
226         may_enable: true
227
228         actor sys_id: aa:66:aa:66:00:00
229         actor sys_priority: 65534
230         actor port_id: 3
231         actor port_priority: 65535
232         actor key: 4
233         actor state: activity timeout aggregation synchronized collecting distributing
234
235         partner sys_id: aa:55:aa:55:00:00
236         partner sys_priority: 65534
237         partner port_id: 1
238         partner port_priority: 65535
239         partner key: 2
240         partner state: activity timeout aggregation synchronized collecting distributing
241
242 slave: p3: current attached
243         port_id: 4
244         port_priority: 65535
245         may_enable: true
246
247         actor sys_id: aa:66:aa:66:00:00
248         actor sys_priority: 65534
249         actor port_id: 4
250         actor port_priority: 65535
251         actor key: 4
252         actor state: activity timeout aggregation synchronized collecting distributing
253
254         partner sys_id: aa:55:aa:55:00:00
255         partner sys_priority: 65534
256         partner port_id: 2
257         partner port_priority: 65535
258         partner key: 2
259         partner state: activity timeout aggregation synchronized collecting distributing
260 ---- bond0 ----
261 bond_mode: balance-tcp
262 bond-hash-basis: 0
263 updelay: 0 ms
264 downdelay: 0 ms
265 lacp_status: negotiated
266
267 slave p0: enabled
268         may_enable: true
269
270 slave p1: enabled
271         may_enable: true
272
273 ---- bond1 ----
274 bond_mode: balance-tcp
275 bond-hash-basis: 0
276 updelay: 0 ms
277 downdelay: 0 ms
278 lacp_status: negotiated
279
280 slave p2: enabled
281         may_enable: true
282
283 slave p3: enabled
284         may_enable: true
285
286 ])
287 AT_CHECK([grep 'active slave' stdout], [0], [dnl
288         active slave
289         active slave
290 ])
291
292 # Redirect the patch link between p0 and p2 so that no packets get
293 # back and forth across them anymore.  Then wait 2.5 simulated
294 # seconds.  The LACP state should become "expired" for p0 and p2.
295 AT_CHECK([ovs-vsctl \
296 -- add-port br0 null0 -- set int null0 type=patch options:peer=p2 -- set int p2 options:peer=null0 \
297 -- add-port br1 null1 -- set int null1 type=patch options:peer=p0 -- set int p0 options:peer=null1])
298
299 for i in `seq 0 25`; do ovs-appctl time/warp 100; done
300 AT_CHECK(
301   [ovs-appctl lacp/show bond0
302 ovs-appctl lacp/show bond1
303 ovs-appctl bond/show bond0
304 ovs-appctl bond/show bond1], [0], [dnl
305 ---- bond0 ----
306         status: active negotiated
307         sys_id: aa:55:aa:55:00:00
308         sys_priority: 65534
309         aggregation key: 2
310         lacp_time: fast
311
312 slave: p0: expired attached
313         port_id: 1
314         port_priority: 65535
315         may_enable: false
316
317         actor sys_id: aa:55:aa:55:00:00
318         actor sys_priority: 65534
319         actor port_id: 1
320         actor port_priority: 65535
321         actor key: 2
322         actor state: activity timeout aggregation synchronized collecting distributing expired
323
324         partner sys_id: aa:66:aa:66:00:00
325         partner sys_priority: 65534
326         partner port_id: 3
327         partner port_priority: 65535
328         partner key: 4
329         partner state: activity timeout aggregation collecting distributing
330
331 slave: p1: current attached
332         port_id: 2
333         port_priority: 65535
334         may_enable: true
335
336         actor sys_id: aa:55:aa:55:00:00
337         actor sys_priority: 65534
338         actor port_id: 2
339         actor port_priority: 65535
340         actor key: 2
341         actor state: activity timeout aggregation synchronized collecting distributing
342
343         partner sys_id: aa:66:aa:66:00:00
344         partner sys_priority: 65534
345         partner port_id: 4
346         partner port_priority: 65535
347         partner key: 4
348         partner state: activity timeout aggregation synchronized collecting distributing
349 ---- bond1 ----
350         status: active negotiated
351         sys_id: aa:66:aa:66:00:00
352         sys_priority: 65534
353         aggregation key: 4
354         lacp_time: fast
355
356 slave: p2: expired attached
357         port_id: 3
358         port_priority: 65535
359         may_enable: false
360
361         actor sys_id: aa:66:aa:66:00:00
362         actor sys_priority: 65534
363         actor port_id: 3
364         actor port_priority: 65535
365         actor key: 4
366         actor state: activity timeout aggregation synchronized collecting distributing expired
367
368         partner sys_id: aa:55:aa:55:00:00
369         partner sys_priority: 65534
370         partner port_id: 1
371         partner port_priority: 65535
372         partner key: 2
373         partner state: activity timeout aggregation collecting distributing
374
375 slave: p3: current attached
376         port_id: 4
377         port_priority: 65535
378         may_enable: true
379
380         actor sys_id: aa:66:aa:66:00:00
381         actor sys_priority: 65534
382         actor port_id: 4
383         actor port_priority: 65535
384         actor key: 4
385         actor state: activity timeout aggregation synchronized collecting distributing
386
387         partner sys_id: aa:55:aa:55:00:00
388         partner sys_priority: 65534
389         partner port_id: 2
390         partner port_priority: 65535
391         partner key: 2
392         partner state: activity timeout aggregation synchronized collecting distributing
393 ---- bond0 ----
394 bond_mode: balance-tcp
395 bond-hash-basis: 0
396 updelay: 0 ms
397 downdelay: 0 ms
398 lacp_status: negotiated
399
400 slave p0: disabled
401         may_enable: false
402
403 slave p1: enabled
404         active slave
405         may_enable: true
406
407 ---- bond1 ----
408 bond_mode: balance-tcp
409 bond-hash-basis: 0
410 updelay: 0 ms
411 downdelay: 0 ms
412 lacp_status: negotiated
413
414 slave p2: disabled
415         may_enable: false
416
417 slave p3: enabled
418         active slave
419         may_enable: true
420
421 ])
422
423 # Wait 4 more simulated seconds.  The LACP state should become
424 # "defaulted" for p0 and p2.
425 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
426 AT_CHECK(
427   [ovs-appctl lacp/show bond0
428 ovs-appctl lacp/show bond1
429 ovs-appctl bond/show bond0
430 ovs-appctl bond/show bond1], [0], [dnl
431 ---- bond0 ----
432         status: active negotiated
433         sys_id: aa:55:aa:55:00:00
434         sys_priority: 65534
435         aggregation key: 2
436         lacp_time: fast
437
438 slave: p0: defaulted detached
439         port_id: 1
440         port_priority: 65535
441         may_enable: false
442
443         actor sys_id: aa:55:aa:55:00:00
444         actor sys_priority: 65534
445         actor port_id: 1
446         actor port_priority: 65535
447         actor key: 2
448         actor state: activity timeout aggregation defaulted
449
450         partner sys_id: 00:00:00:00:00:00
451         partner sys_priority: 0
452         partner port_id: 0
453         partner port_priority: 0
454         partner key: 0
455         partner state:
456
457 slave: p1: current attached
458         port_id: 2
459         port_priority: 65535
460         may_enable: true
461
462         actor sys_id: aa:55:aa:55:00:00
463         actor sys_priority: 65534
464         actor port_id: 2
465         actor port_priority: 65535
466         actor key: 2
467         actor state: activity timeout aggregation synchronized collecting distributing
468
469         partner sys_id: aa:66:aa:66:00:00
470         partner sys_priority: 65534
471         partner port_id: 4
472         partner port_priority: 65535
473         partner key: 4
474         partner state: activity timeout aggregation synchronized collecting distributing
475 ---- bond1 ----
476         status: active negotiated
477         sys_id: aa:66:aa:66:00:00
478         sys_priority: 65534
479         aggregation key: 4
480         lacp_time: fast
481
482 slave: p2: defaulted detached
483         port_id: 3
484         port_priority: 65535
485         may_enable: false
486
487         actor sys_id: aa:66:aa:66:00:00
488         actor sys_priority: 65534
489         actor port_id: 3
490         actor port_priority: 65535
491         actor key: 4
492         actor state: activity timeout aggregation defaulted
493
494         partner sys_id: 00:00:00:00:00:00
495         partner sys_priority: 0
496         partner port_id: 0
497         partner port_priority: 0
498         partner key: 0
499         partner state:
500
501 slave: p3: current attached
502         port_id: 4
503         port_priority: 65535
504         may_enable: true
505
506         actor sys_id: aa:66:aa:66:00:00
507         actor sys_priority: 65534
508         actor port_id: 4
509         actor port_priority: 65535
510         actor key: 4
511         actor state: activity timeout aggregation synchronized collecting distributing
512
513         partner sys_id: aa:55:aa:55:00:00
514         partner sys_priority: 65534
515         partner port_id: 2
516         partner port_priority: 65535
517         partner key: 2
518         partner state: activity timeout aggregation synchronized collecting distributing
519 ---- bond0 ----
520 bond_mode: balance-tcp
521 bond-hash-basis: 0
522 updelay: 0 ms
523 downdelay: 0 ms
524 lacp_status: negotiated
525
526 slave p0: disabled
527         may_enable: false
528
529 slave p1: enabled
530         active slave
531         may_enable: true
532
533 ---- bond1 ----
534 bond_mode: balance-tcp
535 bond-hash-basis: 0
536 updelay: 0 ms
537 downdelay: 0 ms
538 lacp_status: negotiated
539
540 slave p2: disabled
541         may_enable: false
542
543 slave p3: enabled
544         active slave
545         may_enable: true
546
547 ])
548 OVS_VSWITCHD_STOP
549 AT_CLEANUP