From patchwork Fri Oct 18 10:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1999044 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=UngZQcBd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4XVL6g6ShWz1xth for ; Fri, 18 Oct 2024 21:10:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0D2C640F7F; Fri, 18 Oct 2024 10:10:02 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id te6TO8cYcYwG; Fri, 18 Oct 2024 10:10:00 +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 smtp2.osuosl.org AEC2440F66 Authentication-Results: smtp2.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=UngZQcBd Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id AEC2440F66; Fri, 18 Oct 2024 10:09:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 64406C08A6; Fri, 18 Oct 2024 10:09:58 +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 46BD6C08A3 for ; Fri, 18 Oct 2024 10:09:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id B01B68136D for ; Fri, 18 Oct 2024 10:09:51 +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 cX-V-ubKmEm4 for ; Fri, 18 Oct 2024 10:09:49 +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 A00EE8135A 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 A00EE8135A Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UngZQcBd 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 A00EE8135A for ; Fri, 18 Oct 2024 10:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729246188; 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=Sd16Qn9xWsuaZLqcy51rnVuHD+RkZcD7XUK9zvE0Emk=; b=UngZQcBdCXzmBt9+BqMry+tKvvdt+gq+fiHc2Ak20DjdRDuoH491kir0fKg8KYE8fWhzYq T+I7oNuQblFDykji6TTJdi/ZycICHfJguDoglQCZpQBhuQgID1cDgMPrt2C5LljJTSh0ws Ob7NbsAXxp14vVJ4KY/byQ5WcJsmnsM= 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-259-8P8WpI-bOJuhpWg52EpQSA-1; Fri, 18 Oct 2024 06:09:45 -0400 X-MC-Unique: 8P8WpI-bOJuhpWg52EpQSA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 A35E71955EE7; Fri, 18 Oct 2024 10:09:44 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.45.225.43]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C9A3519560A3; Fri, 18 Oct 2024 10:09:42 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 18 Oct 2024 12:09:29 +0200 Message-ID: <20241018100930.826293-5-amusil@redhat.com> In-Reply-To: <20241018100930.826293-1-amusil@redhat.com> References: <20241018100930.826293-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 4/5] northd: Use the same UUID for SB representation of Mirror. 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 NB Mirror has exactly one corresponding row in SB database. Use the NB UUID for the SB representation which makes the processing easier and the link between the rows is obvious at first glance. Signed-off-by: Ales Musil --- northd/northd.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index a81defe49..3b9db5b3c 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -18096,23 +18096,21 @@ mirror_needs_update(const struct nbrec_mirror *nb_mirror, } static void -sync_mirrors_iterate_nb_mirror(struct ovsdb_idl_txn *ovnsb_txn, - const char *mirror_name, - const struct nbrec_mirror *nb_mirror, - struct shash *sb_mirrors) +sync_nb_and_sb_mirror(struct ovsdb_idl_txn *ovnsb_txn, + const char *mirror_name, + const struct nbrec_mirror *nb_mirror, + const struct sbrec_mirror_table *sbrec_mirror_table) { - const struct sbrec_mirror *sb_mirror; - bool new_sb_mirror = false; + const struct uuid *nb_uuid = &nb_mirror->header_.uuid; + const struct sbrec_mirror *sb_mirror = + sbrec_mirror_table_get_for_uuid(sbrec_mirror_table, nb_uuid); - sb_mirror = shash_find_data(sb_mirrors, mirror_name); if (!sb_mirror) { - sb_mirror = sbrec_mirror_insert(ovnsb_txn); + sb_mirror = sbrec_mirror_insert_persist_uuid(ovnsb_txn, nb_uuid); sbrec_mirror_set_name(sb_mirror, mirror_name); - shash_add(sb_mirrors, sb_mirror->name, sb_mirror); - new_sb_mirror = true; } - if (new_sb_mirror || mirror_needs_update(nb_mirror, sb_mirror)) { + if (mirror_needs_update(nb_mirror, sb_mirror)) { sbrec_mirror_set_filter(sb_mirror, nb_mirror->filter); sbrec_mirror_set_index(sb_mirror, nb_mirror->index); sbrec_mirror_set_sink(sb_mirror, nb_mirror->sink); @@ -18125,26 +18123,19 @@ sync_mirrors(struct ovsdb_idl_txn *ovnsb_txn, const struct nbrec_mirror_table *nbrec_mirror_table, const struct sbrec_mirror_table *sbrec_mirror_table) { - struct shash sb_mirrors = SHASH_INITIALIZER(&sb_mirrors); - const struct sbrec_mirror *sb_mirror; - SBREC_MIRROR_TABLE_FOR_EACH (sb_mirror, sbrec_mirror_table) { - shash_add(&sb_mirrors, sb_mirror->name, sb_mirror); + SBREC_MIRROR_TABLE_FOR_EACH_SAFE (sb_mirror, sbrec_mirror_table) { + if (!nbrec_mirror_table_get_for_uuid(nbrec_mirror_table, + &sb_mirror->header_.uuid)) { + sbrec_mirror_delete(sb_mirror); + } } const struct nbrec_mirror *nb_mirror; NBREC_MIRROR_TABLE_FOR_EACH (nb_mirror, nbrec_mirror_table) { - sync_mirrors_iterate_nb_mirror(ovnsb_txn, nb_mirror->name, nb_mirror, - &sb_mirrors); - shash_find_and_delete(&sb_mirrors, nb_mirror->name); - } - - struct shash_node *node, *next; - SHASH_FOR_EACH_SAFE (node, next, &sb_mirrors) { - sbrec_mirror_delete(node->data); - shash_delete(&sb_mirrors, node); + sync_nb_and_sb_mirror(ovnsb_txn, nb_mirror->name, + nb_mirror, sbrec_mirror_table); } - shash_destroy(&sb_mirrors); } /*