3 m4_define([CFM_CHECK_EXTENDED], [
4 AT_CHECK([ovs-appctl cfm/show $1 | sed -e '/next CCM tx:/d' | sed -e '/next fault check:/d' | sed -e '/recv since check:/d'],[0],
17 m4_define([CFM_CHECK_EXTENDED_FAULT], [
18 AT_CHECK([ovs-appctl cfm/show $1 | sed -e '/next CCM tx:/d' | sed -e '/next fault check:/d' | sed -e '/recv since check:/d'],[0],
30 m4_define([CFM_VSCTL_LIST_IFACE], [
31 AT_CHECK([ovs-vsctl list interface $1 | sed -n '/$2 /p'],[0],
37 m4_define([CFM_CHECK_DB], [
38 CFM_VSCTL_LIST_IFACE([$1], [cfm_fault], [cfm_fault : $2])
39 CFM_VSCTL_LIST_IFACE([$1], [cfm_fault_status], [cfm_fault_status : [[$3]]])
40 CFM_VSCTL_LIST_IFACE([$1], [cfm_flap_count], [cfm_flap_count : $4])
41 CFM_VSCTL_LIST_IFACE([$1], [cfm_health], [cfm_health : [[$5]]])
42 CFM_VSCTL_LIST_IFACE([$1], [cfm_remote_mpids], [cfm_remote_mpids : [[$6]]])
43 CFM_VSCTL_LIST_IFACE([$1], [cfm_remote_opstate], [cfm_remote_opstate : $7])
46 # These two tests check the update of cfm status at different scenarios.
48 # Test cfm status update at startup and removal.
49 AT_SETUP([cfm - check update ovsdb 1])
50 OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=gre \
51 options:remote_ip=1.2.3.4 -- \
52 set Interface p0 other_config:cfm_interval=300 other_config:cfm_extended=true])
55 AT_CHECK([ovs-appctl ofproto/list-tunnels], [0], [dnl
56 port 1: p0 (gre: ::->1.2.3.4, key=0, legacy_l2, dp port=1, ttl=64)
59 AT_CHECK([ovs-vsctl set Interface p0 cfm_mpid=1])
60 # at beginning, since the first fault check timeout is not reached
61 # cfm_fault should be false.
62 for i in `seq 0 4`; do
63 ovs-appctl time/warp 100
64 CFM_CHECK_DB([p0], [false], [], [0], [], [], [up])
67 # advance clock to pass the fault check timeout and check cfm
68 # status update in OVSDB.
69 ovs-appctl time/warp 1500 100
70 CFM_CHECK_DB([p0], [true], [recv], [1], [], [], [up])
72 # remove the cfm on p0 and status should be all empty.
73 AT_CHECK([ovs-vsctl remove int p0 cfm_mpid 1])
74 ovs-appctl time/warp 500 100
75 CFM_CHECK_DB([p0], [[[]]], [], [[[]]], [], [], [[[]]])
80 # Test cfm status update in normal case.
81 AT_SETUP([cfm - check update ovsdb 2])
82 #Create 2 bridges connected by patch ports and enable cfm
83 OVS_VSWITCHD_START([add-br br1 -- \
84 set bridge br1 datapath-type=dummy \
85 other-config:hwaddr=aa:55:aa:56:00:00 -- \
86 add-port br1 p1 -- set Interface p1 type=patch \
88 add-port br0 p0 -- set Interface p0 type=patch \
90 set Interface p0 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
91 set Interface p1 other_config:cfm_interval=300 other_config:cfm_extended=true])
95 AT_CHECK([ovs-vsctl set Interface p0 cfm_mpid=1])
96 # check cfm status update in OVSDB.
97 ovs-appctl time/warp 1500 100
98 CFM_CHECK_DB([p0], [true], [recv], [1], [], [], [up])
100 # turn cfm on p1 on, cfm status of p0 and p1 should all go up.
101 AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
102 ovs-appctl time/warp 1500 100
103 CFM_CHECK_DB([p0], [false], [], [2], [], [2], [up])
104 CFM_CHECK_DB([p1], [false], [], [0], [], [1], [up])
106 # turn cfm on p1 off, cfm status of p0 should go down again.
107 AT_CHECK([ovs-vsctl remove int p1 cfm_mpid 2])
108 ovs-appctl time/warp 1500 100
109 CFM_CHECK_DB([p0], [true], [recv], [3], [], [], [up])
114 # test cfm under demand mode.
115 AT_SETUP([cfm - demand mode])
116 #Create 2 bridges connected by patch ports and enable cfm
117 OVS_VSWITCHD_START([add-br br1 -- \
118 set bridge br1 datapath-type=dummy \
119 other-config:hwaddr=aa:55:aa:56:00:00 -- \
120 add-port br1 p1 -- set Interface p1 type=patch \
122 add-port br0 p0 -- set Interface p0 type=patch \
124 set Interface p0 cfm_mpid=1 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
125 set Interface p1 cfm_mpid=2 other_config:cfm_interval=300 other_config:cfm_extended=true ])
128 # wait for a while to stablize cfm.
129 ovs-appctl time/warp 10100 100
130 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
131 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
133 # turn on demand mode on one end.
134 AT_CHECK([ovs-vsctl set interface p0 other_config:cfm_demand=true])
136 # cfm should never go down.
139 ovs-appctl time/warp 100
140 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
141 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
144 # turn on demand mode on the other end.
145 AT_CHECK([ovs-vsctl set interface p1 other_config:cfm_demand=true])
148 ovs-appctl time/warp 100
149 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
150 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
156 # test demand_rx_ccm under demand mode.
157 AT_SETUP([cfm - demand_rx_ccm])
158 #Create 2 bridges connected by patch ports and enable cfm
159 OVS_VSWITCHD_START([add-br br1 -- \
160 set bridge br1 datapath-type=dummy \
161 other-config:hwaddr=aa:55:aa:56:00:00 -- \
162 add-port br1 p1 -- set Interface p1 type=patch \
163 options:peer=p0 ofport_request=2 -- \
164 add-port br0 p0 -- set Interface p0 type=patch \
165 options:peer=p1 ofport_request=1 -- \
166 set Interface p0 cfm_mpid=1 other_config:cfm_interval=300 other_config:cfm_extended=true other_config:cfm_demand=true -- \
167 set Interface p1 cfm_mpid=2 other_config:cfm_interval=300 other_config:cfm_extended=true other_config:cfm_demand=true])
170 # wait for a while to stablize cfm. (need a longer time, since in demand mode
171 # the fault interval is (MAX(ccm_interval_ms, 500) * 3.5) ms)
172 ovs-appctl time/warp 20100 100
173 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
174 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
176 # turn off the cfm on p1.
177 AT_CHECK([ovs-vsctl clear Interface p1 cfm_mpid])
178 # cfm should never go down while receiving data packets.
181 ovs-appctl time/warp 100
182 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
185 CFM_CHECK_EXTENDED([p0], [1], [0], [up], [up], [300ms], [2], [up])
187 # wait longer, since the demand_rx_ccm interval is 100 * 300 ms.
188 # since there is no ccm received, the [recv] fault should be raised.
191 ovs-appctl time/warp 100
192 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
195 CFM_CHECK_EXTENDED_FAULT([p0], [1], [recv], [0], [up], [up], [300ms])
197 # now turn on the cfm on p1 again,
198 AT_CHECK([ovs-vsctl set Interface p1 cfm_mpid=2])
199 # cfm should be up for both p0 and p1
200 ovs-appctl time/warp 20100 100
201 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
202 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
204 # now turn off the cfm on p1 again
205 AT_CHECK([ovs-vsctl clear Interface p1 cfm_mpid])
206 # since there is no ccm received, the [recv] fault should be raised.
209 ovs-appctl time/warp 100
210 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
213 CFM_CHECK_EXTENDED_FAULT([p0], [1], [recv], [0], [up], [up], [300ms])
218 # test cfm_flap_count.
219 AT_SETUP([cfm - flap_count])
220 #Create 2 bridges connected by patch ports and enable cfm
221 OVS_VSWITCHD_START([add-br br1 -- \
222 set bridge br1 datapath-type=dummy \
223 other-config:hwaddr=aa:55:aa:56:00:00 -- \
224 add-port br1 p1 -- set Interface p1 type=patch \
226 add-port br0 p0 -- set Interface p0 type=patch \
228 set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
229 set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
233 # wait for a while to stablize cfm.
234 ovs-appctl time/warp 10100 100
235 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
236 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
238 # turn cfm on p1 off, should increment the cfm_flap_count on p0.
239 AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
240 ovs-appctl time/warp 1100 100
241 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
242 CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
244 # turn cfm on p1 on again, should increment the cfm_flap_count on p0.
245 AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
246 ovs-appctl time/warp 1100 100
247 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])
252 AT_SETUP([cfm - fault_override])
253 OVS_VSWITCHD_START([add-br br1 -- \
254 set bridge br1 datapath-type=dummy \
255 other-config:hwaddr=aa:55:aa:56:00:00 -- \
256 add-port br1 p1 -- set Interface p1 type=patch \
258 add-port br0 p0 -- set Interface p0 type=patch \
260 set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
261 set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
264 # wait for a while to stablize cfm.
265 ovs-appctl time/warp 10100 100
266 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
267 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
268 AT_CHECK([ovs-appctl cfm/show p1 | grep 'fault_override'], [1], [ignore])
269 CFM_VSCTL_LIST_IFACE([p1], [cfm_fault_status], [cfm_fault_status : [[]]])
271 # set a fault and see that this is shown in the CFM module and the database
272 AT_CHECK([ovs-appctl cfm/set-fault p1 true], [0], [OK
274 AT_CHECK([ovs-appctl time/warp 100], [0], [ignore])
275 AT_CHECK([ovs-appctl cfm/show p1 | grep 'fault_override' | sed -e 's/MPID [[0-9]]*: extended //'], [0], [dnl
278 CFM_VSCTL_LIST_IFACE([p1], [cfm_fault_status], [cfm_fault_status : [[override]]])
280 # reset and see that it returned to normal
281 AT_CHECK([ovs-appctl cfm/set-fault normal], [0], [OK
283 AT_CHECK([ovs-appctl time/warp 100], [0], [ignore])
284 AT_CHECK([ovs-appctl cfm/show p1 | grep 'fault_override'], [1], [ignore])
285 CFM_VSCTL_LIST_IFACE([p1], [cfm_fault_status], [cfm_fault_status : [[]]])
290 AT_SETUP([cfm - check that CFM works together with RSTP])
291 # Create br0 with interfaces p1
292 # and br1 with interfaces p2
293 # with p1 and p2 connected via unix domain socket
295 [set bridge br0 rstp_enable=true -- \
297 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
298 set bridge br1 datapath-type=dummy -- \
299 set bridge br1 rstp_enable=true -- \
302 AT_CHECK([ovs-vsctl add-port br0 p0 -- \
303 set interface p0 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock cfm_mpid=1 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
306 AT_CHECK([ovs-vsctl add-port br1 p1 -- \
307 set interface p1 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock cfm_mpid=2 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
311 ovs-appctl time/warp 10100 100
313 # Forwarding should be true
314 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
315 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
317 # Disable cfm on p1, cfm should receive fault.
318 AT_CHECK([ovs-vsctl set interface p1 other_config:cfm_extended=false])
320 ovs-appctl time/warp 5000 100
321 CFM_CHECK_EXTENDED_FAULT([p0], [1], [recv], [0], [up], [up], [300ms])
326 # test cfm liveness propagation - OF1.3.
327 AT_SETUP([cfm - liveness propagation - OF1.3])
329 AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
331 printf '\n\n--- check_liveness %d ---\n\n\n' $1
334 echo >>expout "OFPT_PORT_STATUS (OF1.3): MOD: 1(p0): addr:
337 speed: 0 Mbps now, 0 Mbps max"
341 s/ (xid=0x[0-9a-fA-F]*)//
343 s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
347 ovs-appctl -t ovs-ofctl ofctl/barrier
348 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
349 # Set miss_send_len to 128, enabling port_status messages to our service connection.
350 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
352 #Create 2 bridges connected by patch ports and enable cfm
353 AT_CHECK([ovs-vsctl add-br br1 -- \
354 set bridge br1 datapath-type=dummy \
355 other-config:hwaddr=aa:55:aa:56:00:00 -- \
356 add-port br1 p1 -- set Interface p1 type=patch \
358 add-port br0 p0 -- set Interface p0 type=patch \
360 check_liveness 1 LIVE
362 AT_CHECK([ovs-vsctl \
363 set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
364 set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
366 # wait for a while to stablize cfm.
367 ovs-appctl time/warp 10100 100
368 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
369 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
371 # turn cfm on p1 off, should increment the cfm_flap_count on p0.
372 AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
373 ovs-appctl time/warp 1100 100
374 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
375 CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
378 # turn cfm on p1 on again, should increment the cfm_flap_count on p0.
379 AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
380 ovs-appctl time/warp 1100 100
381 check_liveness 3 LIVE
383 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])
388 # test cfm liveness propagation - OF1.4.
389 AT_SETUP([cfm - liveness propagation - OF1.4])
391 AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile])
393 printf '\n\n--- check_liveness %d ---\n\n\n' $1
396 echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: 1(p0): addr:
399 speed: 0 Mbps now, 0 Mbps max"
403 s/ (xid=0x[0-9a-fA-F]*)//
405 s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
409 ovs-appctl -t ovs-ofctl ofctl/barrier
410 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
411 # Set miss_send_len to 128, enabling port_status messages to our service connection.
412 ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
414 #Create 2 bridges connected by patch ports and enable cfm
415 AT_CHECK([ovs-vsctl add-br br1 -- \
416 set bridge br1 datapath-type=dummy \
417 other-config:hwaddr=aa:55:aa:56:00:00 -- \
418 add-port br1 p1 -- set Interface p1 type=patch \
420 add-port br0 p0 -- set Interface p0 type=patch \
422 check_liveness 1 LIVE
424 AT_CHECK([ovs-vsctl \
425 set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
426 set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
428 # wait for a while to stablize cfm.
429 ovs-appctl time/warp 10100 100
430 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
431 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
433 # turn cfm on p1 off, should increment the cfm_flap_count on p0.
434 AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
435 ovs-appctl time/warp 1100 100
436 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
437 CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
440 # turn cfm on p1 on again, should increment the cfm_flap_count on p0.
441 AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
442 ovs-appctl time/warp 1100 100
443 check_liveness 3 LIVE
445 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])
450 # test cfm liveness propagation - OF1.5.
451 AT_SETUP([cfm - liveness propagation - OF1.5])
453 AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
455 printf '\n\n--- check_liveness %d ---\n\n\n' $1
458 echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: 1(p0): addr:
461 speed: 0 Mbps now, 0 Mbps max"
465 s/ (xid=0x[0-9a-fA-F]*)//
467 s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
471 ovs-appctl -t ovs-ofctl ofctl/barrier
472 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
473 # Set miss_send_len to 128, enabling port_status messages to our service connection.
474 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
476 #Create 2 bridges connected by patch ports and enable cfm
477 AT_CHECK([ovs-vsctl add-br br1 -- \
478 set bridge br1 datapath-type=dummy \
479 other-config:hwaddr=aa:55:aa:56:00:00 -- \
480 add-port br1 p1 -- set Interface p1 type=patch \
482 add-port br0 p0 -- set Interface p0 type=patch \
484 check_liveness 1 LIVE
486 AT_CHECK([ovs-vsctl \
487 set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
488 set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
490 # wait for a while to stablize cfm.
491 ovs-appctl time/warp 10100 100
492 CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
493 CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
495 # turn cfm on p1 off, should increment the cfm_flap_count on p0.
496 AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
497 ovs-appctl time/warp 1100 100
498 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
499 CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
502 # turn cfm on p1 on again, should increment the cfm_flap_count on p0.
503 AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
504 ovs-appctl time/warp 1100 100
505 check_liveness 3 LIVE
507 CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])