]> git.proxmox.com Git - ovs.git/blame - tests/bfd.at
Fix ovs-dpctl-top by removing 3 wrong hunks in py3-compat.patch.
[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])
804ef1a7 269AT_SKIP_IF([test "$IS_ARM64" = "yes"])
c1c4e8c7
AW
270OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
271 add-port br1 p1 -- set Interface p1 type=patch \
272 options:peer=p0 ofport_request=2 -- \
273 add-port br0 p0 -- set Interface p0 type=patch \
274 options:peer=p1 ofport_request=1 -- \
3688ce7a 275 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
c1c4e8c7
AW
276 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
277
278ovs-appctl time/stop
c1c4e8c7 279
3688ce7a 280# wait for a while to stablize everything.
8661af79 281ovs-appctl time/warp 10000 500
3688ce7a
AW
282BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
283BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
284BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
285BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
c1c4e8c7
AW
286
287# Test-1 BFD decay: decay to decay_min_rx
3688ce7a 288AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=3000])
c1c4e8c7 289# bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up,
27e26e59 290# so for the first 2000ms, there should be no change.
8661af79 291ovs-appctl time/warp 2000 500
c1c4e8c7
AW
292BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
293BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
294
27e26e59 295# advance the clock by 5000ms.
8661af79 296ovs-appctl time/warp 5000 500
3688ce7a 297# now, min_rx should decay to 3000ms.
c1c4e8c7
AW
298BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
299BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
300
898dcef1 301# advance clock by 5000ms and check the flags are all 'none'.
8661af79 302ovs-appctl time/warp 5000 500
c1c4e8c7 303BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
3688ce7a 304BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
c1c4e8c7
AW
305BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
306BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
307# End of Test-1 ###############################################################
308
309
27e26e59 310# Test-2 BFD decay: go back to min_rx when there is traffic
3688ce7a
AW
311# receive packet at 1/100ms rate for 5000ms.
312for i in `seq 0 49`
c1c4e8c7
AW
313do
314 ovs-appctl time/warp 100
6dd3c787 315 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
c1c4e8c7
AW
316 [0], [stdout], [])
317done
318# after a decay interval (3000ms), the p0 min_rx will go back to
27e26e59 319# min_rx.
c1c4e8c7
AW
320BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
321BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
322# End of Test-2 ###############################################################
323
324
27e26e59
AW
325# Test-3 BFD decay: set decay_min_rx to 1000ms.
326# this should firstly reset the min_rx and then re-decay to 1000ms.
327AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
328# advance the clock by 10000ms, decay should have happened.
8661af79 329ovs-appctl time/warp 10000 500
c1c4e8c7
AW
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])
c1c4e8c7
AW
332BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
333BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
c1c4e8c7
AW
334# End of Test-3 ###############################################################
335
336
27e26e59
AW
337# Test-4 BFD decay: set decay_min_rx to 0 to disable bfd decay.
338AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
339# advance the clock by 5000ms.
8661af79 340ovs-appctl time/warp 10000 500
27e26e59 341# min_rx is reset.
c1c4e8c7 342BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
27e26e59 343BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
881d47a9 344
c1c4e8c7
AW
345for i in `seq 0 20`
346do
347 ovs-appctl time/warp 500
348 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
349 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
350 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
351 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
352done
27e26e59 353# End of Test-4 ################################################################
c1c4e8c7
AW
354
355
27e26e59 356# Test-5 BFD decay: rmt_min_tx is greater than decay_min_rx
c1c4e8c7 357AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface p1 bfd:min_tx=5000])
27e26e59 358# advance the clock by 10000ms to stable everything.
8661af79 359ovs-appctl time/warp 10000 500
27e26e59
AW
360BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
361BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
362# p0 rx should show 5000ms even if it is in decay.
c1c4e8c7
AW
363BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
364BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
365# then, there should be no change of status,
27e26e59 366for i in `seq 0 19`
c1c4e8c7
AW
367do
368 ovs-appctl time/warp 500
369 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
370 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
371 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
372 BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
373done
374# reset the p1's min_tx to 500ms.
375AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
27e26e59 376# advance the clock by 20000ms to stable everything.
3688ce7a 377# since p0 has been in decay, now the RX will show 3000ms.
8661af79 378ovs-appctl time/warp 20000 500
c1c4e8c7
AW
379BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
380BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
27e26e59 381# End of Test-5 ###############################################################
c1c4e8c7
AW
382
383
27e26e59 384# Test-6 BFD decay: state up->down->up.
c1c4e8c7
AW
385# turn bfd off on p1
386AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false])
387
27e26e59 388# advance the clock by 15000ms to stable everything.
8661af79 389ovs-appctl time/warp 15000 1000
c1c4e8c7
AW
390BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
391BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
392BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
393
394# resume the bfd on p1. the bfd should not go to decay mode direclty.
395AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
8661af79 396ovs-appctl time/warp 1500 500
c1c4e8c7
AW
397BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
398BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
399
3688ce7a 400# since the decay_min_rx is still 3000ms, so after 5000ms, p0 should have decayed.
8661af79 401ovs-appctl time/warp 5000 500
c1c4e8c7
AW
402BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
403BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
27e26e59 404# End of Test-6 ################################################################
c1c4e8c7
AW
405
406OVS_VSWITCHD_STOP
01d18a3a
AW
407AT_CLEANUP
408
409# Tests below are for bfd forwarding_if_rx feature.
309d9dac
AW
410
411# forwarding_if_rx Test1
412# Test1 tests the case when bfd is only enabled on one end of the link.
34c88624
AW
413# Under this situation, the forwarding flag should always be false, even
414# though there is data packet received, since there is no bfd control
415# packet received during the demand_rx_bfd interval.
309d9dac 416AT_SETUP([bfd - bfd forwarding_if_rx - bfd on one side])
01d18a3a
AW
417OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
418 add-port br1 p1 -- set Interface p1 type=patch \
419 options:peer=p0 ofport_request=2 -- \
420 add-port br0 p0 -- set Interface p0 type=patch \
421 options:peer=p1 ofport_request=1 -- \
422 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
423 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
424
425ovs-appctl time/stop
426# check the inital status.
427BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
428BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
429BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
430
431# enable forwarding_if_rx.
432AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
433
434# there should be no change of forwarding flag, since
435# there is no traffic.
436for i in `seq 0 3`
437do
438 ovs-appctl time/warp 500
439 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
440done
441
3688ce7a
AW
442# receive packet at 1/100ms rate for 2000ms.
443for i in `seq 0 19`
01d18a3a
AW
444do
445 ovs-appctl time/warp 100
6dd3c787 446 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
447 [0], [stdout], [])
448done
34c88624 449# the forwarding flag should be false, due to the demand_rx_bfd.
01d18a3a 450BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
01d18a3a
AW
451
452AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 453OVS_VSWITCHD_STOP
01d18a3a
AW
454AT_CLEANUP
455
309d9dac
AW
456
457# forwarding_if_rx Test2
458# Test2 is for testing that the enable of forwarding_if_rx will not
459# affect the normal bfd communication. bfd is enabled on both ends of
460# the link.
461AT_SETUP([bfd - bfd forwarding_if_rx - bfd on both sides])
01d18a3a
AW
462OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
463 add-port br1 p1 -- set Interface p1 type=patch \
464 options:peer=p0 ofport_request=2 -- \
465 add-port br0 p0 -- set Interface p0 type=patch \
466 options:peer=p1 ofport_request=1 -- \
467 set Interface p0 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500 -- \
468 set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
469 add-port br1 p2 -- set Interface p2 type=internal ofport_request=3])
470
471ovs-appctl time/stop
472# advance the clock, to stablize the states.
8661af79 473ovs-appctl time/warp 5000 500
01d18a3a
AW
474
475# enable forwarding_if_rx.
476AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
477
478# there should be no change of the forwarding flag, since
479# the bfd on both ends is already up.
480for i in `seq 0 5`
481do
482 ovs-appctl time/warp 500
483 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
484done
485
486# stop the bfd on one side.
487AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
488# for within 1500ms, the detection timer is not out.
489# there is no change to status.
490for i in `seq 0 1`
491do
492 ovs-appctl time/warp 500
493 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
3688ce7a 494 for i in `seq 0 4`
01d18a3a 495 do
6dd3c787 496 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
497 [0], [stdout], [])
498 done
499done
500
501# at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired.
502# but forwarding flag should be still true.
503ovs-appctl time/warp 500
504BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
505
01d18a3a
AW
506# reset bfd forwarding_if_rx.
507AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
508# forwarding flag should turn to false since the STATE is DOWN.
509BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
510
511# re-enable bfd on the other end. the states should be up.
512AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
513# advance the clock, to stablize the states.
8661af79 514ovs-appctl time/warp 5000 500
01d18a3a
AW
515BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
516BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
517BFD_CHECK_TX([p0], [500ms], [500ms], [300ms])
518BFD_CHECK_RX([p0], [500ms], [500ms], [300ms])
519
520AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 521OVS_VSWITCHD_STOP
01d18a3a
AW
522AT_CLEANUP
523
309d9dac
AW
524# forwarding_if_rx Test3
525# Test3 is for testing that the enable of forwarding_if_rx will not
526# affect the bfd decay feature. bfd is enabled on both ends of the link.
527AT_SETUP([bfd - bfd forwarding_if_rx - with bfd decay])
01d18a3a
AW
528OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
529 add-port br1 p1 -- set Interface p1 type=patch \
530 options:peer=p0 ofport_request=2 -- \
531 add-port br0 p0 -- set Interface p0 type=patch \
532 options:peer=p1 ofport_request=1 -- \
533 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:decay_min_rx=3000 -- \
534 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
535
536ovs-appctl time/stop
537# advance the clock, to stablize the states.
8661af79 538ovs-appctl time/warp 10000 500
01d18a3a
AW
539BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
540BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
541BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
542BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
543
544# enable forwarding_if_rx.
545AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
546
547# there should be no change of the forwarding flag, since
548# the bfd on both ends is already up.
549for i in `seq 0 9`
550do
551 ovs-appctl time/warp 500
552 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
553done
554
3688ce7a 555# reconfigure the decay_min_rx to 1000ms.
01d18a3a 556AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
01d18a3a 557
3688ce7a 558# wait for 5000ms to decay.
8661af79 559ovs-appctl time/warp 5000 500
309d9dac 560BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
01d18a3a
AW
561BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
562BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
563
564# stop the bfd on one side.
565AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
3688ce7a
AW
566
567# advance clock by 4000ms, while receiving packets.
568# the STATE should go DOWN, due to Control Detection Time Expired.
569# but forwarding flag should be still true.
570for i in `seq 0 7`
01d18a3a
AW
571do
572 ovs-appctl time/warp 500
6dd3c787 573 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
574 [0], [stdout], [])
575done
01d18a3a
AW
576BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
577
578# receive packet at 1/100ms rate for 1000ms.
579for i in `seq 0 9`
580do
6dd3c787 581 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
01d18a3a
AW
582 [0], [stdout], [])
583 ovs-appctl time/warp 100
584 # the forwarding flag should always be true during this time.
585 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
586done
587
309d9dac 588# stop receiving for 5000ms.
8661af79 589ovs-appctl time/warp 5000 100
01d18a3a
AW
590BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
591
592# reset bfd forwarding_if_rx.
593AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false])
01d18a3a 594BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
595# re-enable bfd forwarding_if_rx.
596AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true])
01d18a3a 597BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
01d18a3a
AW
598
599# re-enable bfd on the other end. the states should be up.
600AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300])
601# advance the clock, to stablize the states.
8661af79 602ovs-appctl time/warp 10000 500
01d18a3a
AW
603BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
604BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
605BFD_CHECK_TX([p0], [300ms], [300ms], [300ms])
606BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
607
608AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 609OVS_VSWITCHD_STOP
4905e2df
AW
610AT_CLEANUP
611
34c88624
AW
612# forwarding_if_rx Test4
613# Test4 is for testing the demand_rx_bfd feature.
614# bfd is enabled on both ends of the link.
615AT_SETUP([bfd - bfd forwarding_if_rx - demand_rx_bfd])
616OVS_VSWITCHD_START([add-br br1 -- set bridge br1 datapath-type=dummy -- \
617 add-port br1 p1 -- set Interface p1 type=patch \
618 options:peer=p0 ofport_request=2 -- \
619 add-port br0 p0 -- set Interface p0 type=patch \
620 options:peer=p1 ofport_request=1 -- \
621 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 bfd:forwarding_if_rx=true -- \
622 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
623
624ovs-appctl time/stop
625# advance the clock, to stablize the states.
8661af79 626ovs-appctl time/warp 10000 500
34c88624
AW
627BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
628BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
629BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
630
631# disable the bfd on p1.
632AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
633
634# advance clock by 4000ms, while receiving packets.
635# the STATE should go DOWN, due to Control Detection Time Expired.
636# but forwarding flag should be still true.
637for i in `seq 0 7`
638do
639 ovs-appctl time/warp 500
6dd3c787 640 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
34c88624
AW
641 [0], [stdout], [])
642done
643BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
644
645# advance clock long enough to trigger the demand_bfd_rx interval
646# (100 * bfd->cfm_min_rx), forwarding flag should go down since there
647# is no bfd control packet received during the demand_rx_bfd.
648for i in `seq 0 120`
649do
650 ovs-appctl time/warp 300
6dd3c787 651 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
34c88624
AW
652 [0], [stdout], [])
653done
654BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
655
656# now enable the bfd on p1 again.
657AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true], [0])
658# advance clock by 5000ms. and p1 and p0 should be all up.
8661af79 659ovs-appctl time/warp 5000 500
34c88624
AW
660BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
661BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
662BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
663
664# disable the bfd on p1 again.
665AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
666# advance clock long enough to trigger the demand_rx_bfd,
667# forwarding flag should go down since there is no bfd control packet
668# received during the demand_rx_bfd.
669for i in `seq 0 120`
670do
671 ovs-appctl time/warp 300
6dd3c787 672 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
34c88624
AW
673 [0], [stdout], [])
674done
675BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
676
677AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
2f2695a2 678OVS_VSWITCHD_STOP
34c88624
AW
679AT_CLEANUP
680
4905e2df 681# test bfd:flap_count.
309d9dac
AW
682# This test contains three part:
683# part 1. tests the flap_count on normal bfd monitored link.
684# part 2. tests the flap_count when forwarding override is used.
685# part 3. tests the flap_count when forwarding_if_rx is enabled.
4905e2df
AW
686AT_SETUP([bfd - flap_count])
687#Create 2 bridges connected by patch ports and enable bfd
688OVS_VSWITCHD_START([add-br br1 -- \
689 set bridge br1 datapath-type=dummy \
690 other-config:hwaddr=aa:55:aa:56:00:00 -- \
691 add-port br1 p1 -- set Interface p1 type=patch \
692 options:peer=p0 ofport_request=2 -- \
693 add-port br0 p0 -- set Interface p0 type=patch \
694 options:peer=p1 ofport_request=1 -- \
695 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
696 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
697
698ovs-appctl time/stop
5eca22a2
AW
699# Disable the stats update to prevent the race between ovsdb updating
700# stats and ovs-vsctl cmd closing the jsonrpc session.
701AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
4905e2df
AW
702
703# Part-1 wait for a while to stablize bfd.
8661af79 704ovs-appctl time/warp 10100 100
4905e2df
AW
705BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
706BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
707BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
708BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
709# both p0 and p1 should have flap_count = "1". since down->up.
710BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
711BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
712
713# turn bfd on p1 off, should increment the bfd:flap_count on p0.
714AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
8661af79 715ovs-appctl time/warp 5000 100
4905e2df
AW
716BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
717BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
718AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
719
720# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
721# p1 should still have flap_count = "1", since it is reset.
722AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 723ovs-appctl time/warp 5000 100
4905e2df
AW
724BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
725BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
726
727
728# Part-2 now turn on the forwarding_override.
729AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl
730OK
731])
732
733# turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on.
734AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
8661af79 735ovs-appctl time/warp 5000 100
4905e2df
AW
736BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
737BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
738AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
739
740# turn bfd on p1 on again, should not increment the bfd:flap_count on p0, since forwarding override is on.
741# p1 should still have flap_count = "1", since it is reset.
742AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 743ovs-appctl time/warp 5000 100
4905e2df
AW
744BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
745BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
746
747# turn the forwarding_override back to normal.
748AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl
749OK
750])
751
752# turn bfd on p1 off and on, should increment the bfd:flap_count on p0.
753AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
8661af79 754ovs-appctl time/warp 5000 100
4905e2df 755AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 756ovs-appctl time/warp 5000 100
4905e2df
AW
757BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
758BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
759
760# Part-3 now turn on forwarding_if_rx.
761AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
8661af79 762ovs-appctl time/warp 1100 100
4905e2df
AW
763# disable the bfd on p1.
764AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
765
766# advance clock by 4000ms, while receiving packets.
767# the STATE should go DOWN, due to Control Detection Time Expired.
768# but forwarding flag should be true.
769for i in `seq 0 39`
770do
771 ovs-appctl time/warp 100
6dd3c787 772 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
4905e2df
AW
773 [0], [stdout], [])
774done
775BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
776# flap_count should remain unchanged.
777BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
778
34c88624 779# stop the traffic for more than 100 * bfd->cfm_min_rx ms, the forwarding flag of p0 should turn false.
4905e2df 780# and there should be the increment of flap_count.
8661af79 781ovs-appctl time/warp 12100 100
4905e2df
AW
782BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
783BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
784
785# advance clock by 4000ms, and resume the traffic.
786for i in `seq 0 39`
787do
788 ovs-appctl time/warp 100
6dd3c787 789 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
4905e2df
AW
790 [0], [stdout], [])
791done
34c88624 792# forwarding should be false, since there is still no bfd control packet received.
4905e2df 793BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
34c88624 794BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
4905e2df
AW
795
796# turn on the bfd on p1.
797AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
8661af79 798ovs-appctl time/warp 5000 100
4905e2df 799# even though there is no data traffic, since p1 bfd is on again, should increment the flap_count.
34c88624 800BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"])
4905e2df
AW
801BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
802
803OVS_VSWITCHD_STOP
8661af79 804AT_CLEANUP
67818616
MV
805
806AT_SETUP([bfd - check that BFD works together with RSTP])
807# Create br0 with interfaces p1
808# and br1 with interfaces p2
809# with p1 and p2 connected via unix domain socket
810OVS_VSWITCHD_START(
811 [set bridge br0 rstp_enable=true -- \
812 add-br br1 -- \
813 set bridge br1 other-config:hwaddr=aa:66:aa:66:00:00 -- \
814 set bridge br1 datapath-type=dummy -- \
815 set bridge br1 rstp_enable=true -- \
816])
817
818AT_CHECK([ovs-vsctl add-port br0 p1 -- \
819 set interface p1 type=dummy options:pstream=punix:$OVS_RUNDIR/p0.sock bfd:enable=true -- \
820])
821
822AT_CHECK([ovs-vsctl add-port br1 p2 -- \
823 set interface p2 type=dummy options:stream=unix:$OVS_RUNDIR/p0.sock bfd:enable=true -- \
824])
825
826ovs-appctl time/stop
827ovs-appctl time/warp 4100 100
828
829# Forwarding should be true
830BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
831BFD_CHECK([p2], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
832
833# Disable bfd on p2, forwarding on p1 should go to false
834AT_CHECK([ovs-vsctl set interface p2 bfd:enable=false])
835
836ovs-appctl time/warp 5000 100
837BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
838
839OVS_VSWITCHD_STOP
840AT_CLEANUP
f73b83fd
LS
841
842# test bfd: liveness propagation - OF1.3.
843AT_SETUP([bfd - liveness propagation - OF1.3])
844OVS_VSWITCHD_START
845AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
846check_liveness () {
847 printf '\n\n--- check_liveness %d ---\n\n\n' $1
848 shift
849
5a0e4aec 850 echo >>expout "OFPT_PORT_STATUS (OF1.3): MOD: 1(p0): addr:
f73b83fd
LS
851 config: 0
852 state: $1
853 speed: 0 Mbps now, 0 Mbps max"
854
5a0e4aec 855 AT_CHECK(
f73b83fd
LS
856 [[sed '
857s/ (xid=0x[0-9a-fA-F]*)//
858s/ *duration.*//
859s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
860 [0], [expout])
861}
862: > expout
863ovs-appctl -t ovs-ofctl ofctl/barrier
864ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
865# Set miss_send_len to 128, enabling port_status messages to our service connection.
866ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
867#Create 2 bridges connected by patch ports and enable bfd
868AT_CHECK([ovs-vsctl add-br br1 -- \
869 set bridge br1 datapath-type=dummy \
870 other-config:hwaddr=aa:55:aa:56:00:00 -- \
871 add-port br1 p1 -- set Interface p1 type=patch \
872 options:peer=p0 ofport_request=2 -- \
873 add-port br0 p0 -- set Interface p0 type=patch \
874 options:peer=p1 ofport_request=1 -- \
875 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
876 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
877
878ovs-appctl time/stop
879# Disable the stats update to prevent the race between ovsdb updating
880# stats and ovs-vsctl cmd closing the jsonrpc session.
881AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
882
883# wait for a while to stablize bfd.
884ovs-appctl time/warp 10100 100
885BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
886BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
887BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
888BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
889# both p0 and p1 should have flap_count = "1". since down->up.
890BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
891BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
892check_liveness 1 LIVE
893
894# turn bfd on p1 off, should increment the bfd:flap_count on p0.
895AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
896ovs-appctl time/warp 5000 100
897BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
898BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
899AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
900check_liveness 2 0
901
902# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
903# p1 should still have flap_count = "1", since it is reset.
904AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
905ovs-appctl time/warp 5000 100
906BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
907BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
908check_liveness 3 LIVE
909
910OVS_VSWITCHD_STOP
911AT_CLEANUP
912
913# test bfd: liveness propagation - OF1.4.
914AT_SETUP([bfd - liveness propagation - OF1.4])
915OVS_VSWITCHD_START
916AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile])
917check_liveness () {
918 printf '\n\n--- check_liveness %d ---\n\n\n' $1
919 shift
920
5a0e4aec 921 echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: 1(p0): addr:
f73b83fd
LS
922 config: 0
923 state: $1
924 speed: 0 Mbps now, 0 Mbps max"
925
5a0e4aec 926 AT_CHECK(
f73b83fd
LS
927 [[sed '
928s/ (xid=0x[0-9a-fA-F]*)//
929s/ *duration.*//
930s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
931 [0], [expout])
932}
933: > expout
934ovs-appctl -t ovs-ofctl ofctl/barrier
935ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
936# Set miss_send_len to 128, enabling port_status messages to our service connection.
937ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
938#Create 2 bridges connected by patch ports and enable bfd
939AT_CHECK([ovs-vsctl add-br br1 -- \
940 set bridge br1 datapath-type=dummy \
941 other-config:hwaddr=aa:55:aa:56:00:00 -- \
942 add-port br1 p1 -- set Interface p1 type=patch \
943 options:peer=p0 ofport_request=2 -- \
944 add-port br0 p0 -- set Interface p0 type=patch \
945 options:peer=p1 ofport_request=1 -- \
946 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
947 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
948
949ovs-appctl time/stop
950# Disable the stats update to prevent the race between ovsdb updating
951# stats and ovs-vsctl cmd closing the jsonrpc session.
952AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
953
954# wait for a while to stablize bfd.
955ovs-appctl time/warp 10100 100
956BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
957BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
958BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
959BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
960# both p0 and p1 should have flap_count = "1". since down->up.
961BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
962BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
963check_liveness 1 LIVE
964
965# turn bfd on p1 off, should increment the bfd:flap_count on p0.
966AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
967ovs-appctl time/warp 5000 100
968BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
969BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
970AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
971check_liveness 2 0
972
973# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
974# p1 should still have flap_count = "1", since it is reset.
975AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
976ovs-appctl time/warp 5000 100
977BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
978BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
979check_liveness 3 LIVE
980
981OVS_VSWITCHD_STOP
982AT_CLEANUP
983
984# test bfd: liveness propagation - OF1.5.
985AT_SETUP([bfd - liveness propagation - OF1.5])
986OVS_VSWITCHD_START
987AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
988check_liveness () {
989 printf '\n\n--- check_liveness %d ---\n\n\n' $1
990 shift
991
5a0e4aec 992 echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: 1(p0): addr:
f73b83fd
LS
993 config: 0
994 state: $1
995 speed: 0 Mbps now, 0 Mbps max"
996
5a0e4aec 997 AT_CHECK(
f73b83fd
LS
998 [[sed '
999s/ (xid=0x[0-9a-fA-F]*)//
1000s/ *duration.*//
1001s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
1002 [0], [expout])
1003}
1004: > expout
1005ovs-appctl -t ovs-ofctl ofctl/barrier
1006ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1007# Set miss_send_len to 128, enabling port_status messages to our service connection.
1008ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
1009#Create 2 bridges connected by patch ports and enable bfd
1010AT_CHECK([ovs-vsctl add-br br1 -- \
1011 set bridge br1 datapath-type=dummy \
1012 other-config:hwaddr=aa:55:aa:56:00:00 -- \
1013 add-port br1 p1 -- set Interface p1 type=patch \
1014 options:peer=p0 ofport_request=2 -- \
1015 add-port br0 p0 -- set Interface p0 type=patch \
1016 options:peer=p1 ofport_request=1 -- \
1017 set Interface p0 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100 -- \
1018 set Interface p1 bfd:enable=true bfd:min_tx=100 bfd:min_rx=100])
1019
1020ovs-appctl time/stop
1021# Disable the stats update to prevent the race between ovsdb updating
1022# stats and ovs-vsctl cmd closing the jsonrpc session.
1023AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
1024
1025# wait for a while to stablize bfd.
1026ovs-appctl time/warp 10100 100
1027BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1028BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1029BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
1030BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
1031# both p0 and p1 should have flap_count = "1". since down->up.
1032BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1033BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1034check_liveness 1 LIVE
1035
1036# turn bfd on p1 off, should increment the bfd:flap_count on p0.
1037AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
1038ovs-appctl time/warp 5000 100
1039BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
1040BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
1041AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
1042check_liveness 2 0
1043
1044# turn bfd on p1 on again, should increment the bfd:flap_count on p0.
1045# p1 should still have flap_count = "1", since it is reset.
1046AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
1047ovs-appctl time/warp 5000 100
1048BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
1049BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1050check_liveness 3 LIVE
1051
1052OVS_VSWITCHD_STOP
1053AT_CLEANUP
4cefc3da
SG
1054
1055AT_SETUP([bfd - Edit the Detect Mult values])
1056#Create 2 bridges connected by patch ports and enable BFD
1057OVS_VSWITCHD_START()
1058ovs-appctl time/stop
1059AT_CHECK([ ovs-vsctl -- add-br br1 -- \
1060 set bridge br1 datapath-type=dummy ])
1061AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch\
1062 options:peer=p0 ])
1063AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch\
1064 options:peer=p1 ])
1065AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
1066AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
1067ovs-appctl time/warp 3100 100
1068#Verify that BFD has been enabled on both interfaces.
1069BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1070BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1071#Verify that default mult values are 3.
1072BFD_CHECK_MULT([p0], [3], [3])
1073BFD_CHECK_MULT([p1], [3], [3])
1074#Set the mult values to valid range border mult(p0)=1 mult(p1)=255.
1075AT_CHECK([ovs-vsctl set interface p0 bfd:mult=1])
1076AT_CHECK([ovs-vsctl set interface p1 bfd:mult=255])
1077ovs-appctl time/warp 3100 100
1078BFD_CHECK_MULT([p0], [1], [255])
1079BFD_CHECK_MULT([p1], [255], [1])
1080
1081#Set the mult values out valid range border mult(p0)=0 mult(p1)=256.
1082AT_CHECK([ovs-vsctl set interface p0 bfd:mult=0])
1083AT_CHECK([ovs-vsctl set interface p1 bfd:mult=256])
1084ovs-appctl time/warp 3100 100
1085BFD_CHECK_MULT([p0], [3], [3])
1086BFD_CHECK_MULT([p1], [3], [3])
1087
1088#Set valid non default mult values mult(p0)=8 mult(p1)=125.
1089AT_CHECK([ovs-vsctl set interface p0 bfd:mult=8])
1090AT_CHECK([ovs-vsctl set interface p1 bfd:mult=125])
1091ovs-appctl time/warp 3100 100
1092BFD_CHECK_MULT([p0], [8], [125])
1093BFD_CHECK_MULT([p1], [125], [8])
1094
1095#Clear mult values. Detect mult values shall be default 3 again.
1096AT_CHECK([ovs-vsctl remove interface p0 bfd mult])
1097AT_CHECK([ovs-vsctl remove interface p1 bfd mult])
1098ovs-appctl time/warp 3100 100
1099BFD_CHECK_MULT([p0], [3], [3])
1100BFD_CHECK_MULT([p1], [3], [3])
1101
1102OVS_VSWITCHD_STOP
1103AT_CLEANUP
b793a65c
YS
1104
1105AT_SETUP([bfd - overlay])
1106OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
1107 options:remote_ip=2.2.2.2 ofport_request=1 -- \
1108 set interface p1 bfd:enable=true bfd:bfd_src_ip=2.2.2.1 -- \
1109 set bridge br0 fail-mode=standalone])
1110
1111# Userspace slow path handles normal BFD packets.
1112AT_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()),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=2.2.2.2/0.0.0.0,dst=2.2.2.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])
1113# check that the packet should be handled as BFD packet.
1114AT_CHECK([tail -2 stdout], [0], [dnl
1115This flow is handled by the userspace slow path because it:
1116 - Consists of BFD packets.
1117], [])
1118
1119# Userspace slow path won't handle overlay BFD packets. Instead, other OVS flows, if configured, will handle them.
1120AT_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()),in_port(1),skb_mark(0/0),eth(src=00:11:22:33:44:66,dst=00:23:20:00:00:77),eth_type(0x0800),ipv4(src=192.168.2.2/0.0.0.0,dst=192.168.2.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])
1121AT_CHECK([tail -10 stdout], [0], [dnl
1122bridge("br0")
1123-------------
1124 0. priority 0
1125 NORMAL
1126 -> learned that 00:11:22:33:44:66 is on port p1 in VLAN 0
1127 -> no learned MAC for destination, flooding
1128
1129Final flow: unchanged
1130Megaflow: recirc_id=0,eth,udp,tun_id=0,tun_src=2.2.2.2,tun_dst=2.2.2.1,tun_tos=0,tun_flags=-df-csum+key,in_port=1,dl_src=00:11:22:33:44:66,dl_dst=00:23:20:00:00:77,nw_frag=no,tp_dst=3784
1131Datapath actions: 100
1132], [])
1133
1134OVS_VSWITCHD_STOP
1135AT_CLEANUP