bfd: Add new key "flap_count" to "bfd_status".
[sliver-openvswitch.git] / tests / bfd.at
1 AT_BANNER([bfd])
2
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],
5 [dnl
6         Forwarding: $2
7         Detect Multiplier: 3
8         Concatenated Path Down: $3
9
10         Local Flags: $4
11         Local Session State: $5
12         Local Diagnostic: $6
13
14         Remote Flags: $7
15         Remote Session State: $8
16         Remote Diagnostic: $9
17 ])
18 ])
19
20 m4_define([BFD_CHECK_TX], [
21 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
22 [dnl
23         TX Interval: Approx $2
24         Local Minimum TX Interval: $3
25         Remote Minimum TX Interval: $4
26 ])
27 ])
28
29 m4_define([BFD_CHECK_RX], [
30 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
31 [dnl
32         RX Interval: Approx $2
33         Local Minimum RX Interval: $3
34         Remote Minimum RX Interval: $4
35 ])
36 ])
37
38 m4_define([BFD_VSCTL_LIST_IFACE], [
39 AT_CHECK([ovs-vsctl list interface $1 | sed -n $2],[0],
40 [dnl
41 $3
42 ])
43 ])
44
45 AT_SETUP([bfd - basic config on different bridges])
46 #Create 2 bridges connected by patch ports and enable BFD
47 OVS_VSWITCHD_START(
48    [add-br br1 -- \
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 \
52        options:peer=p0 -- \
53     add-port br0 p0 -- set Interface p0 type=patch \
54        options:peer=p1 -- \
55     set Interface p0 bfd:enable=true -- \
56     set Interface p1 bfd:enable=true ])
57 ovs-appctl time/stop
58 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
59
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])
63
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])
67
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])
72
73 ovs-vsctl del-br br0
74 AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
75 ovs-appctl: ovs-vswitchd: server returned an error
76 ])
77 ovs-vsctl del-br br1
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
81 ])
82
83 OVS_VSWITCHD_STOP
84 AT_CLEANUP
85
86
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.
92
93 OVS_VSWITCHD_START(
94    [add-br br-bfd0 -- \
95        set bridge br-bfd0 datapath-type=dummy \
96        other-config:hwaddr=aa:55:aa:56:00:00 -- \
97     add-br br-bfd1 -- \
98        set bridge br-bfd1 datapath-type=dummy \
99        other-config:hwaddr=aa:55:aa:57:00:00 -- \
100     add-br br-sw -- \
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 -- \
105     add-port br-sw p0-sw -- set Interface p0-sw type=patch \
106        options:peer=p0 -- \
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 --])
111
112 ovs-appctl time/stop
113
114 #Create 2 bridges connected by patch ports and enable BFD
115
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])
121
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])
127
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
133
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])
136
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.
140
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.
143
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])
151
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.
155
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])
163 OVS_VSWITCHD_STOP
164 AT_CLEANUP
165
166
167 AT_SETUP([bfd - concatenated path down])
168 #Create 2 bridges connected by patch ports and enable BFD
169 OVS_VSWITCHD_START()
170 ovs-appctl time/stop
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 \
175            options:peer=p0 ])
176 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
177            options:peer=p1 ])
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
181
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])
185
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])
190 OVS_VSWITCHD_STOP
191 AT_CLEANUP
192
193
194 AT_SETUP([bfd - Edit the Min Tx/Rx values])
195 #Create 2 bridges connected by patch ports and enable BFD
196 OVS_VSWITCHD_START()
197 ovs-appctl time/stop
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 \
201            options:peer=p0 ])
202 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
203            options:peer=p1 ])
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])
215
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])
221
222 OVS_VSWITCHD_STOP
223 AT_CLEANUP
224
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])
230
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.
237 ], [])
238
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
245 ], [])
246
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.
254 ], [])
255
256 OVS_VSWITCHD_STOP
257 AT_CLEANUP
258
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])
268
269 ovs-appctl time/stop
270
271 # wait for a while to stablize everything.
272 for i in `seq 0 9`; 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])
277
278 # Test-1 BFD decay: decay to decay_min_rx
279 AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=3000])
280 # set the bfd:decay_min_rx of p0 to 3000ms.
281 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
282 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
283
284 # bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up,
285 # so for the first 2500ms, there should be no change.
286 for i in `seq 0 4`; do ovs-appctl time/warp 500; done
287 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
288 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
289 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
290
291 # advance the clock by 2000ms.
292 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
293 # now, min_rx should decay to 3000ms.
294 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
295 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
296
297 # the rx_min of p0 is 3000ms now, and p1 will send next control message
298 # 3000ms after decay. so, advance clock by 5000ms to make that happen.
299 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
300 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
301 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
302 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
303 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
304 # End of Test-1 ###############################################################
305
306
307 # Test-2 BFD decay: go back to cfg_min_rx when there is traffic
308 # receive packet at 1/100ms rate for 5000ms.
309 for i in `seq 0 49`
310 do
311     ovs-appctl time/warp 100
312     AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
313              [0], [stdout], [])
314 done
315 # after a decay interval (3000ms), the p0 min_rx will go back to
316 # cfg_min_rx.
317 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
318 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
319 # End of Test-2 ###############################################################
320
321
322 # Test-3 BFD decay: go back to cfg_min_rx when decay_min_rx is changed
323 # advance the clock by 5000m. p0 shoud decay.
324 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
325 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
326 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
327
328 # advance the clock, to make 'flag' go back to none.
329 for i in `seq 0 5`; do ovs-appctl time/warp 500; done
330 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
331 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
332
333 # change decay_min_rx to 1000ms.
334 # for decay_min_rx < 2000ms, the decay detection time is set to 2000ms.
335 # this should reset the min_rx.
336 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
337 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
338 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
339
340 # for the following 1500ms, there should be no decay,
341 # since the decay_detect_time is set to 2000ms.
342 for i in `seq 0 2`
343 do
344     ovs-appctl time/warp 500
345     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
346     BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
347     BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
348     BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
349 done
350
351 # advance the clock by 2000ms, decay should have happened.
352 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
353 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
354 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
355 # advance the clock, so 'flag' go back to none.
356 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
357 # End of Test-3 ###############################################################
358
359
360 # Test-4 BFD decay: set min_rx to 800ms.
361 # this should firstly reset the min_rx and then re-decay to 1000ms.
362 AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=800])
363 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
364 BFD_CHECK_RX([p0], [800ms], [800ms], [500ms])
365
366 # for the following 1600ms, there should be no decay,
367 # since the decay detection time is set to 2000ms.
368 for i in `seq 0 1`
369 do
370     ovs-appctl time/warp 800
371     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
372     BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
373     BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
374     BFD_CHECK_RX([p0], [800ms], [800ms], [500ms])
375 done
376
377 # advance the clock by 2000ms, decay should have happened.
378 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
379 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
380 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
381 # advance the clock, so 'flag' go back to none.
382 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
383 # End of Test-4 ###############################################################
384
385
386 # Test-5 BFD decay: set min_rx to 300ms and decay_min_rx to 5000ms together.
387 AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=300 bfd:decay_min_rx=5000])
388 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
389 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
390
391 # for decay_min_rx > 2000ms, the decay detection time is set to
392 # decay_min_rx (5000ms).
393 # for the following 4500ms, there should be no decay,
394 # since the decay detection time is set to 5000ms.
395 for i in `seq 0 8`
396 do
397     ovs-appctl time/warp 500
398     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
399     BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
400     BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
401     BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
402 done
403
404 # advance the clock by 2000ms, decay should have happened.
405 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
406 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
407 BFD_CHECK_RX([p0], [5000ms], [5000ms], [500ms])
408 # advance the clock, to make 'flag' go back to none.
409 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
410 # End of Test-5 ###############################################################
411
412
413 # Test-6 BFD decay: set decay_min_rx to 0 to disable bfd decay.
414 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
415 # min_rx is reset.
416 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
417 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
418 for i in `seq 0 20`
419 do
420     ovs-appctl time/warp 500
421     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
422     BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
423     BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
424     BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
425 done
426 # End of Test-6 ################################################################
427
428
429 # Test-7 BFD decay: rmt_min_tx is greater than decay_min_rx
430 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface p1 bfd:min_tx=5000])
431 # there will be poll sequences from both sides. and it is hard to determine the
432 # order. so just skip 10000ms and check the RX/TX. at that time, p0 should be in decay already.
433 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
434 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
435 BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
436 # then, there should be no change of status,
437 for i in `seq 0 9`
438 do
439     ovs-appctl time/warp 500
440     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
441     BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
442     BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
443     BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
444 done
445 # reset the p1's min_tx to 500ms.
446 AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
447 # since p0 has been in decay, now the RX will show 3000ms.
448 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
449 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
450 # End of Test-7 ###############################################################
451
452
453 # Test-8 BFD decay: state up->down->up.
454 # turn bfd off on p1
455 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false])
456
457 # check the state change of bfd on p0. After 15000 ms (> 3 min_rx intervals)
458 for i in `seq 0 14`; do ovs-appctl time/warp 1000; done
459 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
460 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
461 BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
462
463 # resume the bfd on p1. the bfd should not go to decay mode direclty.
464 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
465 for i in `seq 0 3`; do ovs-appctl time/warp 500; done
466 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
467 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
468
469 # since the decay_min_rx is still 3000ms, so after 5000ms, p0 should have decayed.
470 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
471 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
472 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
473 # End of Test-8 ################################################################
474
475 OVS_VSWITCHD_STOP
476 AT_CLEANUP
477
478 # Tests below are for bfd forwarding_if_rx feature.
479 # forwarding_if_rx Test1: bfd is enabled on one end of link.
480 AT_SETUP([bfd - bfd forwarding_if_rx 1])
481 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
482                     add-port br1 p1 -- set Interface p1 type=patch \
483                     options:peer=p0 ofport_request=2 -- \
484                     add-port br0 p0 -- set Interface p0 type=patch \
485                     options:peer=p1 ofport_request=1 -- \
486                     set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
487                     add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
488
489 ovs-appctl time/stop
490 # check the inital status.
491 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
492 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
493 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
494
495 # enable forwarding_if_rx.
496 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
497
498 # there should be no change of forwarding flag, since
499 # there is no traffic.
500 for i in `seq 0 3`
501 do
502     ovs-appctl time/warp 500
503     BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
504 done
505
506 # receive one packet.
507 AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
508              [0], [stdout], [])
509 # wait for 1000ms
510 for i in `seq 0 14`; do ovs-appctl time/warp 100; done
511 # the forwarding flag should turn to true sometime in this 1000ms, since there is data received.
512 BFD_CHECK([p0], [true], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
513 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
514 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
515
516 # Stop sending packets for 2000ms.
517 for i in `seq 0 19`; do ovs-appctl time/warp 100; done
518 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
519 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
520 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
521
522 # receive packet at 1/100ms rate for 2000ms.
523 for i in `seq 0 19`
524 do
525     ovs-appctl time/warp 100
526     AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
527              [0], [stdout], [])
528 done
529 # the forwarding flag should be true, since there is data received.
530 BFD_CHECK([p0], [true], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
531 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
532 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
533
534 # reset bfd forwarding_if_rx.
535 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
536 # forwarding flag should turn to false since the STATE is DOWN.
537 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
538 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
539 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
540
541 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
542 AT_CLEANUP
543
544 # forwarding_if_rx Test2: bfd is enabled on both ends of link.
545 AT_SETUP([bfd - bfd forwarding_if_rx 2])
546 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
547                     add-port br1 p1 -- set Interface p1 type=patch \
548                     options:peer=p0 ofport_request=2 -- \
549                     add-port br0 p0 -- set Interface p0 type=patch \
550                     options:peer=p1 ofport_request=1 -- \
551                     set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
552                     set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
553                     add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
554
555 ovs-appctl time/stop
556 # advance the clock, to stablize the states.
557 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
558
559 # enable forwarding_if_rx.
560 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
561
562 # there should be no change of the forwarding flag, since
563 # the bfd on both ends is already up.
564 for i in `seq 0 5`
565 do
566     ovs-appctl time/warp 500
567     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
568 done
569
570 # stop the bfd on one side.
571 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
572 # for within 1500ms, the detection timer is not out.
573 # there is no change to status.
574 for i in `seq 0 1`
575 do
576     ovs-appctl time/warp 500
577     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
578     for i in `seq 0 4`
579     do
580         AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
581                  [0], [stdout], [])
582     done
583 done
584
585 # at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired.
586 # but forwarding flag should be still true.
587 ovs-appctl time/warp 500
588 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
589
590 # receive packet at 1/100ms rate for 1000ms.
591 for i in `seq 0 9`
592 do
593     AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
594              [0], [stdout], [])
595     ovs-appctl time/warp 100
596     # the forwarding flag should always be true during this time.
597     BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
598 done
599
600 # reset bfd forwarding_if_rx.
601 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
602 # forwarding flag should turn to false since the STATE is DOWN.
603 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
604 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
605 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
606
607 # re-enable bfd on the other end. the states should be up.
608 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
609 # advance the clock, to stablize the states.
610 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
611 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
612 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
613 BFD_CHECK_TX([p0], [500ms], [500ms], [300ms])
614 BFD_CHECK_RX([p0], [500ms], [500ms], [300ms])
615
616 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
617 AT_CLEANUP
618
619 # forwarding_if_rx Test3: bfd is enabled on both ends of link and decay is enabled.
620 AT_SETUP([bfd - bfd forwarding_if_rx 3])
621 OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
622                     add-port br1 p1 -- set Interface p1 type=patch \
623                     options:peer=p0 ofport_request=2 -- \
624                     add-port br0 p0 -- set Interface p0 type=patch \
625                     options:peer=p1 ofport_request=1 -- \
626                     set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:decay_min_rx=3000 -- \
627                     set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
628
629 ovs-appctl time/stop
630 # advance the clock, to stablize the states.
631 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
632 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
633 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
634 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
635 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
636
637 # enable forwarding_if_rx.
638 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
639
640 # there should be no change of the forwarding flag, since
641 # the bfd on both ends is already up.
642 for i in `seq 0 9`
643 do
644     ovs-appctl time/warp 500
645     BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
646 done
647
648 # reconfigure the decay_min_rx to 1000ms.
649 AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
650 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
651 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
652
653 # wait for 5000ms to decay.
654 for i in `seq 0 9`; do ovs-appctl time/warp 500; done
655 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
656 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
657
658 # stop the bfd on one side.
659 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
660
661 # advance clock by 4000ms, while receiving packets.
662 # the STATE should go DOWN, due to Control Detection Time Expired.
663 # but forwarding flag should be still true.
664 for i in `seq 0 7`
665 do
666     ovs-appctl time/warp 500
667     AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
668              [0], [stdout], [])
669 done
670 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
671
672 # receive packet at 1/100ms rate for 1000ms.
673 for i in `seq 0 9`
674 do
675     AT_CHECK([ovs-ofctl packet-out br1 3 2  "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
676              [0], [stdout], [])
677     ovs-appctl time/warp 100
678     # the forwarding flag should always be true during this time.
679     BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
680 done
681
682 # stop receiving for 3000ms.
683 for i in `seq 0 29`; do ovs-appctl time/warp 100; done
684 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
685
686 # reset bfd forwarding_if_rx.
687 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false])
688 # forwarding flag should turn to false since the STATE is DOWN.
689 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
690 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
691 BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
692
693 # re-enable bfd forwarding_if_rx.
694 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true])
695 # there should be no change.
696 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
697 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
698 BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
699
700 # re-enable bfd on the other end. the states should be up.
701 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
702 # advance the clock, to stablize the states.
703 for i in `seq 0 19`; do ovs-appctl time/warp 500; done
704 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
705 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
706 BFD_CHECK_TX([p0], [300ms], [300ms], [300ms])
707 BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
708
709 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
710 AT_CLEANUP
711
712 # test bfd:flap_count.
713 AT_SETUP([bfd - flap_count])
714 #Create 2 bridges connected by patch ports and enable bfd
715 OVS_VSWITCHD_START([add-br br1 -- \
716                     set bridge br1 datapath-type=dummy \
717                     other-config:hwaddr=aa:55:aa:56:00:00 -- \
718                     add-port br1 p1 -- set Interface p1 type=patch \
719                     options:peer=p0 ofport_request=2 -- \
720                     add-port br0 p0 -- set Interface p0 type=patch \
721                     options:peer=p1 ofport_request=1 -- \
722                     set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
723                     set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
724
725 ovs-appctl time/stop
726
727 # Part-1 wait for a while to stablize bfd.
728 for i in `seq 0 100`; do ovs-appctl time/warp 100; done
729 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
730 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
731 BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
732 BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
733 # both p0 and p1 should have flap_count = "1". since down->up.
734 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
735 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
736
737 # turn bfd on p1 off, should increment the bfd:flap_count on p0.
738 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
739 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
740 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
741 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
742 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
743
744 # turn bfd on p1 on again, should increment the bfd:flap_count on p0.
745 # p1 should still have flap_count = "1", since it is reset.
746 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
747 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
748 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
749 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
750
751
752 # Part-2 now turn on the forwarding_override.
753 AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl
754 OK
755 ])
756
757 # turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on.
758 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
759 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
760 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
761 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
762 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
763
764 # turn bfd on p1 on again, should not increment the bfd:flap_count on p0, since forwarding override is on.
765 # p1 should still have flap_count = "1", since it is reset.
766 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
767 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
768 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
769 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
770
771 # turn the forwarding_override back to normal.
772 AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl
773 OK
774 ])
775
776 # turn bfd on p1 off and on, should increment the bfd:flap_count on p0.
777 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
778 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
779 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
780 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
781 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
782 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
783
784 # Part-3 now turn on forwarding_if_rx.
785 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
786 # disable the bfd on p1.
787 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
788
789 # advance clock by 4000ms, while receiving packets.
790 # the STATE should go DOWN, due to Control Detection Time Expired.
791 # but forwarding flag should be true.
792 for i in `seq 0 39`
793 do
794     ovs-appctl time/warp 100
795     AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
796              [0], [stdout], [])
797 done
798 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
799 # flap_count should remain unchanged.
800 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
801
802 # stop the traffic for 4000ms, the forwarding flag of p0 should turn false.
803 # and there should be the increment of flap_count.
804 for i in `seq 0 7`; do ovs-appctl time/warp 500; done
805 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
806 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
807
808 # advance clock by 4000ms, and resume the traffic.
809 for i in `seq 0 39`
810 do
811     ovs-appctl time/warp 100
812     AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
813              [0], [stdout], [])
814 done
815 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
816 # flap_count should be incremented again.
817 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"])
818
819 # stop the traffic for 4000ms, the forwarding flag of p0 should turn false.
820 # and there should be the increment of flap_count.
821 for i in `seq 0 7`; do ovs-appctl time/warp 500; done
822 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
823 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["8"])
824
825 # turn on the bfd on p1.
826 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
827 for i in `seq 0 10`; do ovs-appctl time/warp 100; done
828 # even though there is no data traffic, since p1 bfd is on again, should increment the flap_count.
829 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["9"])
830 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
831
832 OVS_VSWITCHD_STOP
833 AT_CLEANUP