3 m4_define([BFD_CHECK], [
4 AT_CHECK([ovs-appctl bfd/show $1 | sed -e '/Time:/d' | sed -e '/Discriminator/d' | sed -e '/Interval:/d'],[0],
8 Concatenated Path Down: $3
11 Local Session State: $5
15 Remote Session State: $8
20 m4_define([BFD_CHECK_TX], [
21 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
23 TX Interval: Approx $2
24 Local Minimum TX Interval: $3
25 Remote Minimum TX Interval: $4
29 m4_define([BFD_CHECK_RX], [
30 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
32 RX Interval: Approx $2
33 Local Minimum RX Interval: $3
34 Remote Minimum RX Interval: $4
38 m4_define([BFD_VSCTL_LIST_IFACE], [
39 AT_CHECK([ovs-vsctl list interface $1 | sed -n $2],[0],
45 AT_SETUP([bfd - basic config on different bridges])
46 #Create 2 bridges connected by patch ports and enable BFD
49 set bridge br1 datapath-type=dummy \
50 other-config:hwaddr=aa:55:aa:56:00:00 -- \
51 add-port br1 p1 -- set Interface p1 type=patch \
53 add-port br0 p0 -- set Interface p0 type=patch \
55 set Interface p0 bfd:enable=true -- \
56 set Interface p1 bfd:enable=true ])
58 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
60 #Verify that BFD has been enabled on both interfaces.
61 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
62 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
64 AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=false])
65 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
66 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
68 AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=true])
69 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
70 BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
71 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
74 AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
75 ovs-appctl: ovs-vswitchd: server returned an error
78 #Check that the entries are gone.
79 AT_CHECK([ovs-appctl bfd/show p1], [2],[ignore], [no such bfd object
80 ovs-appctl: ovs-vswitchd: server returned an error
87 AT_SETUP([bfd - Verify tunnel down detection])
88 #Create 3 bridges - br-bfd0, br-bfd1 and br-sw which is midway between the two. br2 is
89 #connected to br-bfd0 and br-bfd1 through patch ports p0-2 and p1-2. Enable BFD on
90 #interfaces in br-bfd0 and br-bfd1. When br-sw is dropping all packets, BFD should detect
91 # that the tunnel is down, and come back up when br-sw is working fine.
95 set bridge br-bfd0 datapath-type=dummy \
96 other-config:hwaddr=aa:55:aa:56:00:00 -- \
98 set bridge br-bfd1 datapath-type=dummy \
99 other-config:hwaddr=aa:55:aa:57:00:00 -- \
101 set bridge br-sw datapath-type=dummy \
102 other-config:hwaddr=aa:55:aa:58:00:00 -- \
103 add-port br-sw p1-sw -- set Interface p1-sw type=patch \
104 options:peer=p1 ofport_request=2 -- \
105 add-port br-sw p0-sw -- set Interface p0-sw type=patch \
106 options:peer=p0 ofport_request=1 -- \
107 add-port br-bfd1 p1 -- set Interface p1 type=patch \
108 options:peer=p1-sw bfd:enable=true -- \
109 add-port br-bfd0 p0 -- set Interface p0 type=patch \
110 options:peer=p0-sw bfd:enable=true --])
114 #Create 2 bridges connected by patch ports and enable BFD
116 AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
117 #Verify that BFD is enabled.
118 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
119 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
120 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
122 #Drop all packets in the br-sw bridge so that the tunnel is down.
123 AT_CHECK([ ovs-ofctl add-flow br-sw 'priority=5,actions=drop' ])
124 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
125 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
126 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
128 #Delete the added flow
129 AT_CHECK([ovs-ofctl del-flows br-sw], [0])
130 AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
131 #Verify that BFD is back up again.
132 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
134 BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
135 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
137 #Now, Verify one-side tunnel down detection
138 #When br-sw is dropping packets from one end, BFD should detect
139 # that the tunnel is down, and come back up when br-sw is working fine.
141 #Bring down the br-bfd1 - br-sw link. So BFD packets will be sent from p0,
142 # but not received by p1. p0 will receive all BFD packets from p1.
144 AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=1,priority=5,actions=drop'])
145 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
146 # Make sure p1 BFD state is down since it received no BFD packets.
147 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
148 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
149 # p0 will be in init state once it receives "down" BFD message from p1.
150 BFD_CHECK([p0], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
152 AT_CHECK([ovs-ofctl del-flows br-sw])
153 AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
154 #Ensure that BFD is back up again.
156 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
157 #Bring down the br-bfd0 - br-sw link
158 AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=2,priority=5,actions=drop'])
159 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
160 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
161 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
162 BFD_CHECK([p1], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
167 AT_SETUP([bfd - concatenated path down])
168 #Create 2 bridges connected by patch ports and enable BFD
171 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
172 set bridge br1 datapath-type=dummy \
173 other-config:hwaddr=aa:55:aa:56:00:00 ])
174 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
176 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
178 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
179 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
180 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
182 #Verify that BFD has been enabled on both interfaces.
183 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
184 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
186 #Set cpath_down to true on one interface, make sure the remote interface updates its values.
187 AT_CHECK([ovs-vsctl set interface p0 bfd:cpath_down=true])
188 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
189 BFD_CHECK([p1], [false], [false], [none], [up], [No Diagnostic], [none], [up], [Concatenated Path Down])
194 AT_SETUP([bfd - Edit the Min Tx/Rx values])
195 #Create 2 bridges connected by patch ports and enable BFD
198 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
199 set bridge br1 datapath-type=dummy ])
200 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
202 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
204 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
205 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
206 for i in `seq 0 30`; do ovs-appctl time/warp 100; done
207 #Verify that BFD has been enabled on both interfaces.
208 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
209 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
210 #Edit the min Tx value.
211 AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200])
212 for i in `seq 0 20`; do ovs-appctl time/warp 100; done
213 BFD_CHECK_TX([p0], [1000ms], [200ms], [100ms])
214 BFD_CHECK_TX([p1], [1000ms], [100ms], [200ms])
216 #Edit the min Rx value.
217 AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300])
218 for i in `seq 0 20`; do ovs-appctl time/warp 100; done
219 BFD_CHECK_RX([p1], [300ms], [300ms], [1000ms])
220 BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
225 AT_SETUP([bfd - check_tnl_key])
226 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
227 options:remote_ip=2.2.2.2 options:key=1 ofport_request=1 -- \
228 set interface p1 bfd:enable=true -- \
229 set bridge br0 fail-mode=standalone])
231 # by default check_tnl_key is false. so we should process a bfd packet with tun_id=1.
232 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,flags(key)),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:55,dst=00:23:20:00:00:01),eth_type(0x0800),ipv4(src=169.254.1.0/0.0.0.0,dst=169.254.1.1/0.0.0.0,proto=17/0xff,tos=0/0,ttl=255/0,frag=no/0xff),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
233 # check that the packet should be handled as BFD packet.
234 AT_CHECK([tail -2 stdout], [0], [dnl
235 This flow is handled by the userspace slow path because it:
236 - Consists of BFD packets.
239 # turn on the check_tnl_key.
240 AT_CHECK([ovs-vsctl set interface p1 bfd:check_tnl_key=true])
241 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,flags(key)),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:55,dst=00:23:20:00:00:01),eth_type(0x0800),ipv4(src=169.254.1.0/0.0.0.0,dst=169.254.1.1/0.0.0.0,proto=17/0xff,tos=0/0,ttl=255/0,frag=no/0xff),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
242 # check that the packet should be handled as normal packet.
243 AT_CHECK([tail -1 stdout], [0],[dnl
244 Datapath actions: 100
247 # set the tunnel key to 0.
248 AT_CHECK([ovs-vsctl set interface p1 options:key=0])
249 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,flags(key)),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:55,dst=00:23:20:00:00:01),eth_type(0x0800),ipv4(src=169.254.1.0/0.0.0.0,dst=169.254.1.1/0.0.0.0,proto=17/0xff,tos=0/0,ttl=255/0,frag=no/0xff),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
250 # check that the packet should be handled as BFD packet.
251 AT_CHECK([tail -2 stdout], [0], [dnl
252 This flow is handled by the userspace slow path because it:
253 - Consists of BFD packets.
259 # Tests below are for bfd decay features.
260 AT_SETUP([bfd - bfd decay])
261 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
262 add-port br1 p1 -- set Interface p1 type=patch \
263 options:peer=p0 ofport_request=2 -- \
264 add-port br0 p0 -- set Interface p0 type=patch \
265 options:peer=p1 ofport_request=1 -- \
266 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
267 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
271 # wait for a while to stablize everything.
272 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
273 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
274 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
275 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
276 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
278 # Test-1 BFD decay: decay to decay_min_rx
279 AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=3000])
280 # bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up,
281 # so for the first 2000ms, there should be no change.
282 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
283 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
284 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
286 # advance the clock by 5000ms.
287 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
288 # now, min_rx should decay to 3000ms.
289 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
290 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
292 # advance clock by 5000ms and check the the flags are all 'none'.
293 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
294 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
295 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
296 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
297 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
298 # End of Test-1 ###############################################################
301 # Test-2 BFD decay: go back to min_rx when there is traffic
302 # receive packet at 1/100ms rate for 5000ms.
305 ovs-appctl time/warp 100
306 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
309 # after a decay interval (3000ms), the p0 min_rx will go back to
311 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
312 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
313 # End of Test-2 ###############################################################
316 # Test-3 BFD decay: set decay_min_rx to 1000ms.
317 # this should firstly reset the min_rx and then re-decay to 1000ms.
318 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
319 # advance the clock by 10000ms, decay should have happened.
320 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
321 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
322 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
323 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
324 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
325 # End of Test-3 ###############################################################
328 # Test-4 BFD decay: set decay_min_rx to 0 to disable bfd decay.
329 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
330 # advance the clock by 5000ms.
331 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
333 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
334 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
338 ovs-appctl time/warp 500
339 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
340 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
341 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
342 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
344 # End of Test-4 ################################################################
347 # Test-5 BFD decay: rmt_min_tx is greater than decay_min_rx
348 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface p1 bfd:min_tx=5000])
349 # advance the clock by 10000ms to stable everything.
350 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
351 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
352 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
353 # p0 rx should show 5000ms even if it is in decay.
354 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
355 BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
356 # then, there should be no change of status,
359 ovs-appctl time/warp 500
360 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
361 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
362 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
363 BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
365 # reset the p1's min_tx to 500ms.
366 AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
367 # advance the clock by 20000ms to stable everything.
368 # since p0 has been in decay, now the RX will show 3000ms.
369 for i in `seq 0 39`; do ovs-appctl time/warp 500; done
370 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
371 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
372 # End of Test-5 ###############################################################
375 # Test-6 BFD decay: state up->down->up.
377 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false])
379 # advance the clock by 15000ms to stable everything.
380 for i in `seq 0 14`; do ovs-appctl time/warp 1000; done
381 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
382 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
383 BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
385 # resume the bfd on p1. the bfd should not go to decay mode direclty.
386 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
387 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
388 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
389 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
391 # since the decay_min_rx is still 3000ms, so after 5000ms, p0 should have decayed.
392 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
393 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
394 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
395 # End of Test-6 ################################################################
400 # Tests below are for bfd forwarding_if_rx feature.
402 # forwarding_if_rx Test1
403 # Test1 tests the case when bfd is only enabled on one end of the link.
404 # Under this situation, the forwarding flag should always be false, even
405 # though there is data packet received, since there is no bfd control
406 # packet received during the demand_rx_bfd interval.
407 AT_SETUP([bfd - bfd forwarding_if_rx - bfd on one side])
408 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
409 add-port br1 p1 -- set Interface p1 type=patch \
410 options:peer=p0 ofport_request=2 -- \
411 add-port br0 p0 -- set Interface p0 type=patch \
412 options:peer=p1 ofport_request=1 -- \
413 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
414 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
417 # check the inital status.
418 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
419 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
420 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
422 # enable forwarding_if_rx.
423 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
425 # there should be no change of forwarding flag, since
426 # there is no traffic.
429 ovs-appctl time/warp 500
430 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
433 # receive packet at 1/100ms rate for 2000ms.
436 ovs-appctl time/warp 100
437 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
440 # the forwarding flag should be false, due to the demand_rx_bfd.
441 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
443 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
447 # forwarding_if_rx Test2
448 # Test2 is for testing that the enable of forwarding_if_rx will not
449 # affect the normal bfd communication. bfd is enabled on both ends of
451 AT_SETUP([bfd - bfd forwarding_if_rx - bfd on both sides])
452 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
453 add-port br1 p1 -- set Interface p1 type=patch \
454 options:peer=p0 ofport_request=2 -- \
455 add-port br0 p0 -- set Interface p0 type=patch \
456 options:peer=p1 ofport_request=1 -- \
457 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
458 set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
459 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
462 # advance the clock, to stablize the states.
463 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
465 # enable forwarding_if_rx.
466 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
468 # there should be no change of the forwarding flag, since
469 # the bfd on both ends is already up.
472 ovs-appctl time/warp 500
473 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
476 # stop the bfd on one side.
477 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
478 # for within 1500ms, the detection timer is not out.
479 # there is no change to status.
482 ovs-appctl time/warp 500
483 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
486 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
491 # at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired.
492 # but forwarding flag should be still true.
493 ovs-appctl time/warp 500
494 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
496 # reset bfd forwarding_if_rx.
497 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
498 # forwarding flag should turn to false since the STATE is DOWN.
499 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
501 # re-enable bfd on the other end. the states should be up.
502 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
503 # advance the clock, to stablize the states.
504 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
505 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
506 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
507 BFD_CHECK_TX([p0], [500ms], [500ms], [300ms])
508 BFD_CHECK_RX([p0], [500ms], [500ms], [300ms])
510 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
513 # forwarding_if_rx Test3
514 # Test3 is for testing that the enable of forwarding_if_rx will not
515 # affect the bfd decay feature. bfd is enabled on both ends of the link.
516 AT_SETUP([bfd - bfd forwarding_if_rx - with bfd decay])
517 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
518 add-port br1 p1 -- set Interface p1 type=patch \
519 options:peer=p0 ofport_request=2 -- \
520 add-port br0 p0 -- set Interface p0 type=patch \
521 options:peer=p1 ofport_request=1 -- \
522 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:decay_min_rx=3000 -- \
523 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
526 # advance the clock, to stablize the states.
527 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
528 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
529 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
530 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
531 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
533 # enable forwarding_if_rx.
534 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
536 # there should be no change of the forwarding flag, since
537 # the bfd on both ends is already up.
540 ovs-appctl time/warp 500
541 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
544 # reconfigure the decay_min_rx to 1000ms.
545 AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
547 # wait for 5000ms to decay.
548 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
549 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
550 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
551 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
553 # stop the bfd on one side.
554 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
556 # advance clock by 4000ms, while receiving packets.
557 # the STATE should go DOWN, due to Control Detection Time Expired.
558 # but forwarding flag should be still true.
561 ovs-appctl time/warp 500
562 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
565 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
567 # receive packet at 1/100ms rate for 1000ms.
570 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
572 ovs-appctl time/warp 100
573 # the forwarding flag should always be true during this time.
574 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
577 # stop receiving for 5000ms.
578 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
579 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
581 # reset bfd forwarding_if_rx.
582 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false])
583 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
584 # re-enable bfd forwarding_if_rx.
585 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true])
586 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
588 # re-enable bfd on the other end. the states should be up.
589 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
590 # advance the clock, to stablize the states.
591 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
592 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
593 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
594 BFD_CHECK_TX([p0], [300ms], [300ms], [300ms])
595 BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
597 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
600 # forwarding_if_rx Test4
601 # Test4 is for testing the demand_rx_bfd feature.
602 # bfd is enabled on both ends of the link.
603 AT_SETUP([bfd - bfd forwarding_if_rx - demand_rx_bfd])
604 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
605 add-port br1 p1 -- set Interface p1 type=patch \
606 options:peer=p0 ofport_request=2 -- \
607 add-port br0 p0 -- set Interface p0 type=patch \
608 options:peer=p1 ofport_request=1 -- \
609 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:forwarding_if_rx=true -- \
610 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
613 # advance the clock, to stablize the states.
614 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
615 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
616 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
617 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
619 # disable the bfd on p1.
620 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
622 # advance clock by 4000ms, while receiving packets.
623 # the STATE should go DOWN, due to Control Detection Time Expired.
624 # but forwarding flag should be still true.
627 ovs-appctl time/warp 500
628 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
631 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
633 # advance clock long enough to trigger the demand_bfd_rx interval
634 # (100 * bfd->cfm_min_rx), forwarding flag should go down since there
635 # is no bfd control packet received during the demand_rx_bfd.
638 ovs-appctl time/warp 300
639 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
642 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
644 # now enable the bfd on p1 again.
645 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true], [0])
646 # advance clock by 5000ms. and p1 and p0 should be all up.
647 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
648 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
649 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
650 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
652 # disable the bfd on p1 again.
653 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
654 # advance clock long enough to trigger the demand_rx_bfd,
655 # forwarding flag should go down since there is no bfd control packet
656 # received during the demand_rx_bfd.
659 ovs-appctl time/warp 300
660 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
663 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
665 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
668 # test bfd:flap_count.
669 # This test contains three part:
670 # part 1. tests the flap_count on normal bfd monitored link.
671 # part 2. tests the flap_count when forwarding override is used.
672 # part 3. tests the flap_count when forwarding_if_rx is enabled.
673 AT_SETUP([bfd - flap_count])
674 #Create 2 bridges connected by patch ports and enable bfd
675 OVS_VSWITCHD_START([add-br br1 -- \
676 set bridge br1 datapath-type=dummy \
677 other-config:hwaddr=aa:55:aa:56:00:00 -- \
678 add-port br1 p1 -- set Interface p1 type=patch \
679 options:peer=p0 ofport_request=2 -- \
680 add-port br0 p0 -- set Interface p0 type=patch \
681 options:peer=p1 ofport_request=1 -- \
682 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
683 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
687 # Part-1 wait for a while to stablize bfd.
688 for i in `seq 0 100`; do ovs-appctl time/warp 100; done
689 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
690 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
691 BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
692 BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
693 # both p0 and p1 should have flap_count = "1". since down->up.
694 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
695 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
697 # turn bfd on p1 off, should increment the bfd:flap_count on p0.
698 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
699 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
700 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
701 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
702 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
704 # turn bfd on p1 on again, should increment the bfd:flap_count on p0.
705 # p1 should still have flap_count = "1", since it is reset.
706 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
707 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
708 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
709 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
712 # Part-2 now turn on the forwarding_override.
713 AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl
717 # turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on.
718 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
719 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
720 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
721 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
722 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
724 # turn bfd on p1 on again, should not increment the bfd:flap_count on p0, since forwarding override is on.
725 # p1 should still have flap_count = "1", since it is reset.
726 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
727 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
728 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
729 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
731 # turn the forwarding_override back to normal.
732 AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl
736 # turn bfd on p1 off and on, should increment the bfd:flap_count on p0.
737 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
738 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
739 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
740 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
741 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
742 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
744 # Part-3 now turn on forwarding_if_rx.
745 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
746 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
747 # disable the bfd on p1.
748 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
750 # advance clock by 4000ms, while receiving packets.
751 # the STATE should go DOWN, due to Control Detection Time Expired.
752 # but forwarding flag should be true.
755 ovs-appctl time/warp 100
756 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
759 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
760 # flap_count should remain unchanged.
761 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
763 # stop the traffic for more than 100 * bfd->cfm_min_rx ms, the forwarding flag of p0 should turn false.
764 # and there should be the increment of flap_count.
765 for i in `seq 0 120`; do ovs-appctl time/warp 100; done
766 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
767 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
769 # advance clock by 4000ms, and resume the traffic.
772 ovs-appctl time/warp 100
773 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
776 # forwarding should be false, since there is still no bfd control packet received.
777 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
778 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
780 # turn on the bfd on p1.
781 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
782 for i in `seq 0 49`; do ovs-appctl time/warp 100; done
783 # even though there is no data traffic, since p1 bfd is on again, should increment the flap_count.
784 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"])
785 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])