BFD: Edit the unit test time/stop command
[sliver-openvswitch.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'],[0],
5 [dnl
6         Forwarding: $2
7         Detect Multiplier: 3
8         Concatenated Path Down: $3
9
10         Local Flags: $4
11         Local Session State: $5
12         Local Diagnostic: $6
13
14         Remote Flags: $7
15         Remote Session State: $8
16         Remote Diagnostic: $9
17 ])
18 ])
19
20 m4_define([BFD_CHECK_TX], [
21 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/TX Interval/p'],[0],
22 [dnl
23         TX Interval: Approx 1000ms
24         Local Minimum TX Interval: $2
25         Remote Minimum TX Interval: $3
26 ])
27 ])
28
29 m4_define([BFD_CHECK_RX], [
30 AT_CHECK([ovs-appctl bfd/show $1 | sed -n '/RX Interval/p'],[0],
31 [dnl
32         RX Interval: Approx $2
33         Local Minimum RX Interval: $2
34         Remote Minimum RX Interval: $3
35 ])
36 ])
37 AT_SETUP([bfd - basic config on different bridges])
38 #Create 2 bridges connected by patch ports and enable BFD
39 OVS_VSWITCHD_START(
40    [add-br br1 -- \
41        set bridge br1 datapath-type=dummy \
42        other-config:hwaddr=aa:55:aa:56:00:00 -- \
43     add-port br1 p1 -- set Interface p1 type=patch \
44        options:peer=p0 -- \
45     add-port br0 p0 -- set Interface p0 type=patch \
46        options:peer=p1 -- \
47     set Interface p0 bfd:enable=true -- \
48     set Interface p1 bfd:enable=true ])
49 ovs-appctl time/stop
50 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
51
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])
55
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])
59
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])
64
65 ovs-vsctl del-br br0
66 AT_CHECK([ovs-appctl bfd/show p0], [2],[ignore], [no such bfd object
67 ovs-appctl: ovs-vswitchd: server returned an error
68 ])
69 ovs-vsctl del-br br1
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
73 ])
74
75 OVS_VSWITCHD_STOP
76 AT_CLEANUP
77
78
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.
84
85 OVS_VSWITCHD_START(
86    [add-br br-bfd0 -- \
87        set bridge br-bfd0 datapath-type=dummy \
88        other-config:hwaddr=aa:55:aa:56:00:00 -- \
89     add-br br-bfd1 -- \
90        set bridge br-bfd1 datapath-type=dummy \
91        other-config:hwaddr=aa:55:aa:57:00:00 -- \
92     add-br br-sw -- \
93        set bridge br-sw datapath-type=dummy \
94        other-config:hwaddr=aa:55:aa:58:00:00 -- \
95     add-port br-sw p1-sw -- set Interface p1-sw type=patch \
96        options:peer=p1 -- \
97     add-port br-sw p0-sw -- set Interface p0-sw type=patch \
98        options:peer=p0 -- \
99     add-port br-bfd1 p1 -- set Interface p1 type=patch \
100        options:peer=p1-sw bfd:enable=true -- \
101     add-port br-bfd0 p0 -- set Interface p0 type=patch \
102        options:peer=p0-sw bfd:enable=true --])
103
104 ovs-appctl time/stop
105
106 #Create 2 bridges connected by patch ports and enable BFD
107
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])
113
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])
119
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
125
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])
128
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.
132
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.
135
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])
143
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.
147
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])
155 OVS_VSWITCHD_STOP
156 AT_CLEANUP
157
158
159 AT_SETUP([bfd - concatenated path down])
160 #Create 2 bridges connected by patch ports and enable BFD
161 OVS_VSWITCHD_START()
162 ovs-appctl time/stop
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 ])
166 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
167            options:peer=p0 ])
168 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
169            options:peer=p1 ])
170 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
171 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
172 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
173
174 #Verify that BFD has been enabled on both interfaces.
175 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
176 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
177
178 #Set cpath_down to true on one interface, make sure the remote interface updates its values.
179 AT_CHECK([ovs-vsctl set interface p0 bfd:cpath_down=true])
180 for i in `seq 0 40`; do ovs-appctl time/warp 100; done
181 BFD_CHECK([p1], [false], [false], [none], [up], [No Diagnostic], [none], [up], [Concatenated Path Down])
182 OVS_VSWITCHD_STOP
183 AT_CLEANUP
184
185
186 AT_SETUP([bfd - Edit the Min Tx/Rx values])
187 #Create 2 bridges connected by patch ports and enable BFD
188 OVS_VSWITCHD_START()
189 ovs-appctl time/stop
190 AT_CHECK([ ovs-vsctl -- add-br br1 -- \
191            set bridge br1 datapath-type=dummy ])
192 AT_CHECK([ ovs-vsctl -- add-port br1 p1 -- set Interface p1 type=patch \
193            options:peer=p0 ])
194 AT_CHECK([ ovs-vsctl -- add-port br0 p0 -- set Interface p0 type=patch \
195            options:peer=p1 ])
196 AT_CHECK([ ovs-vsctl -- set interface p0 bfd:enable=true ])
197 AT_CHECK([ ovs-vsctl -- set interface p1 bfd:enable=true ])
198 for i in `seq 0 30`; do ovs-appctl time/warp 100; done
199 #Verify that BFD has been enabled on both interfaces.
200 BFD_CHECK([p1], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
201 BFD_CHECK([p0], [true], [false], [none], [up], [No Diagnostic], [none], [up], [No Diagnostic])
202 #Edit the min Tx value.
203 AT_CHECK([ovs-vsctl set interface p0 bfd:min_tx=200])
204 for i in `seq 0 20`; do ovs-appctl time/warp 100; done
205 BFD_CHECK_TX([p0], [200ms], [100ms])
206 BFD_CHECK_TX([p1], [100ms], [200ms])
207
208 #Edit the min Rx value.
209 AT_CHECK([ovs-vsctl set interface p1 bfd:min_rx=300])
210 for i in `seq 0 20`; do ovs-appctl time/warp 100; done
211 BFD_CHECK_RX([p1], [300ms], [1000ms])
212 BFD_CHECK_RX([p0], [1000ms], [300ms])
213
214 OVS_VSWITCHD_STOP
215 AT_CLEANUP