]> git.proxmox.com Git - mirror_ovs.git/blame - tests/bfd.at
treewide: Convert leading tabs to spaces.
[mirror_ovs.git] / tests / bfd.at
CommitLineData
015cf297
PR
1AT_BANNER([bfd])
2
3m4_define([BFD_CHECK], [
4cefc3da 4AT_CHECK([ovs-appctl bfd/show $1 | sed -e '/Time:/d' | sed -e '/Discriminator/d' | sed -e '/Interval:/d'| sed -e '/Multiplier/d'],[0],
015cf297 5[dnl
fc002ed3
BP
6 Forwarding: $2
7 Concatenated Path Down: $3
015cf297 8
fc002ed3
BP
9 Local Flags: $4
10 Local Session State: $5
11 Local Diagnostic: $6
015cf297 12
fc002ed3
BP
13 Remote Flags: $7
14 Remote Session State: $8
15 Remote Diagnostic: $9
015cf297
PR
16])
17])
18
19m4_define([BFD_CHECK_TX], [
20AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
21[dnl
fc002ed3
BP
22 TX Interval: Approx $2
23 Local Minimum TX Interval: $3
24 Remote Minimum TX Interval: $4
015cf297
PR
25])
26])
27
28m4_define([BFD_CHECK_RX], [
29AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
30[dnl
fc002ed3
BP
31 RX Interval: Approx $2
32 Local Minimum RX Interval: $3
33 Remote Minimum RX Interval: $4
015cf297
PR
34])
35])
4905e2df
AW
36
37m4_define([BFD_VSCTL_LIST_IFACE], [
38AT_CHECK([ovs-vsctl list interface $1 | sed -n $2],[0],
39[dnl
40$3
41])
42])
43
4cefc3da
SG
44m4_define([BFD_CHECK_MULT], [
45AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/Detect Multiplier/p'],[0],
46[dnl
fc002ed3
BP
47 Detect Multiplier: $2
48 Remote Detect Multiplier: $3
4cefc3da
SG
49])
50])
51
015cf297 52AT_SETUP([bfd - basic config on different bridges])
015cf297
PR
53#Create 2 bridges connected by patch ports and enable BFD
54OVS_VSWITCHD_START(
55 [add-br br1 -- \
56 set bridge br1 datapath-type=dummy \
57 other-config:hwaddr=aa:55:aa:56:00:00 -- \
58 add-port br1 p1 -- set Interface p1 type=patch \
59 options:peer=p0 -- \
60 add-port br0 p0 -- set Interface p0 type=patch \
61 options:peer=p1 -- \
62 set Interface p0 bfd:enable=true -- \
63 set Interface p1 bfd:enable=true ])
43d66d3b 64ovs-appctl time/stop
8661af79 65ovs-appctl time/warp 4100 100
015cf297
PR
66
67#Verify that BFD has been enabled on both interfaces.
68BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
69BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
70
71AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=false])
8661af79 72ovs-appctl time/warp 4100 100
015cf297
PR
73BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
74
75AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=true])
8661af79 76ovs-appctl time/warp 4100 100
015cf297
PR
77BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
78BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
79
80ovs-vsctl del-br br0
81AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
82ovs-appctl: ovs-vswitchd: server returned an error
83])
84ovs-vsctl del-br br1
85#Check that the entries are gone.
86AT_CHECK([ovs-appctl bfd/show p1], [2],[ignore], [no such bfd object
87ovs-appctl: ovs-vswitchd: server returned an error
88])
89
90OVS_VSWITCHD_STOP
91AT_CLEANUP
92
93
94AT_SETUP([bfd - Verify tunnel down detection])
622ad885
MC
95#Create 3 bridges - br-bfd0, br-bfd1 and br-sw which is midway between the two. br-sw is
96#connected to br-bfd0 and br-bfd1 through patch ports p0-sw and p1-sw. Enable BFD on
015cf297
PR
97#interfaces in br-bfd0 and br-bfd1. When br-sw is dropping all packets, BFD should detect
98# that the tunnel is down, and come back up when br-sw is working fine.
99
015cf297
PR
100OVS_VSWITCHD_START(
101 [add-br br-bfd0 -- \
102 set bridge br-bfd0 datapath-type=dummy \
103 other-config:hwaddr=aa:55:aa:56:00:00 -- \
104 add-br br-bfd1 -- \
105 set bridge br-bfd1 datapath-type=dummy \
106 other-config:hwaddr=aa:55:aa:57:00:00 -- \
107 add-br br-sw -- \
108 set bridge br-sw datapath-type=dummy \
109 other-config:hwaddr=aa:55:aa:58:00:00 -- \
110 add-port br-sw p1-sw -- set Interface p1-sw type=patch \
125bf01d 111 options:peer=p1 ofport_request=2 -- \
015cf297 112 add-port br-sw p0-sw -- set Interface p0-sw type=patch \
125bf01d 113 options:peer=p0 ofport_request=1 -- \
015cf297
PR
114 add-port br-bfd1 p1 -- set Interface p1 type=patch \
115 options:peer=p1-sw bfd:enable=true -- \
116 add-port br-bfd0 p0 -- set Interface p0 type=patch \
117 options:peer=p0-sw bfd:enable=true --])
118
43d66d3b 119ovs-appctl time/stop
015cf297
PR
120
121#Create 2 bridges connected by patch ports and enable BFD
122
123AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
124#Verify that BFD is enabled.
8661af79 125ovs-appctl time/warp 4100 100
015cf297
PR
126BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
127BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
128
129#Drop all packets in the br-sw bridge so that the tunnel is down.
130AT_CHECK([ ovs-ofctl add-flow br-sw 'priority=5,actions=drop' ])
8661af79 131ovs-appctl time/warp 4100 100
015cf297
PR
132BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
133BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
134
135#Delete the added flow
136AT_CHECK([ovs-ofctl del-flows br-sw], [0])
137AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
138#Verify that BFD is back up again.
8661af79 139ovs-appctl time/warp 4100 100
015cf297
PR
140
141BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
142BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
143
144#Now, Verify one-side tunnel down detection
145#When br-sw is dropping packets from one end, BFD should detect
146# that the tunnel is down, and come back up when br-sw is working fine.
147
148#Bring down the br-bfd1 - br-sw link. So BFD packets will be sent from p0,
149# but not received by p1. p0 will receive all BFD packets from p1.
150
151AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=1,priority=5,actions=drop'])
8661af79 152ovs-appctl time/warp 4100 100
015cf297
PR
153# Make sure p1 BFD state is down since it received no BFD packets.
154BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
8661af79
GS
155ovs-appctl time/warp 4100 100
156
015cf297
PR
157# p0 will be in init state once it receives "down" BFD message from p1.
158BFD_CHECK([p0], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
159
160AT_CHECK([ovs-ofctl del-flows br-sw])
161AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
162#Ensure that BFD is back up again.
163
8661af79 164ovs-appctl time/warp 1100 100
015cf297
PR
165#Bring down the br-bfd0 - br-sw link
166AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=2,priority=5,actions=drop'])
8661af79 167ovs-appctl time/warp 4100 100
015cf297 168BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
8661af79 169ovs-appctl time/warp 4100 100
015cf297
PR
170BFD_CHECK([p1], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
171OVS_VSWITCHD_STOP
172AT_CLEANUP
173
174
175AT_SETUP([bfd - concatenated path down])
176#Create 2 bridges connected by patch ports and enable BFD
015cf297 177OVS_VSWITCHD_START()
43d66d3b 178ovs-appctl time/stop
015cf297
PR
179AT_CHECK([ ovs-vsctl -- add-br br1 -- \
180 set bridge br1 datapath-type=dummy \
181 other-config:hwaddr=aa:55:aa:56:00:00 ])
015cf297
PR
182AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
183 options:peer=p0 ])
184AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
185 options:peer=p1 ])
186AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
187AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
8661af79 188ovs-appctl time/warp 4100 100
015cf297
PR
189
190#Verify that BFD has been enabled on both interfaces.
191BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
192BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
193
194#Set cpath_down to true on one interface, make sure the remote interface updates its values.
195AT_CHECK([ovs-vsctl set interface p0 bfd:cpath_down=true])
8661af79 196ovs-appctl time/warp 4100 100
015cf297
PR
197BFD_CHECK([p1], [false], [false], [none], [up], [No Diagnostic], [none], [up], [Concatenated Path Down])
198OVS_VSWITCHD_STOP
199AT_CLEANUP
200
201
202AT_SETUP([bfd - Edit the Min Tx/Rx values])
203#Create 2 bridges connected by patch ports and enable BFD
015cf297 204OVS_VSWITCHD_START()
43d66d3b 205ovs-appctl time/stop
015cf297
PR
206AT_CHECK([ ovs-vsctl -- add-br br1 -- \
207 set bridge br1 datapath-type=dummy ])
208AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
209 options:peer=p0 ])
210AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
211 options:peer=p1 ])
212AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
213AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
8661af79 214ovs-appctl time/warp 3100 100
015cf297
PR
215#Verify that BFD has been enabled on both interfaces.
216BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
217BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
218#Edit the min Tx value.
219AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200])
8661af79 220ovs-appctl time/warp 2100 100
c1c4e8c7
AW
221BFD_CHECK_TX([p0], [1000ms], [200ms], [100ms])
222BFD_CHECK_TX([p1], [1000ms], [100ms], [200ms])
015cf297
PR
223
224#Edit the min Rx value.
225AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300])
8661af79 226ovs-appctl time/warp 2100 100
c1c4e8c7
AW
227BFD_CHECK_RX([p1], [300ms], [300ms], [1000ms])
228BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
015cf297
PR
229
230OVS_VSWITCHD_STOP
231AT_CLEANUP
2d21cf72
AW
232
233AT_SETUP([bfd - check_tnl_key])
234OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
235 options:remote_ip=2.2.2.2 options:key=1 ofport_request=1 -- \
236 set interface p1 bfd:enable=true -- \
237 set bridge br0 fail-mode=standalone])
238
239# by default check_tnl_key is false. so we should process a bfd packet with tun_id=1.
6f068379 240AT_CHECK([ovs-appctl ofproto/trace --l7-len 0 ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,tp_src=0,tp_dst=0,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),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
2d21cf72
AW
241# check that the packet should be handled as BFD packet.
242AT_CHECK([tail -2 stdout], [0], [dnl
243This flow is handled by the userspace slow path because it:
393e9f7c 244 - Consists of BFD packets.
2d21cf72
AW
245], [])
246
247# turn on the check_tnl_key.
248AT_CHECK([ovs-vsctl set interface p1 bfd:check_tnl_key=true])
2d18eae8 249AT_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,tp_src=0,tp_dst=0,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),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
2d21cf72
AW
250# check that the packet should be handled as normal packet.
251AT_CHECK([tail -1 stdout], [0],[dnl
252Datapath actions: 100
253], [])
254
255# set the tunnel key to 0.
256AT_CHECK([ovs-vsctl set interface p1 options:key=0])
6f068379 257AT_CHECK([ovs-appctl ofproto/trace --l7-len 0 ovs-dummy 'tunnel(tun_id=0x0,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,tp_src=0,tp_dst=0,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),udp(src=49152/0,dst=3784/0xffff)' -generate], [0], [stdout])
2d21cf72
AW
258# check that the packet should be handled as BFD packet.
259AT_CHECK([tail -2 stdout], [0], [dnl
260This flow is handled by the userspace slow path because it:
393e9f7c 261 - Consists of BFD packets.
2d21cf72
AW
262], [])
263
264OVS_VSWITCHD_STOP
265AT_CLEANUP
c1c4e8c7
AW
266
267# Tests below are for bfd decay features.
268AT_SETUP([bfd - bfd decay])
269OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
270 add-port br1 p1 -- set Interface p1 type=patch \
271 options:peer=p0 ofport_request=2 -- \
272 add-port br0 p0 -- set Interface p0 type=patch \
273 options:peer=p1 ofport_request=1 -- \
3688ce7a 274 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
c1c4e8c7
AW
275 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
276
277ovs-appctl time/stop
c1c4e8c7 278
3688ce7a 279# wait for a while to stablize everything.
8661af79 280ovs-appctl time/warp 10000 500
3688ce7a
AW
281BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
282BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
283BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
284BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
c1c4e8c7
AW
285
286# Test-1 BFD decay: decay to decay_min_rx
3688ce7a 287AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=3000])
c1c4e8c7 288# bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up,
27e26e59 289# so for the first 2000ms, there should be no change.
8661af79 290ovs-appctl time/warp 2000 500
c1c4e8c7
AW
291BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
292BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
293
27e26e59 294# advance the clock by 5000ms.
8661af79 295ovs-appctl time/warp 5000 500
3688ce7a 296# now, min_rx should decay to 3000ms.
c1c4e8c7
AW
297BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
298BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
299
898dcef1 300# advance clock by 5000ms and check the flags are all 'none'.
8661af79 301ovs-appctl time/warp 5000 500
c1c4e8c7 302BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
3688ce7a 303BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
c1c4e8c7
AW
304BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
305BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
306# End of Test-1 ###############################################################
307
308
27e26e59 309# Test-2 BFD decay: go back to min_rx when there is traffic
3688ce7a
AW
310# receive packet at 1/100ms rate for 5000ms.
311for i in `seq 0 49`
c1c4e8c7
AW
312do
313 ovs-appctl time/warp 100
6dd3c787 314 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
c1c4e8c7
AW
315 [0], [stdout], [])
316done
317# after a decay interval (3000ms), the p0 min_rx will go back to
27e26e59 318# min_rx.
c1c4e8c7
AW
319BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
320BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
321# End of Test-2 ###############################################################
322
323
27e26e59
AW
324# Test-3 BFD decay: set decay_min_rx to 1000ms.
325# this should firstly reset the min_rx and then re-decay to 1000ms.
326AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
327# advance the clock by 10000ms, decay should have happened.
8661af79 328ovs-appctl time/warp 10000 500
c1c4e8c7
AW
329BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
330BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
c1c4e8c7
AW
331BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
332BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
c1c4e8c7
AW
333# End of Test-3 ###############################################################
334
335
27e26e59
AW
336# Test-4 BFD decay: set decay_min_rx to 0 to disable bfd decay.
337AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
338# advance the clock by 5000ms.
8661af79 339ovs-appctl time/warp 10000 500
27e26e59 340# min_rx is reset.
c1c4e8c7 341BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
27e26e59 342BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
881d47a9 343
c1c4e8c7
AW
344for i in `seq 0 20`
345do
346 ovs-appctl time/warp 500
347 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
348 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
349 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
350 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
351done
27e26e59 352# End of Test-4 ################################################################
c1c4e8c7
AW
353
354
27e26e59 355# Test-5 BFD decay: rmt_min_tx is greater than decay_min_rx
c1c4e8c7 356AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface p1 bfd:min_tx=5000])
27e26e59 357# advance the clock by 10000ms to stable everything.
8661af79 358ovs-appctl time/warp 10000 500
27e26e59
AW
359BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
360BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
361# p0 rx should show 5000ms even if it is in decay.
c1c4e8c7
AW
362BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
363BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
364# then, there should be no change of status,
27e26e59 365for i in `seq 0 19`
c1c4e8c7
AW
366do
367 ovs-appctl time/warp 500
368 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
369 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
370 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
371 BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
372done
373# reset the p1's min_tx to 500ms.
374AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
27e26e59 375# advance the clock by 20000ms to stable everything.
3688ce7a 376# since p0 has been in decay, now the RX will show 3000ms.
8661af79 377ovs-appctl time/warp 20000 500
c1c4e8c7
AW
378BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
379BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
27e26e59 380# End of Test-5 ###############################################################
c1c4e8c7
AW
381
382
27e26e59 383# Test-6 BFD decay: state up->down->up.
c1c4e8c7
AW
384# turn bfd off on p1
385AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false])
386
27e26e59 387# advance the clock by 15000ms to stable everything.
8661af79 388ovs-appctl time/warp 15000 1000
c1c4e8c7
AW
389BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
390BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
391BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
392
393# resume the bfd on p1. the bfd should not go to decay mode direclty.
394AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
8661af79 395ovs-appctl time/warp 1500 500
c1c4e8c7
AW
396BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
397BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
398
3688ce7a 399# since the decay_min_rx is still 3000ms, so after 5000ms, p0 should have decayed.
8661af79 400ovs-appctl time/warp 5000 500
c1c4e8c7
AW
401BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
402BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
27e26e59 403# End of Test-6 ################################################################
c1c4e8c7
AW
404
405OVS_VSWITCHD_STOP
01d18a3a
AW
406AT_CLEANUP
407
408# Tests below are for bfd forwarding_if_rx feature.
309d9dac
AW
409
410# forwarding_if_rx Test1
411# Test1 tests the case when bfd is only enabled on one end of the link.
34c88624
AW
412# Under this situation, the forwarding flag should always be false, even
413# though there is data packet received, since there is no bfd control
414# packet received during the demand_rx_bfd interval.
309d9dac 415AT_SETUP([bfd - bfd forwarding_if_rx - bfd on one side])
01d18a3a
AW
416OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
417 add-port br1 p1 -- set Interface p1 type=patch \
418 options:peer=p0 ofport_request=2 -- \
419 add-port br0 p0 -- set Interface p0 type=patch \
420 options:peer=p1 ofport_request=1 -- \
421 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
422 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
423
424ovs-appctl time/stop
425# check the inital status.
426BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
427BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
428BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
429
430# enable forwarding_if_rx.
431AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
432
433# there should be no change of forwarding flag, since
434# there is no traffic.
435for i in `seq 0 3`
436do
437 ovs-appctl time/warp 500
438 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
439done
440
3688ce7a
AW
441# receive packet at 1/100ms rate for 2000ms.
442for i in `seq 0 19`
01d18a3a
AW
443do
444 ovs-appctl time/warp 100
6dd3c787 445 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
446 [0], [stdout], [])
447done
34c88624 448# the forwarding flag should be false, due to the demand_rx_bfd.
01d18a3a 449BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
01d18a3a
AW
450
451AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 452OVS_VSWITCHD_STOP
01d18a3a
AW
453AT_CLEANUP
454
309d9dac
AW
455
456# forwarding_if_rx Test2
457# Test2 is for testing that the enable of forwarding_if_rx will not
458# affect the normal bfd communication. bfd is enabled on both ends of
459# the link.
460AT_SETUP([bfd - bfd forwarding_if_rx - bfd on both sides])
01d18a3a
AW
461OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
462 add-port br1 p1 -- set Interface p1 type=patch \
463 options:peer=p0 ofport_request=2 -- \
464 add-port br0 p0 -- set Interface p0 type=patch \
465 options:peer=p1 ofport_request=1 -- \
466 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
467 set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
468 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
469
470ovs-appctl time/stop
471# advance the clock, to stablize the states.
8661af79 472ovs-appctl time/warp 5000 500
01d18a3a
AW
473
474# enable forwarding_if_rx.
475AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
476
477# there should be no change of the forwarding flag, since
478# the bfd on both ends is already up.
479for i in `seq 0 5`
480do
481 ovs-appctl time/warp 500
482 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
483done
484
485# stop the bfd on one side.
486AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
487# for within 1500ms, the detection timer is not out.
488# there is no change to status.
489for i in `seq 0 1`
490do
491 ovs-appctl time/warp 500
492 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
3688ce7a 493 for i in `seq 0 4`
01d18a3a 494 do
6dd3c787 495 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
496 [0], [stdout], [])
497 done
498done
499
500# at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired.
501# but forwarding flag should be still true.
502ovs-appctl time/warp 500
503BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
504
01d18a3a
AW
505# reset bfd forwarding_if_rx.
506AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
507# forwarding flag should turn to false since the STATE is DOWN.
508BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
509
510# re-enable bfd on the other end. the states should be up.
511AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
512# advance the clock, to stablize the states.
8661af79 513ovs-appctl time/warp 5000 500
01d18a3a
AW
514BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
515BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
516BFD_CHECK_TX([p0], [500ms], [500ms], [300ms])
517BFD_CHECK_RX([p0], [500ms], [500ms], [300ms])
518
519AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 520OVS_VSWITCHD_STOP
01d18a3a
AW
521AT_CLEANUP
522
309d9dac
AW
523# forwarding_if_rx Test3
524# Test3 is for testing that the enable of forwarding_if_rx will not
525# affect the bfd decay feature. bfd is enabled on both ends of the link.
526AT_SETUP([bfd - bfd forwarding_if_rx - with bfd decay])
01d18a3a
AW
527OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
528 add-port br1 p1 -- set Interface p1 type=patch \
529 options:peer=p0 ofport_request=2 -- \
530 add-port br0 p0 -- set Interface p0 type=patch \
531 options:peer=p1 ofport_request=1 -- \
532 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:decay_min_rx=3000 -- \
533 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
534
535ovs-appctl time/stop
536# advance the clock, to stablize the states.
8661af79 537ovs-appctl time/warp 10000 500
01d18a3a
AW
538BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
539BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
540BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
541BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
542
543# enable forwarding_if_rx.
544AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
545
546# there should be no change of the forwarding flag, since
547# the bfd on both ends is already up.
548for i in `seq 0 9`
549do
550 ovs-appctl time/warp 500
551 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
552done
553
3688ce7a 554# reconfigure the decay_min_rx to 1000ms.
01d18a3a 555AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
01d18a3a 556
3688ce7a 557# wait for 5000ms to decay.
8661af79 558ovs-appctl time/warp 5000 500
309d9dac 559BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
01d18a3a
AW
560BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
561BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
562
563# stop the bfd on one side.
564AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
3688ce7a
AW
565
566# advance clock by 4000ms, while receiving packets.
567# the STATE should go DOWN, due to Control Detection Time Expired.
568# but forwarding flag should be still true.
569for i in `seq 0 7`
01d18a3a
AW
570do
571 ovs-appctl time/warp 500
6dd3c787 572 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
573 [0], [stdout], [])
574done
01d18a3a
AW
575BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
576
577# receive packet at 1/100ms rate for 1000ms.
578for i in `seq 0 9`
579do
6dd3c787 580 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
581 [0], [stdout], [])
582 ovs-appctl time/warp 100
583 # the forwarding flag should always be true during this time.
584 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
585done
586
309d9dac 587# stop receiving for 5000ms.
8661af79 588ovs-appctl time/warp 5000 100
01d18a3a
AW
589BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
590
591# reset bfd forwarding_if_rx.
592AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false])
01d18a3a 593BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
594# re-enable bfd forwarding_if_rx.
595AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true])
01d18a3a 596BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
597
598# re-enable bfd on the other end. the states should be up.
599AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
600# advance the clock, to stablize the states.
8661af79 601ovs-appctl time/warp 10000 500
01d18a3a
AW
602BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
603BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
604BFD_CHECK_TX([p0], [300ms], [300ms], [300ms])
605BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
606
607AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 608OVS_VSWITCHD_STOP
4905e2df
AW
609AT_CLEANUP
610
34c88624
AW
611# forwarding_if_rx Test4
612# Test4 is for testing the demand_rx_bfd feature.
613# bfd is enabled on both ends of the link.
614AT_SETUP([bfd - bfd forwarding_if_rx - demand_rx_bfd])
615OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
616 add-port br1 p1 -- set Interface p1 type=patch \
617 options:peer=p0 ofport_request=2 -- \
618 add-port br0 p0 -- set Interface p0 type=patch \
619 options:peer=p1 ofport_request=1 -- \
620 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:forwarding_if_rx=true -- \
621 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
622
623ovs-appctl time/stop
624# advance the clock, to stablize the states.
8661af79 625ovs-appctl time/warp 10000 500
34c88624
AW
626BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
627BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
628BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
629
630# disable the bfd on p1.
631AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
632
633# advance clock by 4000ms, while receiving packets.
634# the STATE should go DOWN, due to Control Detection Time Expired.
635# but forwarding flag should be still true.
636for i in `seq 0 7`
637do
638 ovs-appctl time/warp 500
6dd3c787 639 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
34c88624
AW
640 [0], [stdout], [])
641done
642BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
643
644# advance clock long enough to trigger the demand_bfd_rx interval
645# (100 * bfd->cfm_min_rx), forwarding flag should go down since there
646# is no bfd control packet received during the demand_rx_bfd.
647for i in `seq 0 120`
648do
649 ovs-appctl time/warp 300
6dd3c787 650 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
34c88624
AW
651 [0], [stdout], [])
652done
653BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
654
655# now enable the bfd on p1 again.
656AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true], [0])
657# advance clock by 5000ms. and p1 and p0 should be all up.
8661af79 658ovs-appctl time/warp 5000 500
34c88624
AW
659BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
660BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
661BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
662
663# disable the bfd on p1 again.
664AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
665# advance clock long enough to trigger the demand_rx_bfd,
666# forwarding flag should go down since there is no bfd control packet
667# received during the demand_rx_bfd.
668for i in `seq 0 120`
669do
670 ovs-appctl time/warp 300
6dd3c787 671 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
34c88624
AW
672 [0], [stdout], [])
673done
674BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
675
676AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 677OVS_VSWITCHD_STOP
34c88624
AW
678AT_CLEANUP
679
4905e2df 680# test bfd:flap_count.
309d9dac
AW
681# This test contains three part:
682# part 1. tests the flap_count on normal bfd monitored link.
683# part 2. tests the flap_count when forwarding override is used.
684# part 3. tests the flap_count when forwarding_if_rx is enabled.
4905e2df
AW
685AT_SETUP([bfd - flap_count])
686#Create 2 bridges connected by patch ports and enable bfd
687OVS_VSWITCHD_START([add-br br1 -- \
688 set bridge br1 datapath-type=dummy \
689 other-config:hwaddr=aa:55:aa:56:00:00 -- \
690 add-port br1 p1 -- set Interface p1 type=patch \
691 options:peer=p0 ofport_request=2 -- \
692 add-port br0 p0 -- set Interface p0 type=patch \
693 options:peer=p1 ofport_request=1 -- \
694 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
695 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
696
697ovs-appctl time/stop
5eca22a2
AW
698# Disable the stats update to prevent the race between ovsdb updating
699# stats and ovs-vsctl cmd closing the jsonrpc session.
700AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
4905e2df
AW
701
702# Part-1 wait for a while to stablize bfd.
8661af79 703ovs-appctl time/warp 10100 100
4905e2df
AW
704BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
705BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
706BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
707BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
708# both p0 and p1 should have flap_count = "1". since down->up.
709BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
710BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
711
712# turn bfd on p1 off, should increment the bfd:flap_count on p0.
713AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
8661af79 714ovs-appctl time/warp 5000 100
4905e2df
AW
715BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
716BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
717AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
718
719# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
720# p1 should still have flap_count = "1", since it is reset.
721AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 722ovs-appctl time/warp 5000 100
4905e2df
AW
723BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
724BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
725
726
727# Part-2 now turn on the forwarding_override.
728AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl
729OK
730])
731
732# turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on.
733AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
8661af79 734ovs-appctl time/warp 5000 100
4905e2df
AW
735BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
736BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
737AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
738
739# turn bfd on p1 on again, should not increment the bfd:flap_count on p0, since forwarding override is on.
740# p1 should still have flap_count = "1", since it is reset.
741AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 742ovs-appctl time/warp 5000 100
4905e2df
AW
743BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
744BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
745
746# turn the forwarding_override back to normal.
747AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl
748OK
749])
750
751# turn bfd on p1 off and on, should increment the bfd:flap_count on p0.
752AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
8661af79 753ovs-appctl time/warp 5000 100
4905e2df 754AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 755ovs-appctl time/warp 5000 100
4905e2df
AW
756BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
757BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
758
759# Part-3 now turn on forwarding_if_rx.
760AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
8661af79 761ovs-appctl time/warp 1100 100
4905e2df
AW
762# disable the bfd on p1.
763AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
764
765# advance clock by 4000ms, while receiving packets.
766# the STATE should go DOWN, due to Control Detection Time Expired.
767# but forwarding flag should be true.
768for i in `seq 0 39`
769do
770 ovs-appctl time/warp 100
6dd3c787 771 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
4905e2df
AW
772 [0], [stdout], [])
773done
774BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
775# flap_count should remain unchanged.
776BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
777
34c88624 778# stop the traffic for more than 100 * bfd->cfm_min_rx ms, the forwarding flag of p0 should turn false.
4905e2df 779# and there should be the increment of flap_count.
8661af79 780ovs-appctl time/warp 12100 100
4905e2df
AW
781BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
782BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
783
784# advance clock by 4000ms, and resume the traffic.
785for i in `seq 0 39`
786do
787 ovs-appctl time/warp 100
6dd3c787 788 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
4905e2df
AW
789 [0], [stdout], [])
790done
34c88624 791# forwarding should be false, since there is still no bfd control packet received.
4905e2df 792BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
34c88624 793BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
4905e2df
AW
794
795# turn on the bfd on p1.
796AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 797ovs-appctl time/warp 5000 100
4905e2df 798# even though there is no data traffic, since p1 bfd is on again, should increment the flap_count.
34c88624 799BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"])
4905e2df
AW
800BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
801
802OVS_VSWITCHD_STOP
8661af79 803AT_CLEANUP
67818616
MV
804
805AT_SETUP([bfd - check that BFD works together with RSTP])
806# Create br0 with interfaces p1
807# and br1 with interfaces p2
808# with p1 and p2 connected via unix domain socket
809OVS_VSWITCHD_START(
810 [set bridge br0 rstp_enable=true -- \
811 add-br br1 -- \
812 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
813 set bridge br1 datapath-type=dummy -- \
814 set bridge br1 rstp_enable=true -- \
815])
816
817AT_CHECK([ovs-vsctl add-port br0 p1 -- \
818 set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock bfd:enable=true -- \
819])
820
821AT_CHECK([ovs-vsctl add-port br1 p2 -- \
822 set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock bfd:enable=true -- \
823])
824
825ovs-appctl time/stop
826ovs-appctl time/warp 4100 100
827
828# Forwarding should be true
829BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
830BFD_CHECK([p2], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
831
832# Disable bfd on p2, forwarding on p1 should go to false
833AT_CHECK([ovs-vsctl set interface p2 bfd:enable=false])
834
835ovs-appctl time/warp 5000 100
836BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
837
838OVS_VSWITCHD_STOP
839AT_CLEANUP
f73b83fd
LS
840
841# test bfd: liveness propagation - OF1.3.
842AT_SETUP([bfd - liveness propagation - OF1.3])
843OVS_VSWITCHD_START
844AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
845check_liveness () {
846 printf '\n\n--- check_liveness %d ---\n\n\n' $1
847 shift
848
5a0e4aec 849 echo >>expout "OFPT_PORT_STATUS (OF1.3): MOD: 1(p0): addr:
f73b83fd
LS
850 config: 0
851 state: $1
852 speed: 0 Mbps now, 0 Mbps max"
853
5a0e4aec 854 AT_CHECK(
f73b83fd
LS
855 [[sed '
856s/ (xid=0x[0-9a-fA-F]*)//
857s/ *duration.*//
858s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
859 [0], [expout])
860}
861: > expout
862ovs-appctl -t ovs-ofctl ofctl/barrier
863ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
864# Set miss_send_len to 128, enabling port_status messages to our service connection.
865ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
866#Create 2 bridges connected by patch ports and enable bfd
867AT_CHECK([ovs-vsctl add-br br1 -- \
868 set bridge br1 datapath-type=dummy \
869 other-config:hwaddr=aa:55:aa:56:00:00 -- \
870 add-port br1 p1 -- set Interface p1 type=patch \
871 options:peer=p0 ofport_request=2 -- \
872 add-port br0 p0 -- set Interface p0 type=patch \
873 options:peer=p1 ofport_request=1 -- \
874 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
875 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
876
877ovs-appctl time/stop
878# Disable the stats update to prevent the race between ovsdb updating
879# stats and ovs-vsctl cmd closing the jsonrpc session.
880AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
881
882# wait for a while to stablize bfd.
883ovs-appctl time/warp 10100 100
884BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
885BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
886BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
887BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
888# both p0 and p1 should have flap_count = "1". since down->up.
889BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
890BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
891check_liveness 1 LIVE
892
893# turn bfd on p1 off, should increment the bfd:flap_count on p0.
894AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
895ovs-appctl time/warp 5000 100
896BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
897BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
898AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
899check_liveness 2 0
900
901# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
902# p1 should still have flap_count = "1", since it is reset.
903AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
904ovs-appctl time/warp 5000 100
905BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
906BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
907check_liveness 3 LIVE
908
909OVS_VSWITCHD_STOP
910AT_CLEANUP
911
912# test bfd: liveness propagation - OF1.4.
913AT_SETUP([bfd - liveness propagation - OF1.4])
914OVS_VSWITCHD_START
915AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile])
916check_liveness () {
917 printf '\n\n--- check_liveness %d ---\n\n\n' $1
918 shift
919
5a0e4aec 920 echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: 1(p0): addr:
f73b83fd
LS
921 config: 0
922 state: $1
923 speed: 0 Mbps now, 0 Mbps max"
924
5a0e4aec 925 AT_CHECK(
f73b83fd
LS
926 [[sed '
927s/ (xid=0x[0-9a-fA-F]*)//
928s/ *duration.*//
929s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
930 [0], [expout])
931}
932: > expout
933ovs-appctl -t ovs-ofctl ofctl/barrier
934ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
935# Set miss_send_len to 128, enabling port_status messages to our service connection.
936ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
937#Create 2 bridges connected by patch ports and enable bfd
938AT_CHECK([ovs-vsctl add-br br1 -- \
939 set bridge br1 datapath-type=dummy \
940 other-config:hwaddr=aa:55:aa:56:00:00 -- \
941 add-port br1 p1 -- set Interface p1 type=patch \
942 options:peer=p0 ofport_request=2 -- \
943 add-port br0 p0 -- set Interface p0 type=patch \
944 options:peer=p1 ofport_request=1 -- \
945 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
946 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
947
948ovs-appctl time/stop
949# Disable the stats update to prevent the race between ovsdb updating
950# stats and ovs-vsctl cmd closing the jsonrpc session.
951AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
952
953# wait for a while to stablize bfd.
954ovs-appctl time/warp 10100 100
955BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
956BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
957BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
958BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
959# both p0 and p1 should have flap_count = "1". since down->up.
960BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
961BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
962check_liveness 1 LIVE
963
964# turn bfd on p1 off, should increment the bfd:flap_count on p0.
965AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
966ovs-appctl time/warp 5000 100
967BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
968BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
969AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
970check_liveness 2 0
971
972# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
973# p1 should still have flap_count = "1", since it is reset.
974AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
975ovs-appctl time/warp 5000 100
976BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
977BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
978check_liveness 3 LIVE
979
980OVS_VSWITCHD_STOP
981AT_CLEANUP
982
983# test bfd: liveness propagation - OF1.5.
984AT_SETUP([bfd - liveness propagation - OF1.5])
985OVS_VSWITCHD_START
986AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
987check_liveness () {
988 printf '\n\n--- check_liveness %d ---\n\n\n' $1
989 shift
990
5a0e4aec 991 echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: 1(p0): addr:
f73b83fd
LS
992 config: 0
993 state: $1
994 speed: 0 Mbps now, 0 Mbps max"
995
5a0e4aec 996 AT_CHECK(
f73b83fd
LS
997 [[sed '
998s/ (xid=0x[0-9a-fA-F]*)//
999s/ *duration.*//
1000s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
1001 [0], [expout])
1002}
1003: > expout
1004ovs-appctl -t ovs-ofctl ofctl/barrier
1005ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1006# Set miss_send_len to 128, enabling port_status messages to our service connection.
1007ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
1008#Create 2 bridges connected by patch ports and enable bfd
1009AT_CHECK([ovs-vsctl add-br br1 -- \
1010 set bridge br1 datapath-type=dummy \
1011 other-config:hwaddr=aa:55:aa:56:00:00 -- \
1012 add-port br1 p1 -- set Interface p1 type=patch \
1013 options:peer=p0 ofport_request=2 -- \
1014 add-port br0 p0 -- set Interface p0 type=patch \
1015 options:peer=p1 ofport_request=1 -- \
1016 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
1017 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
1018
1019ovs-appctl time/stop
1020# Disable the stats update to prevent the race between ovsdb updating
1021# stats and ovs-vsctl cmd closing the jsonrpc session.
1022AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
1023
1024# wait for a while to stablize bfd.
1025ovs-appctl time/warp 10100 100
1026BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1027BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1028BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
1029BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
1030# both p0 and p1 should have flap_count = "1". since down->up.
1031BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1032BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1033check_liveness 1 LIVE
1034
1035# turn bfd on p1 off, should increment the bfd:flap_count on p0.
1036AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
1037ovs-appctl time/warp 5000 100
1038BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
1039BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
1040AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
1041check_liveness 2 0
1042
1043# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
1044# p1 should still have flap_count = "1", since it is reset.
1045AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
1046ovs-appctl time/warp 5000 100
1047BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
1048BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1049check_liveness 3 LIVE
1050
1051OVS_VSWITCHD_STOP
1052AT_CLEANUP
4cefc3da
SG
1053
1054AT_SETUP([bfd - Edit the Detect Mult values])
1055#Create 2 bridges connected by patch ports and enable BFD
1056OVS_VSWITCHD_START()
1057ovs-appctl time/stop
1058AT_CHECK([ ovs-vsctl -- add-br br1 -- \
1059 set bridge br1 datapath-type=dummy ])
1060AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch\
1061 options:peer=p0 ])
1062AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch\
1063 options:peer=p1 ])
1064AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
1065AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
1066ovs-appctl time/warp 3100 100
1067#Verify that BFD has been enabled on both interfaces.
1068BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1069BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1070#Verify that default mult values are 3.
1071BFD_CHECK_MULT([p0], [3], [3])
1072BFD_CHECK_MULT([p1], [3], [3])
1073#Set the mult values to valid range border mult(p0)=1 mult(p1)=255.
1074AT_CHECK([ovs-vsctl set interface p0 bfd:mult=1])
1075AT_CHECK([ovs-vsctl set interface p1 bfd:mult=255])
1076ovs-appctl time/warp 3100 100
1077BFD_CHECK_MULT([p0], [1], [255])
1078BFD_CHECK_MULT([p1], [255], [1])
1079
1080#Set the mult values out valid range border mult(p0)=0 mult(p1)=256.
1081AT_CHECK([ovs-vsctl set interface p0 bfd:mult=0])
1082AT_CHECK([ovs-vsctl set interface p1 bfd:mult=256])
1083ovs-appctl time/warp 3100 100
1084BFD_CHECK_MULT([p0], [3], [3])
1085BFD_CHECK_MULT([p1], [3], [3])
1086
1087#Set valid non default mult values mult(p0)=8 mult(p1)=125.
1088AT_CHECK([ovs-vsctl set interface p0 bfd:mult=8])
1089AT_CHECK([ovs-vsctl set interface p1 bfd:mult=125])
1090ovs-appctl time/warp 3100 100
1091BFD_CHECK_MULT([p0], [8], [125])
1092BFD_CHECK_MULT([p1], [125], [8])
1093
1094#Clear mult values. Detect mult values shall be default 3 again.
1095AT_CHECK([ovs-vsctl remove interface p0 bfd mult])
1096AT_CHECK([ovs-vsctl remove interface p1 bfd mult])
1097ovs-appctl time/warp 3100 100
1098BFD_CHECK_MULT([p0], [3], [3])
1099BFD_CHECK_MULT([p1], [3], [3])
1100
1101OVS_VSWITCHD_STOP
1102AT_CLEANUP