From patchwork Wed Jun 26 13:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1952632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aNaKHPuh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W8MyW6Gvkz20X1 for ; Wed, 26 Jun 2024 23:30:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 51E7E8206A; Wed, 26 Jun 2024 13:30:26 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id vEUBN1AIWOZd; Wed, 26 Jun 2024 13:30:24 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8677681D5F Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aNaKHPuh Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 8677681D5F; Wed, 26 Jun 2024 13:30:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48195C0925; Wed, 26 Jun 2024 13:30:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4A393C0035 for ; Wed, 26 Jun 2024 13:30:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 060EC81BF4 for ; Wed, 26 Jun 2024 13:30:20 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id zjD5jYLQRt7O for ; Wed, 26 Jun 2024 13:30:19 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 38FD781A5F Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 38FD781A5F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 38FD781A5F for ; Wed, 26 Jun 2024 13:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719408617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ItYxYkO55tb/X3y0p59BkHtTATcr/5pl1j5EPbP4Vak=; b=aNaKHPuh88WAE9uFEof2mSESrhgK6fcyfpA1mBIf1E0U6fi9uuqeTqYpWLGLxhULpuZcvF aU1w3PLwAxQ0PBmU3gDTa58sxV1nra4ZhNr33UIlvqEMZFfRPA6LDoS5o2Q/E7Z07to4a8 OmrAXJzY7Ptnx/zgtrO3UCy8zvvIPSE= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-CPZzB4LfOUWvDD7GE_l0mg-1; Wed, 26 Jun 2024 09:30:16 -0400 X-MC-Unique: CPZzB4LfOUWvDD7GE_l0mg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 563E019560B0 for ; Wed, 26 Jun 2024 13:30:15 +0000 (UTC) Received: from amusil.brq.redhat.com (unknown [10.43.17.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 048273000221; Wed, 26 Jun 2024 13:30:13 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Wed, 26 Jun 2024 15:30:06 +0200 Message-ID: <20240626133007.694177-4-amusil@redhat.com> In-Reply-To: <20240626133007.694177-1-amusil@redhat.com> References: <20240626133007.694177-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 3/4] ovn-nbctl: Avoid uninitialized value for mirror index. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dceara@redhat.com Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 --- tests/ovn-nbctl.at | 9 +++++++++ utilities/ovn-nbctl.c | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 19c83a4a5..31de30921 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -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 diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index 32ca4f750..c37cc010c 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -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"); }