@@ -452,6 +452,7 @@ OVN_NBCTL_TEST([ovn_nbctl_mirrors], [mirrors], [
check ovn-nbctl mirror-add mirror1 gre 0 from-lport 10.10.10.1
check ovn-nbctl mirror-add mirror2 erspan 1 to-lport 10.10.10.2
check ovn-nbctl mirror-add mirror3 gre 2 to-lport 10.10.10.3
+check ovn-nbctl mirror-add mirror-local local both 10.10.10.3
check ovn-nbctl ls-add sw0
check ovn-nbctl lsp-add sw0 sw0-port1
check ovn-nbctl lsp-add sw0 sw0-port2
@@ -480,6 +481,11 @@ check_column "$mirror3uuid" nb:Logical_Switch_Port mirror_rules name=sw0-port3
dnl Verify if multiple ports are attached to the same mirror properly
AT_CHECK([ovn-nbctl mirror-list], [0], [dnl
+mirror-local:
+ Type : local
+ Sink : 10.10.10.3
+ Filter : both
+
mirror1:
Type : gre
Sink : 10.10.10.1
@@ -500,6 +506,9 @@ mirror3:
])
+dnl Remove the local mirror
+check ovn-nbctl mirror-del mirror-local
+
dnl Detach one source port from mirror
check ovn-nbctl lsp-detach-mirror sw0-port3 mirror3
@@ -7691,7 +7691,7 @@ nbctl_mirror_add(struct ctl_context *ctx)
const char *sink = NULL;
const char *type = NULL;
const char *name = NULL;
- int64_t index;
+ int64_t index = -1;
char *error = NULL;
const struct nbrec_mirror *mirror_check = NULL;
int pos = 1;
@@ -7824,8 +7824,10 @@ nbctl_mirror_list(struct ctl_context *ctx)
ds_put_format(&ctx->output, " Type : %s\n", mirror->type);
ds_put_format(&ctx->output, " Sink : %s\n", mirror->sink);
ds_put_format(&ctx->output, " Filter : %s\n", mirror->filter);
- ds_put_format(&ctx->output, " Index/Key: %ld\n",
- (long int) mirror->index);
+ if (strcmp(mirror->type, "local")) {
+ ds_put_format(&ctx->output, " Index/Key: %"PRId64"\n",
+ mirror->index);
+ }
ds_put_cstr(&ctx->output, "\n");
}
The local mirror doesn't have an index, avoid storing uninitialized value in that case. Also prevent from index printing for local mirrors. Signed-off-by: Ales Musil <amusil@redhat.com> --- tests/ovn-nbctl.at | 9 +++++++++ utilities/ovn-nbctl.c | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-)