forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfm.at
285 lines (244 loc) · 11 KB
/
cfm.at
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
AT_BANNER([cfm])
m4_define([CFM_CHECK_EXTENDED], [
AT_CHECK([ovs-appctl cfm/show $1 | sed -e '/next CCM tx:/d' | sed -e '/next fault check:/d' | sed -e '/recv since check:/d'],[0],
[dnl
---- $1 ----
MPID $2: extended
average health: $3
opstate: $4
remote_opstate: $5
interval: $6
Remote MPID $7
opstate: $8
])
])
m4_define([CFM_CHECK_EXTENDED_FAULT], [
AT_CHECK([ovs-appctl cfm/show $1 | sed -e '/next CCM tx:/d' | sed -e '/next fault check:/d' | sed -e '/recv since check:/d'],[0],
[dnl
---- $1 ----
MPID $2: extended
fault: $3
average health: $4
opstate: $5
remote_opstate: $6
interval: $7
])
])
m4_define([CFM_VSCTL_LIST_IFACE], [
AT_CHECK([ovs-vsctl list interface $1 | sed -n '/$2 /p'],[0],
[dnl
$3
])
])
m4_define([CFM_CHECK_DB], [
CFM_VSCTL_LIST_IFACE([$1], [cfm_fault], [cfm_fault : $2])
CFM_VSCTL_LIST_IFACE([$1], [cfm_fault_status], [cfm_fault_status : [[$3]]])
CFM_VSCTL_LIST_IFACE([$1], [cfm_flap_count], [cfm_flap_count : $4])
CFM_VSCTL_LIST_IFACE([$1], [cfm_health], [cfm_health : [[$5]]])
CFM_VSCTL_LIST_IFACE([$1], [cfm_remote_mpids], [cfm_remote_mpids : [[$6]]])
CFM_VSCTL_LIST_IFACE([$1], [cfm_remote_opstate], [cfm_remote_opstate : $7])
])
# These two tests check the update of cfm status at different scenarios.
# Test cfm status update at startup and removal.
AT_SETUP([cfm - check update ovsdb 1])
OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=gre \
options:remote_ip=1.2.3.4 -- \
set Interface p0 other_config:cfm_interval=300 other_config:cfm_extended=true])
ovs-appctl time/stop
AT_CHECK([ovs-vsctl set Interface p0 cfm_mpid=1])
# at beginning, since the first fault check timeout is not reached
# cfm_fault should be false.
for i in `seq 0 4`; do
ovs-appctl time/warp 100
CFM_CHECK_DB([p0], [false], [], [0], [], [], [up])
done
# advance clock to pass the fault check timeout and check cfm
# status update in OVSDB.
ovs-appctl time/warp 1500 100
CFM_CHECK_DB([p0], [true], [recv], [1], [], [], [up])
# remove the cfm on p0 and status should be all empty.
AT_CHECK([ovs-vsctl remove int p0 cfm_mpid 1])
ovs-appctl time/warp 500 100
CFM_CHECK_DB([p0], [[[]]], [], [[[]]], [], [], [[[]]])
OVS_VSWITCHD_STOP
AT_CLEANUP
# Test cfm status update in normal case.
AT_SETUP([cfm - check update ovsdb 2])
#Create 2 bridges connected by patch ports and enable cfm
OVS_VSWITCHD_START([add-br br1 -- \
set bridge br1 datapath-type=dummy \
other-config:hwaddr=aa:55:aa:56:00:00 -- \
add-port br1 p1 -- set Interface p1 type=patch \
options:peer=p0 -- \
add-port br0 p0 -- set Interface p0 type=patch \
options:peer=p1 -- \
set Interface p0 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
set Interface p1 other_config:cfm_interval=300 other_config:cfm_extended=true])
ovs-appctl time/stop
AT_CHECK([ovs-vsctl set Interface p0 cfm_mpid=1])
# check cfm status update in OVSDB.
ovs-appctl time/warp 1500 100
CFM_CHECK_DB([p0], [true], [recv], [1], [], [], [up])
# turn cfm on p1 on, cfm status of p0 and p1 should all go up.
AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
ovs-appctl time/warp 1500 100
CFM_CHECK_DB([p0], [false], [], [2], [], [2], [up])
CFM_CHECK_DB([p1], [false], [], [0], [], [1], [up])
# turn cfm on p1 off, cfm status of p0 should go down again.
AT_CHECK([ovs-vsctl remove int p1 cfm_mpid 2])
ovs-appctl time/warp 1500 100
CFM_CHECK_DB([p0], [true], [recv], [3], [], [], [up])
OVS_VSWITCHD_STOP
AT_CLEANUP
# test cfm under demand mode.
AT_SETUP([cfm - demand mode])
#Create 2 bridges connected by patch ports and enable cfm
OVS_VSWITCHD_START([add-br br1 -- \
set bridge br1 datapath-type=dummy \
other-config:hwaddr=aa:55:aa:56:00:00 -- \
add-port br1 p1 -- set Interface p1 type=patch \
options:peer=p0 -- \
add-port br0 p0 -- set Interface p0 type=patch \
options:peer=p1 -- \
set Interface p0 cfm_mpid=1 other_config:cfm_interval=300 other_config:cfm_extended=true -- \
set Interface p1 cfm_mpid=2 other_config:cfm_interval=300 other_config:cfm_extended=true ])
ovs-appctl time/stop
# wait for a while to stablize cfm.
ovs-appctl time/warp 10100 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
# turn on demand mode on one end.
AT_CHECK([ovs-vsctl set interface p0 other_config:cfm_demand=true])
# cfm should never go down.
for i in `seq 0 100`
do
ovs-appctl time/warp 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
done
# turn on demand mode on the other end.
AT_CHECK([ovs-vsctl set interface p1 other_config:cfm_demand=true])
for i in `seq 0 100`
do
ovs-appctl time/warp 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
done
OVS_VSWITCHD_STOP
AT_CLEANUP
# test demand_rx_ccm under demand mode.
AT_SETUP([cfm - demand_rx_ccm])
#Create 2 bridges connected by patch ports and enable cfm
OVS_VSWITCHD_START([add-br br1 -- \
set bridge br1 datapath-type=dummy \
other-config:hwaddr=aa:55:aa:56:00:00 -- \
add-port br1 p1 -- set Interface p1 type=patch \
options:peer=p0 ofport_request=2 -- \
add-port br0 p0 -- set Interface p0 type=patch \
options:peer=p1 ofport_request=1 -- \
set Interface p0 cfm_mpid=1 other_config:cfm_interval=300 other_config:cfm_extended=true other_config:cfm_demand=true -- \
set Interface p1 cfm_mpid=2 other_config:cfm_interval=300 other_config:cfm_extended=true other_config:cfm_demand=true])
ovs-appctl time/stop
# wait for a while to stablize cfm. (need a longer time, since in demand mode
# the fault interval is (MAX(ccm_interval_ms, 500) * 3.5) ms)
ovs-appctl time/warp 20100 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
# turn off the cfm on p1.
AT_CHECK([ovs-vsctl clear Interface p1 cfm_mpid])
# cfm should never go down while receiving data packets.
for i in `seq 0 200`
do
ovs-appctl time/warp 100
AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
[0], [stdout], [])
done
CFM_CHECK_EXTENDED([p0], [1], [0], [up], [up], [300ms], [2], [up])
# wait longer, since the demand_rx_ccm interval is 100 * 300 ms.
# since there is no ccm received, the [recv] fault should be raised.
for i in `seq 0 200`
do
ovs-appctl time/warp 100
AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
[0], [stdout], [])
done
CFM_CHECK_EXTENDED_FAULT([p0], [1], [recv], [0], [up], [up], [300ms])
# now turn on the cfm on p1 again,
AT_CHECK([ovs-vsctl set Interface p1 cfm_mpid=2])
# cfm should be up for both p0 and p1
ovs-appctl time/warp 20100 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [300ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [300ms], [1], [up])
# now turn off the cfm on p1 again
AT_CHECK([ovs-vsctl clear Interface p1 cfm_mpid])
# since there is no ccm received, the [recv] fault should be raised.
for i in `seq 0 400`
do
ovs-appctl time/warp 100
AT_CHECK([ovs-ofctl packet-out br1 3 2 "90e2ba01475000101856b2e80806000108000604000100101856b2e80202020300000000000002020202"],
[0], [stdout], [])
done
CFM_CHECK_EXTENDED_FAULT([p0], [1], [recv], [0], [up], [up], [300ms])
OVS_VSWITCHD_STOP
AT_CLEANUP
# test cfm_flap_count.
AT_SETUP([cfm - flap_count])
#Create 2 bridges connected by patch ports and enable cfm
OVS_VSWITCHD_START([add-br br1 -- \
set bridge br1 datapath-type=dummy \
other-config:hwaddr=aa:55:aa:56:00:00 -- \
add-port br1 p1 -- set Interface p1 type=patch \
options:peer=p0 -- \
add-port br0 p0 -- set Interface p0 type=patch \
options:peer=p1 -- \
set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
ovs-appctl time/stop
# wait for a while to stablize cfm.
ovs-appctl time/warp 10100 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
# turn cfm on p1 off, should increment the cfm_flap_count on p0.
AT_CHECK([ovs-vsctl remove interface p1 cfm_mpid 2])
ovs-appctl time/warp 1100 100
CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 1])
CFM_VSCTL_LIST_IFACE([p1], [cfm_flap_count], [cfm_flap_count : [[]]])
# turn cfm on p1 on again, should increment the cfm_flap_count on p0.
AT_CHECK([ovs-vsctl set interface p1 cfm_mpid=2])
ovs-appctl time/warp 1100 100
CFM_VSCTL_LIST_IFACE([p0], [cfm_flap_count], [cfm_flap_count : 2])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([cfm - fault_override])
OVS_VSWITCHD_START([add-br br1 -- \
set bridge br1 datapath-type=dummy \
other-config:hwaddr=aa:55:aa:56:00:00 -- \
add-port br1 p1 -- set Interface p1 type=patch \
options:peer=p0 -- \
add-port br0 p0 -- set Interface p0 type=patch \
options:peer=p1 -- \
set Interface p0 cfm_mpid=1 other_config:cfm_interval=100 other_config:cfm_extended=true -- \
set Interface p1 cfm_mpid=2 other_config:cfm_interval=100 other_config:cfm_extended=true])
ovs-appctl time/stop
# wait for a while to stablize cfm.
ovs-appctl time/warp 10100 100
CFM_CHECK_EXTENDED([p0], [1], [100], [up], [up], [100ms], [2], [up])
CFM_CHECK_EXTENDED([p1], [2], [100], [up], [up], [100ms], [1], [up])
AT_CHECK([ovs-appctl cfm/show p1 | grep 'fault_override'], [1], [ignore])
CFM_VSCTL_LIST_IFACE([p1], [cfm_fault_status], [cfm_fault_status : [[]]])
# set a fault and see that this is shown in the CFM module and the database
AT_CHECK([ovs-appctl cfm/set-fault p1 true], [0], [OK
])
AT_CHECK([ovs-appctl time/warp 100], [0], [ignore])
AT_CHECK([ovs-appctl cfm/show p1 | grep 'fault_override' | sed -e 's/MPID [[0-9]]*: extended //'], [0], [dnl
fault_override
])
CFM_VSCTL_LIST_IFACE([p1], [cfm_fault_status], [cfm_fault_status : [[override]]])
# reset and see that it returned to normal
AT_CHECK([ovs-appctl cfm/set-fault normal], [0], [OK
])
AT_CHECK([ovs-appctl time/warp 100], [0], [ignore])
AT_CHECK([ovs-appctl cfm/show p1 | grep 'fault_override'], [1], [ignore])
CFM_VSCTL_LIST_IFACE([p1], [cfm_fault_status], [cfm_fault_status : [[]]])
OVS_VSWITCHD_STOP
AT_CLEANUP