From patchwork Fri Aug 5 16:27:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1664129 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=NFf8T3hX; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lzrbb1H3wz9sB4 for ; Sat, 6 Aug 2022 02:27:23 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2861D41DC4; Fri, 5 Aug 2022 16:27:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2861D41DC4 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=NFf8T3hX X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W_dePND1yvO3; Fri, 5 Aug 2022 16:27:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3067A41DDE; Fri, 5 Aug 2022 16:27:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 3067A41DDE Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01975C0032; Fri, 5 Aug 2022 16:27:18 +0000 (UTC) X-Original-To: ovs-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 5B057C002D for ; Fri, 5 Aug 2022 16:27:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 30CEE83EEF for ; Fri, 5 Aug 2022 16:27:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 30CEE83EEF 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=NFf8T3hX X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TDu98KwrmwFb for ; Fri, 5 Aug 2022 16:27:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 567C783F17 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 567C783F17 for ; Fri, 5 Aug 2022 16:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659716831; 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=Yz5T6tjczL4jmqG/QqN4QCPT+BWMWKKLB4BPt+XWUDY=; b=NFf8T3hXjdPmaJ0TsKQGU+j5vgSGQNeQ+L8xhB/eORFc8HHXuJKRR7ElpO+cUjG9PDjrHF xVt0YSWogOWGqeeLQXedMlH4ef4uK7ltAPDzJH3X+x2JIk4lOeUuCxdF4lGhWGQZmttNWh 8okU160HW5AF0QqwSpzztV7TLbA1jWk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611--MaCHRE2N0WrUb-I6oaV2w-1; Fri, 05 Aug 2022 12:27:09 -0400 X-MC-Unique: -MaCHRE2N0WrUb-I6oaV2w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30A2F811E75 for ; Fri, 5 Aug 2022 16:27:09 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.192.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EDAB1121314; Fri, 5 Aug 2022 16:27:08 +0000 (UTC) From: Dumitru Ceara To: ovs-dev@openvswitch.org Date: Fri, 5 Aug 2022 18:27:05 +0200 Message-Id: <165971682264.246236.16785225575256752280.stgit@dceara.remote.csb> In-Reply-To: <165971680356.246236.1723217950402767004.stgit@dceara.remote.csb> References: <165971680356.246236.1723217950402767004.stgit@dceara.remote.csb> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: surya@redhat.com Subject: [ovs-dev] [RFC PATCH ovn 1/5] Add NB and SB Template_Var tables. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Propagate the contents of the NB table to the Southbound. Signed-off-by: Dumitru Ceara --- TODO: - Document the new Template_Var tables. --- lib/automake.mk | 2 ++ lib/template-var.c | 41 +++++++++++++++++++++++++++++++++++++++++ lib/template-var.h | 28 ++++++++++++++++++++++++++++ northd/en-northd.c | 6 ++++++ northd/inc-proc-northd.c | 14 ++++++++++++-- northd/northd.c | 33 +++++++++++++++++++++++++++++++++ northd/northd.h | 2 ++ ovn-nb.ovsschema | 16 +++++++++++++--- ovn-nb.xml | 7 +++++++ ovn-sb.ovsschema | 11 +++++++++-- ovn-sb.xml | 6 ++++++ 11 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 lib/template-var.c create mode 100644 lib/template-var.h diff --git a/lib/automake.mk b/lib/automake.mk index 3a2da1fe4..7ae5528fb 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -41,6 +41,8 @@ lib_libovn_la_SOURCES = \ lib/static-mac-binding-index.c \ lib/static-mac-binding-index.h \ lib/stopwatch-names.h \ + lib/template-var.c \ + lib/template-var.h \ lib/vif-plug-provider.h \ lib/vif-plug-provider.c \ lib/vif-plug-providers/dummy/vif-plug-dummy.c diff --git a/lib/template-var.c b/lib/template-var.c new file mode 100644 index 000000000..1a6d4dfbb --- /dev/null +++ b/lib/template-var.c @@ -0,0 +1,41 @@ +/* Copyright (c) 2022 Red Hat, Inc. + * 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/template-var.h" + +struct ovsdb_idl_index * +sbrec_template_var_by_name_chassis_index_create(struct ovsdb_idl *idl) +{ + return ovsdb_idl_index_create2(idl, &sbrec_template_var_col_name, + &sbrec_template_var_col_chassis); +} + +const struct sbrec_template_var * +sb_template_var_lookup_by_name_chassis( + struct ovsdb_idl_index *sbrec_template_var_by_name_chassis, + const char *name, const char *chassis) +{ + struct sbrec_template_var *target = + sbrec_template_var_index_init_row(sbrec_template_var_by_name_chassis); + sbrec_template_var_index_set_name(target, name); + sbrec_template_var_index_set_chassis(target, chassis); + + struct sbrec_template_var *retval = + sbrec_template_var_index_find(sbrec_template_var_by_name_chassis, + target); + sbrec_template_var_index_destroy_row(target); + return retval; +} diff --git a/lib/template-var.h b/lib/template-var.h new file mode 100644 index 000000000..33351055f --- /dev/null +++ b/lib/template-var.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2022, Red Hat, Inc. + * + * 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_TEMPLATE_VAR_H +#define OVN_TEMPLATE_VAR_H 1 + +#include "ovn-sb-idl.h" + +struct ovsdb_idl_index *sbrec_template_var_by_name_chassis_index_create( + struct ovsdb_idl *idl); + +const struct sbrec_template_var *sb_template_var_lookup_by_name_chassis( + struct ovsdb_idl_index *sbrec_template_var_by_name_chassis, + const char *name, const char *chassis); + +#endif /* lib/template-var.h */ diff --git a/northd/en-northd.c b/northd/en-northd.c index 4907a1ff2..ec89ec002 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -59,6 +59,10 @@ void en_northd_run(struct engine_node *node, void *data) engine_ovsdb_node_get_index( engine_get_input("SB_static_mac_binding", node), "sbrec_static_mac_binding_by_lport_ip"); + input_data.sbrec_template_var_by_name_chassis = + engine_ovsdb_node_get_index( + engine_get_input("SB_template_var", node), + "sbrec_template_var_by_name_chassis"); input_data.nbrec_nb_global_table = EN_OVSDB_GET(engine_get_input("NB_nb_global", node)); @@ -78,6 +82,8 @@ void en_northd_run(struct engine_node *node, void *data) EN_OVSDB_GET(engine_get_input("NB_acl", node)); input_data.nbrec_static_mac_binding_table = EN_OVSDB_GET(engine_get_input("NB_static_mac_binding", node)); + input_data.nbrec_template_var_table = + EN_OVSDB_GET(engine_get_input("NB_template_var", node)); input_data.sbrec_sb_global_table = EN_OVSDB_GET(engine_get_input("SB_sb_global", node)); diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index 43093cb5a..feb0ffe04 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -24,6 +24,7 @@ #include "lib/inc-proc-eng.h" #include "lib/ovn-nb-idl.h" #include "lib/ovn-sb-idl.h" +#include "lib/template-var.h" #include "mcast-group-index.h" #include "openvswitch/poll-loop.h" #include "openvswitch/vlog.h" @@ -62,7 +63,8 @@ VLOG_DEFINE_THIS_MODULE(inc_proc_northd); NB_NODE(ha_chassis_group, "ha_chassis_group") \ NB_NODE(ha_chassis, "ha_chassis") \ NB_NODE(bfd, "bfd") \ - NB_NODE(static_mac_binding, "static_mac_binding") + NB_NODE(static_mac_binding, "static_mac_binding") \ + NB_NODE(template_var, "template_var") enum nb_engine_node { #define NB_NODE(NAME, NAME_STR) NB_##NAME, @@ -112,7 +114,8 @@ VLOG_DEFINE_THIS_MODULE(inc_proc_northd); SB_NODE(load_balancer, "load_balancer") \ SB_NODE(bfd, "bfd") \ SB_NODE(fdb, "fdb") \ - SB_NODE(static_mac_binding, "static_mac_binding") + SB_NODE(static_mac_binding, "static_mac_binding") \ + SB_NODE(template_var, "template_var") enum sb_engine_node { #define SB_NODE(NAME, NAME_STR) SB_##NAME, @@ -182,6 +185,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_nb_ha_chassis_group, NULL); engine_add_input(&en_northd, &en_nb_ha_chassis, NULL); engine_add_input(&en_northd, &en_nb_static_mac_binding, NULL); + engine_add_input(&en_northd, &en_nb_template_var, NULL); engine_add_input(&en_northd, &en_sb_sb_global, NULL); engine_add_input(&en_northd, &en_sb_chassis, NULL); @@ -211,6 +215,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_load_balancer, NULL); engine_add_input(&en_northd, &en_sb_fdb, NULL); engine_add_input(&en_northd, &en_sb_static_mac_binding, NULL); + engine_add_input(&en_northd, &en_sb_template_var, NULL); engine_add_input(&en_lflow, &en_nb_bfd, NULL); engine_add_input(&en_lflow, &en_sb_bfd, NULL); engine_add_input(&en_lflow, &en_sb_logical_flow, NULL); @@ -235,6 +240,8 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, 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_template_var_by_name_chassis + = sbrec_template_var_by_name_chassis_index_create(sb->idl); engine_init(&en_lflow, &engine_arg); @@ -256,6 +263,9 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, 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_template_var, + "sbrec_template_var_by_name_chassis", + sbrec_template_var_by_name_chassis); } void inc_proc_northd_run(struct ovsdb_idl_txn *ovnnb_txn, diff --git a/northd/northd.c b/northd/northd.c index 0fcd3a642..c4769ea07 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -36,6 +36,7 @@ #include "lib/ovn-sb-idl.h" #include "lib/ovn-util.h" #include "lib/lb.h" +#include "lib/template-var.h" #include "memory.h" #include "northd.h" #include "lib/ovn-parallel-hmap.h" @@ -14973,6 +14974,36 @@ sync_dns_entries(struct northd_input *input_data, } hmap_destroy(&dns_map); } + +static void +sync_template_var(struct ovsdb_idl_txn *ovnsb_txn, + struct ovsdb_idl_index *sbrec_template_var_by_name_chassis, + const char *name, const char *value, const char *chassis) +{ + const struct sbrec_template_var *sb_tv = + sb_template_var_lookup_by_name_chassis( + sbrec_template_var_by_name_chassis, name, chassis); + + if (!sb_tv) { + sb_tv = sbrec_template_var_insert(ovnsb_txn); + sbrec_template_var_set_name(sb_tv, name); + sbrec_template_var_set_chassis(sb_tv, chassis); + } + sbrec_template_var_set_value(sb_tv, value); +} + +static void +sync_template_vars(struct northd_input *input_data, + struct ovsdb_idl_txn *ovnsb_txn) +{ + const struct nbrec_template_var *nb_tv; + NBREC_TEMPLATE_VAR_TABLE_FOR_EACH (nb_tv, + input_data->nbrec_template_var_table) { + sync_template_var(ovnsb_txn, + input_data->sbrec_template_var_by_name_chassis, + nb_tv->name, nb_tv->value, nb_tv->chassis); + } +} static void destroy_datapaths_and_ports(struct hmap *datapaths, struct hmap *ports, @@ -15476,6 +15507,8 @@ ovnnb_db_run(struct northd_input *input_data, sync_port_groups(input_data, ovnsb_txn, &data->port_groups); sync_meters(input_data, ovnsb_txn, &data->meter_groups); sync_dns_entries(input_data, ovnsb_txn, &data->datapaths); + sync_template_vars(input_data, ovnsb_txn); + cleanup_stale_fdb_entries(input_data, &data->datapaths); stopwatch_stop(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec()); diff --git a/northd/northd.h b/northd/northd.h index 677b35877..33dd210fd 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -30,6 +30,7 @@ struct northd_input { const struct nbrec_acl_table *nbrec_acl_table; const struct nbrec_static_mac_binding_table *nbrec_static_mac_binding_table; + const struct nbrec_template_var_table *nbrec_template_var_table; /* Southbound table references */ const struct sbrec_sb_global_table *sbrec_sb_global_table; @@ -56,6 +57,7 @@ struct northd_input { 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_template_var_by_name_chassis; }; struct chassis_features { diff --git a/ovn-nb.ovsschema b/ovn-nb.ovsschema index 174364c8b..c38ed4f69 100644 --- a/ovn-nb.ovsschema +++ b/ovn-nb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Northbound", - "version": "6.3.0", - "cksum": "4042813038 31869", + "version": "6.4.0", + "cksum": "337369157 32292", "tables": { "NB_Global": { "columns": { @@ -620,6 +620,16 @@ "mac": {"type": "string"}, "override_dynamic_mac": {"type": "boolean"}}, "indexes": [["logical_port", "ip"]], - "isRoot": true} + "isRoot": true}, + "Template_Var": { + "columns": { + "name": {"type": "string"}, + "value": {"type": "string"}, + "chassis": {"type": "string"}, + "external_ids": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}}, + "indexes": [["name", "chassis"]], + "isRoot": true} } } diff --git a/ovn-nb.xml b/ovn-nb.xml index e26afd83c..b9bfb59d4 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -4421,4 +4421,11 @@ + + + + + + +
diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema index 3b78ea6f6..94487a894 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "20.23.0", - "cksum": "4045988377 28575", + "version": "20.24.0", + "cksum": "2495293843 28838", "tables": { "SB_Global": { "columns": { @@ -560,6 +560,13 @@ "key": {"type": "uuid", "refTable": "Datapath_Binding"}}}}, "indexes": [["logical_port", "ip"]], + "isRoot": true}, + "Template_Var": { + "columns": { + "name": {"type": "string"}, + "value": {"type": "string"}, + "chassis": {"type": "string"}}, + "indexes": [["name", "chassis"]], "isRoot": true} } } diff --git a/ovn-sb.xml b/ovn-sb.xml index 59ad3aa2d..e991899bb 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -4739,4 +4739,10 @@ tcp.flags = RST; The logical datapath to which the logical router port belongs. + + + + + +