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