]> git.proxmox.com Git - mirror_ovs.git/blame - tests/bfd.at
fedora-build: Remove %{build_number} from the configure line
[mirror_ovs.git] / tests / bfd.at
CommitLineData
015cf297
PR
1AT_BANNER([bfd])
2
3m4_define([BFD_CHECK], [
4AT_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
20m4_define([BFD_CHECK_TX], [
21AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
22[dnl
c1c4e8c7
AW
23 TX Interval: Approx $2
24 Local Minimum TX Interval: $3
25 Remote Minimum TX Interval: $4
015cf297
PR
26])
27])
28
29m4_define([BFD_CHECK_RX], [
30AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
31[dnl
32 RX Interval: Approx $2
c1c4e8c7
AW
33 Local Minimum RX Interval: $3
34 Remote Minimum RX Interval: $4
015cf297
PR
35])
36])
4905e2df
AW
37
38m4_define([BFD_VSCTL_LIST_IFACE], [
39AT_CHECK([ovs-vsctl list interface $1 | sed -n $2],[0],
40[dnl
41$3
42])
43])
44
015cf297 45AT_SETUP([bfd - basic config on different bridges])
015cf297
PR
46#Create 2 bridges connected by patch ports and enable BFD
47OVS_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 ])
43d66d3b 57ovs-appctl time/stop
015cf297
PR
58for i in `seq 0 40`; do ovs-appctl time/warp 100; done
59
60#Verify that BFD has been enabled on both interfaces.
61BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
62BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
63
64AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=false])
65for i in `seq 0 40`; do ovs-appctl time/warp 100; done
66BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
67
68AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=true])
69for i in `seq 0 40`; do ovs-appctl time/warp 100; done
70BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
71BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
72
73ovs-vsctl del-br br0
74AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
75ovs-appctl: ovs-vswitchd: server returned an error
76])
77ovs-vsctl del-br br1
78#Check that the entries are gone.
79AT_CHECK([ovs-appctl bfd/show p1], [2],[ignore], [no such bfd object
80ovs-appctl: ovs-vswitchd: server returned an error
81])
82
83OVS_VSWITCHD_STOP
84AT_CLEANUP
85
86
87AT_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
015cf297
PR
93OVS_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
43d66d3b 112ovs-appctl time/stop
015cf297
PR
113
114#Create 2 bridges connected by patch ports and enable BFD
115
116AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
117#Verify that BFD is enabled.
118for i in `seq 0 40`; do ovs-appctl time/warp 100; done
119BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
120BFD_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.
123AT_CHECK([ ovs-ofctl add-flow br-sw 'priority=5,actions=drop' ])
124for i in `seq 0 40`; do ovs-appctl time/warp 100; done
125BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
126BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
127
128#Delete the added flow
129AT_CHECK([ovs-ofctl del-flows br-sw], [0])
130AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
131#Verify that BFD is back up again.
132for i in `seq 0 40`; do ovs-appctl time/warp 100; done
133
134BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
135BFD_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
144AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=1,priority=5,actions=drop'])
145for 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.
147BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
148for 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.
150BFD_CHECK([p0], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
151
152AT_CHECK([ovs-ofctl del-flows br-sw])
153AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
154#Ensure that BFD is back up again.
155
156for i in `seq 0 10`; do ovs-appctl time/warp 100; done
157#Bring down the br-bfd0 - br-sw link
158AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=2,priority=5,actions=drop'])
159for i in `seq 0 40`; do ovs-appctl time/warp 100; done
160BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
161for i in `seq 0 40`; do ovs-appctl time/warp 100; done
162BFD_CHECK([p1], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
163OVS_VSWITCHD_STOP
164AT_CLEANUP
165
166
167AT_SETUP([bfd - concatenated path down])
168#Create 2 bridges connected by patch ports and enable BFD
015cf297 169OVS_VSWITCHD_START()
43d66d3b 170ovs-appctl time/stop
015cf297
PR
171AT_CHECK([ ovs-vsctl -- add-br br1 -- \
172 set bridge br1 datapath-type=dummy \
173 other-config:hwaddr=aa:55:aa:56:00:00 ])
015cf297
PR
174AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
175 options:peer=p0 ])
176AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
177 options:peer=p1 ])
178AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
179AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
180for i in `seq 0 40`; do ovs-appctl time/warp 100; done
181
182#Verify that BFD has been enabled on both interfaces.
183BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
184BFD_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.
187AT_CHECK([ovs-vsctl set interface p0 bfd:cpath_down=true])
188for i in `seq 0 40`; do ovs-appctl time/warp 100; done
189BFD_CHECK([p1], [false], [false], [none], [up], [No Diagnostic], [none], [up], [Concatenated Path Down])
190OVS_VSWITCHD_STOP
191AT_CLEANUP
192
193
194AT_SETUP([bfd - Edit the Min Tx/Rx values])
195#Create 2 bridges connected by patch ports and enable BFD
015cf297 196OVS_VSWITCHD_START()
43d66d3b 197ovs-appctl time/stop
015cf297
PR
198AT_CHECK([ ovs-vsctl -- add-br br1 -- \
199 set bridge br1 datapath-type=dummy ])
200AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
201 options:peer=p0 ])
202AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
203 options:peer=p1 ])
204AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
205AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
43d66d3b 206for i in `seq 0 30`; do ovs-appctl time/warp 100; done
015cf297
PR
207#Verify that BFD has been enabled on both interfaces.
208BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
209BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
210#Edit the min Tx value.
211AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200])
212for i in `seq 0 20`; do ovs-appctl time/warp 100; done
c1c4e8c7
AW
213BFD_CHECK_TX([p0], [1000ms], [200ms], [100ms])
214BFD_CHECK_TX([p1], [1000ms], [100ms], [200ms])
015cf297
PR
215
216#Edit the min Rx value.
217AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300])
218for i in `seq 0 20`; do ovs-appctl time/warp 100; done
c1c4e8c7
AW
219BFD_CHECK_RX([p1], [300ms], [300ms], [1000ms])
220BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
015cf297
PR
221
222OVS_VSWITCHD_STOP
223AT_CLEANUP
2d21cf72
AW
224
225AT_SETUP([bfd - check_tnl_key])
226OVS_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.
232AT_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.
234AT_CHECK([tail -2 stdout], [0], [dnl
235This flow is handled by the userspace slow path because it:
236 - Consists of BFD packets.
237], [])
238
239# turn on the check_tnl_key.
240AT_CHECK([ovs-vsctl set interface p1 bfd:check_tnl_key=true])
241AT_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.
243AT_CHECK([tail -1 stdout], [0],[dnl
244Datapath actions: 100
245], [])
246
247# set the tunnel key to 0.
248AT_CHECK([ovs-vsctl set interface p1 options:key=0])
249AT_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.
251AT_CHECK([tail -2 stdout], [0], [dnl
252This flow is handled by the userspace slow path because it:
253 - Consists of BFD packets.
254], [])
255
256OVS_VSWITCHD_STOP
257AT_CLEANUP
c1c4e8c7
AW
258
259# Tests below are for bfd decay features.
260AT_SETUP([bfd - bfd decay])
261OVS_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 -- \
3688ce7a 266 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
c1c4e8c7
AW
267 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
268
269ovs-appctl time/stop
c1c4e8c7 270
3688ce7a
AW
271# wait for a while to stablize everything.
272for i in `seq 0 9`; do ovs-appctl time/warp 500; done
273BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
274BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
275BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
276BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
c1c4e8c7
AW
277
278# Test-1 BFD decay: decay to decay_min_rx
3688ce7a
AW
279AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=3000])
280# set the bfd:decay_min_rx of p0 to 3000ms.
281BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
282BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
283
c1c4e8c7
AW
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.
01d18a3a 286for i in `seq 0 4`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
287BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
288BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
289BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
290
3688ce7a
AW
291# advance the clock by 2000ms.
292for i in `seq 0 3`; do ovs-appctl time/warp 500; done
293# now, min_rx should decay to 3000ms.
c1c4e8c7
AW
294BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
295BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
296
c1c4e8c7 297# the rx_min of p0 is 3000ms now, and p1 will send next control message
3688ce7a
AW
298# 3000ms after decay. so, advance clock by 5000ms to make that happen.
299for i in `seq 0 9`; do ovs-appctl time/warp 500; done
c1c4e8c7 300BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
3688ce7a 301BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
c1c4e8c7
AW
302BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
303BFD_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
3688ce7a
AW
308# receive packet at 1/100ms rate for 5000ms.
309for i in `seq 0 49`
c1c4e8c7
AW
310do
311 ovs-appctl time/warp 100
312 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
313 [0], [stdout], [])
314done
315# after a decay interval (3000ms), the p0 min_rx will go back to
3688ce7a 316# cfg_min_rx.
c1c4e8c7
AW
317BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
318BFD_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
3688ce7a
AW
323# advance the clock by 5000m. p0 shoud decay.
324for i in `seq 0 9`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
325BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
326BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
327
328# advance the clock, to make 'flag' go back to none.
329for i in `seq 0 5`; do ovs-appctl time/warp 500; done
330BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
331BFD_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.
3688ce7a 335# this should reset the min_rx.
c1c4e8c7 336AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
c1c4e8c7
AW
337BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
338BFD_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.
342for i in `seq 0 2`
343do
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])
349done
350
3688ce7a
AW
351# advance the clock by 2000ms, decay should have happened.
352for i in `seq 0 3`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
353BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
354BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
355# advance the clock, so 'flag' go back to none.
3688ce7a 356for i in `seq 0 9`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
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.
362AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=800])
c1c4e8c7
AW
363BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
364BFD_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.
368for i in `seq 0 1`
369do
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])
375done
376
3688ce7a
AW
377# advance the clock by 2000ms, decay should have happened.
378for i in `seq 0 3`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
379BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
380BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
381# advance the clock, so 'flag' go back to none.
3688ce7a 382for i in `seq 0 9`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
383# End of Test-4 ###############################################################
384
385
386# Test-5 BFD decay: set min_rx to 300ms and decay_min_rx to 5000ms together.
387AT_CHECK([ovs-vsctl set Interface p0 bfd:min_rx=300 bfd:decay_min_rx=5000])
c1c4e8c7
AW
388BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
389BFD_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.
395for i in `seq 0 8`
396do
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])
402done
403
3688ce7a
AW
404# advance the clock by 2000ms, decay should have happened.
405for i in `seq 0 3`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
406BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
407BFD_CHECK_RX([p0], [5000ms], [5000ms], [500ms])
408# advance the clock, to make 'flag' go back to none.
409for 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.
414AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
3688ce7a 415# min_rx is reset.
c1c4e8c7
AW
416BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
417BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
418for i in `seq 0 20`
419do
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])
425done
426# End of Test-6 ################################################################
427
428
429# Test-7 BFD decay: rmt_min_tx is greater than decay_min_rx
430AT_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.
635c5db9 433for i in `seq 0 19`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
434BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
435BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
436# then, there should be no change of status,
437for i in `seq 0 9`
438do
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])
444done
445# reset the p1's min_tx to 500ms.
446AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
3688ce7a 447# since p0 has been in decay, now the RX will show 3000ms.
c1c4e8c7
AW
448BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
449BFD_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
455AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false])
456
3688ce7a
AW
457# check the state change of bfd on p0. After 15000 ms (> 3 min_rx intervals)
458for i in `seq 0 14`; do ovs-appctl time/warp 1000; done
c1c4e8c7
AW
459BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
460BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
461BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
462
463# resume the bfd on p1. the bfd should not go to decay mode direclty.
464AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
635c5db9 465for i in `seq 0 3`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
466BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
467BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
468
3688ce7a
AW
469# since the decay_min_rx is still 3000ms, so after 5000ms, p0 should have decayed.
470for i in `seq 0 9`; do ovs-appctl time/warp 500; done
c1c4e8c7
AW
471BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
472BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
473# End of Test-8 ################################################################
474
475OVS_VSWITCHD_STOP
01d18a3a
AW
476AT_CLEANUP
477
478# Tests below are for bfd forwarding_if_rx feature.
309d9dac
AW
479
480# forwarding_if_rx Test1
481# Test1 tests the case when bfd is only enabled on one end of the link.
482# Under this situation, the bfd state should be DOWN and the forwarding
483# flag should be FALSE by default. However, if forwarding_if_rx is
484# enabled, as long as there is packet received, the bfd forwarding flag
485# should be TRUE.
486AT_SETUP([bfd - bfd forwarding_if_rx - bfd on one side])
01d18a3a
AW
487OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
488 add-port br1 p1 -- set Interface p1 type=patch \
489 options:peer=p0 ofport_request=2 -- \
490 add-port br0 p0 -- set Interface p0 type=patch \
491 options:peer=p1 ofport_request=1 -- \
492 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
493 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
494
495ovs-appctl time/stop
496# check the inital status.
497BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
498BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
499BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
500
501# enable forwarding_if_rx.
502AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
503
504# there should be no change of forwarding flag, since
505# there is no traffic.
506for i in `seq 0 3`
507do
508 ovs-appctl time/warp 500
509 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
510done
511
3688ce7a
AW
512# receive packet at 1/100ms rate for 2000ms.
513for i in `seq 0 19`
01d18a3a
AW
514do
515 ovs-appctl time/warp 100
516 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
517 [0], [stdout], [])
518done
519# the forwarding flag should be true, since there is data received.
520BFD_CHECK([p0], [true], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
01d18a3a
AW
521
522# reset bfd forwarding_if_rx.
523AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
524# forwarding flag should turn to false since the STATE is DOWN.
525BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
526BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
527BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
528
529AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
530AT_CLEANUP
531
309d9dac
AW
532
533# forwarding_if_rx Test2
534# Test2 is for testing that the enable of forwarding_if_rx will not
535# affect the normal bfd communication. bfd is enabled on both ends of
536# the link.
537AT_SETUP([bfd - bfd forwarding_if_rx - bfd on both sides])
01d18a3a
AW
538OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
539 add-port br1 p1 -- set Interface p1 type=patch \
540 options:peer=p0 ofport_request=2 -- \
541 add-port br0 p0 -- set Interface p0 type=patch \
542 options:peer=p1 ofport_request=1 -- \
543 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
544 set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
545 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
546
547ovs-appctl time/stop
548# advance the clock, to stablize the states.
549for i in `seq 0 9`; do ovs-appctl time/warp 500; done
550
551# enable forwarding_if_rx.
552AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
553
554# there should be no change of the forwarding flag, since
555# the bfd on both ends is already up.
556for i in `seq 0 5`
557do
558 ovs-appctl time/warp 500
559 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
560done
561
562# stop the bfd on one side.
563AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
564# for within 1500ms, the detection timer is not out.
565# there is no change to status.
566for i in `seq 0 1`
567do
568 ovs-appctl time/warp 500
569 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
3688ce7a 570 for i in `seq 0 4`
01d18a3a
AW
571 do
572 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
573 [0], [stdout], [])
574 done
575done
576
577# at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired.
578# but forwarding flag should be still true.
579ovs-appctl time/warp 500
580BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
581
01d18a3a
AW
582# reset bfd forwarding_if_rx.
583AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
584# forwarding flag should turn to false since the STATE is DOWN.
585BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
586
587# re-enable bfd on the other end. the states should be up.
588AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
589# advance the clock, to stablize the states.
590for i in `seq 0 9`; do ovs-appctl time/warp 500; done
591BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
592BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
593BFD_CHECK_TX([p0], [500ms], [500ms], [300ms])
594BFD_CHECK_RX([p0], [500ms], [500ms], [300ms])
595
596AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
597AT_CLEANUP
598
309d9dac
AW
599# forwarding_if_rx Test3
600# Test3 is for testing that the enable of forwarding_if_rx will not
601# affect the bfd decay feature. bfd is enabled on both ends of the link.
602AT_SETUP([bfd - bfd forwarding_if_rx - with bfd decay])
01d18a3a
AW
603OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
604 add-port br1 p1 -- set Interface p1 type=patch \
605 options:peer=p0 ofport_request=2 -- \
606 add-port br0 p0 -- set Interface p0 type=patch \
607 options:peer=p1 ofport_request=1 -- \
608 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:decay_min_rx=3000 -- \
609 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
610
611ovs-appctl time/stop
612# advance the clock, to stablize the states.
613for i in `seq 0 19`; do ovs-appctl time/warp 500; done
614BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
615BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
616BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
617BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
618
619# enable forwarding_if_rx.
620AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
621
622# there should be no change of the forwarding flag, since
623# the bfd on both ends is already up.
624for i in `seq 0 9`
625do
626 ovs-appctl time/warp 500
627 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
628done
629
3688ce7a 630# reconfigure the decay_min_rx to 1000ms.
01d18a3a 631AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
01d18a3a
AW
632BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
633BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
634
3688ce7a
AW
635# wait for 5000ms to decay.
636for i in `seq 0 9`; do ovs-appctl time/warp 500; done
309d9dac 637BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
01d18a3a
AW
638BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
639BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
640
641# stop the bfd on one side.
642AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
3688ce7a
AW
643
644# advance clock by 4000ms, while receiving packets.
645# the STATE should go DOWN, due to Control Detection Time Expired.
646# but forwarding flag should be still true.
647for i in `seq 0 7`
01d18a3a
AW
648do
649 ovs-appctl time/warp 500
01d18a3a
AW
650 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
651 [0], [stdout], [])
652done
01d18a3a
AW
653BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
654
655# receive packet at 1/100ms rate for 1000ms.
656for i in `seq 0 9`
657do
658 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
659 [0], [stdout], [])
660 ovs-appctl time/warp 100
661 # the forwarding flag should always be true during this time.
662 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
663done
664
309d9dac
AW
665# stop receiving for 5000ms.
666for i in `seq 0 49`; do ovs-appctl time/warp 100; done
01d18a3a
AW
667BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
668
669# reset bfd forwarding_if_rx.
670AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false])
01d18a3a 671BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
672# re-enable bfd forwarding_if_rx.
673AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true])
01d18a3a 674BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
675
676# re-enable bfd on the other end. the states should be up.
677AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
678# advance the clock, to stablize the states.
3688ce7a 679for i in `seq 0 19`; do ovs-appctl time/warp 500; done
01d18a3a
AW
680BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
681BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
682BFD_CHECK_TX([p0], [300ms], [300ms], [300ms])
683BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
684
685AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
4905e2df
AW
686AT_CLEANUP
687
688# test bfd:flap_count.
309d9dac
AW
689# This test contains three part:
690# part 1. tests the flap_count on normal bfd monitored link.
691# part 2. tests the flap_count when forwarding override is used.
692# part 3. tests the flap_count when forwarding_if_rx is enabled.
4905e2df
AW
693AT_SETUP([bfd - flap_count])
694#Create 2 bridges connected by patch ports and enable bfd
695OVS_VSWITCHD_START([add-br br1 -- \
696 set bridge br1 datapath-type=dummy \
697 other-config:hwaddr=aa:55:aa:56:00:00 -- \
698 add-port br1 p1 -- set Interface p1 type=patch \
699 options:peer=p0 ofport_request=2 -- \
700 add-port br0 p0 -- set Interface p0 type=patch \
701 options:peer=p1 ofport_request=1 -- \
702 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
703 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
704
705ovs-appctl time/stop
706
707# Part-1 wait for a while to stablize bfd.
708for i in `seq 0 100`; do ovs-appctl time/warp 100; done
709BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
710BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
711BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
712BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
713# both p0 and p1 should have flap_count = "1". since down->up.
714BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
715BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
716
717# turn bfd on p1 off, should increment the bfd:flap_count on p0.
718AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
a1aeea86 719for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df
AW
720BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
721BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
722AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
723
724# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
725# p1 should still have flap_count = "1", since it is reset.
726AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
a1aeea86 727for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df
AW
728BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
729BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
730
731
732# Part-2 now turn on the forwarding_override.
733AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl
734OK
735])
736
737# turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on.
738AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
a1aeea86 739for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df
AW
740BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
741BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
742AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
743
744# turn bfd on p1 on again, should not increment the bfd:flap_count on p0, since forwarding override is on.
745# p1 should still have flap_count = "1", since it is reset.
746AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
a1aeea86 747for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df
AW
748BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
749BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
750
751# turn the forwarding_override back to normal.
752AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl
753OK
754])
755
756# turn bfd on p1 off and on, should increment the bfd:flap_count on p0.
757AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
a1aeea86 758for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df 759AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
a1aeea86 760for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df
AW
761BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
762BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
763
764# Part-3 now turn on forwarding_if_rx.
765AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
766# disable the bfd on p1.
767AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
768
769# advance clock by 4000ms, while receiving packets.
770# the STATE should go DOWN, due to Control Detection Time Expired.
771# but forwarding flag should be true.
772for i in `seq 0 39`
773do
774 ovs-appctl time/warp 100
775 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
776 [0], [stdout], [])
777done
778BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
779# flap_count should remain unchanged.
780BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
781
782# stop the traffic for 4000ms, the forwarding flag of p0 should turn false.
783# and there should be the increment of flap_count.
784for i in `seq 0 7`; do ovs-appctl time/warp 500; done
785BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
786BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
787
788# advance clock by 4000ms, and resume the traffic.
789for i in `seq 0 39`
790do
791 ovs-appctl time/warp 100
792 AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
793 [0], [stdout], [])
794done
795BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
796# flap_count should be incremented again.
797BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"])
798
799# stop the traffic for 4000ms, the forwarding flag of p0 should turn false.
800# and there should be the increment of flap_count.
801for i in `seq 0 7`; do ovs-appctl time/warp 500; done
802BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
803BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["8"])
804
805# turn on the bfd on p1.
806AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
a1aeea86 807for i in `seq 0 49`; do ovs-appctl time/warp 100; done
4905e2df
AW
808# even though there is no data traffic, since p1 bfd is on again, should increment the flap_count.
809BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["9"])
810BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
811
812OVS_VSWITCHD_STOP
c1c4e8c7 813AT_CLEANUP