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