]> git.proxmox.com Git - ovs.git/blob - tests/bfd.at
dpif-netdev: Incremental addition/deletion of PMD threads.
[ovs.git] / tests / bfd.at
1 AT_BANNER([bfd])
2
3 m4_define([BFD_CHECK], [
4 AT_CHECK([ovs-appctl bfd/show $1 | sed -e '/Time:/d' | sed -e '/Discriminator/d' | sed -e '/Interval:/d'| sed -e '/Multiplier/d'],[0],
5 [dnl
6 Forwarding: $2
7 Concatenated Path Down: $3
8
9 Local Flags: $4
10 Local Session State: $5
11 Local Diagnostic: $6
12
13 Remote Flags: $7
14 Remote Session State: $8
15 Remote Diagnostic: $9
16 ])
17 ])
18
19 m4_define([BFD_CHECK_TX], [
20 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
21 [dnl
22 TX Interval: Approx $2
23 Local Minimum TX Interval: $3
24 Remote Minimum TX Interval: $4
25 ])
26 ])
27
28 m4_define([BFD_CHECK_RX], [
29 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
30 [dnl
31 RX Interval: Approx $2
32 Local Minimum RX Interval: $3
33 Remote Minimum RX Interval: $4
34 ])
35 ])
36
37 m4_define([BFD_VSCTL_LIST_IFACE], [
38 AT_CHECK([ovs-vsctl list interface $1 | sed -n $2],[0],
39 [dnl
40 $3
41 ])
42 ])
43
44 m4_define([BFD_CHECK_MULT], [
45 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/Detect Multiplier/p'],[0],
46 [dnl
47 Detect Multiplier: $2
48 Remote Detect Multiplier: $3
49 ])
50 ])
51
52 AT_SETUP([bfd - basic config on different bridges])
53 #Create 2 bridges connected by patch ports and enable BFD
54 OVS_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 ])
64 ovs-appctl time/stop
65 ovs-appctl time/warp 4100 100
66
67 #Verify that BFD has been enabled on both interfaces.
68 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
69 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
70
71 AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=false])
72 ovs-appctl time/warp 4100 100
73 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
74
75 AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=true])
76 ovs-appctl time/warp 4100 100
77 BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
78 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
79
80 ovs-vsctl del-br br0
81 AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
82 ovs-appctl: ovs-vswitchd: server returned an error
83 ])
84 ovs-vsctl del-br br1
85 #Check that the entries are gone.
86 AT_CHECK([ovs-appctl bfd/show p1], [2],[ignore], [no such bfd object
87 ovs-appctl: ovs-vswitchd: server returned an error
88 ])
89
90 OVS_VSWITCHD_STOP
91 AT_CLEANUP
92
93
94 AT_SETUP([bfd - Verify tunnel down detection])
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
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
100 OVS_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 \
111 options:peer=p1 ofport_request=2 -- \
112 add-port br-sw p0-sw -- set Interface p0-sw type=patch \
113 options:peer=p0 ofport_request=1 -- \
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
119 ovs-appctl time/stop
120
121 #Create 2 bridges connected by patch ports and enable BFD
122
123 AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
124 #Verify that BFD is enabled.
125 ovs-appctl time/warp 4100 100
126 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
127 BFD_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.
130 AT_CHECK([ ovs-ofctl add-flow br-sw 'priority=5,actions=drop' ])
131 ovs-appctl time/warp 4100 100
132 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
133 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
134
135 #Delete the added flow
136 AT_CHECK([ovs-ofctl del-flows br-sw], [0])
137 AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
138 #Verify that BFD is back up again.
139 ovs-appctl time/warp 4100 100
140
141 BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
142 BFD_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
151 AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=1,priority=5,actions=drop'])
152 ovs-appctl time/warp 4100 100
153 # Make sure p1 BFD state is down since it received no BFD packets.
154 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
155 ovs-appctl time/warp 4100 100
156
157 # p0 will be in init state once it receives "down" BFD message from p1.
158 BFD_CHECK([p0], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
159
160 AT_CHECK([ovs-ofctl del-flows br-sw])
161 AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
162 #Ensure that BFD is back up again.
163
164 ovs-appctl time/warp 1100 100
165 #Bring down the br-bfd0 - br-sw link
166 AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=2,priority=5,actions=drop'])
167 ovs-appctl time/warp 4100 100
168 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
169 ovs-appctl time/warp 4100 100
170 BFD_CHECK([p1], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
171 OVS_VSWITCHD_STOP
172 AT_CLEANUP
173
174
175 AT_SETUP([bfd - concatenated path down])
176 #Create 2 bridges connected by patch ports and enable BFD
177 OVS_VSWITCHD_START()
178 ovs-appctl time/stop
179 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
180 set bridge br1 datapath-type=dummy \
181 other-config:hwaddr=aa:55:aa:56:00:00 ])
182 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
183 options:peer=p0 ])
184 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
185 options:peer=p1 ])
186 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
187 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
188 ovs-appctl time/warp 4100 100
189
190 #Verify that BFD has been enabled on both interfaces.
191 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
192 BFD_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.
195 AT_CHECK([ovs-vsctl set interface p0 bfd:cpath_down=true])
196 ovs-appctl time/warp 4100 100
197 BFD_CHECK([p1], [false], [false], [none], [up], [No Diagnostic], [none], [up], [Concatenated Path Down])
198 OVS_VSWITCHD_STOP
199 AT_CLEANUP
200
201
202 AT_SETUP([bfd - Edit the Min Tx/Rx values])
203 #Create 2 bridges connected by patch ports and enable BFD
204 OVS_VSWITCHD_START()
205 ovs-appctl time/stop
206 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
207 set bridge br1 datapath-type=dummy ])
208 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
209 options:peer=p0 ])
210 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
211 options:peer=p1 ])
212 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
213 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
214 ovs-appctl time/warp 3100 100
215 #Verify that BFD has been enabled on both interfaces.
216 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
217 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
218 #Edit the min Tx value.
219 AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200])
220 ovs-appctl time/warp 2100 100
221 BFD_CHECK_TX([p0], [1000ms], [200ms], [100ms])
222 BFD_CHECK_TX([p1], [1000ms], [100ms], [200ms])
223
224 #Edit the min Rx value.
225 AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300])
226 ovs-appctl time/warp 2100 100
227 BFD_CHECK_RX([p1], [300ms], [300ms], [1000ms])
228 BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
229
230 OVS_VSWITCHD_STOP
231 AT_CLEANUP
232
233 AT_SETUP([bfd - check_tnl_key])
234 OVS_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.
240 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,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])
241 # check that the packet should be handled as BFD packet.
242 AT_CHECK([tail -2 stdout], [0], [dnl
243 This flow is handled by the userspace slow path because it:
244 - Consists of BFD packets.
245 ], [])
246
247 # turn on the check_tnl_key.
248 AT_CHECK([ovs-vsctl set interface p1 bfd:check_tnl_key=true])
249 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x1,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,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])
250 # check that the packet should be handled as normal packet.
251 AT_CHECK([tail -1 stdout], [0],[dnl
252 Datapath actions: 100
253 ], [])
254
255 # set the tunnel key to 0.
256 AT_CHECK([ovs-vsctl set interface p1 options:key=0])
257 AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'tunnel(tun_id=0x0,src=2.2.2.2,dst=2.2.2.1,tos=0x0,ttl=64,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])
258 # check that the packet should be handled as BFD packet.
259 AT_CHECK([tail -2 stdout], [0], [dnl
260 This flow is handled by the userspace slow path because it:
261 - Consists of BFD packets.
262 ], [])
263
264 OVS_VSWITCHD_STOP
265 AT_CLEANUP
266
267 # Tests below are for bfd decay features.
268 AT_SETUP([bfd - bfd decay])
269 OVS_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 -- \
274 set Interface p0 bfd:enable=true bfd:min_tx=300 bfd:min_rx=300 -- \
275 set Interface p1 bfd:enable=true bfd:min_tx=500 bfd:min_rx=500])
276
277 ovs-appctl time/stop
278
279 # wait for a while to stablize everything.
280 ovs-appctl time/warp 10000 500
281 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
282 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
283 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
284 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
285
286 # Test-1 BFD decay: decay to decay_min_rx
287 AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=3000])
288 # bfd:decay_min_rx is set to 3000ms after the local state of p0 goes up,
289 # so for the first 2000ms, there should be no change.
290 ovs-appctl time/warp 2000 500
291 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
292 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
293
294 # advance the clock by 5000ms.
295 ovs-appctl time/warp 5000 500
296 # now, min_rx should decay to 3000ms.
297 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
298 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
299
300 # advance clock by 5000ms and check the flags are all 'none'.
301 ovs-appctl time/warp 5000 500
302 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
303 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
304 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
305 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
306 # End of Test-1 ###############################################################
307
308
309 # Test-2 BFD decay: go back to min_rx when there is traffic
310 # receive packet at 1/100ms rate for 5000ms.
311 for i in `seq 0 49`
312 do
313 ovs-appctl time/warp 100
314 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
315 [0], [stdout], [])
316 done
317 # after a decay interval (3000ms), the p0 min_rx will go back to
318 # min_rx.
319 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
320 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
321 # End of Test-2 ###############################################################
322
323
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.
326 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000])
327 # advance the clock by 10000ms, decay should have happened.
328 ovs-appctl time/warp 10000 500
329 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
330 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
331 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
332 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
333 # End of Test-3 ###############################################################
334
335
336 # Test-4 BFD decay: set decay_min_rx to 0 to disable bfd decay.
337 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0])
338 # advance the clock by 5000ms.
339 ovs-appctl time/warp 10000 500
340 # min_rx is reset.
341 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
342 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
343
344 for i in `seq 0 20`
345 do
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])
351 done
352 # End of Test-4 ################################################################
353
354
355 # Test-5 BFD decay: rmt_min_tx is greater than decay_min_rx
356 AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=3000 -- set interface p1 bfd:min_tx=5000])
357 # advance the clock by 10000ms to stable everything.
358 ovs-appctl time/warp 10000 500
359 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
360 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
361 # p0 rx should show 5000ms even if it is in decay.
362 BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms])
363 BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms])
364 # then, there should be no change of status,
365 for i in `seq 0 19`
366 do
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])
372 done
373 # reset the p1's min_tx to 500ms.
374 AT_CHECK([ovs-vsctl set Interface p1 bfd:min_tx=500])
375 # advance the clock by 20000ms to stable everything.
376 # since p0 has been in decay, now the RX will show 3000ms.
377 ovs-appctl time/warp 20000 500
378 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
379 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
380 # End of Test-5 ###############################################################
381
382
383 # Test-6 BFD decay: state up->down->up.
384 # turn bfd off on p1
385 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false])
386
387 # advance the clock by 15000ms to stable everything.
388 ovs-appctl time/warp 15000 1000
389 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
390 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
391 BFD_CHECK_RX([p0], [300ms], [300ms], [1ms])
392
393 # resume the bfd on p1. the bfd should not go to decay mode direclty.
394 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true])
395 ovs-appctl time/warp 1500 500
396 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
397 BFD_CHECK_RX([p0], [500ms], [300ms], [500ms])
398
399 # since the decay_min_rx is still 3000ms, so after 5000ms, p0 should have decayed.
400 ovs-appctl time/warp 5000 500
401 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
402 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
403 # End of Test-6 ################################################################
404
405 OVS_VSWITCHD_STOP
406 AT_CLEANUP
407
408 # Tests below are for bfd forwarding_if_rx feature.
409
410 # forwarding_if_rx Test1
411 # Test1 tests the case when bfd is only enabled on one end of the link.
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.
415 AT_SETUP([bfd - bfd forwarding_if_rx - bfd on one side])
416 OVS_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
424 ovs-appctl time/stop
425 # check the inital status.
426 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
427 BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms])
428 BFD_CHECK_RX([p0], [500ms], [500ms], [1ms])
429
430 # enable forwarding_if_rx.
431 AT_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.
435 for i in `seq 0 3`
436 do
437 ovs-appctl time/warp 500
438 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
439 done
440
441 # receive packet at 1/100ms rate for 2000ms.
442 for i in `seq 0 19`
443 do
444 ovs-appctl time/warp 100
445 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
446 [0], [stdout], [])
447 done
448 # the forwarding flag should be false, due to the demand_rx_bfd.
449 BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic])
450
451 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
452 OVS_VSWITCHD_STOP
453 AT_CLEANUP
454
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.
460 AT_SETUP([bfd - bfd forwarding_if_rx - bfd on both sides])
461 OVS_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
470 ovs-appctl time/stop
471 # advance the clock, to stablize the states.
472 ovs-appctl time/warp 5000 500
473
474 # enable forwarding_if_rx.
475 AT_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.
479 for i in `seq 0 5`
480 do
481 ovs-appctl time/warp 500
482 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
483 done
484
485 # stop the bfd on one side.
486 AT_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.
489 for i in `seq 0 1`
490 do
491 ovs-appctl time/warp 500
492 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
493 for i in `seq 0 4`
494 do
495 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
496 [0], [stdout], [])
497 done
498 done
499
500 # at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired.
501 # but forwarding flag should be still true.
502 ovs-appctl time/warp 500
503 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
504
505 # reset bfd forwarding_if_rx.
506 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0])
507 # forwarding flag should turn to false since the STATE is DOWN.
508 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
509
510 # re-enable bfd on the other end. the states should be up.
511 AT_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.
513 ovs-appctl time/warp 5000 500
514 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
515 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
516 BFD_CHECK_TX([p0], [500ms], [500ms], [300ms])
517 BFD_CHECK_RX([p0], [500ms], [500ms], [300ms])
518
519 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
520 OVS_VSWITCHD_STOP
521 AT_CLEANUP
522
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.
526 AT_SETUP([bfd - bfd forwarding_if_rx - with bfd decay])
527 OVS_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
535 ovs-appctl time/stop
536 # advance the clock, to stablize the states.
537 ovs-appctl time/warp 10000 500
538 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
539 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
540 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
541 BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms])
542
543 # enable forwarding_if_rx.
544 AT_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.
548 for i in `seq 0 9`
549 do
550 ovs-appctl time/warp 500
551 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
552 done
553
554 # reconfigure the decay_min_rx to 1000ms.
555 AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000])
556
557 # wait for 5000ms to decay.
558 ovs-appctl time/warp 5000 500
559 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
560 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
561 BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms])
562
563 # stop the bfd on one side.
564 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false], [0])
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.
569 for i in `seq 0 7`
570 do
571 ovs-appctl time/warp 500
572 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
573 [0], [stdout], [])
574 done
575 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
576
577 # receive packet at 1/100ms rate for 1000ms.
578 for i in `seq 0 9`
579 do
580 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
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])
585 done
586
587 # stop receiving for 5000ms.
588 ovs-appctl time/warp 5000 100
589 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
590
591 # reset bfd forwarding_if_rx.
592 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false])
593 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
594 # re-enable bfd forwarding_if_rx.
595 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true])
596 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
597
598 # re-enable bfd on the other end. the states should be up.
599 AT_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.
601 ovs-appctl time/warp 10000 500
602 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
603 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
604 BFD_CHECK_TX([p0], [300ms], [300ms], [300ms])
605 BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms])
606
607 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
608 OVS_VSWITCHD_STOP
609 AT_CLEANUP
610
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.
614 AT_SETUP([bfd - bfd forwarding_if_rx - demand_rx_bfd])
615 OVS_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
623 ovs-appctl time/stop
624 # advance the clock, to stablize the states.
625 ovs-appctl time/warp 10000 500
626 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
627 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
628 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
629
630 # disable the bfd on p1.
631 AT_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.
636 for i in `seq 0 7`
637 do
638 ovs-appctl time/warp 500
639 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
640 [0], [stdout], [])
641 done
642 BFD_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.
647 for i in `seq 0 120`
648 do
649 ovs-appctl time/warp 300
650 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
651 [0], [stdout], [])
652 done
653 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
654
655 # now enable the bfd on p1 again.
656 AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true], [0])
657 # advance clock by 5000ms. and p1 and p0 should be all up.
658 ovs-appctl time/warp 5000 500
659 BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
660 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
661 BFD_CHECK_TX([p0], [500ms], [300ms], [500ms])
662
663 # disable the bfd on p1 again.
664 AT_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.
668 for i in `seq 0 120`
669 do
670 ovs-appctl time/warp 300
671 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
672 [0], [stdout], [])
673 done
674 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
675
676 AT_CHECK([ovs-vsctl del-br br1], [0], [ignore])
677 OVS_VSWITCHD_STOP
678 AT_CLEANUP
679
680 # test bfd:flap_count.
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.
685 AT_SETUP([bfd - flap_count])
686 #Create 2 bridges connected by patch ports and enable bfd
687 OVS_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
697 ovs-appctl time/stop
698 # Disable the stats update to prevent the race between ovsdb updating
699 # stats and ovs-vsctl cmd closing the jsonrpc session.
700 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
701
702 # Part-1 wait for a while to stablize bfd.
703 ovs-appctl time/warp 10100 100
704 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
705 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
706 BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
707 BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
708 # both p0 and p1 should have flap_count = "1". since down->up.
709 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
710 BFD_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.
713 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
714 ovs-appctl time/warp 5000 100
715 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
716 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
717 AT_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.
721 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
722 ovs-appctl time/warp 5000 100
723 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
724 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
725
726
727 # Part-2 now turn on the forwarding_override.
728 AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl
729 OK
730 ])
731
732 # turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on.
733 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
734 ovs-appctl time/warp 5000 100
735 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
736 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
737 AT_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.
741 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
742 ovs-appctl time/warp 5000 100
743 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
744 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
745
746 # turn the forwarding_override back to normal.
747 AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl
748 OK
749 ])
750
751 # turn bfd on p1 off and on, should increment the bfd:flap_count on p0.
752 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
753 ovs-appctl time/warp 5000 100
754 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
755 ovs-appctl time/warp 5000 100
756 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
757 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
758
759 # Part-3 now turn on forwarding_if_rx.
760 AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0])
761 ovs-appctl time/warp 1100 100
762 # disable the bfd on p1.
763 AT_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.
768 for i in `seq 0 39`
769 do
770 ovs-appctl time/warp 100
771 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
772 [0], [stdout], [])
773 done
774 BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
775 # flap_count should remain unchanged.
776 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"])
777
778 # stop the traffic for more than 100 * bfd->cfm_min_rx ms, the forwarding flag of p0 should turn false.
779 # and there should be the increment of flap_count.
780 ovs-appctl time/warp 12100 100
781 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
782 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
783
784 # advance clock by 4000ms, and resume the traffic.
785 for i in `seq 0 39`
786 do
787 ovs-appctl time/warp 100
788 AT_CHECK([ovs-ofctl packet-out br1 "in_port=3 packet=90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202 actions=2"],
789 [0], [stdout], [])
790 done
791 # forwarding should be false, since there is still no bfd control packet received.
792 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
793 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"])
794
795 # turn on the bfd on p1.
796 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
797 ovs-appctl time/warp 5000 100
798 # even though there is no data traffic, since p1 bfd is on again, should increment the flap_count.
799 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"])
800 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
801
802 OVS_VSWITCHD_STOP
803 AT_CLEANUP
804
805 AT_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
809 OVS_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
817 AT_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
821 AT_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
825 ovs-appctl time/stop
826 ovs-appctl time/warp 4100 100
827
828 # Forwarding should be true
829 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
830 BFD_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
833 AT_CHECK([ovs-vsctl set interface p2 bfd:enable=false])
834
835 ovs-appctl time/warp 5000 100
836 BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
837
838 OVS_VSWITCHD_STOP
839 AT_CLEANUP
840
841 # test bfd: liveness propagation - OF1.3.
842 AT_SETUP([bfd - liveness propagation - OF1.3])
843 OVS_VSWITCHD_START
844 AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
845 check_liveness () {
846 printf '\n\n--- check_liveness %d ---\n\n\n' $1
847 shift
848
849 echo >>expout "OFPT_PORT_STATUS (OF1.3): MOD: 1(p0): addr:
850 config: 0
851 state: $1
852 speed: 0 Mbps now, 0 Mbps max"
853
854 AT_CHECK(
855 [[sed '
856 s/ (xid=0x[0-9a-fA-F]*)//
857 s/ *duration.*//
858 s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
859 [0], [expout])
860 }
861 : > expout
862 ovs-appctl -t ovs-ofctl ofctl/barrier
863 ovs-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.
865 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
866 #Create 2 bridges connected by patch ports and enable bfd
867 AT_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
877 ovs-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.
880 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
881
882 # wait for a while to stablize bfd.
883 ovs-appctl time/warp 10100 100
884 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
885 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
886 BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
887 BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
888 # both p0 and p1 should have flap_count = "1". since down->up.
889 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
890 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
891 check_liveness 1 LIVE
892
893 # turn bfd on p1 off, should increment the bfd:flap_count on p0.
894 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
895 ovs-appctl time/warp 5000 100
896 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
897 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
898 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
899 check_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.
903 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
904 ovs-appctl time/warp 5000 100
905 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
906 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
907 check_liveness 3 LIVE
908
909 OVS_VSWITCHD_STOP
910 AT_CLEANUP
911
912 # test bfd: liveness propagation - OF1.4.
913 AT_SETUP([bfd - liveness propagation - OF1.4])
914 OVS_VSWITCHD_START
915 AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile])
916 check_liveness () {
917 printf '\n\n--- check_liveness %d ---\n\n\n' $1
918 shift
919
920 echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: 1(p0): addr:
921 config: 0
922 state: $1
923 speed: 0 Mbps now, 0 Mbps max"
924
925 AT_CHECK(
926 [[sed '
927 s/ (xid=0x[0-9a-fA-F]*)//
928 s/ *duration.*//
929 s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
930 [0], [expout])
931 }
932 : > expout
933 ovs-appctl -t ovs-ofctl ofctl/barrier
934 ovs-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.
936 ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
937 #Create 2 bridges connected by patch ports and enable bfd
938 AT_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
948 ovs-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.
951 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
952
953 # wait for a while to stablize bfd.
954 ovs-appctl time/warp 10100 100
955 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
956 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
957 BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
958 BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
959 # both p0 and p1 should have flap_count = "1". since down->up.
960 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
961 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
962 check_liveness 1 LIVE
963
964 # turn bfd on p1 off, should increment the bfd:flap_count on p0.
965 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
966 ovs-appctl time/warp 5000 100
967 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
968 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
969 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
970 check_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.
974 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
975 ovs-appctl time/warp 5000 100
976 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
977 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
978 check_liveness 3 LIVE
979
980 OVS_VSWITCHD_STOP
981 AT_CLEANUP
982
983 # test bfd: liveness propagation - OF1.5.
984 AT_SETUP([bfd - liveness propagation - OF1.5])
985 OVS_VSWITCHD_START
986 AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
987 check_liveness () {
988 printf '\n\n--- check_liveness %d ---\n\n\n' $1
989 shift
990
991 echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: 1(p0): addr:
992 config: 0
993 state: $1
994 speed: 0 Mbps now, 0 Mbps max"
995
996 AT_CHECK(
997 [[sed '
998 s/ (xid=0x[0-9a-fA-F]*)//
999 s/ *duration.*//
1000 s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]],
1001 [0], [expout])
1002 }
1003 : > expout
1004 ovs-appctl -t ovs-ofctl ofctl/barrier
1005 ovs-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.
1007 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
1008 #Create 2 bridges connected by patch ports and enable bfd
1009 AT_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
1019 ovs-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.
1022 AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000])
1023
1024 # wait for a while to stablize bfd.
1025 ovs-appctl time/warp 10100 100
1026 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1027 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1028 BFD_CHECK_TX([p0], [100ms], [100ms], [100ms])
1029 BFD_CHECK_RX([p0], [100ms], [100ms], [100ms])
1030 # both p0 and p1 should have flap_count = "1". since down->up.
1031 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1032 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1033 check_liveness 1 LIVE
1034
1035 # turn bfd on p1 off, should increment the bfd:flap_count on p0.
1036 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false])
1037 ovs-appctl time/warp 5000 100
1038 BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
1039 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"])
1040 AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"])
1041 check_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.
1045 AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true])
1046 ovs-appctl time/warp 5000 100
1047 BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"])
1048 BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"])
1049 check_liveness 3 LIVE
1050
1051 OVS_VSWITCHD_STOP
1052 AT_CLEANUP
1053
1054 AT_SETUP([bfd - Edit the Detect Mult values])
1055 #Create 2 bridges connected by patch ports and enable BFD
1056 OVS_VSWITCHD_START()
1057 ovs-appctl time/stop
1058 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
1059 set bridge br1 datapath-type=dummy ])
1060 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch\
1061 options:peer=p0 ])
1062 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch\
1063 options:peer=p1 ])
1064 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
1065 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
1066 ovs-appctl time/warp 3100 100
1067 #Verify that BFD has been enabled on both interfaces.
1068 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1069 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
1070 #Verify that default mult values are 3.
1071 BFD_CHECK_MULT([p0], [3], [3])
1072 BFD_CHECK_MULT([p1], [3], [3])
1073 #Set the mult values to valid range border mult(p0)=1 mult(p1)=255.
1074 AT_CHECK([ovs-vsctl set interface p0 bfd:mult=1])
1075 AT_CHECK([ovs-vsctl set interface p1 bfd:mult=255])
1076 ovs-appctl time/warp 3100 100
1077 BFD_CHECK_MULT([p0], [1], [255])
1078 BFD_CHECK_MULT([p1], [255], [1])
1079
1080 #Set the mult values out valid range border mult(p0)=0 mult(p1)=256.
1081 AT_CHECK([ovs-vsctl set interface p0 bfd:mult=0])
1082 AT_CHECK([ovs-vsctl set interface p1 bfd:mult=256])
1083 ovs-appctl time/warp 3100 100
1084 BFD_CHECK_MULT([p0], [3], [3])
1085 BFD_CHECK_MULT([p1], [3], [3])
1086
1087 #Set valid non default mult values mult(p0)=8 mult(p1)=125.
1088 AT_CHECK([ovs-vsctl set interface p0 bfd:mult=8])
1089 AT_CHECK([ovs-vsctl set interface p1 bfd:mult=125])
1090 ovs-appctl time/warp 3100 100
1091 BFD_CHECK_MULT([p0], [8], [125])
1092 BFD_CHECK_MULT([p1], [125], [8])
1093
1094 #Clear mult values. Detect mult values shall be default 3 again.
1095 AT_CHECK([ovs-vsctl remove interface p0 bfd mult])
1096 AT_CHECK([ovs-vsctl remove interface p1 bfd mult])
1097 ovs-appctl time/warp 3100 100
1098 BFD_CHECK_MULT([p0], [3], [3])
1099 BFD_CHECK_MULT([p1], [3], [3])
1100
1101 OVS_VSWITCHD_STOP
1102 AT_CLEANUP