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