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'],[0],
8
Concatenated Path Down: $3
11
Local Session State: $5
15
Remote Session State: $8
20
m4_define([BFD_CHECK_TX], [
21
AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
23
TX Interval: Approx 1000ms
24
Local Minimum TX Interval: $2
25
Remote Minimum TX Interval: $3
29
m4_define([BFD_CHECK_RX], [
30
AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
32
RX Interval: Approx $2
33
Local Minimum RX Interval: $2
34
Remote Minimum RX Interval: $3
37
AT_SETUP([bfd - basic config on different bridges])
39
#Create 2 bridges connected by patch ports and enable BFD
42
set bridge br1 datapath-type=dummy \
43
other-config:hwaddr=aa:55:aa:56:00:00 -- \
44
add-port br1 p1 -- set Interface p1 type=patch \
46
add-port br0 p0 -- set Interface p0 type=patch \
48
set Interface p0 bfd:enable=true -- \
49
set Interface p1 bfd:enable=true ])
50
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
52
#Verify that BFD has been enabled on both interfaces.
53
BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
54
BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
56
AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=false])
57
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
58
BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
60
AT_CHECK([ ovs-vsctl set interface p0 bfd:enable=true])
61
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
62
BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [No Diagnostic])
63
BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [Control Detection Time Expired])
66
AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
67
ovs-appctl: ovs-vswitchd: server returned an error
70
#Check that the entries are gone.
71
AT_CHECK([ovs-appctl bfd/show p1], [2],[ignore], [no such bfd object
72
ovs-appctl: ovs-vswitchd: server returned an error
79
AT_SETUP([bfd - Verify tunnel down detection])
80
#Create 3 bridges - br-bfd0, br-bfd1 and br-sw which is midway between the two. br2 is
81
#connected to br-bfd0 and br-bfd1 through patch ports p0-2 and p1-2. Enable BFD on
82
#interfaces in br-bfd0 and br-bfd1. When br-sw is dropping all packets, BFD should detect
83
# that the tunnel is down, and come back up when br-sw is working fine.
88
set bridge br-bfd0 datapath-type=dummy \
89
other-config:hwaddr=aa:55:aa:56:00:00 -- \
91
set bridge br-bfd1 datapath-type=dummy \
92
other-config:hwaddr=aa:55:aa:57:00:00 -- \
94
set bridge br-sw datapath-type=dummy \
95
other-config:hwaddr=aa:55:aa:58:00:00 -- \
96
add-port br-sw p1-sw -- set Interface p1-sw type=patch \
98
add-port br-sw p0-sw -- set Interface p0-sw type=patch \
100
add-port br-bfd1 p1 -- set Interface p1 type=patch \
101
options:peer=p1-sw bfd:enable=true -- \
102
add-port br-bfd0 p0 -- set Interface p0 type=patch \
103
options:peer=p0-sw bfd:enable=true --])
106
#Create 2 bridges connected by patch ports and enable BFD
108
AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
109
#Verify that BFD is enabled.
110
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
111
BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
112
BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
114
#Drop all packets in the br-sw bridge so that the tunnel is down.
115
AT_CHECK([ ovs-ofctl add-flow br-sw 'priority=5,actions=drop' ])
116
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
117
BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
118
BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
120
#Delete the added flow
121
AT_CHECK([ovs-ofctl del-flows br-sw], [0])
122
AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
123
#Verify that BFD is back up again.
124
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
126
BFD_CHECK([p1], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
127
BFD_CHECK([p0], [true], [false], [none], [up], [Control Detection Time Expired], [none], [up], [Control Detection Time Expired])
129
#Now, Verify one-side tunnel down detection
130
#When br-sw is dropping packets from one end, BFD should detect
131
# that the tunnel is down, and come back up when br-sw is working fine.
133
#Bring down the br-bfd1 - br-sw link. So BFD packets will be sent from p0,
134
# but not received by p1. p0 will receive all BFD packets from p1.
136
AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=1,priority=5,actions=drop'])
137
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
138
# Make sure p1 BFD state is down since it received no BFD packets.
139
BFD_CHECK([p1], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
140
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
141
# p0 will be in init state once it receives "down" BFD message from p1.
142
BFD_CHECK([p0], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
144
AT_CHECK([ovs-ofctl del-flows br-sw])
145
AT_CHECK([ovs-ofctl add-flow br-sw 'priority=0,actions=NORMAL'])
146
#Ensure that BFD is back up again.
148
for i in `seq 0 10`; do ovs-appctl time/warp 100; done
149
#Bring down the br-bfd0 - br-sw link
150
AT_CHECK([ ovs-ofctl add-flow br-sw 'in_port=2,priority=5,actions=drop'])
151
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
152
BFD_CHECK([p0], [false], [false], [none], [down], [Control Detection Time Expired], [none], [down], [No Diagnostic])
153
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
154
BFD_CHECK([p1], [false], [false], [none], [init], [Neighbor Signaled Session Down], [none], [down], [Control Detection Time Expired])
159
AT_SETUP([bfd - concatenated path down])
160
#Create 2 bridges connected by patch ports and enable BFD
163
AT_CHECK([ ovs-vsctl -- add-br br1 -- \
164
set bridge br1 datapath-type=dummy \
165
other-config:hwaddr=aa:55:aa:56:00:00 ])
167
AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
169
AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
171
AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
172
AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
173
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
175
#Verify that BFD has been enabled on both interfaces.
176
BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
177
BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
179
#Set cpath_down to true on one interface, make sure the remote interface updates its values.
180
AT_CHECK([ovs-vsctl set interface p0 bfd:cpath_down=true])
181
for i in `seq 0 40`; do ovs-appctl time/warp 100; done
182
BFD_CHECK([p1], [false], [false], [none], [up], [No Diagnostic], [none], [up], [Concatenated Path Down])
187
AT_SETUP([bfd - Edit the Min Tx/Rx values])
188
#Create 2 bridges connected by patch ports and enable BFD
190
ovs-appctl vlog/set bfd:dbg
192
AT_CHECK([ ovs-vsctl -- add-br br1 -- \
193
set bridge br1 datapath-type=dummy ])
194
AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
196
AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
198
AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
199
AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
200
for i in `seq 0 20`; do ovs-appctl time/warp 100; done
201
#Verify that BFD has been enabled on both interfaces.
202
BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
203
BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
204
#Edit the min Tx value.
205
AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200])
206
for i in `seq 0 20`; do ovs-appctl time/warp 100; done
207
BFD_CHECK_TX([p0], [200ms], [100ms])
208
BFD_CHECK_TX([p1], [100ms], [200ms])
210
#Edit the min Rx value.
211
AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300])
212
for i in `seq 0 20`; do ovs-appctl time/warp 100; done
213
BFD_CHECK_RX([p1], [300ms], [1000ms])
214
BFD_CHECK_RX([p0], [1000ms], [300ms])