3 OVS_START_SHELL_HELPERS
5 m4_define([OVN_NBCTL_TEST_START],
7 AT_CAPTURE_FILE([ovsdb-server.log])
8 ovn_nbctl_test_start $1])
9 ovn_nbctl_test_start() {
10 dnl Create ovn-nb database.
11 AT_CHECK([ovsdb-tool create ovn-nb.db $abs_top_srcdir/ovn/ovn-nb.ovsschema])
13 dnl Start ovsdb-server.
14 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
15 on_exit "kill `cat ovsdb-server.pid`"
18 [export OVN_NB_DAEMON=$(ovn-nbctl --pidfile --detach --no-chdir --log-file -vsocket_util:off)
19 on_exit "kill `cat ovn-nbctl.pid`"],
22 AT_CHECK([ovn-nbctl init])
23 AT_CHECK([[sed < stderr '
24 /vlog|INFO|opened log file/d
25 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
29 m4_define([OVN_NBCTL_TEST_STOP], [ovn_nbctl_test_stop])
30 ovn_nbctl_test_stop() {
31 AT_CHECK([check_logs "$1"])
32 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
36 # OVN_NBCTL_TEST(NAME, TITLE, COMMANDS)
37 m4_define([OVN_NBCTL_TEST],
38 [OVS_START_SHELL_HELPERS
44 AT_SETUP([ovn-nbctl - $2 - direct])
45 OVN_NBCTL_TEST_START direct
50 AT_SETUP([ovn-nbctl - $2 - daemon])
51 OVN_NBCTL_TEST_START daemon
56 OVN_NBCTL_TEST([ovn_nbctl_basic_switch], [basic switch commands], [
57 AT_CHECK([ovn-nbctl ls-add ls0])
58 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
62 AT_CHECK([ovn-nbctl ls-add ls1])
63 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
68 AT_CHECK([ovn-nbctl ls-del ls0])
69 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
73 AT_CHECK([ovn-nbctl show ls0])
74 AT_CHECK([ovn-nbctl ls-add ls0])
75 AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0],
78 AT_CHECK([ovn-nbctl ls-add ls0], [1], [],
79 [ovn-nbctl: ls0: a switch with this name already exists
81 AT_CHECK([ovn-nbctl --may-exist ls-add ls0])
82 AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0],
85 AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0])
86 AT_CHECK([ovn-nbctl --may-exist --add-duplicate ls-add ls0], [1], [],
87 [ovn-nbctl: --may-exist and --add-duplicate may not be used together
89 AT_CHECK([ovn-nbctl ls-del ls0], [1], [],
90 [ovn-nbctl: Multiple logical switches named 'ls0'. Use a UUID.
93 AT_CHECK([ovn-nbctl ls-del ls2], [1], [],
94 [ovn-nbctl: ls2: switch name not found
96 AT_CHECK([ovn-nbctl --if-exists ls-del ls2])
98 AT_CHECK([ovn-nbctl ls-add])
99 AT_CHECK([ovn-nbctl ls-add])
100 AT_CHECK([ovn-nbctl --add-duplicate ls-add], [1], [],
101 [ovn-nbctl: --add-duplicate requires specifying a name
103 AT_CHECK([ovn-nbctl --may-exist ls-add], [1], [],
104 [ovn-nbctl: --may-exist requires specifying a name
107 dnl ---------------------------------------------------------------------
109 OVN_NBCTL_TEST([ovn_nbctl_basic_lsp], [basic logical switch port commands], [
110 AT_CHECK([ovn-nbctl ls-add ls0])
111 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
112 AT_CHECK([ovn-nbctl lsp-add ls0 lp0], [1], [],
113 [ovn-nbctl: lp0: a port with this name already exists
115 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp0])
116 AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl
120 AT_CHECK([ovn-nbctl lsp-add ls0 lp1])
121 AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl
126 AT_CHECK([ovn-nbctl ls-add ls1])
127 AT_CHECK([ovn-nbctl lsp-add ls0 lp1], [1], [],
128 [ovn-nbctl: lp1: a port with this name already exists
130 AT_CHECK([ovn-nbctl --may-exist lsp-add ls1 lp1], [1], [],
131 [ovn-nbctl: lp1: port already exists but in switch ls0
133 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp1 lp0 5], [1], [],
134 [ovn-nbctl: lp1: port already exists but has no parent
137 AT_CHECK([ovn-nbctl lsp-del lp1])
138 AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl
142 AT_CHECK([ovn-nbctl lsp-add ls0 lp2 lp3 5])
143 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp4 5], [1], [],
144 [ovn-nbctl: lp2: port already exists with different parent lp3
146 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 10], [1], [],
147 [ovn-nbctl: lp2: port already exists with different tag_request 5
149 AT_CHECK([ovn-nbctl clear Logical_Switch_Port lp2 tag_request])
150 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 5], [1], [],
151 [ovn-nbctl: lp2: port already exists but has no tag_request
154 dnl ---------------------------------------------------------------------
156 OVN_NBCTL_TEST([ovn_nbctl_lsp_get_ls], [lsp get ls], [
157 AT_CHECK([ovn-nbctl ls-add ls0])
158 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
160 AT_CHECK([ovn-nbctl lsp-get-ls lp0 | uuidfilt], [0], [dnl
164 AT_CHECK([ovn-nbctl lsp-get-ls lp1], [1], [],
165 [ovn-nbctl: lp1: port name not found
168 dnl ---------------------------------------------------------------------
170 OVN_NBCTL_TEST([ovn_nbctl_lport_addresses], [lport addresses], [
171 AT_CHECK([ovn-nbctl ls-add ls0])
172 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
173 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
176 AT_CHECK([ovn-nbctl lsp-set-addresses lp0 00:11:22:33:44:55 unknown])
177 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
182 AT_CHECK([ovn-nbctl lsp-set-addresses lp0])
183 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
186 dnl ---------------------------------------------------------------------
188 OVN_NBCTL_TEST([ovn_nbctl_port_security], [port security], [
189 AT_CHECK([ovn-nbctl ls-add ls0])
190 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
191 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
194 AT_CHECK([ovn-nbctl lsp-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
195 AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
200 AT_CHECK([ovn-nbctl lsp-set-port-security lp0])
201 AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
204 dnl ---------------------------------------------------------------------
206 OVN_NBCTL_TEST([ovn_nbctl_acls], [ACLs], [
207 ovn_nbctl_test_acl() {
208 AT_CHECK([ovn-nbctl $2 --log acl-add $1 from-lport 600 udp drop])
209 AT_CHECK([ovn-nbctl $2 --log --name=test --severity=info acl-add $1 to-lport 500 udp drop])
210 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 400 tcp drop])
211 AT_CHECK([ovn-nbctl $2 acl-add $1 to-lport 300 tcp drop])
212 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 200 ip drop])
213 AT_CHECK([ovn-nbctl $2 acl-add $1 to-lport 100 ip drop])
214 dnl Add duplicated ACL
215 AT_CHECK([ovn-nbctl $2 acl-add $1 to-lport 100 ip drop], [1], [], [stderr])
216 AT_CHECK([grep 'already existed' stderr], [0], [ignore])
217 AT_CHECK([ovn-nbctl $2 --may-exist acl-add $1 to-lport 100 ip drop])
219 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
220 from-lport 600 (udp) drop log()
221 from-lport 400 (tcp) drop
222 from-lport 200 (ip) drop
223 to-lport 500 (udp) drop log(name=test,severity=info)
224 to-lport 300 (tcp) drop
225 to-lport 100 (ip) drop
228 dnl Delete in one direction.
229 AT_CHECK([ovn-nbctl $2 acl-del $1 to-lport])
230 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
231 from-lport 600 (udp) drop log()
232 from-lport 400 (tcp) drop
233 from-lport 200 (ip) drop
237 AT_CHECK([ovn-nbctl $2 acl-del $1])
238 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
241 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 600 udp drop])
242 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 400 tcp drop])
243 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 200 ip drop])
245 dnl Delete a single flow.
246 AT_CHECK([ovn-nbctl $2 acl-del $1 from-lport 400 tcp])
247 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
248 from-lport 600 (udp) drop
249 from-lport 200 (ip) drop
253 AT_CHECK([ovn-nbctl ls-add ls0])
254 ovn_nbctl_test_acl ls0
255 AT_CHECK([ovn-nbctl ls-add ls1])
256 ovn_nbctl_test_acl ls1 --type=switch
257 AT_CHECK([ovn-nbctl create port_group name=pg0], [0], [ignore])
258 ovn_nbctl_test_acl pg0 --type=port-group
260 dnl Test when port group doesn't exist
261 AT_CHECK([ovn-nbctl --type=port-group acl-add pg1 to-lport 100 ip drop], [1], [], [dnl
262 ovn-nbctl: pg1: port group name not found
265 dnl Test when same name exists in logical switches and portgroups
266 AT_CHECK([ovn-nbctl create port_group name=ls0], [0], [ignore])
267 AT_CHECK([ovn-nbctl acl-add ls0 to-lport 100 ip drop], [1], [], [stderr])
268 AT_CHECK([grep 'exists in both' stderr], [0], [ignore])
269 AT_CHECK([ovn-nbctl --type=port-group acl-add ls0 to-lport 100 ip drop], [0], [ignore])])
271 dnl ---------------------------------------------------------------------
273 OVN_NBCTL_TEST([ovn_nbctl_qos], [QoS], [
274 AT_CHECK([ovn-nbctl ls-add ls0])
275 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 tcp dscp=63])
276 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 500 udp rate=100 burst=1000])
277 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 400 tcp dscp=0 rate=300 burst=3000])
278 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 300 tcp dscp=48])
279 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 200 ip rate=101])
280 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 100 ip4 dscp=13 rate=301 burst=30000])
282 dnl Add duplicated qos
283 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 100 ip4 dscp=11 rate=302 burst=30002], [1], [], [stderr])
284 AT_CHECK([grep 'already existed' stderr], [0], [ignore])
285 AT_CHECK([ovn-nbctl --may-exist qos-add ls0 to-lport 100 ip4 dscp=11 rate=302 burst=30002])
287 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
288 from-lport 600 (tcp) dscp=63
289 from-lport 500 (udp) rate=100 burst=1000
290 from-lport 400 (tcp) rate=300 burst=3000 dscp=0
291 to-lport 300 (tcp) dscp=48
292 to-lport 200 (ip) rate=101
293 to-lport 100 (ip4) rate=301 burst=30000 dscp=13
296 dnl Delete in one direction.
297 AT_CHECK([ovn-nbctl qos-del ls0 to-lport])
298 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
299 from-lport 600 (tcp) dscp=63
300 from-lport 500 (udp) rate=100 burst=1000
301 from-lport 400 (tcp) rate=300 burst=3000 dscp=0
304 dnl Delete all qos_rules.
305 AT_CHECK([ovn-nbctl qos-del ls0])
306 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
309 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip rate=1000101])
310 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 400 tcp dscp=44])
311 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 200 ip burst=1000102 rate=301 dscp=19])
313 dnl Delete a single flow.
314 AT_CHECK([ovn-nbctl qos-del ls0 from-lport 400 tcp])
315 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
316 from-lport 600 (ip) rate=1000101
317 from-lport 200 (ip) rate=301 burst=1000102 dscp=19
320 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip rate=100010111111], [1], [],
321 [ovn-nbctl: 100010111111: rate must be in the range 1...4294967295
324 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip burst=100010111112 rate=100010], [1], [],
325 [ovn-nbctl: 100010111112: burst must be in the range 1...4294967295
328 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip dscp=-1], [1], [],
329 [ovn-nbctl: -1: dscp must be in the range 0...63
332 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip dscpa=-1], [1], [],
333 [ovn-nbctl: dscpa=-1: supported arguments are "dscp=", "rate=", and "burst="
336 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip burst=123], [1], [],
337 [ovn-nbctl: Either "rate" and/or "dscp" must be specified
340 dnl ---------------------------------------------------------------------
342 OVN_NBCTL_TEST([ovn_nbctl_meters], [meters], [
343 AT_CHECK([ovn-nbctl meter-add meter1 drop 10 kbps])
344 AT_CHECK([ovn-nbctl meter-add meter2 drop 3 kbps 2])
345 AT_CHECK([ovn-nbctl meter-add meter3 drop 100 kbps 200])
346 AT_CHECK([ovn-nbctl meter-add meter4 drop 10 pktps 30])
348 dnl Add duplicate meter name
349 AT_CHECK([ovn-nbctl meter-add meter1 drop 10 kbps], [1], [], [stderr])
350 AT_CHECK([grep 'already exists' stderr], [0], [ignore])
352 dnl Add reserved meter name
353 AT_CHECK([ovn-nbctl meter-add __meter1 drop 10 kbps], [1], [], [stderr])
354 AT_CHECK([grep 'reserved' stderr], [0], [ignore])
356 dnl Add meter with invalid rates
357 AT_CHECK([ovn-nbctl meter-add meter5 drop 100010111111 kbps], [1], [],
358 [ovn-nbctl: rate must be in the range 1...4294967295
361 dnl Add meter with invalid rates
362 AT_CHECK([ovn-nbctl meter-add meter5 drop 100010111111 foo], [1], [],
363 [ovn-nbctl: rate must be in the range 1...4294967295
366 AT_CHECK([ovn-nbctl meter-add meter5 drop 0 kbps], [1], [],
367 [ovn-nbctl: rate must be in the range 1...4294967295
370 dnl Add meter with invalid burst
371 AT_CHECK([ovn-nbctl meter-add meter5 drop 10 100010111111 kbps], [1], [],
372 [ovn-nbctl: unit must be "kbps" or "pktps"
375 AT_CHECK([ovn-nbctl meter-list], [0], [dnl
379 drop: 3 kbps, 2 kb burst
381 drop: 100 kbps, 200 kb burst
383 drop: 10 pktps, 30 packet burst
386 dnl Delete a single meter.
387 AT_CHECK([ovn-nbctl meter-del meter2])
388 AT_CHECK([ovn-nbctl meter-list], [0], [dnl
392 drop: 100 kbps, 200 kb burst
394 drop: 10 pktps, 30 packet burst
397 dnl Delete all meters.
398 AT_CHECK([ovn-nbctl meter-del])
399 AT_CHECK([ovn-nbctl meter-list], [0], [dnl
402 dnl ---------------------------------------------------------------------
404 OVN_NBCTL_TEST([ovn_nbctl_nats], [NATs], [
405 AT_CHECK([ovn-nbctl lr-add lr0])
406 AT_CHECK([ovn-nbctl lr-nat-add lr0 snatt 30.0.0.2 192.168.1.2], [1], [],
407 [ovn-nbctl: snatt: type must be one of "dnat", "snat" and "dnat_and_snat".
409 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2a 192.168.1.2], [1], [],
410 [ovn-nbctl: 30.0.0.2a: should be an IPv4 address.
412 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0 192.168.1.2], [1], [],
413 [ovn-nbctl: 30.0.0: should be an IPv4 address.
415 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2/24 192.168.1.2], [1], [],
416 [ovn-nbctl: 30.0.0.2/24: should be an IPv4 address.
418 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2:80 192.168.1.2], [1], [],
419 [ovn-nbctl: 30.0.0.2:80: should be an IPv4 address.
421 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2a], [1], [],
422 [ovn-nbctl: 192.168.1.2a: should be an IPv4 address or network.
424 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1], [1], [],
425 [ovn-nbctl: 192.168.1: should be an IPv4 address or network.
427 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2:80], [1], [],
428 [ovn-nbctl: 192.168.1.2:80: should be an IPv4 address or network.
430 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2/a], [1], [],
431 [ovn-nbctl: 192.168.1.2/a: should be an IPv4 address or network.
433 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2a], [1], [],
434 [ovn-nbctl: 192.168.1.2a: should be an IPv4 address.
436 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1], [1], [],
437 [ovn-nbctl: 192.168.1: should be an IPv4 address.
439 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2:80], [1], [],
440 [ovn-nbctl: 192.168.1.2:80: should be an IPv4 address.
442 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2/24], [1], [],
443 [ovn-nbctl: 192.168.1.2/24: should be an IPv4 address.
445 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2/24], [1], [],
446 [ovn-nbctl: 192.168.1.2/24: should be an IPv4 address.
448 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0], [1], [],
449 [ovn-nbctl: lr-nat-add with logical_port must also specify external_mac.
451 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
452 [ovn-nbctl: logical_port and external_mac are only valid when type is "dnat_and_snat".
454 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
455 [ovn-nbctl: logical_port and external_mac are only valid when type is "dnat_and_snat".
457 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
458 [ovn-nbctl: lp0: port name not found
460 AT_CHECK([ovn-nbctl ls-add ls0])
461 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
462 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02], [1], [],
463 [ovn-nbctl: invalid mac address 00:00:00:01:02.
466 dnl Add snat and dnat
467 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24])
468 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2])
469 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2])
470 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3 lp0 00:00:00:01:02:03])
471 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
472 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
473 dnat 30.0.0.1 192.168.1.2
474 dnat_and_snat 30.0.0.1 192.168.1.2
475 dnat_and_snat 30.0.0.2 192.168.1.3 00:00:00:01:02:03 lp0
476 snat 30.0.0.1 192.168.1.0/24
478 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24], [1], [],
479 [ovn-nbctl: 30.0.0.1, 192.168.1.0/24: a NAT with this external_ip and logical_ip already exists
481 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.10/24], [1], [],
482 [ovn-nbctl: 30.0.0.1, 192.168.1.0/24: a NAT with this external_ip and logical_ip already exists
484 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24])
485 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.0/24], [1], [],
486 [ovn-nbctl: a NAT with this type (snat) and logical_ip (192.168.1.0/24) already exists
488 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2], [1], [],
489 [ovn-nbctl: 30.0.0.1, 192.168.1.2: a NAT with this external_ip and logical_ip already exists
491 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2])
492 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.3], [1], [],
493 [ovn-nbctl: a NAT with this type (dnat) and external_ip (30.0.0.1) already exists
495 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2], [1], [],
496 [ovn-nbctl: 30.0.0.1, 192.168.1.2: a NAT with this external_ip and logical_ip already exists
498 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2])
499 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.3], [1], [],
500 [ovn-nbctl: a NAT with this type (dnat_and_snat) and external_ip (30.0.0.1) already exists
502 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3 lp0 00:00:00:04:05:06])
503 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
504 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
505 dnat 30.0.0.1 192.168.1.2
506 dnat_and_snat 30.0.0.1 192.168.1.2
507 dnat_and_snat 30.0.0.2 192.168.1.3 00:00:00:04:05:06 lp0
508 snat 30.0.0.1 192.168.1.0/24
510 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3])
511 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
512 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
513 dnat 30.0.0.1 192.168.1.2
514 dnat_and_snat 30.0.0.1 192.168.1.2
515 dnat_and_snat 30.0.0.2 192.168.1.3
516 snat 30.0.0.1 192.168.1.0/24
520 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat_and_snat 30.0.0.3], [1], [],
521 [ovn-nbctl: no matching NAT with the type (dnat_and_snat) and external_ip (30.0.0.3)
523 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat 30.0.0.2], [1], [],
524 [ovn-nbctl: no matching NAT with the type (dnat) and external_ip (30.0.0.2)
526 AT_CHECK([ovn-nbctl lr-nat-del lr0 snat 192.168.10.0/24], [1], [],
527 [ovn-nbctl: no matching NAT with the type (snat) and logical_ip (192.168.10.0/24)
529 AT_CHECK([ovn-nbctl --if-exists lr-nat-del lr0 snat 192.168.10.0/24])
531 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat_and_snat 30.0.0.1])
532 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
533 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
534 dnat 30.0.0.1 192.168.1.2
535 dnat_and_snat 30.0.0.2 192.168.1.3
536 snat 30.0.0.1 192.168.1.0/24
539 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])
540 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
541 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
542 dnat_and_snat 30.0.0.2 192.168.1.3
543 snat 30.0.0.1 192.168.1.0/24
546 AT_CHECK([ovn-nbctl lr-nat-del lr0])
547 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [])
548 AT_CHECK([ovn-nbctl lr-nat-del lr0])
549 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])])
551 dnl ---------------------------------------------------------------------
553 OVN_NBCTL_TEST([ovn_nbctl_lbs], [LBs], [
555 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10:80a 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
556 [ovn-nbctl: 30.0.0.10:80a: should be an IP address (or an IP address and a port number with : as a separator).
559 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10:a80 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
560 [ovn-nbctl: 30.0.0.10:a80: should be an IP address (or an IP address and a port number with : as a separator).
563 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20 tcp], [1], [],
564 [ovn-nbctl: 192.168.10.20: should be an IP address and a port number with : as a separator.
567 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.1a 192.168.10.10:80,192.168.10.20:80], [1], [],
568 [ovn-nbctl: 30.0.0.1a: should be an IP address (or an IP address and a port number with : as a separator).
571 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0 192.168.10.10:80,192.168.10.20:80], [1], [],
572 [ovn-nbctl: 30.0.0: should be an IP address (or an IP address and a port number with : as a separator).
575 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.10,192.168.10.20:80], [1], [],
576 [ovn-nbctl: 192.168.10.20:80: should be an IP address.
579 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.10:a80], [1], [],
580 [ovn-nbctl: 192.168.10.10:a80: should be an IP address.
583 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.10:], [1], [],
584 [ovn-nbctl: 192.168.10.10:: should be an IP address.
587 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.1a], [1], [],
588 [ovn-nbctl: 192.168.10.1a: should be an IP address.
591 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10: 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
592 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
595 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10 tcp], [1], [],
596 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
599 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10:900 tcp], [1], [],
600 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
604 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 ,,,192.168.10.10:80,,,,,])
605 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 ,,,192.168.10.10:80,,,,192.168.10.20:80,,,,])
606 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
607 UUID LB PROTO VIP IPs
608 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80
609 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
611 AT_CHECK([ovn-nbctl lb-del lb0])
612 AT_CHECK([ovn-nbctl lb-del lb1])
614 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80])
615 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 tcp])
616 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
617 UUID LB PROTO VIP IPs
618 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
619 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
622 dnl Update the VIP of the lb1.
623 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080])
624 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
625 UUID LB PROTO VIP IPs
626 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
627 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
630 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 udp])
631 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
632 UUID LB PROTO VIP IPs
633 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
634 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
637 dnl Config lb1 with another VIP.
638 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.20:80 192.168.10.10:80 udp])
639 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
640 UUID LB PROTO VIP IPs
641 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
642 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
643 udp 30.0.0.20:80 192.168.10.10:80
646 AT_CHECK([ovn-nbctl lb-del lb1 30.0.0.20:80])
647 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
648 UUID LB PROTO VIP IPs
649 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
650 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
653 dnl Add LBs whose vip is just an IP address.
654 AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.30 192.168.10.10])
655 AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.30 192.168.10.10])
656 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
657 UUID LB PROTO VIP IPs
658 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
659 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
660 <2> lb2 tcp/udp 30.0.0.30 192.168.10.10
661 <3> lb3 tcp/udp 30.0.0.30 192.168.10.10
663 AT_CHECK([ovn-nbctl lb-del lb2 30.0.0.30])
664 AT_CHECK([ovn-nbctl lb-del lb3 30.0.0.30])
666 AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp])
667 AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp])
668 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
669 UUID LB PROTO VIP IPs
670 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
671 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
672 <2> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
673 <3> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
676 dnl If there are multiple load balancers with the same name, use a UUID to update/delete.
677 AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
678 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
681 AT_CHECK([ovn-nbctl lb-del lb2], [1], [],
682 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
685 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:8080,192.168.10.20:8080 udp])
686 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:8080 192.168.10.10:8080,192.168.10.20:8080 udp])
687 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:9090 192.168.10.10:8080,192.168.10.20:8080 udp])
688 AT_CHECK([ovn-nbctl lb-del lb0 30.0.0.10:80])
689 AT_CHECK([ovn-nbctl lb-del lb1])
690 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
691 UUID LB PROTO VIP IPs
692 <0> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
693 <1> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
696 dnl Add load balancer to logical switch.
697 AT_CHECK([ovn-nbctl ls-add ls0])
698 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80])
699 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 udp])
700 AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.10 192.168.10.10,192.168.10.20])
701 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
702 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
703 AT_CHECK([ovn-nbctl --may-exist ls-lb-add ls0 lb1])
704 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [],
705 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
707 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
709 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
710 UUID LB PROTO VIP IPs
711 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
712 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
713 <2> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
716 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0])
717 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
718 UUID LB PROTO VIP IPs
719 <0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
720 <1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
723 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1])
724 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3])
725 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
726 AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1])
728 dnl Remove all load balancers from logical switch.
729 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
730 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
731 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
732 AT_CHECK([ovn-nbctl ls-lb-del ls0])
733 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
735 dnl Add load balancer to logical router.
736 AT_CHECK([ovn-nbctl lr-add lr0])
737 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
738 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
739 AT_CHECK([ovn-nbctl --may-exist lr-lb-add lr0 lb1])
740 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [],
741 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
743 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
745 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
746 UUID LB PROTO VIP IPs
747 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
748 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
749 <2> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
752 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0])
753 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
754 UUID LB PROTO VIP IPs
755 <0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
756 <1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
759 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1])
760 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3])
761 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
762 AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1])
764 dnl Remove all load balancers from logical router.
765 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
766 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
767 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
768 AT_CHECK([ovn-nbctl lr-lb-del lr0])
769 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
771 dnl Remove load balancers after adding them to a logical router/switch.
772 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
773 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
774 AT_CHECK([ovn-nbctl lb-del lb0])
775 AT_CHECK([ovn-nbctl lb-del lb1])
776 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
777 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])])
779 dnl ---------------------------------------------------------------------
781 OVN_NBCTL_TEST([ovn_nbctl_lbs_ipv6], [LBs IPv6], [
782 dnl A bunch of commands that should fail
783 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]:80a [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
784 [ovn-nbctl: [[ae0f::10]]:80a: should be an IP address (or an IP address and a port number with : as a separator).
788 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]:a80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
789 [ovn-nbctl: [[ae0f::10]]:a80: should be an IP address (or an IP address and a port number with : as a separator).
793 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,fd0f::20 tcp], [1], [],
794 [ovn-nbctl: fd0f::20: should be an IP address and a port number with : as a separator.
798 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10fff [[fd0f::10]]:80,fd0f::20 tcp], [1], [],
799 [ovn-nbctl: ae0f::10fff: should be an IP address (or an IP address and a port number with : as a separator).
803 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 [[fd0f::10]]:80,[[fd0f::20]]:80], [1], [],
804 [ovn-nbctl: [[fd0f::10]]:80: should be an IP address.
808 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 fd0f::10,[[fd0f::20]]:80], [1], [],
809 [ovn-nbctl: [[fd0f::20]]:80: should be an IP address.
813 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 [[fd0f::10]]:a80], [1], [],
814 [ovn-nbctl: [[fd0f::10]]:a80: should be an IP address.
818 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 [[fd0f::10]]:], [1], [],
819 [ovn-nbctl: [[fd0f::10]]:: should be an IP address.
823 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 fd0f::1001a], [1], [],
824 [ovn-nbctl: fd0f::1001a: should be an IP address.
828 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]: [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
829 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
833 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10 tcp], [1], [],
834 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
838 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 [[fd0f::10]]:900 tcp], [1], [],
839 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
842 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 192.168.10.10], [1], [],
843 [ovn-nbctl: 192.168.10.10: IP address family is different from VIP ae0f::10.
846 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 192.168.10.10], [1], [],
847 [ovn-nbctl: 192.168.10.10: IP address family is different from VIP ae0f::10.
850 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 192.168.10.10:80], [1], [],
851 [ovn-nbctl: 192.168.10.10:80: IP address family is different from VIP [[ae0f::10]]:80.
854 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 ae0f::10], [1], [],
855 [ovn-nbctl: ae0f::10: IP address family is different from VIP 30.0.0.10.
858 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 [[ae0f::10]]:80], [1], [],
859 [ovn-nbctl: [[ae0f::10]]:80: IP address family is different from VIP 30.0.0.10:80.
862 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10])
863 AT_CHECK([ovn-nbctl lb-add lb0 ae0f:0000:0000:0000:0000:0000:0000:0010 fd0f::20],
864 [1], [], [ovn-nbctl: lb0: a load balancer with this vip (ae0f::10) already exists
867 AT_CHECK([ovn-nbctl lb-del lb0])
870 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,,])
871 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,[[fd0f::20]]:80,,,,])
872 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
873 UUID LB PROTO VIP IPs
874 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80
875 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
877 AT_CHECK([ovn-nbctl lb-del lb0])
878 AT_CHECK([ovn-nbctl lb-del lb1])
881 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80])
882 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
883 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
884 UUID LB PROTO VIP IPs
885 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
886 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
889 dnl Update the VIP of the lb1.
890 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080])
891 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
892 UUID LB PROTO VIP IPs
893 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
894 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
897 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 udp])
898 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
899 UUID LB PROTO VIP IPs
900 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
901 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
904 dnl Config lb1 with another VIP.
905 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::20]]:80 [[fd0f::10]]:80 udp])
906 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
907 UUID LB PROTO VIP IPs
908 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
909 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
910 udp [[ae0f::20]]:80 [[fd0f::10]]:80
913 AT_CHECK([ovn-nbctl lb-del lb1 [[ae0f::20]]:80])
914 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
915 UUID LB PROTO VIP IPs
916 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
917 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
920 dnl Add LBs whose vip is just an IP address.
921 AT_CHECK([ovn-nbctl lb-add lb2 ae0f::30 fd0f::10])
922 AT_CHECK([ovn-nbctl lb-add lb3 ae0f::30 fd0f::10])
923 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
924 UUID LB PROTO VIP IPs
925 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
926 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
927 <2> lb2 tcp/udp ae0f::30 fd0f::10
928 <3> lb3 tcp/udp ae0f::30 fd0f::10
930 AT_CHECK([ovn-nbctl lb-del lb2 ae0f::30])
931 AT_CHECK([ovn-nbctl lb-del lb3 ae0f::30])
933 AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
934 AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
935 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
936 UUID LB PROTO VIP IPs
937 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
938 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
939 <2> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
940 <3> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
943 dnl If there are multiple load balancers with the same name, use a UUID to update/delete.
944 AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
945 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
948 AT_CHECK([ovn-nbctl lb-del lb2], [1], [],
949 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
952 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
953 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:8080 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
954 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:9090 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
955 AT_CHECK([ovn-nbctl lb-del lb0 [[ae0f::10]]:80])
956 AT_CHECK([ovn-nbctl lb-del lb1])
957 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
958 UUID LB PROTO VIP IPs
959 <0> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
960 <1> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
963 dnl Add load balancer to logical switch.
964 AT_CHECK([ovn-nbctl ls-add ls0])
965 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80])
966 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 udp])
967 AT_CHECK([ovn-nbctl lb-add lb3 ae0f::10 fd0f::10,fd0f::20])
968 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
969 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
970 AT_CHECK([ovn-nbctl --may-exist ls-lb-add ls0 lb1])
971 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [],
972 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
974 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
976 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
977 UUID LB PROTO VIP IPs
978 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
979 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
980 <2> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
983 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0])
984 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
985 UUID LB PROTO VIP IPs
986 <0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
987 <1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
990 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1])
991 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3])
992 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
993 AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1])
995 dnl Remove all load balancers from logical switch.
996 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
997 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
998 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
999 AT_CHECK([ovn-nbctl ls-lb-del ls0])
1000 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
1002 dnl Add load balancer to logical router.
1003 AT_CHECK([ovn-nbctl lr-add lr0])
1004 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
1005 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
1006 AT_CHECK([ovn-nbctl --may-exist lr-lb-add lr0 lb1])
1007 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [],
1008 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
1010 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
1012 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
1013 UUID LB PROTO VIP IPs
1014 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
1015 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
1016 <2> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
1019 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0])
1020 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
1021 UUID LB PROTO VIP IPs
1022 <0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
1023 <1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
1026 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1])
1027 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3])
1028 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
1029 AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1])
1031 dnl Remove all load balancers from logical router.
1032 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
1033 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
1034 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
1035 AT_CHECK([ovn-nbctl lr-lb-del lr0])
1036 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])])
1038 dnl ---------------------------------------------------------------------
1040 OVN_NBCTL_TEST([ovn_nbctl_basic_lr], [basic logical router commands], [
1041 AT_CHECK([ovn-nbctl lr-add lr0])
1042 AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl
1046 AT_CHECK([ovn-nbctl lr-add lr1])
1047 AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl
1052 AT_CHECK([ovn-nbctl lr-del lr0])
1053 AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl
1057 AT_CHECK([ovn-nbctl show lr0])
1058 AT_CHECK([ovn-nbctl lr-add lr0])
1059 AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0],
1062 AT_CHECK([ovn-nbctl lr-add lr0], [1], [],
1063 [ovn-nbctl: lr0: a router with this name already exists
1065 AT_CHECK([ovn-nbctl --may-exist lr-add lr0])
1066 AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0],
1069 AT_CHECK([ovn-nbctl --add-duplicate lr-add lr0])
1070 AT_CHECK([ovn-nbctl --may-exist --add-duplicate lr-add lr0], [1], [],
1071 [ovn-nbctl: --may-exist and --add-duplicate may not be used together
1073 AT_CHECK([ovn-nbctl lr-del lr0], [1], [],
1074 [ovn-nbctl: Multiple logical routers named 'lr0'. Use a UUID.
1077 AT_CHECK([ovn-nbctl lr-del lr2], [1], [],
1078 [ovn-nbctl: lr2: router name not found
1080 AT_CHECK([ovn-nbctl --if-exists lr-del lr2])
1082 AT_CHECK([ovn-nbctl lr-add])
1083 AT_CHECK([ovn-nbctl lr-add])
1084 AT_CHECK([ovn-nbctl --add-duplicate lr-add], [1], [],
1085 [ovn-nbctl: --add-duplicate requires specifying a name
1087 AT_CHECK([ovn-nbctl --may-exist lr-add], [1], [],
1088 [ovn-nbctl: --may-exist requires specifying a name
1091 dnl ---------------------------------------------------------------------
1093 OVN_NBCTL_TEST([ovn_nbctl_basic_lrp], [basic logical router port commands], [
1094 AT_CHECK([ovn-nbctl lr-add lr0])
1095 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02 192.168.1.1/24], [1], [],
1096 [ovn-nbctl: lrp0: invalid mac address 00:00:00:01:02
1098 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03:04 192.168.1.1/24], [1], [],
1099 [ovn-nbctl: lrp0: invalid mac address 00:00:00:01:02:03:04
1102 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1104 AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0], [dnl
1107 mac: "00:00:00:01:02:03"
1108 networks: [["192.168.1.1/24"]]
1111 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1112 [ovn-nbctl: lrp0: a port with this name already exists
1114 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1115 AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl
1119 AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
1120 AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl
1125 AT_CHECK([ovn-nbctl lr-add lr1])
1126 AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1127 [ovn-nbctl: lrp1: a port with this name already exists
1130 AT_CHECK([ovn-nbctl --may-exist lrp-add lr1 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1131 [ovn-nbctl: lrp1: port already exists but in router lr0
1134 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:04:05:06 192.168.1.1/24], [1], [],
1135 [ovn-nbctl: lrp1: port already exists with mac 00:00:00:01:02:03
1138 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1139 [ovn-nbctl: lrp1: port already exists with mismatching peer
1142 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 peer=lrp1-peer], [1], [],
1143 [ovn-nbctl: lrp1: port already exists with different network
1146 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
1148 AT_CHECK([ovn-nbctl lrp-del lrp1])
1149 AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl
1153 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 10.0.0.1/24 peer=lrp1-peer])
1155 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 172.16.0.1/24 peer=lrp1-peer], [1], [],
1156 [ovn-nbctl: lrp1: port already exists with different network
1159 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 192.168.1.1/24 peer=lrp1-peer])])
1161 dnl ---------------------------------------------------------------------
1163 OVN_NBCTL_TEST([ovn_nbctl_lrp_gw_chassi], [logical router port gateway chassis], [
1164 AT_CHECK([ovn-nbctl lr-add lr0])
1165 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1166 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [])
1168 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lp0 chassis1], [1], [],
1169 [ovn-nbctl: lp0: port name not found
1172 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lp0], [1], [],
1173 [ovn-nbctl: lp0: port name not found
1176 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lp0 chassis1], [1], [],
1177 [ovn-nbctl: lp0: port name not found
1180 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1], [1], [],
1181 [ovn-nbctl: chassis chassis1 is not added to logical port lrp0
1183 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1])
1185 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1188 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 10])
1190 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1193 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 20])
1195 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1198 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis2 5])
1199 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1204 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1])
1205 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1209 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis2])
1210 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0])
1212 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 1])
1213 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis2 10])
1214 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis3 5])
1215 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1221 dnl ---------------------------------------------------------------------
1223 OVN_NBCTL_TEST([ovn_nbctl_lrp_enable], [logical router port enable and disable], [
1224 AT_CHECK([ovn-nbctl lr-add lr0])
1225 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1226 AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
1229 AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 disabled])
1230 AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [disabled
1233 AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 enabled])
1234 AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
1237 AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 xyzzy], [1], [],
1238 [ovn-nbctl: xyzzy: state must be "enabled" or "disabled"
1241 dnl ---------------------------------------------------------------------
1243 OVN_NBCTL_TEST([ovn_nbctl_routes], [routes], [
1244 AT_CHECK([ovn-nbctl lr-add lr0])
1246 dnl Check IPv4 routes
1247 AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
1248 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.0/24 11.0.1.1 lp0])
1249 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.2])
1251 dnl Add overlapping route with 10.0.0.1/24
1252 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1], [1], [],
1253 [ovn-nbctl: duplicate prefix: 10.0.0.0/24
1255 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111a/24 11.0.0.1], [1], [],
1256 [ovn-nbctl: bad prefix argument: 10.0.0.111a/24
1258 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24a 11.0.0.1], [1], [],
1259 [ovn-nbctl: bad prefix argument: 10.0.0.111/24a
1261 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1a], [1], [],
1262 [ovn-nbctl: bad next hop argument: 11.0.0.1a
1264 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1/24], [1], [],
1265 [ovn-nbctl: bad IPv4 nexthop argument: 11.0.0.1/24
1267 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1/64], [1], [],
1268 [ovn-nbctl: bad IPv6 nexthop argument: 2001:0db8:0:f103::1/64
1271 AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1])
1272 AT_CHECK([ovn-nbctl --policy=src-ip lr-route-add lr0 9.16.1.0/24 11.0.0.1])
1274 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1276 10.0.0.0/24 11.0.0.1 dst-ip
1277 10.0.1.0/24 11.0.1.1 dst-ip lp0
1278 9.16.1.0/24 11.0.0.1 src-ip
1279 0.0.0.0/0 192.168.0.1 dst-ip
1282 AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1 lp1])
1283 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1285 10.0.0.0/24 11.0.0.1 dst-ip lp1
1286 10.0.1.0/24 11.0.1.1 dst-ip lp0
1287 9.16.1.0/24 11.0.0.1 src-ip
1288 0.0.0.0/0 192.168.0.1 dst-ip
1291 dnl Delete non-existent prefix
1292 AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.2.1/24], [1], [],
1293 [ovn-nbctl: no matching prefix: 10.0.2.0/24
1295 AT_CHECK([ovn-nbctl --if-exists lr-route-del lr0 10.0.2.1/24])
1297 AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.1.1/24])
1298 AT_CHECK([ovn-nbctl lr-route-del lr0 9.16.1.0/24])
1300 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1302 10.0.0.0/24 11.0.0.1 dst-ip lp1
1303 0.0.0.0/0 192.168.0.1 dst-ip
1306 AT_CHECK([ovn-nbctl lr-route-del lr0])
1307 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1310 dnl Check IPv6 routes
1311 AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
1312 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
1313 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
1315 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1317 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0
1318 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1319 ::/0 2001:db8:0:f101::1 dst-ip
1322 AT_CHECK([ovn-nbctl lr-route-del lr0 2001:0db8:0::/64])
1324 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1326 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1327 ::/0 2001:db8:0:f101::1 dst-ip
1330 AT_CHECK([ovn-nbctl lr-route-del lr0])
1331 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1334 dnl Check IPv4 and IPv6 routes
1335 AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
1336 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.1/24 11.0.1.1 lp0])
1337 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.1])
1338 AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
1339 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
1340 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
1342 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1344 10.0.0.0/24 11.0.0.1 dst-ip
1345 10.0.1.0/24 11.0.1.1 dst-ip lp0
1346 0.0.0.0/0 192.168.0.1 dst-ip
1349 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0
1350 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1351 ::/0 2001:db8:0:f101::1 dst-ip
1354 dnl ---------------------------------------------------------------------
1356 OVN_NBCTL_TEST([ovn_nbctl_policies], [policies], [
1357 AT_CHECK([ovn-nbctl lr-add lr0])
1359 dnl Add policies with allow and drop actions
1360 AT_CHECK([ovn-nbctl lr-policy-add lr0 100 "ip4.src == 1.1.1.0/24" drop])
1361 AT_CHECK([ovn-nbctl lr-policy-add lr0 100 "ip4.src == 1.1.2.0/24" allow])
1362 AT_CHECK([ovn-nbctl lr-policy-add lr0 101 "ip4.src == 2.1.1.0/24" allow])
1363 AT_CHECK([ovn-nbctl lr-policy-add lr0 101 "ip4.src == 2.1.2.0/24" drop])
1364 AT_CHECK([ovn-nbctl lr-policy-add lr0 101 "ip6.src == 2002::/64" drop])
1366 dnl Add duplicated policy
1367 AT_CHECK([ovn-nbctl lr-policy-add lr0 100 "ip4.src == 1.1.1.0/24" drop], [1], [],
1368 [ovn-nbctl: Same routing policy already existed on the logical router lr0.
1371 dnl Add duplicated policy
1372 AT_CHECK([ovn-nbctl lr-policy-add lr0 103 "ip4.src == 1.1.1.0/24" deny], [1], [],
1373 [ovn-nbctl: deny: action must be one of "allow", "drop", and "reroute"
1376 dnl Delete by priority and match string
1377 AT_CHECK([ovn-nbctl lr-policy-del lr0 100 "ip4.src == 1.1.1.0/24"])
1378 AT_CHECK([ovn-nbctl lr-policy-list lr0], [0], [dnl
1380 101 ip4.src == 2.1.1.0/24 allow
1381 101 ip4.src == 2.1.2.0/24 drop
1382 101 ip6.src == 2002::/64 drop
1383 100 ip4.src == 1.1.2.0/24 allow
1386 dnl Delete all policies for given priority
1387 AT_CHECK([ovn-nbctl lr-policy-del lr0 101])
1388 AT_CHECK([ovn-nbctl lr-policy-list lr0], [0], [dnl
1390 100 ip4.src == 1.1.2.0/24 allow
1393 dnl Add policy with reroute action
1394 AT_CHECK([ovn-nbctl lr-policy-add lr0 102 "ip4.src == 3.1.2.0/24" reroute 3.3.3.3])
1396 dnl Add policy with invalid reroute ip
1397 AT_CHECK([ovn-nbctl lr-policy-add lr0 103 "ip4.src == 3.1.2.0/24" reroute 3.3.3.x], [1], [],
1398 [ovn-nbctl: bad next hop argument: 3.3.3.x
1401 dnl Add policy with reroute action
1402 AT_CHECK([ovn-nbctl lr-policy-add lr0 104 "ip6.src == 2001::/64" reroute 2002::5])
1404 dnl Add policy with invalid reroute ip
1405 AT_CHECK([ovn-nbctl lr-policy-add lr0 105 "ip6.src == 2001::/64" reroute 2002::x], [1], [],
1406 [ovn-nbctl: bad next hop argument: 2002::x
1411 dnl ---------------------------------------------------------------------
1413 OVN_NBCTL_TEST([ovn_nbctl_lsp_types], [lsp types], [
1414 AT_CHECK([ovn-nbctl ls-add ls0])
1415 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
1417 dnl switchport type defaults to empty
1418 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1422 dnl The following are the valid entries for
1424 AT_CHECK([ovn-nbctl lsp-set-type lp0 l2gateway])
1425 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1429 AT_CHECK([ovn-nbctl lsp-set-type lp0 router])
1430 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1434 AT_CHECK([ovn-nbctl lsp-set-type lp0 localnet])
1435 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1439 AT_CHECK([ovn-nbctl lsp-set-type lp0 localport])
1440 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1444 AT_CHECK([ovn-nbctl lsp-set-type lp0 vtep])
1445 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1449 dnl All of these are valid southbound port types but
1450 dnl should be rejected for northbound logical switch
1452 AT_CHECK([ovn-nbctl lsp-set-type lp0 l3gateway], [1], [], [dnl
1453 ovn-nbctl: Logical switch port type 'l3gateway' is unrecognized. Not setting type.
1455 AT_CHECK([ovn-nbctl lsp-set-type lp0 patch], [1], [], [dnl
1456 ovn-nbctl: Logical switch port type 'patch' is unrecognized. Not setting type.
1458 AT_CHECK([ovn-nbctl lsp-set-type lp0 chassisredirect], [1], [], [dnl
1459 ovn-nbctl: Logical switch port type 'chassisredirect' is unrecognized. Not setting type.
1462 dnl switch port type should still be "vtep" since previous
1463 dnl commands failed.
1464 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1468 dnl Attempt a nonsense type
1469 AT_CHECK([ovn-nbctl lsp-set-type lp0 eggs], [1], [], [dnl
1470 ovn-nbctl: Logical switch port type 'eggs' is unrecognized. Not setting type.
1473 dnl Empty string should work too
1474 AT_CHECK([ovn-nbctl lsp-set-type lp0 ""])
1475 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1479 dnl ---------------------------------------------------------------------
1481 OVN_NBCTL_TEST([ovn_nbctl_connection], [connection], [
1482 AT_CHECK([ovn-nbctl --inactivity-probe=30000 set-connection ptcp:6641:127.0.0.1 punix:$OVS_RUNDIR/ovnnb_db.sock])
1483 AT_CHECK([ovn-nbctl list connection | grep inactivity_probe], [0], [dnl
1484 inactivity_probe : 30000
1485 inactivity_probe : 30000
1488 dnl ---------------------------------------------------------------------
1490 OVN_NBCTL_TEST([ovn_nbctl_dry_run_mode], [dry run mode], [
1491 dnl Check that dry run has no permanent effect.
1492 AT_CHECK([ovn-nbctl --dry-run ls-add ls0 -- ls-list | uuidfilt], [0], [dnl
1495 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
1498 dnl Check that dry-run mode is not sticky.
1499 AT_CHECK([ovn-nbctl ls-add ls0])
1500 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
1504 dnl ---------------------------------------------------------------------
1506 OVN_NBCTL_TEST([ovn_nbctl_oneline_output], [oneline output], [
1507 AT_CHECK([ovn-nbctl ls-add ls0 -- ls-add ls1])
1509 dnl Expect one line for one command.
1510 AT_CHECK([ovn-nbctl --oneline ls-list | uuidfilt], [0], [dnl
1511 <0> (ls0)\n<1> (ls1)
1514 dnl Expect lines for two commands.
1515 AT_CHECK([ovn-nbctl --oneline ls-list -- ls-list | uuidfilt], [0], [dnl
1516 <0> (ls0)\n<1> (ls1)
1517 <0> (ls0)\n<1> (ls1)
1520 dnl ---------------------------------------------------------------------
1522 OVN_NBCTL_TEST([ovn_nbctl_error_paths], [commands parser error paths], [
1523 dnl FIXME: Duplicate options are allowed when passed with global options.
1524 dnl For example: ovn-nbctl --if-exists --if-exists list Logical_Switch
1526 dnl Duplicate option
1527 AT_CHECK([ovn-nbctl -- --if-exists --if-exists list Logical_Switch], [1], [], [stderr])
1528 AT_CHECK([grep 'option specified multiple times' stderr], [0], [ignore])
1531 AT_CHECK([ovn-nbctl], [1], [], [stderr])
1532 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1534 AT_CHECK([ovn-nbctl --if-exists], [1], [], [stderr])
1535 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1537 AT_CHECK([ovn-nbctl --], [1], [], [stderr])
1538 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1540 AT_CHECK([ovn-nbctl -- --if-exists], [1], [], [stderr])
1541 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1544 AT_CHECK([ovn-nbctl foo], [1], [], [stderr])
1545 AT_CHECK([grep 'unknown command' stderr], [0], [ignore])
1547 AT_CHECK([ovn-nbctl -- foo], [1], [], [stderr])
1548 AT_CHECK([grep 'unknown command' stderr], [0], [ignore])
1551 AT_CHECK([ovn-nbctl --foo list Logical_Switch], [1], [], [stderr])
1552 AT_CHECK([grep 'unrecognized option' stderr], [0], [ignore])
1554 AT_CHECK([ovn-nbctl -- --foo list Logical_Switch], [1], [], [stderr])
1555 AT_CHECK([grep 'command has no .* option' stderr], [0], [ignore])
1557 dnl Missing option argument
1558 AT_CHECK([ovn-nbctl --columns], [1], [], [stderr])
1559 AT_CHECK([grep 'option .* requires an argument' stderr], [0], [ignore])
1561 AT_CHECK([ovn-nbctl -- --columns list Logical_Switch], [1], [], [stderr])
1562 AT_CHECK([grep 'missing argument to .* option' stderr], [0], [ignore])
1564 dnl Unexpected option argument
1565 AT_CHECK([ovn-nbctl --if-exists=foo list Logical_Switch], [1], [], [stderr])
1566 AT_CHECK([egrep 'option .* doesn'\''t allow an argument|option .* requires an argument' stderr], [0], [ignore])
1568 AT_CHECK([ovn-nbctl -- --if-exists=foo list Logical_Switch], [1], [], [stderr])
1569 AT_CHECK([grep 'option on .* does not accept an argument' stderr], [0], [ignore])
1571 dnl Not enough arguments
1572 AT_CHECK([ovn-nbctl list], [1], [], [stderr])
1573 AT_CHECK([grep 'command requires at least .* arguments' stderr], [0], [ignore])
1575 AT_CHECK([ovn-nbctl -- list], [1], [], [stderr])
1576 AT_CHECK([grep 'command requires at least .* arguments' stderr], [0], [ignore])
1578 dnl Too many arguments
1579 AT_CHECK([ovn-nbctl show foo bar], [1], [], [stderr])
1580 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])
1582 AT_CHECK([ovn-nbctl -- show foo bar], [1], [], [stderr])
1583 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])
1585 AT_CHECK([ovn-nbctl show foo --bar], [1], [], [stderr])
1586 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])
1588 AT_CHECK([ovn-nbctl -- show foo --bar], [1], [], [stderr])
1589 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])])
1591 dnl ---------------------------------------------------------------------
1593 OVN_NBCTL_TEST([ovn_nbctl_port_groups], [port groups], [
1594 dnl Check that port group can be looked up by name
1595 AT_CHECK([ovn-nbctl create Port_Group name=pg0], [0], [ignore])
1596 AT_CHECK([ovn-nbctl get Port_Group pg0 name], [0], [dnl
1600 OVN_NBCTL_TEST([ovn_nbctl_extra_newlines], [extra newlines], [
1601 dnl This test addresses a specific issue seen when running ovn-nbctl in
1602 dnl daemon mode. All we have to do is ensure that each time we list database
1603 dnl information, there is not an extra newline at the beginning of the output.
1604 AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore])
1605 AT_CHECK([ovn-nbctl --columns=name list logical_switch sw1], [0], [dnl
1608 AT_CHECK([ovn-nbctl --columns=name list logical_switch sw1], [0], [dnl
1612 OVN_NBCTL_TEST([ovn_nbctl_table_formatting], [table formatting], [
1613 dnl This test addresses a specific issue seen when running ovn-nbctl in
1614 dnl daemon mode. We need to ensure that table formatting options are honored
1615 dnl when listing database information.
1616 AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore])
1617 AT_CHECK([ovn-nbctl --bare --columns=name list logical_switch sw1], [0], [dnl
1620 dnl ---------------------------------------------------------------------
1622 OVN_NBCTL_TEST([ovn_nbctl_port_group_commands], [port group commands], [
1623 AT_CHECK([ovn-nbctl pg-add pg1], [0], [ignore])
1624 AT_CHECK([ovn-nbctl --bare --columns=name list port_group pg1], [0],
1628 AT_CHECK([ovn-nbctl pg-del pg1], [0], [ignore])
1629 AT_CHECK([ovn-nbctl list port_group], [0], [])
1631 AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore])
1632 AT_CHECK([ovn-nbctl lsp-add sw1 sw1-p1], [0], [ignore])
1633 SW1P1=$(ovn-nbctl --bare --columns=_uuid list logical_switch_port sw1-p1)
1634 AT_CHECK([ovn-nbctl lsp-add sw1 sw1-p2], [0], [ignore])
1635 SW1P2=$(ovn-nbctl --bare --columns=_uuid list logical_switch_port sw1-p2)
1637 AT_CHECK([ovn-nbctl pg-add pg1 sw1-p1], [0], [ignore])
1638 AT_CHECK([ovn-nbctl --bare --columns=name list port_group pg1], [0],[dnl
1641 AT_CHECK_UNQUOTED([ovn-nbctl --bare --columns=ports list port_group pg1], [0], [dnl
1645 AT_CHECK([ovn-nbctl pg-set-ports pg1 sw1-p2], [0], [ignore])
1646 AT_CHECK_UNQUOTED([ovn-nbctl --bare --columns=ports list port_group pg1], [0], [dnl
1650 AT_CHECK([ovn-nbctl pg-del pg1], [0], [ignore])
1651 AT_CHECK([ovn-nbctl list port_group], [0], [])
1654 AT_SETUP([ovn-nbctl - daemon retry connection])
1655 OVN_NBCTL_TEST_START daemon
1656 AT_CHECK([kill `cat ovsdb-server.pid`])
1657 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
1658 AT_CHECK([ovn-nbctl show], [0], [ignore])
1659 OVN_NBCTL_TEST_STOP /Terminated/d