]>
Commit | Line | Data |
---|---|---|
015cf297 PR |
1 | AT_BANNER([bfd]) |
2 | ||
3 | m4_define([BFD_CHECK], [ | |
4cefc3da | 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], |
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 | ||
19 | m4_define([BFD_CHECK_TX], [ | |
20 | AT_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 | ||
28 | m4_define([BFD_CHECK_RX], [ | |
29 | AT_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 | |
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 | ||
4cefc3da SG |
44 | m4_define([BFD_CHECK_MULT], [ |
45 | AT_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 | 52 | AT_SETUP([bfd - basic config on different bridges]) |
015cf297 PR |
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 ]) | |
43d66d3b | 64 | ovs-appctl time/stop |
8661af79 | 65 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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]) | |
8661af79 | 72 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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]) | |
8661af79 | 76 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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]) | |
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 |
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 \ | |
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 | 119 | ovs-appctl time/stop |
015cf297 PR |
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. | |
8661af79 | 125 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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' ]) | |
8661af79 | 131 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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. | |
8661af79 | 139 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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']) | |
8661af79 | 152 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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]) | |
8661af79 GS |
155 | ovs-appctl time/warp 4100 100 |
156 | ||
015cf297 PR |
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 | ||
8661af79 | 164 | ovs-appctl time/warp 1100 100 |
015cf297 PR |
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']) | |
8661af79 | 167 | ovs-appctl time/warp 4100 100 |
015cf297 | 168 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
8661af79 | 169 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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 | |
015cf297 | 177 | OVS_VSWITCHD_START() |
43d66d3b | 178 | ovs-appctl time/stop |
015cf297 PR |
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 ]) | |
015cf297 PR |
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 ]) | |
8661af79 | 188 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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]) | |
8661af79 | 196 | ovs-appctl time/warp 4100 100 |
015cf297 PR |
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 | |
015cf297 | 204 | OVS_VSWITCHD_START() |
43d66d3b | 205 | ovs-appctl time/stop |
015cf297 PR |
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 ]) | |
8661af79 | 214 | ovs-appctl time/warp 3100 100 |
015cf297 PR |
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]) | |
8661af79 | 220 | ovs-appctl time/warp 2100 100 |
c1c4e8c7 AW |
221 | BFD_CHECK_TX([p0], [1000ms], [200ms], [100ms]) |
222 | BFD_CHECK_TX([p1], [1000ms], [100ms], [200ms]) | |
015cf297 PR |
223 | |
224 | #Edit the min Rx value. | |
225 | AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300]) | |
8661af79 | 226 | ovs-appctl time/warp 2100 100 |
c1c4e8c7 AW |
227 | BFD_CHECK_RX([p1], [300ms], [300ms], [1000ms]) |
228 | BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms]) | |
015cf297 PR |
229 | |
230 | OVS_VSWITCHD_STOP | |
231 | AT_CLEANUP | |
2d21cf72 AW |
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. | |
6f068379 | 240 | AT_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. |
242 | AT_CHECK([tail -2 stdout], [0], [dnl | |
243 | This 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. | |
248 | AT_CHECK([ovs-vsctl set interface p1 bfd:check_tnl_key=true]) | |
2d18eae8 | 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]) |
2d21cf72 AW |
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]) | |
6f068379 | 257 | AT_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. |
259 | AT_CHECK([tail -2 stdout], [0], [dnl | |
260 | This flow is handled by the userspace slow path because it: | |
393e9f7c | 261 | - Consists of BFD packets. |
2d21cf72 AW |
262 | ], []) |
263 | ||
264 | OVS_VSWITCHD_STOP | |
265 | AT_CLEANUP | |
c1c4e8c7 AW |
266 | |
267 | # Tests below are for bfd decay features. | |
268 | AT_SETUP([bfd - bfd decay]) | |
804ef1a7 | 269 | AT_SKIP_IF([test "$IS_ARM64" = "yes"]) |
c1c4e8c7 AW |
270 | OVS_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 | ||
278 | ovs-appctl time/stop | |
c1c4e8c7 | 279 | |
3688ce7a | 280 | # wait for a while to stablize everything. |
8661af79 | 281 | ovs-appctl time/warp 10000 500 |
3688ce7a AW |
282 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
283 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
284 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) | |
285 | BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) | |
c1c4e8c7 AW |
286 | |
287 | # Test-1 BFD decay: decay to decay_min_rx | |
3688ce7a | 288 | AT_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 | 291 | ovs-appctl time/warp 2000 500 |
c1c4e8c7 AW |
292 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
293 | BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) | |
294 | ||
27e26e59 | 295 | # advance the clock by 5000ms. |
8661af79 | 296 | ovs-appctl time/warp 5000 500 |
3688ce7a | 297 | # now, min_rx should decay to 3000ms. |
c1c4e8c7 AW |
298 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
299 | BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) | |
300 | ||
898dcef1 | 301 | # advance clock by 5000ms and check the flags are all 'none'. |
8661af79 | 302 | ovs-appctl time/warp 5000 500 |
c1c4e8c7 | 303 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
3688ce7a | 304 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
c1c4e8c7 AW |
305 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
306 | BFD_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. |
312 | for i in `seq 0 49` | |
c1c4e8c7 AW |
313 | do |
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], []) |
317 | done | |
318 | # after a decay interval (3000ms), the p0 min_rx will go back to | |
27e26e59 | 319 | # min_rx. |
c1c4e8c7 AW |
320 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
321 | BFD_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. | |
327 | AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=1000]) | |
328 | # advance the clock by 10000ms, decay should have happened. | |
8661af79 | 329 | ovs-appctl time/warp 10000 500 |
c1c4e8c7 AW |
330 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
331 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
c1c4e8c7 AW |
332 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
333 | BFD_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. |
338 | AT_CHECK([ovs-vsctl set Interface p0 bfd:decay_min_rx=0]) | |
339 | # advance the clock by 5000ms. | |
8661af79 | 340 | ovs-appctl time/warp 10000 500 |
27e26e59 | 341 | # min_rx is reset. |
c1c4e8c7 | 342 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
27e26e59 | 343 | BFD_CHECK_RX([p0], [500ms], [300ms], [500ms]) |
881d47a9 | 344 | |
c1c4e8c7 AW |
345 | for i in `seq 0 20` |
346 | do | |
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]) | |
352 | done | |
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 | 357 | AT_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 | 359 | ovs-appctl time/warp 10000 500 |
27e26e59 AW |
360 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
361 | BFD_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 |
363 | BFD_CHECK_TX([p0], [500ms], [300ms], [5000ms]) |
364 | BFD_CHECK_RX([p0], [5000ms], [3000ms], [500ms]) | |
365 | # then, there should be no change of status, | |
27e26e59 | 366 | for i in `seq 0 19` |
c1c4e8c7 AW |
367 | do |
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]) | |
373 | done | |
374 | # reset the p1's min_tx to 500ms. | |
375 | AT_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 | 378 | ovs-appctl time/warp 20000 500 |
c1c4e8c7 AW |
379 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
380 | BFD_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 |
386 | AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=false]) | |
387 | ||
27e26e59 | 388 | # advance the clock by 15000ms to stable everything. |
8661af79 | 389 | ovs-appctl time/warp 15000 1000 |
c1c4e8c7 AW |
390 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
391 | BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms]) | |
392 | BFD_CHECK_RX([p0], [300ms], [300ms], [1ms]) | |
393 | ||
394 | # resume the bfd on p1. the bfd should not go to decay mode direclty. | |
395 | AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true]) | |
8661af79 | 396 | ovs-appctl time/warp 1500 500 |
c1c4e8c7 AW |
397 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
398 | BFD_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 | 401 | ovs-appctl time/warp 5000 500 |
c1c4e8c7 AW |
402 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
403 | BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) | |
27e26e59 | 404 | # End of Test-6 ################################################################ |
c1c4e8c7 AW |
405 | |
406 | OVS_VSWITCHD_STOP | |
01d18a3a AW |
407 | AT_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 | 416 | AT_SETUP([bfd - bfd forwarding_if_rx - bfd on one side]) |
01d18a3a AW |
417 | OVS_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 | ||
425 | ovs-appctl time/stop | |
426 | # check the inital status. | |
427 | BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic]) | |
428 | BFD_CHECK_TX([p0], [1000ms], [1000ms], [0ms]) | |
429 | BFD_CHECK_RX([p0], [500ms], [500ms], [1ms]) | |
430 | ||
431 | # enable forwarding_if_rx. | |
432 | AT_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. | |
436 | for i in `seq 0 3` | |
437 | do | |
438 | ovs-appctl time/warp 500 | |
439 | BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic]) | |
440 | done | |
441 | ||
3688ce7a AW |
442 | # receive packet at 1/100ms rate for 2000ms. |
443 | for i in `seq 0 19` | |
01d18a3a AW |
444 | do |
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], []) |
448 | done | |
34c88624 | 449 | # the forwarding flag should be false, due to the demand_rx_bfd. |
01d18a3a | 450 | BFD_CHECK([p0], [false], [false], [none], [down], [No Diagnostic], [none], [down], [No Diagnostic]) |
01d18a3a AW |
451 | |
452 | AT_CHECK([ovs-vsctl del-br br1], [0], [ignore]) | |
2f2695a2 | 453 | OVS_VSWITCHD_STOP |
01d18a3a AW |
454 | AT_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. | |
461 | AT_SETUP([bfd - bfd forwarding_if_rx - bfd on both sides]) | |
01d18a3a AW |
462 | OVS_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 | ||
471 | ovs-appctl time/stop | |
472 | # advance the clock, to stablize the states. | |
8661af79 | 473 | ovs-appctl time/warp 5000 500 |
01d18a3a AW |
474 | |
475 | # enable forwarding_if_rx. | |
476 | AT_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. | |
480 | for i in `seq 0 5` | |
481 | do | |
482 | ovs-appctl time/warp 500 | |
483 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
484 | done | |
485 | ||
486 | # stop the bfd on one side. | |
487 | AT_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. | |
490 | for i in `seq 0 1` | |
491 | do | |
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 | |
499 | done | |
500 | ||
501 | # at 1500ms, the STATE should go DOWN, due to Control Detection Time Expired. | |
502 | # but forwarding flag should be still true. | |
503 | ovs-appctl time/warp 500 | |
504 | BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
505 | ||
01d18a3a AW |
506 | # reset bfd forwarding_if_rx. |
507 | AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false], [0]) | |
508 | # forwarding flag should turn to false since the STATE is DOWN. | |
509 | BFD_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. | |
512 | AT_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 | 514 | ovs-appctl time/warp 5000 500 |
01d18a3a AW |
515 | BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic]) |
516 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired]) | |
517 | BFD_CHECK_TX([p0], [500ms], [500ms], [300ms]) | |
518 | BFD_CHECK_RX([p0], [500ms], [500ms], [300ms]) | |
519 | ||
520 | AT_CHECK([ovs-vsctl del-br br1], [0], [ignore]) | |
2f2695a2 | 521 | OVS_VSWITCHD_STOP |
01d18a3a AW |
522 | AT_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. | |
527 | AT_SETUP([bfd - bfd forwarding_if_rx - with bfd decay]) | |
01d18a3a AW |
528 | OVS_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 | ||
536 | ovs-appctl time/stop | |
537 | # advance the clock, to stablize the states. | |
8661af79 | 538 | ovs-appctl time/warp 10000 500 |
01d18a3a AW |
539 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
540 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
541 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) | |
542 | BFD_CHECK_RX([p0], [3000ms], [3000ms], [500ms]) | |
543 | ||
544 | # enable forwarding_if_rx. | |
545 | AT_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. | |
549 | for i in `seq 0 9` | |
550 | do | |
551 | ovs-appctl time/warp 500 | |
552 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
553 | done | |
554 | ||
3688ce7a | 555 | # reconfigure the decay_min_rx to 1000ms. |
01d18a3a | 556 | AT_CHECK([ovs-vsctl set interface p0 bfd:decay_min_rx=1000]) |
01d18a3a | 557 | |
3688ce7a | 558 | # wait for 5000ms to decay. |
8661af79 | 559 | ovs-appctl time/warp 5000 500 |
309d9dac | 560 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
01d18a3a AW |
561 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) |
562 | BFD_CHECK_RX([p0], [1000ms], [1000ms], [500ms]) | |
563 | ||
564 | # stop the bfd on one side. | |
565 | AT_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. | |
570 | for i in `seq 0 7` | |
01d18a3a AW |
571 | do |
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], []) |
575 | done | |
01d18a3a AW |
576 | BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
577 | ||
578 | # receive packet at 1/100ms rate for 1000ms. | |
579 | for i in `seq 0 9` | |
580 | do | |
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]) | |
586 | done | |
587 | ||
309d9dac | 588 | # stop receiving for 5000ms. |
8661af79 | 589 | ovs-appctl time/warp 5000 100 |
01d18a3a AW |
590 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
591 | ||
592 | # reset bfd forwarding_if_rx. | |
593 | AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=false]) | |
01d18a3a | 594 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
01d18a3a AW |
595 | # re-enable bfd forwarding_if_rx. |
596 | AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true]) | |
01d18a3a | 597 | BFD_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. | |
600 | AT_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 | 602 | ovs-appctl time/warp 10000 500 |
01d18a3a AW |
603 | BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic]) |
604 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired]) | |
605 | BFD_CHECK_TX([p0], [300ms], [300ms], [300ms]) | |
606 | BFD_CHECK_RX([p0], [1000ms], [1000ms], [300ms]) | |
607 | ||
608 | AT_CHECK([ovs-vsctl del-br br1], [0], [ignore]) | |
2f2695a2 | 609 | OVS_VSWITCHD_STOP |
4905e2df AW |
610 | AT_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. | |
615 | AT_SETUP([bfd - bfd forwarding_if_rx - demand_rx_bfd]) | |
616 | OVS_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 | ||
624 | ovs-appctl time/stop | |
625 | # advance the clock, to stablize the states. | |
8661af79 | 626 | ovs-appctl time/warp 10000 500 |
34c88624 AW |
627 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
628 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
629 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) | |
630 | ||
631 | # disable the bfd on p1. | |
632 | AT_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. | |
637 | for i in `seq 0 7` | |
638 | do | |
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], []) |
642 | done | |
643 | BFD_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. | |
648 | for i in `seq 0 120` | |
649 | do | |
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], []) |
653 | done | |
654 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
655 | ||
656 | # now enable the bfd on p1 again. | |
657 | AT_CHECK([ovs-vsctl set Interface p1 bfd:enable=true], [0]) | |
658 | # advance clock by 5000ms. and p1 and p0 should be all up. | |
8661af79 | 659 | ovs-appctl time/warp 5000 500 |
34c88624 AW |
660 | BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic]) |
661 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired]) | |
662 | BFD_CHECK_TX([p0], [500ms], [300ms], [500ms]) | |
663 | ||
664 | # disable the bfd on p1 again. | |
665 | AT_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. | |
669 | for i in `seq 0 120` | |
670 | do | |
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], []) |
674 | done | |
675 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
676 | ||
677 | AT_CHECK([ovs-vsctl del-br br1], [0], [ignore]) | |
2f2695a2 | 678 | OVS_VSWITCHD_STOP |
34c88624 AW |
679 | AT_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 |
686 | AT_SETUP([bfd - flap_count]) |
687 | #Create 2 bridges connected by patch ports and enable bfd | |
688 | OVS_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 | ||
698 | ovs-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. | |
701 | AT_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 | 704 | ovs-appctl time/warp 10100 100 |
4905e2df AW |
705 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) |
706 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
707 | BFD_CHECK_TX([p0], [100ms], [100ms], [100ms]) | |
708 | BFD_CHECK_RX([p0], [100ms], [100ms], [100ms]) | |
709 | # both p0 and p1 should have flap_count = "1". since down->up. | |
710 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
711 | BFD_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. | |
714 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false]) | |
8661af79 | 715 | ovs-appctl time/warp 5000 100 |
4905e2df AW |
716 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
717 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"]) | |
718 | AT_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. | |
722 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) | |
8661af79 | 723 | ovs-appctl time/warp 5000 100 |
4905e2df AW |
724 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"]) |
725 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
726 | ||
727 | ||
728 | # Part-2 now turn on the forwarding_override. | |
729 | AT_CHECK([ovs-appctl bfd/set-forwarding p0 true], [0], [dnl | |
730 | OK | |
731 | ]) | |
732 | ||
733 | # turn bfd on p1 off, should not increment the bfd:flap_count on p0, since forwarding_override is on. | |
734 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false]) | |
8661af79 | 735 | ovs-appctl time/warp 5000 100 |
4905e2df AW |
736 | BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
737 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"]) | |
738 | AT_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. | |
742 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) | |
8661af79 | 743 | ovs-appctl time/warp 5000 100 |
4905e2df AW |
744 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"]) |
745 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
746 | ||
747 | # turn the forwarding_override back to normal. | |
748 | AT_CHECK([ovs-appctl bfd/set-forwarding p0 normal], [0], [dnl | |
749 | OK | |
750 | ]) | |
751 | ||
752 | # turn bfd on p1 off and on, should increment the bfd:flap_count on p0. | |
753 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false]) | |
8661af79 | 754 | ovs-appctl time/warp 5000 100 |
4905e2df | 755 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) |
8661af79 | 756 | ovs-appctl time/warp 5000 100 |
4905e2df AW |
757 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["5"]) |
758 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
759 | ||
760 | # Part-3 now turn on forwarding_if_rx. | |
761 | AT_CHECK([ovs-vsctl set Interface p0 bfd:forwarding_if_rx=true], [0]) | |
8661af79 | 762 | ovs-appctl time/warp 1100 100 |
4905e2df AW |
763 | # disable the bfd on p1. |
764 | AT_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. | |
769 | for i in `seq 0 39` | |
770 | do | |
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], []) |
774 | done | |
775 | BFD_CHECK([p0], [true], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
776 | # flap_count should remain unchanged. | |
777 | BFD_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 | 781 | ovs-appctl time/warp 12100 100 |
4905e2df AW |
782 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
783 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"]) | |
784 | ||
785 | # advance clock by 4000ms, and resume the traffic. | |
786 | for i in `seq 0 39` | |
787 | do | |
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], []) |
791 | done | |
34c88624 | 792 | # forwarding should be false, since there is still no bfd control packet received. |
4905e2df | 793 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) |
34c88624 | 794 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["6"]) |
4905e2df AW |
795 | |
796 | # turn on the bfd on p1. | |
797 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) | |
8661af79 | 798 | ovs-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 | 800 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["7"]) |
4905e2df AW |
801 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) |
802 | ||
803 | OVS_VSWITCHD_STOP | |
8661af79 | 804 | AT_CLEANUP |
67818616 MV |
805 | |
806 | AT_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 | |
810 | OVS_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 | ||
818 | AT_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 | ||
822 | AT_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 | ||
826 | ovs-appctl time/stop | |
827 | ovs-appctl time/warp 4100 100 | |
828 | ||
829 | # Forwarding should be true | |
830 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
831 | BFD_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 | |
834 | AT_CHECK([ovs-vsctl set interface p2 bfd:enable=false]) | |
835 | ||
836 | ovs-appctl time/warp 5000 100 | |
837 | BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
838 | ||
839 | OVS_VSWITCHD_STOP | |
840 | AT_CLEANUP | |
f73b83fd LS |
841 | |
842 | # test bfd: liveness propagation - OF1.3. | |
843 | AT_SETUP([bfd - liveness propagation - OF1.3]) | |
844 | OVS_VSWITCHD_START | |
845 | AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile]) | |
846 | check_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 ' |
857 | s/ (xid=0x[0-9a-fA-F]*)// | |
858 | s/ *duration.*// | |
859 | s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]], | |
860 | [0], [expout]) | |
861 | } | |
862 | : > expout | |
863 | ovs-appctl -t ovs-ofctl ofctl/barrier | |
864 | ovs-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. | |
866 | ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080 | |
867 | #Create 2 bridges connected by patch ports and enable bfd | |
868 | AT_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 | ||
878 | ovs-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. | |
881 | AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000]) | |
882 | ||
883 | # wait for a while to stablize bfd. | |
884 | ovs-appctl time/warp 10100 100 | |
885 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
886 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
887 | BFD_CHECK_TX([p0], [100ms], [100ms], [100ms]) | |
888 | BFD_CHECK_RX([p0], [100ms], [100ms], [100ms]) | |
889 | # both p0 and p1 should have flap_count = "1". since down->up. | |
890 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
891 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
892 | check_liveness 1 LIVE | |
893 | ||
894 | # turn bfd on p1 off, should increment the bfd:flap_count on p0. | |
895 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false]) | |
896 | ovs-appctl time/warp 5000 100 | |
897 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
898 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"]) | |
899 | AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"]) | |
900 | check_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. | |
904 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) | |
905 | ovs-appctl time/warp 5000 100 | |
906 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"]) | |
907 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
908 | check_liveness 3 LIVE | |
909 | ||
910 | OVS_VSWITCHD_STOP | |
911 | AT_CLEANUP | |
912 | ||
913 | # test bfd: liveness propagation - OF1.4. | |
914 | AT_SETUP([bfd - liveness propagation - OF1.4]) | |
915 | OVS_VSWITCHD_START | |
916 | AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile]) | |
917 | check_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 ' |
928 | s/ (xid=0x[0-9a-fA-F]*)// | |
929 | s/ *duration.*// | |
930 | s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]], | |
931 | [0], [expout]) | |
932 | } | |
933 | : > expout | |
934 | ovs-appctl -t ovs-ofctl ofctl/barrier | |
935 | ovs-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. | |
937 | ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080 | |
938 | #Create 2 bridges connected by patch ports and enable bfd | |
939 | AT_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 | ||
949 | ovs-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. | |
952 | AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000]) | |
953 | ||
954 | # wait for a while to stablize bfd. | |
955 | ovs-appctl time/warp 10100 100 | |
956 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
957 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
958 | BFD_CHECK_TX([p0], [100ms], [100ms], [100ms]) | |
959 | BFD_CHECK_RX([p0], [100ms], [100ms], [100ms]) | |
960 | # both p0 and p1 should have flap_count = "1". since down->up. | |
961 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
962 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
963 | check_liveness 1 LIVE | |
964 | ||
965 | # turn bfd on p1 off, should increment the bfd:flap_count on p0. | |
966 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false]) | |
967 | ovs-appctl time/warp 5000 100 | |
968 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
969 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"]) | |
970 | AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"]) | |
971 | check_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. | |
975 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) | |
976 | ovs-appctl time/warp 5000 100 | |
977 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"]) | |
978 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
979 | check_liveness 3 LIVE | |
980 | ||
981 | OVS_VSWITCHD_STOP | |
982 | AT_CLEANUP | |
983 | ||
984 | # test bfd: liveness propagation - OF1.5. | |
985 | AT_SETUP([bfd - liveness propagation - OF1.5]) | |
986 | OVS_VSWITCHD_START | |
987 | AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile]) | |
988 | check_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 ' |
999 | s/ (xid=0x[0-9a-fA-F]*)// | |
1000 | s/ *duration.*// | |
1001 | s/addr:[0-9a-fA-F:]*/addr:/' < monitor.log|grep -A3 "MOD: 1(p0)"|grep -ve --]], | |
1002 | [0], [expout]) | |
1003 | } | |
1004 | : > expout | |
1005 | ovs-appctl -t ovs-ofctl ofctl/barrier | |
1006 | ovs-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. | |
1008 | ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080 | |
1009 | #Create 2 bridges connected by patch ports and enable bfd | |
1010 | AT_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 | ||
1020 | ovs-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. | |
1023 | AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:stats-update-interval=50000000]) | |
1024 | ||
1025 | # wait for a while to stablize bfd. | |
1026 | ovs-appctl time/warp 10100 100 | |
1027 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
1028 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
1029 | BFD_CHECK_TX([p0], [100ms], [100ms], [100ms]) | |
1030 | BFD_CHECK_RX([p0], [100ms], [100ms], [100ms]) | |
1031 | # both p0 and p1 should have flap_count = "1". since down->up. | |
1032 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
1033 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
1034 | check_liveness 1 LIVE | |
1035 | ||
1036 | # turn bfd on p1 off, should increment the bfd:flap_count on p0. | |
1037 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=false]) | |
1038 | ovs-appctl time/warp 5000 100 | |
1039 | BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic]) | |
1040 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["2"]) | |
1041 | AT_CHECK([ovs-vsctl list interface p1 | sed -n "s/^.*flap_count=\(.*\), forwarding.*$/\1/p"]) | |
1042 | check_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. | |
1046 | AT_CHECK([ovs-vsctl set interface p1 bfd:enable=true]) | |
1047 | ovs-appctl time/warp 5000 100 | |
1048 | BFD_VSCTL_LIST_IFACE([p0], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["3"]) | |
1049 | BFD_VSCTL_LIST_IFACE([p1], ["s/^.*flap_count=\(.*\), forwarding.*$/\1/p"], ["1"]) | |
1050 | check_liveness 3 LIVE | |
1051 | ||
1052 | OVS_VSWITCHD_STOP | |
1053 | AT_CLEANUP | |
4cefc3da SG |
1054 | |
1055 | AT_SETUP([bfd - Edit the Detect Mult values]) | |
1056 | #Create 2 bridges connected by patch ports and enable BFD | |
1057 | OVS_VSWITCHD_START() | |
1058 | ovs-appctl time/stop | |
1059 | AT_CHECK([ ovs-vsctl -- add-br br1 -- \ | |
1060 | set bridge br1 datapath-type=dummy ]) | |
1061 | AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch\ | |
1062 | options:peer=p0 ]) | |
1063 | AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch\ | |
1064 | options:peer=p1 ]) | |
1065 | AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ]) | |
1066 | AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ]) | |
1067 | ovs-appctl time/warp 3100 100 | |
1068 | #Verify that BFD has been enabled on both interfaces. | |
1069 | BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
1070 | BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic]) | |
1071 | #Verify that default mult values are 3. | |
1072 | BFD_CHECK_MULT([p0], [3], [3]) | |
1073 | BFD_CHECK_MULT([p1], [3], [3]) | |
1074 | #Set the mult values to valid range border mult(p0)=1 mult(p1)=255. | |
1075 | AT_CHECK([ovs-vsctl set interface p0 bfd:mult=1]) | |
1076 | AT_CHECK([ovs-vsctl set interface p1 bfd:mult=255]) | |
1077 | ovs-appctl time/warp 3100 100 | |
1078 | BFD_CHECK_MULT([p0], [1], [255]) | |
1079 | BFD_CHECK_MULT([p1], [255], [1]) | |
1080 | ||
1081 | #Set the mult values out valid range border mult(p0)=0 mult(p1)=256. | |
1082 | AT_CHECK([ovs-vsctl set interface p0 bfd:mult=0]) | |
1083 | AT_CHECK([ovs-vsctl set interface p1 bfd:mult=256]) | |
1084 | ovs-appctl time/warp 3100 100 | |
1085 | BFD_CHECK_MULT([p0], [3], [3]) | |
1086 | BFD_CHECK_MULT([p1], [3], [3]) | |
1087 | ||
1088 | #Set valid non default mult values mult(p0)=8 mult(p1)=125. | |
1089 | AT_CHECK([ovs-vsctl set interface p0 bfd:mult=8]) | |
1090 | AT_CHECK([ovs-vsctl set interface p1 bfd:mult=125]) | |
1091 | ovs-appctl time/warp 3100 100 | |
1092 | BFD_CHECK_MULT([p0], [8], [125]) | |
1093 | BFD_CHECK_MULT([p1], [125], [8]) | |
1094 | ||
1095 | #Clear mult values. Detect mult values shall be default 3 again. | |
1096 | AT_CHECK([ovs-vsctl remove interface p0 bfd mult]) | |
1097 | AT_CHECK([ovs-vsctl remove interface p1 bfd mult]) | |
1098 | ovs-appctl time/warp 3100 100 | |
1099 | BFD_CHECK_MULT([p0], [3], [3]) | |
1100 | BFD_CHECK_MULT([p1], [3], [3]) | |
1101 | ||
1102 | OVS_VSWITCHD_STOP | |
1103 | AT_CLEANUP | |
b793a65c YS |
1104 | |
1105 | AT_SETUP([bfd - overlay]) | |
1106 | OVS_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. | |
1112 | AT_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. | |
1114 | AT_CHECK([tail -2 stdout], [0], [dnl | |
1115 | This 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. | |
1120 | AT_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]) | |
1121 | AT_CHECK([tail -10 stdout], [0], [dnl | |
1122 | bridge("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 | ||
1129 | Final flow: unchanged | |
1130 | Megaflow: 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 | |
1131 | Datapath actions: 100 | |
1132 | ], []) | |
1133 | ||
1134 | OVS_VSWITCHD_STOP | |
1135 | AT_CLEANUP |