netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / tests / ovn-controller-vtep.at
1 AT_BANNER([ovn_controller_vtep])
2
3 # OVN_CONTROLLER_VTEP_START
4 #
5 # Starts the test with a setup with vtep device.  Each test case must first
6 # call this macro.
7 #
8 # Uses vtep-ovs to simulate the vtep switch 'br-vtep' with two physical ports
9 # 'p0', 'p1'.
10 #
11 # Configures ovn-nb with a logical switch 'br-test'.
12 #
13 #
14 m4_define([OVN_CONTROLLER_VTEP_START],
15   [
16    AT_KEYWORDS([ovn])
17    # this will cause skip when 'make check' using Windows setup.
18    AT_SKIP_IF([test $HAVE_PYTHON = no])
19
20    dnl Create databases (ovn-nb, ovn-sb, vtep).
21    AT_CHECK([ovsdb-tool create vswitchd.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
22    for daemon in ovn-nb ovn-sb vtep; do
23       AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema])
24    done
25
26    dnl Start ovsdb-server.
27    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock vswitchd.db vtep.db ovn-nb.db ovn-sb.db], [0], [], [stderr])
28    on_exit "kill `cat ovsdb-server.pid`"
29    AT_CHECK([[sed < stderr '
30 /vlog|INFO|opened log file/d
31 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
32    AT_CAPTURE_FILE([ovsdb-server.log])
33
34    dnl Start ovs-vswitchd.
35    AT_CHECK([ovs-vswitchd --enable-dummy=system --disable-system --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
36    AT_CAPTURE_FILE([ovs-vswitchd.log])
37    on_exit "kill `cat ovs-vswitchd.pid`"
38    AT_CHECK([[sed < stderr '
39 /ovs_numa|INFO|Discovered /d
40 /vlog|INFO|opened log file/d
41 /vswitchd|INFO|ovs-vswitchd (Open vSwitch)/d
42 /reconnect|INFO|/d
43 /ofproto|INFO|using datapath ID/d
44 /ofproto|INFO|datapath ID changed to fedcba9876543210/d']])
45    AT_CHECK([ovs-vsctl -- add-br br-vtep \
46               -- set bridge br-vtep datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure \
47               -- add-port br-vtep p0 -- set Interface p0 type=dummy ofport_request=1 \
48               -- add-port br-vtep p1 -- set Interface p1 type=dummy ofport_request=2])
49
50    dnl Start ovs-vtep.
51    AT_CHECK([vtep-ctl add-ps br-vtep -- set Physical_Switch br-vtep tunnel_ips=1.2.3.4])
52    AT_CHECK([ovs-vtep --log-file=ovs-vtep.log --pidfile=ovs-vtep.pid --detach br-vtep \], [0], [], [stderr])
53    on_exit "kill `cat ovs-vtep.pid`"
54    AT_CHECK([[sed < stderr '
55 /vlog|INFO|opened log file/d']])
56    # waits until ovs-vtep starts up.
57    OVS_WAIT_UNTIL([test -n "`vtep-ctl show | grep Physical_Port`"])
58
59    dnl Start ovn-northd.
60    AT_CHECK([ovn-nbctl lswitch-add br-test])
61    AT_CHECK([ovn-northd --detach --pidfile --log-file --ovnnb-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
62    on_exit "kill `cat ovn-northd.pid`"
63    AT_CHECK([[sed < stderr '
64 /vlog|INFO|opened log file/d']])
65    AT_CAPTURE_FILE([ovn-northd.log])
66
67    dnl Start ovn-controllger-vtep.
68    AT_CHECK([ovn-controller-vtep --detach --pidfile --log-file --vtep-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
69    AT_CAPTURE_FILE([ovn-controller-vtep.log])
70    on_exit "kill `cat ovn-controller-vtep.pid`"
71    AT_CHECK([[sed < stderr '
72 /vlog|INFO|opened log file/d
73 /reconnect|INFO|/d']])
74 ])
75
76 # OVN_CONTROLLER_VTEP_STOP
77 #
78 # So many exits... Yeah, we started a lot daemons~
79 #
80 m4_define([OVN_CONTROLLER_VTEP_STOP],
81   [# removes all 'Broken pipe' warning logs from ovsdb-server.log.  this is in
82    # that *ctl command (e.g. ovn-nbctl) exits right after committing the change
83    # to database.  however, in reaction, some daemon (e.g. ovn-controller-vtep)
84    # may immediately update the database.  this later update may cause database
85    # sending update back to *ctl command if *ctl has not proceeded to exit yet.
86    # and if *ctl command exits before database calling send, the send from
87    # database will fail with 'Broken pipe' error.
88    AT_CHECK([check_logs "$1
89 /Broken pipe/d"])
90    AT_CHECK([ovs-appctl -t ovs-vtep exit])
91    AT_CHECK([ovs-appctl -t ovn-northd exit])
92    AT_CHECK([ovs-appctl -t ovn-controller-vtep exit])
93    # makes sure ovn-controller-vtep exits.
94    OVS_WAIT_UNTIL([test ! -f ovn-controller-vtep.pid])
95    AT_CHECK([ovs-appctl -t ovsdb-server exit])
96    AT_CHECK([ovs-appctl -t ovs-vswitchd exit])])
97
98 # Adds logical port for a vtep gateway chassis in ovn-nb database.
99 #
100 # $1: logical switch name in ovn-nb database
101 # $2: logical port name
102 # $3: physical vtep gateway name
103 # $4: logical switch name on vtep gateway chassis
104 m4_define([OVN_NB_ADD_VTEP_PORT], [
105 AT_CHECK([ovn-nbctl lport-add $1 $2])
106 AT_CHECK([ovn-nbctl lport-set-type $2 vtep])
107 AT_CHECK([ovn-nbctl lport-set-options $2 vtep-physical-switch=$3 vtep-logical-switch=$4])
108 ])
109
110 ##############################################
111
112 # tests chassis related updates.
113 AT_SETUP([ovn-controller-vtep - test chassis])
114 OVN_CONTROLLER_VTEP_START
115
116 # verifies the initial ovn-sb db configuration.
117 OVS_WAIT_UNTIL([test -n "`ovn-sbctl show | grep Chassis`"])
118 AT_CHECK([ovn-sbctl show], [0], [dnl
119 Chassis br-vtep
120     Encap vxlan
121         ip: "1.2.3.4"
122 ])
123
124 # deletes the chassis via ovn-sbctl and check that it is readded back
125 # with the log.
126 AT_CHECK([ovn-sbctl chassis-del br-vtep])
127 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
128 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log], [0], [dnl
129 |WARN|Chassis for VTEP physical switch (br-vtep) disappears, maybe deleted by ovn-sbctl, adding it back
130 ])
131
132 # changes the tunnel_ip on physical switch, watches the update of chassis's
133 # encap.
134 AT_CHECK([vtep-ctl set Physical_Switch br-vtep tunnel_ips=1.2.3.5])
135 OVS_WAIT_UNTIL([test -n "`ovn-sbctl show | grep 1\.2\.3\.5`"])
136 AT_CHECK([ovn-sbctl --columns=ip list Encap | cut -d ':' -f2 | tr -d ' '], [0], [dnl
137 "1.2.3.5"
138 ])
139
140 # adds vlan_bindings to physical ports.
141 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0 -- bind-ls br-vtep p0 200 lswitch0 -- bind-ls br-vtep p1 300 lswitch0])
142 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch0`"])
143 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
144 [["lswitch0"]]
145 ])
146
147 # adds another logical switch and new vlan_bindings.
148 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 300 lswitch1])
149 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch1`"])
150 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl
151 [["lswitch0","lswitch1"]]
152 ])
153
154 # unbinds one port from lswitch0, nothing should change.
155 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 200])
156 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=vlan_bindings list physical_port p0 | grep -- '200='`"])
157 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
158 [["lswitch0","lswitch1"]]
159 ])
160
161 # unbinds all ports from lswitch0.
162 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 100 -- unbind-ls br-vtep p1 300])
163 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch0`"])
164 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
165 [["lswitch1"]]
166 ])
167
168 # unbinds all ports from lswitch1.
169 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 300])
170 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch1`"])
171 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl
172 [[]]
173 ])
174
175 OVN_CONTROLLER_VTEP_STOP([/Chassis for VTEP physical switch (br-vtep) disappears/d])
176 AT_CLEANUP
177
178
179 # Tests binding updates.
180 AT_SETUP([ovn-controller-vtep - test binding 1])
181 OVN_CONTROLLER_VTEP_START
182
183 # adds logical switch 'lswitch0' and vlan_bindings.
184 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0 -- bind-ls br-vtep p1 300 lswitch0])
185 # adds lport in ovn-nb database, and sets the type and options.
186 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
187 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
188 # should see one binding, associated to chassis of 'br-vtep'.
189 chassis_uuid=$(ovn-sbctl --columns=_uuid list Chassis br-vtep | cut -d ':' -f2 | tr -d ' ')
190 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
191 ${chassis_uuid}
192 ])
193
194 # adds another logical switch 'lswitch1' and vlan_bindings.
195 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 200 lswitch1])
196 # adds lport in ovn-nb database for lswitch1.
197 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch1], [br-vtep], [lswitch1])
198 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch1`"])
199 # This is allowed, but not recommended, to have two vlan_bindings (to different vtep logical switches)
200 # from one vtep gateway physical port in one ovn-nb logical swithch.
201 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort -d], [0], [dnl
202
203 ${chassis_uuid}
204 ${chassis_uuid}
205 ])
206
207 # adds another lport in ovn-nb database for lswitch0.
208 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0_dup], [br-vtep], [lswitch0])
209 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch0_dup`"])
210 # it is not allowed to have more than one ovn-nb logical port for the same
211 # vtep logical switch on a vtep gateway chassis, so should still see only
212 # two port_binding entries bound.
213 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort -d], [0], [dnl
214
215
216 [[]]
217 ${chassis_uuid}
218 ${chassis_uuid}
219 ])
220 # confirms the warning log.
221 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_0-9a-z]][[-_0-9a-z]]*)/()/g' | uniq], [0], [dnl
222 |WARN|logical switch (), on vtep gateway chassis () has already been associated with logical port (), ignore logical port ()
223 ])
224
225 # deletes physical ports from vtep.
226 AT_CHECK([ovs-vsctl del-port p0 -- del-port p1])
227 AT_CHECK([vtep-ctl del-port br-vtep p0 -- del-port br-vtep p1])
228 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch`"])
229 # should see empty chassis column in both binding entries.
230 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort], [0], [dnl
231
232
233 [[]]
234 [[]]
235 [[]]
236 ])
237
238 OVN_CONTROLLER_VTEP_STOP([/has already been associated with logical port/d])
239 AT_CLEANUP
240
241
242 # Tests corner case: Binding the vtep logical switch from two different
243 # datapath.
244 AT_SETUP([ovn-controller-vtep - test binding 2])
245 OVN_CONTROLLER_VTEP_START
246
247 # adds logical switch 'lswitch0' and vlan_bindings.
248 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
249 # adds lport in ovn-nb database, and sets the type and options.
250 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
251 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
252
253 # adds another lswitch 'br-void' in ovn-nb database.
254 AT_CHECK([ovn-nbctl lswitch-add br-void])
255 # adds another vtep pswitch 'br-vtep-void' in vtep database.
256 AT_CHECK([vtep-ctl add-ps br-vtep-void -- add-port br-vtep-void p0-void -- bind-ls br-vtep-void p0-void 100 lswitch0])
257 # adds a conflicting logical port (both br-vtep_lswitch0 and br-vtep-void_lswitch0
258 # are bound to the same logical switch, but they are on different datapath).
259 OVN_NB_ADD_VTEP_PORT([br-void], [br-vtep-void_lswitch0], [br-vtep-void], [lswitch0])
260 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep-void_lswitch0`"])
261 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
262 # confirms the warning log.
263 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_0-9a-z]][[-_0-9a-z]]*)/()/g;s/(with tunnel key [[0-9]][[0-9]]*)/()/g' | uniq], [0], [dnl
264 |WARN|logical switch (), on vtep gateway chassis () has already been associated with logical datapath (), ignore logical port () which belongs to logical datapath ()
265 ])
266
267 # then deletes 'br-void' and 'br-vtep-void', should see 'br-vtep_lswitch0'
268 # bound correctly.
269 AT_CHECK([ovn-nbctl lswitch-del br-void])
270 # adds another vtep pswitch 'br-vtep-void' in vtep database.
271 AT_CHECK([vtep-ctl del-ps br-vtep-void])
272 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Port_Binding | grep br-vtep-void_lswitch0`"])
273 chassis_uuid=$(ovn-sbctl --columns=_uuid list Chassis br-vtep | cut -d ':' -f2 | tr -d ' ')
274 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
275 ${chassis_uuid}
276 ])
277
278 OVN_CONTROLLER_VTEP_STOP([/has already been associated with logical datapath/d])
279 AT_CLEANUP
280
281
282 # Tests vtep module vtep logical switch tunnel key update.
283 AT_SETUP([ovn-controller-vtep - test vtep-lswitch])
284 OVN_CONTROLLER_VTEP_START
285
286 # creates the logical switch in vtep and adds the corresponding logical
287 # port to 'br-test'.
288 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
289 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
290 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep -- br-vtep_lswitch0`"])
291
292 # retrieves the expected tunnel key.
293 datapath_uuid=$(ovn-sbctl --columns=datapath list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' ')
294 tunnel_key=$(ovn-sbctl --columns=tunnel_key list Datapath_Binding ${datapath_uuid} | cut -d ':' -f2 | tr -d ' ')
295 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=tunnel_key list Logical_Switch | grep 0`"])
296 # checks the vtep logical switch tunnel key configuration.
297 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
298 ${tunnel_key}
299 ])
300
301 # creates a second physical switch in vtep database, and binds its p0 vlan-100
302 # to the same logical switch 'lswitch0'.
303 AT_CHECK([vtep-ctl add-ps br-vtep-void -- add-port br-vtep-void p0 -- bind-ls br-vtep-void p0 100 lswitch0])
304 OVS_WAIT_UNTIL([test -n "`ovn-sbctl --columns=name list Chassis  | grep -- br-vtep-void`"])
305 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep-void_lswitch0], [br-vtep-void], [lswitch0])
306 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep -- br-vtep-void_lswitch0`"])
307
308 # checks the vtep logical switch tunnel key configuration.
309 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
310 ${tunnel_key}
311 ])
312
313 # now, deletes br-vtep-void.
314 AT_CHECK([vtep-ctl del-ps br-vtep-void])
315 OVS_WAIT_UNTIL([test -z "`ovn-sbctl --columns=name list Chassis  | grep -- br-vtep-void`"])
316 # checks the vtep logical switch tunnel key configuration.
317 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
318 ${tunnel_key}
319 ])
320
321 # changes the ovn-nb logical port type so that it is no longer
322 # vtep port.
323 AT_CHECK([ovn-nbctl lport-set-type br-vtep_lswitch0 void])
324 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=tunnel_key list Logical_Switch | grep 1`"])
325 # now should see the tunnel key reset.
326 AT_CHECK([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
327 0
328 ])
329
330 OVN_CONTROLLER_VTEP_STOP
331 AT_CLEANUP
332
333
334 # Tests vtep module 'Ucast_Macs_Remote's.
335 AT_SETUP([ovn-controller-vtep - test vtep-macs 1])
336 OVN_CONTROLLER_VTEP_START
337
338 # creates a simple logical network with the vtep device and a fake hv chassis
339 # 'ch0'.
340 AT_CHECK([ovn-nbctl lport-add br-test vif0])
341 AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02])
342 AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
343 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
344
345 # creates the logical switch in vtep and adds the corresponding logical
346 # port to 'br-test'.
347 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
348 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
349 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
350
351 # adds another lswitch 'br-void' in ovn-nb database.
352 AT_CHECK([ovn-nbctl lswitch-add br-void])
353 # adds fake hv chassis 'ch1'.
354 AT_CHECK([ovn-nbctl lport-add br-void vif1])
355 AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:02])
356 AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
357 AT_CHECK([ovn-sbctl lport-bind vif1 ch1])
358 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
359
360 # checks Ucast_Macs_Remote creation.
361 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep _uuid`"])
362 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' '], [0], [dnl
363 "f0:ab:cd:ef:01:02"
364 ])
365
366 # checks physical locator creation.
367 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Physical_Locator | grep _uuid`"])
368 AT_CHECK([vtep-ctl --columns=dst_ip list Physical_Locator | cut -d ':' -f2 | tr -d ' ' | grep -v 1.2.3.4 | sed '/^$/d'], [0], [dnl
369 "1.2.3.5"
370 ])
371
372 # checks tunnel creation by ovs-vtep.
373 OVS_WAIT_UNTIL([test -n "`ovs-vsctl list Interface bfd1.2.3.5`"])
374 AT_CHECK([ovs-vsctl --columns=options list Interface bfd1.2.3.5 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
375 {remote_ip="1.2.3.5"}
376 ])
377
378 # adds another mac to lport.
379 AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02 f0:ab:cd:ef:01:03])
380 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep 03`"])
381 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
382
383 "f0:ab:cd:ef:01:02"
384 "f0:ab:cd:ef:01:03"
385 ])
386
387 # removes one mac to lport.
388 AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:03])
389 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02`"])
390 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
391 "f0:ab:cd:ef:01:03"
392 ])
393
394 # migrates mac to lport vif1 on 'br-void'.
395 AT_CHECK([ovn-nbctl lport-set-addresses vif0])
396 AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:03])
397 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 03`"])
398 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
399 ])
400
401 OVN_CONTROLLER_VTEP_STOP
402 AT_CLEANUP
403
404
405 # Tests vtep module 'Ucast_Macs_Remote's (corner cases).
406 AT_SETUP([ovn-controller-vtep - test vtep-macs 2])
407 OVN_CONTROLLER_VTEP_START
408
409 # creates a simple logical network with the vtep device and a fake hv chassis
410 # 'ch0'.
411 AT_CHECK([ovn-nbctl lport-add br-test vif0])
412 AT_CHECK([ovn-nbctl lport-set-addresses vif0 f0:ab:cd:ef:01:02])
413 AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
414 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
415
416 # creates another vif in the same logical switch with duplicate mac.
417 AT_CHECK([ovn-nbctl lport-add br-test vif1])
418 AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:02])
419 AT_CHECK([ovn-sbctl lport-bind vif1 ch0])
420
421 # creates the logical switch in vtep and adds the corresponding logical
422 # port to 'br-test'.
423 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
424 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
425 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
426
427 # checks Ucast_Macs_Remote creation.  Should still only be one entry, since duplicate
428 # mac in the same logical switch is not allowed.
429 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep _uuid`"])
430 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' '], [0], [dnl
431 "f0:ab:cd:ef:01:02"
432 ])
433 # confirms the warning log.
434 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
435 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_:0-9a-z]][[-_:0-9a-z]]*)/()/g' | uniq], [0], [dnl
436 |WARN|MAC address () has already been known to be on logical port () in the same logical datapath, so just ignore this logical port ()
437 ])
438
439 # deletes vif1.
440 AT_CHECK([ovn-nbctl lport-del vif1])
441
442 # adds another lswitch 'br-void' in ovn-nb database.
443 AT_CHECK([ovn-nbctl lswitch-add br-void])
444 # adds fake hv chassis 'ch1' and vif1 with same mac address as vif0.
445 AT_CHECK([ovn-nbctl lport-add br-void vif1])
446 AT_CHECK([ovn-nbctl lport-set-addresses vif1 f0:ab:cd:ef:01:02])
447 AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
448 AT_CHECK([ovn-sbctl lport-bind vif1 ch1])
449 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
450
451 # creates another logical switch in vtep and adds the corresponding logical
452 # port to 'br-void'.
453 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 200 lswitch1])
454 OVN_NB_ADD_VTEP_PORT([br-void], [br-void_lswitch1], [br-vtep], [lswitch1])
455 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-void_lswitch1`"])
456
457 # checks Ucast_Macs_Remote creation.  Should see two entries since it is allowed
458 # to have duplicate macs in different logical switches.
459 OVS_WAIT_UNTIL([test `vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02 | wc -l` -gt 1])
460 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
461
462 "f0:ab:cd:ef:01:02"
463 "f0:ab:cd:ef:01:02"
464 ])
465
466 OVN_CONTROLLER_VTEP_STOP([/has already been known to be on logical port/d])
467 AT_CLEANUP