From patchwork Fri Oct 18 10:09:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1999046 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=YWgOrtyf; 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 4XVL6x4D7gz1xvV for ; Fri, 18 Oct 2024 21:10:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E2BA140F9B; Fri, 18 Oct 2024 10:10:15 +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 htii8vyGbrWK; Fri, 18 Oct 2024 10:10:15 +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 E625D40F9F 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=YWgOrtyf Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id E625D40F9F; Fri, 18 Oct 2024 10:10:14 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C6193C08B4; Fri, 18 Oct 2024 10:10:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9ED78C08A6 for ; Fri, 18 Oct 2024 10:10:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 90AA440E9D for ; Fri, 18 Oct 2024 10:10:04 +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 ING8Udt1Dx3j for ; Fri, 18 Oct 2024 10:10:01 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 57F9740F7C Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 57F9740F7C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 57F9740F7C for ; Fri, 18 Oct 2024 10:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729246200; 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=RqxgDPHfvfM8fpc368qDcufLX2qTDBYkztTo5Dx/C50=; b=YWgOrtyf8o/BqBdQ5KWoq1Vl6uspiL1/Qq8/++MCDjXR+7QRWRtBtbbWgGL1lLjE+4awqn 6gETrcWkJR8fWP7ile44zyq6eQj0xDXf8W/Vcyl9sAt6HWQ0Nipkpu+P+imKMkZW1tE/c8 4Y5oKVgQQGyRmeSfCKwh5t14Y8GXEUg= 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-294-Yq9xy3rOOXi5IyY9mhBMMQ-1; Fri, 18 Oct 2024 06:09:40 -0400 X-MC-Unique: Yq9xy3rOOXi5IyY9mhBMMQ-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 C656F1955F41; Fri, 18 Oct 2024 10:09:39 +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 D91CA19560A3; Fri, 18 Oct 2024 10:09:37 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 18 Oct 2024 12:09:27 +0200 Message-ID: <20241018100930.826293-3-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 2/5] northd: Use the same UUID for SB representation of Chassis_Template_Var. 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 Chassis_Template_Var 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 | 30 +++++++++++++++--------------- tests/ovn-northd.at | 2 ++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index fb34d0231..0dac661b0 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -18283,37 +18283,37 @@ sync_template_vars( const struct nbrec_chassis_template_var_table *nbrec_ch_template_var_table, const struct sbrec_chassis_template_var_table *sbrec_ch_template_var_table) { - struct shash nb_tvs = SHASH_INITIALIZER(&nb_tvs); - const struct nbrec_chassis_template_var *nb_tv; const struct sbrec_chassis_template_var *sb_tv; - NBREC_CHASSIS_TEMPLATE_VAR_TABLE_FOR_EACH ( - nb_tv, nbrec_ch_template_var_table) { - shash_add(&nb_tvs, nb_tv->chassis, nb_tv); - } - SBREC_CHASSIS_TEMPLATE_VAR_TABLE_FOR_EACH_SAFE ( sb_tv, sbrec_ch_template_var_table) { - nb_tv = shash_find_and_delete(&nb_tvs, sb_tv->chassis); + nb_tv = nbrec_chassis_template_var_table_get_for_uuid( + nbrec_ch_template_var_table, &sb_tv->header_.uuid); if (!nb_tv) { sbrec_chassis_template_var_delete(sb_tv); continue; } + if (!smap_equal(&sb_tv->variables, &nb_tv->variables)) { - sbrec_chassis_template_var_set_variables(sb_tv, - &nb_tv->variables); + sbrec_chassis_template_var_set_variables(sb_tv, &nb_tv->variables); } } - struct shash_node *node; - SHASH_FOR_EACH (node, &nb_tvs) { - nb_tv = node->data; - sb_tv = sbrec_chassis_template_var_insert(ovnsb_txn); + NBREC_CHASSIS_TEMPLATE_VAR_TABLE_FOR_EACH ( + nb_tv, nbrec_ch_template_var_table) { + const struct uuid *nb_uuid = &nb_tv->header_.uuid; + sb_tv = sbrec_chassis_template_var_table_get_for_uuid( + sbrec_ch_template_var_table, nb_uuid); + if (sb_tv) { + continue; + } + + sb_tv = sbrec_chassis_template_var_insert_persist_uuid(ovnsb_txn, + nb_uuid); sbrec_chassis_template_var_set_chassis(sb_tv, nb_tv->chassis); sbrec_chassis_template_var_set_variables(sb_tv, &nb_tv->variables); } - shash_destroy(&nb_tvs); } static void diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index bcee2d231..ab65ddb44 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -10138,7 +10138,9 @@ check ovn-nbctl set Chassis_Template_Var hv2 variables:tv=v2 AS_BOX([Ensure values are propagated to SB]) check ovn-nbctl --wait=sb sync check_column "tv=v1" sb:Chassis_Template_Var variables chassis="hv1" +check_column "$(fetch_column nb:Chassis_Template_Var _uuid chassis=\"hv1\")" sb:Chassis_Template_Var _uuid chassis="hv1" check_column "tv=v2" sb:Chassis_Template_Var variables chassis="hv2" +check_column "$(fetch_column nb:Chassis_Template_Var _uuid chassis=\"hv2\")" sb:Chassis_Template_Var _uuid chassis="hv2" AS_BOX([Ensure SB is reconciled]) check ovn-sbctl --all destroy Chassis_Template_Var