From patchwork Fri Oct 18 10:09:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1999042 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=EhaXtRom; 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 4XVL6R37xsz1xth for ; Fri, 18 Oct 2024 21:09:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9424340E86; Fri, 18 Oct 2024 10:09:48 +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 H1puVA1XSxE4; Fri, 18 Oct 2024 10:09:45 +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 72E7640E11 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=EhaXtRom Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 72E7640E11; Fri, 18 Oct 2024 10:09:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 541EAC08A6; Fri, 18 Oct 2024 10:09:45 +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 51560C08A3 for ; Fri, 18 Oct 2024 10:09:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3FC8881318 for ; Fri, 18 Oct 2024 10:09:44 +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 SWRFllkD0Es6 for ; Fri, 18 Oct 2024 10:09:43 +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 smtp1.osuosl.org D331080D78 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 D331080D78 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=EhaXtRom Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id D331080D78 for ; Fri, 18 Oct 2024 10:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729246181; 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=HrtAj+v/f53bDV/MjW1a0zb6ef2pk/R6b27oCzMIsjs=; b=EhaXtRomj6h5Gs4I7vHWTfccP2MG+0QPsJaH9T4tYem77f821n+XXnIrckS6LLEwKrJhbJ eGxr7KIxH32ZPENdVs5lOZ2wouDjBHytRwKtNvaT5Lv41UI1H2WdIFW2rFGQXNiCBPxb+J KSMmMSL6w6giclcLb07L1+M2TWA38C8= Received: from mx-prod-mc-01.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-118-kgVeXWUXNt-LFOSSH4tEkw-1; Fri, 18 Oct 2024 06:09:38 -0400 X-MC-Unique: kgVeXWUXNt-LFOSSH4tEkw-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 41F9F1956058; Fri, 18 Oct 2024 10:09:37 +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 364A119560A3; Fri, 18 Oct 2024 10:09:34 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 18 Oct 2024 12:09:26 +0200 Message-ID: <20241018100930.826293-2-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 1/5] northd: Use the same UUID for SB representation of Static_Mac_Binding. 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 Static_Mac_Binding 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 --- lib/automake.mk | 2 -- lib/static-mac-binding-index.c | 43 ---------------------------------- lib/static-mac-binding-index.h | 27 --------------------- northd/en-northd.c | 4 ---- northd/inc-proc-northd.c | 6 ----- northd/northd.c | 34 ++++++--------------------- northd/northd.h | 1 - tests/ovn-northd.at | 2 ++ 8 files changed, 9 insertions(+), 110 deletions(-) delete mode 100644 lib/static-mac-binding-index.c delete mode 100644 lib/static-mac-binding-index.h diff --git a/lib/automake.mk b/lib/automake.mk index b69e854b0..25e516406 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -44,8 +44,6 @@ lib_libovn_la_SOURCES = \ lib/inc-proc-eng.h \ lib/lb.c \ lib/lb.h \ - lib/static-mac-binding-index.c \ - lib/static-mac-binding-index.h \ lib/stopwatch-names.h \ lib/vif-plug-provider.h \ lib/vif-plug-provider.c \ diff --git a/lib/static-mac-binding-index.c b/lib/static-mac-binding-index.c deleted file mode 100644 index fecc9b74f..000000000 --- a/lib/static-mac-binding-index.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2021 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "lib/static-mac-binding-index.h" -#include "lib/ovn-sb-idl.h" - -struct ovsdb_idl_index * -static_mac_binding_index_create(struct ovsdb_idl *idl) -{ - return ovsdb_idl_index_create2(idl, - &sbrec_static_mac_binding_col_logical_port, - &sbrec_static_mac_binding_col_ip); -} - -const struct sbrec_static_mac_binding * -static_mac_binding_lookup(struct ovsdb_idl_index *smb_index, - const char *logical_port, const char *ip) -{ - struct sbrec_static_mac_binding *target = - sbrec_static_mac_binding_index_init_row(smb_index); - sbrec_static_mac_binding_index_set_logical_port(target, logical_port); - sbrec_static_mac_binding_index_set_ip(target, ip); - - struct sbrec_static_mac_binding *smb = - sbrec_static_mac_binding_index_find(smb_index, target); - sbrec_static_mac_binding_index_destroy_row(target); - - return smb; -} diff --git a/lib/static-mac-binding-index.h b/lib/static-mac-binding-index.h deleted file mode 100644 index 3d4ff06a2..000000000 --- a/lib/static-mac-binding-index.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) 2021 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OVN_STATIC_MAC_BINDING_INDEX_H -#define OVN_STATIC_MAC_BINDING_INDEX_H 1 - -struct ovsdb_idl; - -struct ovsdb_idl_index *static_mac_binding_index_create(struct ovsdb_idl *); -const struct sbrec_static_mac_binding *static_mac_binding_lookup( - struct ovsdb_idl_index *smb_index, - const char *logical_port, - const char *ip); - -#endif /* lib/static-mac-binding-index.h */ diff --git a/northd/en-northd.c b/northd/en-northd.c index 24ed31517..97e90b832 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -57,10 +57,6 @@ northd_get_input_data(struct engine_node *node, engine_ovsdb_node_get_index( engine_get_input("SB_ip_multicast", node), "sbrec_ip_mcast_by_dp"); - input_data->sbrec_static_mac_binding_by_lport_ip = - engine_ovsdb_node_get_index( - engine_get_input("SB_static_mac_binding", node), - "sbrec_static_mac_binding_by_lport_ip"); input_data->sbrec_fdb_by_dp_and_port = engine_ovsdb_node_get_index( engine_get_input("SB_fdb", node), diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index 8c834facb..480100d3c 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -20,7 +20,6 @@ #include "chassis-index.h" #include "ip-mcast-index.h" -#include "static-mac-binding-index.h" #include "lib/inc-proc-eng.h" #include "lib/mac-binding-index.h" #include "lib/ovn-nb-idl.h" @@ -359,8 +358,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, ip_mcast_index_create(sb->idl); struct ovsdb_idl_index *sbrec_chassis_by_hostname = chassis_hostname_index_create(sb->idl); - struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip - = static_mac_binding_index_create(sb->idl); struct ovsdb_idl_index *sbrec_mac_binding_by_datapath = mac_binding_by_datapath_index_create(sb->idl); struct ovsdb_idl_index *fdb_by_dp_key = @@ -383,9 +380,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_ovsdb_node_add_index(&en_sb_ip_multicast, "sbrec_ip_mcast_by_dp", sbrec_ip_mcast_by_dp); - engine_ovsdb_node_add_index(&en_sb_static_mac_binding, - "sbrec_static_mac_binding_by_lport_ip", - sbrec_static_mac_binding_by_lport_ip); engine_ovsdb_node_add_index(&en_sb_mac_binding, "sbrec_mac_binding_by_datapath", sbrec_mac_binding_by_datapath); diff --git a/northd/northd.c b/northd/northd.c index 0fe15ac59..fb34d0231 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -34,7 +34,6 @@ #include "lb.h" #include "lib/chassis-index.h" #include "lib/ip-mcast-index.h" -#include "lib/static-mac-binding-index.h" #include "lib/copp.h" #include "lib/mcast-group-index.h" #include "lib/ovn-l7.h" @@ -18560,29 +18559,11 @@ build_mcast_groups(const struct sbrec_igmp_group_table *sbrec_igmp_group_table, } } -static const struct nbrec_static_mac_binding * -static_mac_binding_by_port_ip( - const struct nbrec_static_mac_binding_table *nbrec_static_mb_table, - const char *logical_port, const char *ip) -{ - const struct nbrec_static_mac_binding *nb_smb = NULL; - - NBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH (nb_smb, nbrec_static_mb_table) { - if (!strcmp(nb_smb->logical_port, logical_port) && - !strcmp(nb_smb->ip, ip)) { - break; - } - } - - return nb_smb; -} - static void build_static_mac_binding_table( struct ovsdb_idl_txn *ovnsb_txn, const struct nbrec_static_mac_binding_table *nbrec_static_mb_table, const struct sbrec_static_mac_binding_table *sbrec_static_mb_table, - struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip, struct hmap *lr_ports) { /* Cleanup SB Static_MAC_Binding entries which do not have corresponding @@ -18592,9 +18573,8 @@ build_static_mac_binding_table( const struct sbrec_static_mac_binding *sb_smb; SBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH_SAFE (sb_smb, sbrec_static_mb_table) { - nb_smb = static_mac_binding_by_port_ip(nbrec_static_mb_table, - sb_smb->logical_port, - sb_smb->ip); + nb_smb = nbrec_static_mac_binding_table_get_for_uuid( + nbrec_static_mb_table, &sb_smb->header_.uuid); if (!nb_smb) { sbrec_static_mac_binding_delete(sb_smb); continue; @@ -18614,13 +18594,14 @@ build_static_mac_binding_table( if (op && op->nbrp) { struct ovn_datapath *od = op->od; if (od && od->sb) { + const struct uuid *nb_uuid = &nb_smb->header_.uuid; const struct sbrec_static_mac_binding *mb = - static_mac_binding_lookup( - sbrec_static_mac_binding_by_lport_ip, - nb_smb->logical_port, nb_smb->ip); + sbrec_static_mac_binding_table_get_for_uuid( + sbrec_static_mb_table, nb_uuid); if (!mb) { /* Create new entry */ - mb = sbrec_static_mac_binding_insert(ovnsb_txn); + mb = sbrec_static_mac_binding_insert_persist_uuid( + ovnsb_txn, nb_uuid); sbrec_static_mac_binding_set_logical_port( mb, nb_smb->logical_port); sbrec_static_mac_binding_set_ip(mb, nb_smb->ip); @@ -18900,7 +18881,6 @@ ovnnb_db_run(struct northd_input *input_data, build_static_mac_binding_table(ovnsb_txn, input_data->nbrec_static_mac_binding_table, input_data->sbrec_static_mac_binding_table, - input_data->sbrec_static_mac_binding_by_lport_ip, &data->lr_ports); stopwatch_stop(BUILD_LFLOWS_CTX_STOPWATCH_NAME, time_msec()); stopwatch_start(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec()); diff --git a/northd/northd.h b/northd/northd.h index 8f76d642d..995af65bc 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -68,7 +68,6 @@ struct northd_input { struct ovsdb_idl_index *sbrec_chassis_by_hostname; struct ovsdb_idl_index *sbrec_ha_chassis_grp_by_name; struct ovsdb_idl_index *sbrec_ip_mcast_by_dp; - struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip; struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port; }; diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index d6a8c4640..bcee2d231 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -8076,7 +8076,9 @@ ovn-nbctl static-mac-binding-add lr0-p0 192.168.10.100 00:00:22:33:44:55 wait_row_count nb:Static_MAC_Binding 2 logical_port=lr0-p0 wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.10 mac="00\:00\:11\:22\:33\:44" +check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10 wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.100 mac="00\:00\:22\:33\:44\:55" +check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100 ovn-nbctl static-mac-binding-add lr0-p1 10.0.0.10 00:00:33:44:55:66 wait_row_count nb:Static_MAC_Binding 1 logical_port=lr0-p1 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 From patchwork Fri Oct 18 10:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1999043 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=K7W444Or; 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 4XVL6c2Gtvz1xwD for ; Fri, 18 Oct 2024 21:10:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CB0E140E16; Fri, 18 Oct 2024 10:09:57 +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 QQdPrfe__0Mq; Fri, 18 Oct 2024 10:09:55 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0260B40E82 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=K7W444Or Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0260B40E82; Fri, 18 Oct 2024 10:09:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C5DBBC08A6; Fri, 18 Oct 2024 10:09:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1F555C08A6 for ; Fri, 18 Oct 2024 10:09:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A1D6A40871 for ; Fri, 18 Oct 2024 10:09:49 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id r5BeZ0H7Nh0s for ; Fri, 18 Oct 2024 10:09:48 +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 smtp4.osuosl.org B0EAF4080C Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B0EAF4080C Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=K7W444Or Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id B0EAF4080C for ; Fri, 18 Oct 2024 10:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729246187; 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=P2dhbzJKjLyLDNYUL/2a1lnA6ii0UqOwuDTM8eLqvWE=; b=K7W444Ornq1FuV/yUhX0Wb9BTUx4/Y4i2SczCKoXu/j6L6l0Ts2ZzGYMLPAtPuIz7X6EgW EWsVmCUSbEUf7aOX9EQl74LZ+fYTmxZTBbsFm0bTNKEnVmJ45+ZVw1d7XbFrrZU86/8O5p hqOixRjeBf03EVAWDGAoFfdXhx5tEpg= Received: from mx-prod-mc-01.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-342-dqMgosQqPBiK96bgJWFhsA-1; Fri, 18 Oct 2024 06:09:43 -0400 X-MC-Unique: dqMgosQqPBiK96bgJWFhsA-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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47D351956096; Fri, 18 Oct 2024 10:09:42 +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 65A4519560A3; Fri, 18 Oct 2024 10:09:40 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 18 Oct 2024 12:09:28 +0200 Message-ID: <20241018100930.826293-4-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 3/5] northd: Use the same UUID for SB representation of DNS. 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 DNS 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 --- controller/pinctrl.c | 76 ++++++++++++++++++++++++-------------------- northd/northd.c | 21 +++--------- 2 files changed, 45 insertions(+), 52 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index b891435c1..8a681ede7 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -3273,6 +3273,8 @@ put_be32(struct ofpbuf *buf, ovs_be32 x) } struct dns_data { + struct hmap_node hmap_node; + struct uuid uuid; uint64_t *dps; size_t n_dps; struct smap records; @@ -3280,7 +3282,20 @@ struct dns_data { bool delete; }; -static struct shash dns_cache = SHASH_INITIALIZER(&dns_cache); +static struct hmap dns_cache = HMAP_INITIALIZER(&dns_cache); + +static struct dns_data * +dns_cache_find_data(const struct uuid *uuid) +{ + struct dns_data *dns_data; + size_t hash = uuid_hash(uuid); + HMAP_FOR_EACH_WITH_HASH (dns_data, hmap_node, hash, &dns_cache) { + if (uuid_equals(&dns_data->uuid, uuid)) { + return dns_data; + } + } + return NULL; +} /* Called by pinctrl_run(). Runs within the main ovn-controller * thread context. */ @@ -3288,25 +3303,20 @@ static void sync_dns_cache(const struct sbrec_dns_table *dns_table) OVS_REQUIRES(pinctrl_mutex) { - struct shash_node *iter; - SHASH_FOR_EACH (iter, &dns_cache) { - struct dns_data *d = iter->data; - d->delete = true; + struct dns_data *dns_data; + HMAP_FOR_EACH (dns_data, hmap_node, &dns_cache) { + dns_data->delete = true; } const struct sbrec_dns *sbrec_dns; SBREC_DNS_TABLE_FOR_EACH (sbrec_dns, dns_table) { - const char *dns_id = smap_get(&sbrec_dns->external_ids, "dns_id"); - if (!dns_id) { - continue; - } - - struct dns_data *dns_data = shash_find_data(&dns_cache, dns_id); + const struct uuid *uuid = &sbrec_dns->header_.uuid; + dns_data = dns_cache_find_data(uuid); if (!dns_data) { dns_data = xmalloc(sizeof *dns_data); smap_init(&dns_data->records); smap_init(&dns_data->options); - shash_add(&dns_cache, dns_id, dns_data); + hmap_insert(&dns_cache, &dns_data->hmap_node, uuid_hash(uuid)); dns_data->n_dps = 0; dns_data->dps = NULL; } else { @@ -3333,14 +3343,13 @@ sync_dns_cache(const struct sbrec_dns_table *dns_table) } } - SHASH_FOR_EACH_SAFE (iter, &dns_cache) { - struct dns_data *d = iter->data; - if (d->delete) { - shash_delete(&dns_cache, iter); - smap_destroy(&d->records); - smap_destroy(&d->options); - free(d->dps); - free(d); + HMAP_FOR_EACH_SAFE (dns_data, hmap_node, &dns_cache) { + if (dns_data->delete) { + hmap_remove(&dns_cache, &dns_data->hmap_node); + smap_destroy(&dns_data->records); + smap_destroy(&dns_data->options); + free(dns_data->dps); + free(dns_data); } } } @@ -3348,14 +3357,12 @@ sync_dns_cache(const struct sbrec_dns_table *dns_table) static void destroy_dns_cache(void) { - struct shash_node *iter; - SHASH_FOR_EACH_SAFE (iter, &dns_cache) { - struct dns_data *d = iter->data; - shash_delete(&dns_cache, iter); - smap_destroy(&d->records); - smap_destroy(&d->options); - free(d->dps); - free(d); + struct dns_data *dns_data; + HMAP_FOR_EACH_POP (dns_data, hmap_node, &dns_cache) { + smap_destroy(&dns_data->records); + smap_destroy(&dns_data->options); + free(dns_data->dps); + free(dns_data); } } @@ -3543,17 +3550,16 @@ pinctrl_handle_dns_lookup( uint64_t dp_key = ntohll(pin->flow_metadata.flow.metadata); const char *answer_data = NULL; bool ovn_owned = false; - struct shash_node *iter; - SHASH_FOR_EACH (iter, &dns_cache) { - struct dns_data *d = iter->data; - ovn_owned = smap_get_bool(&d->options, "ovn-owned", false); - for (size_t i = 0; i < d->n_dps; i++) { - if (d->dps[i] == dp_key) { + struct dns_data *dns_data; + HMAP_FOR_EACH (dns_data, hmap_node, &dns_cache) { + ovn_owned = smap_get_bool(&dns_data->options, "ovn-owned", false); + for (size_t i = 0; i < dns_data->n_dps; i++) { + if (dns_data->dps[i] == dp_key) { /* DNS records in SBDB are stored in lowercase. Convert to * lowercase to perform case insensitive lookup */ char *query_name_lower = str_tolower(ds_cstr(&query_name)); - answer_data = smap_get(&d->records, query_name_lower); + answer_data = smap_get(&dns_data->records, query_name_lower); free(query_name_lower); if (answer_data) { break; diff --git a/northd/northd.c b/northd/northd.c index 0dac661b0..a81defe49 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -18162,7 +18162,7 @@ struct dns_info { }; static inline struct dns_info * -get_dns_info_from_hmap(struct hmap *dns_map, struct uuid *uuid) +get_dns_info_from_hmap(struct hmap *dns_map, const struct uuid *uuid) { struct dns_info *dns_info; size_t hash = uuid_hash(uuid); @@ -18208,15 +18208,8 @@ sync_dns_entries(struct ovsdb_idl_txn *ovnsb_txn, const struct sbrec_dns *sbrec_dns; SBREC_DNS_TABLE_FOR_EACH_SAFE (sbrec_dns, sbrec_dns_table) { - const char *nb_dns_uuid = smap_get(&sbrec_dns->external_ids, "dns_id"); - struct uuid dns_uuid; - if (!nb_dns_uuid || !uuid_from_string(&dns_uuid, nb_dns_uuid)) { - sbrec_dns_delete(sbrec_dns); - continue; - } - struct dns_info *dns_info = - get_dns_info_from_hmap(&dns_map, &dns_uuid); + get_dns_info_from_hmap(&dns_map, &sbrec_dns->header_.uuid); if (dns_info) { dns_info->sb_dns = sbrec_dns; } else { @@ -18227,14 +18220,8 @@ sync_dns_entries(struct ovsdb_idl_txn *ovnsb_txn, struct dns_info *dns_info; HMAP_FOR_EACH_POP (dns_info, hmap_node, &dns_map) { if (!dns_info->sb_dns) { - sbrec_dns = sbrec_dns_insert(ovnsb_txn); - dns_info->sb_dns = sbrec_dns; - char *dns_id = xasprintf( - UUID_FMT, UUID_ARGS(&dns_info->nb_dns->header_.uuid)); - const struct smap external_ids = - SMAP_CONST1(&external_ids, "dns_id", dns_id); - sbrec_dns_set_external_ids(sbrec_dns, &external_ids); - free(dns_id); + dns_info->sb_dns = sbrec_dns_insert_persist_uuid( + ovnsb_txn, &dns_info->nb_dns->header_.uuid); } /* Copy DNS options to SB*/ 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); } /* From patchwork Fri Oct 18 10:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1999045 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=IHe1DNTL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 4XVL6v41rSz1xvV for ; Fri, 18 Oct 2024 21:10:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 51BD9408CF; Fri, 18 Oct 2024 10:10:13 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rP_YUi7HdOr1; Fri, 18 Oct 2024 10:10:11 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C63D6408A9 Authentication-Results: smtp4.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=IHe1DNTL Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id C63D6408A9; Fri, 18 Oct 2024 10:10:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A53AAC08A6; Fri, 18 Oct 2024 10:10:11 +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 31803C08A3 for ; Fri, 18 Oct 2024 10:10:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4AA4D40E92 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 JxpfVnE8MN-f for ; Fri, 18 Oct 2024 10:10:00 +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 5DF2E40F85 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 5DF2E40F85 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IHe1DNTL 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 5DF2E40F85 for ; Fri, 18 Oct 2024 10:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729246199; 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=vT5cvxuZTiUW8ozWQewNvjhgc5zrrCjvf85fZkTlF1I=; b=IHe1DNTLVuXLi+qZu76hyC1xig1x3TMiMhtjWHqkGtX/NO48wjGPije7J0v5z0ted1Vf2y opN4y+3l46PYxEE0A3J6UZcq8uy5jZpt72tMEi10r35CHZPfo3AOmj7CLyKcipumwxdJib puIqo1ibHAOfxWxKitOcFl6ue84IMOw= Received: from mx-prod-mc-05.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-694-4neRtuOdNDiIdJ6LL6PzMw-1; Fri, 18 Oct 2024 06:09:48 -0400 X-MC-Unique: 4neRtuOdNDiIdJ6LL6PzMw-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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0098C195608D; Fri, 18 Oct 2024 10:09:47 +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 1AF7E1956056; Fri, 18 Oct 2024 10:09:44 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Fri, 18 Oct 2024 12:09:30 +0200 Message-ID: <20241018100930.826293-6-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 5/5] northd: Use the same UUID for SB representation of Load_Balancer. 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 Load_Balancer 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/en-sync-sb.c | 80 ++++++---------------------------------- northd/en-sync-sb.h | 2 - northd/inc-proc-northd.c | 4 +- tests/ovn-northd.at | 3 +- 4 files changed, 16 insertions(+), 73 deletions(-) diff --git a/northd/en-sync-sb.c b/northd/en-sync-sb.c index 9bd8a1fc6..d9dc25eb8 100644 --- a/northd/en-sync-sb.c +++ b/northd/en-sync-sb.c @@ -225,7 +225,6 @@ struct sb_lb_record { const struct sbrec_load_balancer *sbrec_lb; struct ovn_dp_group *ls_dpg; struct ovn_dp_group *lr_dpg; - struct uuid sb_uuid; }; struct sb_lb_table { @@ -268,7 +267,6 @@ static bool sync_changed_lbs(struct sb_lb_table *, struct ovn_datapaths *ls_datapaths, struct ovn_datapaths *lr_datapaths, struct chassis_features *); -static bool check_sb_lb_duplicates(const struct sbrec_load_balancer_table *); void * en_sync_to_sb_lb_init(struct engine_node *node OVS_UNUSED, @@ -346,23 +344,6 @@ sync_to_sb_lb_northd_handler(struct engine_node *node, void *data_) return true; } -bool -sync_to_sb_lb_sb_load_balancer(struct engine_node *node, void *data OVS_UNUSED) -{ - const struct sbrec_load_balancer_table *sb_load_balancer_table = - EN_OVSDB_GET(engine_get_input("SB_load_balancer", node)); - - /* The only reason to handle SB.Load_Balancer updates is to detect - * spurious records being created in clustered databases due to - * lack of indexing on the SB.Load_Balancer table. All other changes - * are valid and performed by northd, the only write-client for - * this table. */ - if (check_sb_lb_duplicates(sb_load_balancer_table)) { - return false; - } - return true; -} - /* sync_to_sb_pb engine node functions. * This engine node syncs the SB Port Bindings (partly). * en_northd engine create the SB Port binding rows and @@ -690,14 +671,7 @@ sb_lb_table_build_and_sync( const struct sbrec_load_balancer *sbrec_lb; SBREC_LOAD_BALANCER_TABLE_FOR_EACH_SAFE (sbrec_lb, sb_lb_table) { - const char *nb_lb_uuid = smap_get(&sbrec_lb->external_ids, "lb_id"); - struct uuid lb_uuid; - if (!nb_lb_uuid || !uuid_from_string(&lb_uuid, nb_lb_uuid)) { - sbrec_load_balancer_delete(sbrec_lb); - continue; - } - - sb_lb = sb_lb_table_find(&tmp_sb_lbs, &lb_uuid); + sb_lb = sb_lb_table_find(&tmp_sb_lbs, &sbrec_lb->header_.uuid); if (sb_lb) { sb_lb->sbrec_lb = sbrec_lb; bool success = sync_sb_lb_record(sb_lb, sbrec_lb, sb_dpgrp_table, @@ -751,17 +725,9 @@ sync_sb_lb_record(struct sb_lb_record *sb_lb, pre_sync_lr_dpg = sb_lb->lr_dpg; if (!sbrec_lb) { - sb_lb->sb_uuid = uuid_random(); - sbrec_lb = sbrec_load_balancer_insert_persist_uuid(ovnsb_txn, - &sb_lb->sb_uuid); - char *lb_id = xasprintf( - UUID_FMT, UUID_ARGS(&lb_dps->lb->nlb->header_.uuid)); - const struct smap external_ids = - SMAP_CONST1(&external_ids, "lb_id", lb_id); - sbrec_load_balancer_set_external_ids(sbrec_lb, &external_ids); - free(lb_id); + const struct uuid *nb_uuid = &lb_dps->lb->nlb->header_.uuid; + sbrec_lb = sbrec_load_balancer_insert_persist_uuid(ovnsb_txn, nb_uuid); } else { - sb_lb->sb_uuid = sbrec_lb->header_.uuid; sbrec_ls_dp_group = chassis_features->ls_dpg_column ? sbrec_lb->ls_datapath_group @@ -923,13 +889,11 @@ sync_changed_lbs(struct sb_lb_table *sb_lbs, HMAPX_FOR_EACH (hmapx_node, &trk_lbs->deleted) { lb_dps = hmapx_node->data; - - sb_lb = sb_lb_table_find(&sb_lbs->entries, - &lb_dps->lb->nlb->header_.uuid); + const struct uuid *nb_uuid = &lb_dps->lb->nlb->header_.uuid; + sb_lb = sb_lb_table_find(&sb_lbs->entries, nb_uuid); if (sb_lb) { const struct sbrec_load_balancer *sbrec_lb = - sbrec_load_balancer_table_get_for_uuid(sb_lb_table, - &sb_lb->sb_uuid); + sbrec_load_balancer_table_get_for_uuid(sb_lb_table, nb_uuid); if (sbrec_lb) { sbrec_load_balancer_delete(sbrec_lb); } @@ -941,9 +905,9 @@ sync_changed_lbs(struct sb_lb_table *sb_lbs, HMAPX_FOR_EACH (hmapx_node, &trk_lbs->crupdated) { lb_dps = hmapx_node->data; + const struct uuid *nb_uuid = &lb_dps->lb->nlb->header_.uuid; - sb_lb = sb_lb_table_find(&sb_lbs->entries, - &lb_dps->lb->nlb->header_.uuid); + sb_lb = sb_lb_table_find(&sb_lbs->entries, nb_uuid); if (!sb_lb && !lb_dps->n_nb_ls && !lb_dps->n_nb_lr) { continue; @@ -953,17 +917,15 @@ sync_changed_lbs(struct sb_lb_table *sb_lbs, sb_lb = xzalloc(sizeof *sb_lb); sb_lb->lb_dps = lb_dps; hmap_insert(&sb_lbs->entries, &sb_lb->key_node, - uuid_hash(&lb_dps->lb->nlb->header_.uuid)); + uuid_hash(nb_uuid)); } else { sb_lb->sbrec_lb = - sbrec_load_balancer_table_get_for_uuid(sb_lb_table, - &sb_lb->sb_uuid); + sbrec_load_balancer_table_get_for_uuid(sb_lb_table, nb_uuid); } if (sb_lb && !lb_dps->n_nb_ls && !lb_dps->n_nb_lr) { const struct sbrec_load_balancer *sbrec_lb = - sbrec_load_balancer_table_get_for_uuid(sb_lb_table, - &sb_lb->sb_uuid); + sbrec_load_balancer_table_get_for_uuid(sb_lb_table, nb_uuid); if (sbrec_lb) { sbrec_load_balancer_delete(sbrec_lb); } @@ -981,23 +943,3 @@ sync_changed_lbs(struct sb_lb_table *sb_lbs, return true; } - -static bool -check_sb_lb_duplicates(const struct sbrec_load_balancer_table *table) -{ - struct sset existing_nb_lb_uuids = - SSET_INITIALIZER(&existing_nb_lb_uuids); - const struct sbrec_load_balancer *sbrec_lb; - bool duplicates = false; - - SBREC_LOAD_BALANCER_TABLE_FOR_EACH (sbrec_lb, table) { - const char *nb_lb_uuid = smap_get(&sbrec_lb->external_ids, "lb_id"); - if (nb_lb_uuid && !sset_add(&existing_nb_lb_uuids, nb_lb_uuid)) { - duplicates = true; - break; - } - } - - sset_destroy(&existing_nb_lb_uuids); - return duplicates; -} diff --git a/northd/en-sync-sb.h b/northd/en-sync-sb.h index 3bcbb8259..f08565eee 100644 --- a/northd/en-sync-sb.h +++ b/northd/en-sync-sb.h @@ -21,8 +21,6 @@ void *en_sync_to_sb_lb_init(struct engine_node *, struct engine_arg *); void en_sync_to_sb_lb_run(struct engine_node *, void *data); void en_sync_to_sb_lb_cleanup(void *data); bool sync_to_sb_lb_northd_handler(struct engine_node *, void *data OVS_UNUSED); -bool sync_to_sb_lb_sb_load_balancer(struct engine_node *, - void *data OVS_UNUSED); void *en_sync_to_sb_pb_init(struct engine_node *, struct engine_arg *); void en_sync_to_sb_pb_run(struct engine_node *, void *data); diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index 480100d3c..f5f414959 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -308,8 +308,10 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, node_global_config_handler); engine_add_input(&en_sync_to_sb_lb, &en_northd, sync_to_sb_lb_northd_handler); + /* There is nothing to handle as duplicates are prevented by using + * UUID mapping between NB and SB. */ engine_add_input(&en_sync_to_sb_lb, &en_sb_load_balancer, - sync_to_sb_lb_sb_load_balancer); + engine_noop_handler); engine_add_input(&en_sync_to_sb_lb, &en_sb_logical_dp_group, NULL); engine_add_input(&en_sync_to_sb_pb, &en_northd, diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index ab65ddb44..f4aa23042 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -6456,7 +6456,8 @@ check ovn-nbctl --wait=sb sync dps=$(fetch_column Load_Balancer ls_datapath_group) nlb=$(fetch_column nb:Load_Balancer _uuid) -AT_CHECK([ovn-sbctl create Load_Balancer name=lb1 ls_datapath_group="$dps" external_ids="lb_id=$nlb"], [0], [ignore]) +AT_CHECK([ovn-sbctl --id="$nlb" create Load_Balancer name=lb1 ls_datapath_group="$dps"], [1], [ignore], [stderr]) +check grep -q "duplicate uuid" stderr check ovn-nbctl --wait=sb sync check_row_count Load_Balancer 1