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