From patchwork Thu Aug 10 12:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1819844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=DeM/1ZQ/; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RM68t1N14z1yYC for ; Thu, 10 Aug 2023 22:45:34 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 67FF141BBE; Thu, 10 Aug 2023 12:45:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 67FF141BBE 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=DeM/1ZQ/ 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 ZkIrfbrA0eIm; Thu, 10 Aug 2023 12:45:29 +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 2A1C041BAF; Thu, 10 Aug 2023 12:45:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2A1C041BAF Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D37FDC008D; Thu, 10 Aug 2023 12:45:27 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3890BC008D for ; Thu, 10 Aug 2023 12:45:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 18CA76124B for ; Thu, 10 Aug 2023 12:45:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 18CA76124B Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DeM/1ZQ/ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ow916WS3HqBD for ; Thu, 10 Aug 2023 12:45:17 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id C8792611DD for ; Thu, 10 Aug 2023 12:45:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org C8792611DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691671515; 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=ApmKY0xxTvAOSH2635bLakEXScDsiNWfVPIfxpa1Oes=; b=DeM/1ZQ/UbNqvVFkC3fZgV2+04fOVkqEZOcAAK2e2FJ4G5mYFD4CZRU0VEzar4RyqUEwvb ZoN3CA+ET2VBW9KmeRqTPT6aWy7EyLgnVjnXkJ/Wpg055l2naXIM2qVXTImePJSYvbemHA LpMEtSLMk9uz8QVeKfR85CmNn+Lpet4= 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-642-dKwuccfEMMWd_6QGSH8CFA-1; Thu, 10 Aug 2023 08:45:12 -0400 X-MC-Unique: dKwuccfEMMWd_6QGSH8CFA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3059E185A792; Thu, 10 Aug 2023 12:45:12 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.194.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6F8D568F7; Thu, 10 Aug 2023 12:45:10 +0000 (UTC) From: Dumitru Ceara To: ovs-dev@openvswitch.org Date: Thu, 10 Aug 2023 14:45:08 +0200 Message-Id: <169167150658.2447623.16064515466507285336.stgit@dceara.remote.csb> In-Reply-To: <169167146062.2447623.4263905982665736274.stgit@dceara.remote.csb> References: <169167146062.2447623.4263905982665736274.stgit@dceara.remote.csb> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 4/5] northd: Move port group processing to its own I-P node. 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" For now it's still a node recompute for every port group change. It doesn't trigger northd recompute anymore though. A follow up commit will add incremental processing of NB.Port_Group changes. Signed-off-by: Dumitru Ceara Acked-by: Ales Musil Acked-by: Han Zhou --- lib/stopwatch-names.h | 1 + northd/en-lflow.c | 4 ++- northd/en-northd.c | 4 --- northd/en-port-group.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ northd/en-port-group.h | 21 +++++++++++++++++ northd/inc-proc-northd.c | 15 ++++++++++-- northd/northd.c | 9 ------- northd/northd.h | 3 -- tests/ovn-northd.at | 8 ++----- 9 files changed, 96 insertions(+), 25 deletions(-) diff --git a/lib/stopwatch-names.h b/lib/stopwatch-names.h index de6fca4ccc..08cb0159a7 100644 --- a/lib/stopwatch-names.h +++ b/lib/stopwatch-names.h @@ -30,5 +30,6 @@ #define LFLOWS_IGMP_STOPWATCH_NAME "lflows_igmp" #define LFLOWS_DP_GROUPS_STOPWATCH_NAME "lflows_dp_groups" #define LFLOWS_TO_SB_STOPWATCH_NAME "lflows_to_sb" +#define PORT_GROUP_RUN_STOPWATCH_NAME "port_group_run" #endif diff --git a/northd/en-lflow.c b/northd/en-lflow.c index 7187cf959f..7f6a7872b2 100644 --- a/northd/en-lflow.c +++ b/northd/en-lflow.c @@ -35,6 +35,8 @@ lflow_get_input_data(struct engine_node *node, struct lflow_input *lflow_input) { struct northd_data *northd_data = engine_get_input_data("northd", node); + struct port_group_data *pg_data = + engine_get_input_data("port_group", node); lflow_input->nbrec_bfd_table = EN_OVSDB_GET(engine_get_input("NB_bfd", node)); lflow_input->sbrec_bfd_table = @@ -55,7 +57,7 @@ lflow_get_input_data(struct engine_node *node, lflow_input->lr_datapaths = &northd_data->lr_datapaths; lflow_input->ls_ports = &northd_data->ls_ports; lflow_input->lr_ports = &northd_data->lr_ports; - lflow_input->ls_port_groups = &northd_data->ls_port_groups; + lflow_input->ls_port_groups = &pg_data->ls_port_groups; lflow_input->meter_groups = &northd_data->meter_groups; lflow_input->lbs = &northd_data->lbs; lflow_input->features = &northd_data->features; diff --git a/northd/en-northd.c b/northd/en-northd.c index 044fa70190..6fb0597144 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -74,8 +74,6 @@ northd_get_input_data(struct engine_node *node, EN_OVSDB_GET(engine_get_input("NB_load_balancer", node)); input_data->nbrec_load_balancer_group_table = EN_OVSDB_GET(engine_get_input("NB_load_balancer_group", node)); - input_data->nbrec_port_group_table = - EN_OVSDB_GET(engine_get_input("NB_port_group", node)); input_data->nbrec_meter_table = EN_OVSDB_GET(engine_get_input("NB_meter", node)); input_data->nbrec_acl_table = @@ -105,8 +103,6 @@ northd_get_input_data(struct engine_node *node, EN_OVSDB_GET(engine_get_input("SB_load_balancer", node)); input_data->sbrec_service_monitor_table = EN_OVSDB_GET(engine_get_input("SB_service_monitor", node)); - input_data->sbrec_port_group_table = - EN_OVSDB_GET(engine_get_input("SB_port_group", node)); input_data->sbrec_meter_table = EN_OVSDB_GET(engine_get_input("SB_meter", node)); input_data->sbrec_dns_table = diff --git a/northd/en-port-group.c b/northd/en-port-group.c index b83926c351..2c36410246 100644 --- a/northd/en-port-group.c +++ b/northd/en-port-group.c @@ -17,8 +17,10 @@ #include #include "openvswitch/vlog.h" +#include "stopwatch.h" #include "en-port-group.h" +#include "lib/stopwatch-names.h" #include "northd.h" VLOG_DEFINE_THIS_MODULE(en_port_group); @@ -235,3 +237,57 @@ ls_port_group_record_destroy(struct ls_port_group *ls_pg, } } +/* Incremental processing implementation. */ +static struct port_group_input +port_group_get_input_data(struct engine_node *node) +{ + struct northd_data *northd_data = engine_get_input_data("northd", node); + + return (struct port_group_input) { + .nbrec_port_group_table = + EN_OVSDB_GET(engine_get_input("NB_port_group", node)), + .sbrec_port_group_table = + EN_OVSDB_GET(engine_get_input("SB_port_group", node)), + .ls_ports = &northd_data->ls_ports, + }; +} + +void * +en_port_group_init(struct engine_node *node OVS_UNUSED, + struct engine_arg *arg OVS_UNUSED) +{ + struct port_group_data *pg_data = xmalloc(sizeof *pg_data); + + ls_port_group_table_init(&pg_data->ls_port_groups); + return pg_data; +} + +void +en_port_group_cleanup(void *data_) +{ + struct port_group_data *data = data_; + + ls_port_group_table_destroy(&data->ls_port_groups); +} + +void +en_port_group_run(struct engine_node *node, void *data_) +{ + const struct engine_context *eng_ctx = engine_get_context(); + struct port_group_input input_data = port_group_get_input_data(node); + struct port_group_data *data = data_; + + stopwatch_start(PORT_GROUP_RUN_STOPWATCH_NAME, time_msec()); + + ls_port_group_table_clear(&data->ls_port_groups); + ls_port_group_table_build(&data->ls_port_groups, + input_data.nbrec_port_group_table, + input_data.ls_ports); + + ls_port_group_table_sync(&data->ls_port_groups, + input_data.sbrec_port_group_table, + eng_ctx->ovnsb_idl_txn); + + stopwatch_stop(PORT_GROUP_RUN_STOPWATCH_NAME, time_msec()); + engine_set_node_state(node, EN_UPDATED); +} diff --git a/northd/en-port-group.h b/northd/en-port-group.h index 2c8e01f51f..5cbf6c6c4a 100644 --- a/northd/en-port-group.h +++ b/northd/en-port-group.h @@ -60,4 +60,25 @@ void ls_port_group_table_build(struct ls_port_group_table *ls_port_groups, void ls_port_group_table_sync(const struct ls_port_group_table *ls_port_groups, const struct sbrec_port_group_table *, struct ovsdb_idl_txn *ovnsb_txn); + +/* Incremental processing implementation. */ +struct port_group_input { + /* Northbound table references. */ + const struct nbrec_port_group_table *nbrec_port_group_table; + + /* Southbound table references. */ + const struct sbrec_port_group_table *sbrec_port_group_table; + + /* northd node references. */ + const struct hmap *ls_ports; +}; + +struct port_group_data { + struct ls_port_group_table ls_port_groups; +}; + +void *en_port_group_init(struct engine_node *, struct engine_arg *); +void en_port_group_cleanup(void *data); +void en_port_group_run(struct engine_node *, void *data); + #endif /* EN_PORT_GROUP_H */ diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index d328deb222..6d5f9e8d16 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -137,6 +137,7 @@ static ENGINE_NODE(mac_binding_aging_waker, "mac_binding_aging_waker"); static ENGINE_NODE(northd_output, "northd_output"); static ENGINE_NODE(sync_to_sb, "sync_to_sb"); static ENGINE_NODE(sync_to_sb_addr_set, "sync_to_sb_addr_set"); +static ENGINE_NODE(port_group, "port_group"); static ENGINE_NODE(fdb_aging, "fdb_aging"); static ENGINE_NODE(fdb_aging_waker, "fdb_aging_waker"); @@ -145,7 +146,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, { /* Define relationships between nodes where first argument is dependent * on the second argument */ - engine_add_input(&en_northd, &en_nb_port_group, NULL); engine_add_input(&en_northd, &en_nb_load_balancer, NULL); engine_add_input(&en_northd, &en_nb_load_balancer_group, NULL); engine_add_input(&en_northd, &en_nb_acl, NULL); @@ -157,7 +157,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_sb_global, NULL); engine_add_input(&en_northd, &en_sb_chassis, NULL); - engine_add_input(&en_northd, &en_sb_port_group, NULL); engine_add_input(&en_northd, &en_sb_mirror, NULL); engine_add_input(&en_northd, &en_sb_meter, NULL); engine_add_input(&en_northd, &en_sb_datapath_binding, NULL); @@ -194,6 +193,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_lflow, &en_sb_multicast_group, NULL); engine_add_input(&en_lflow, &en_sb_igmp_group, NULL); engine_add_input(&en_lflow, &en_northd, lflow_northd_handler); + engine_add_input(&en_lflow, &en_port_group, NULL); engine_add_input(&en_sync_to_sb_addr_set, &en_nb_address_set, sync_to_sb_addr_set_nb_address_set_handler); @@ -202,11 +202,20 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_sync_to_sb_addr_set, &en_northd, NULL); engine_add_input(&en_sync_to_sb_addr_set, &en_sb_address_set, NULL); + engine_add_input(&en_port_group, &en_nb_port_group, NULL); + engine_add_input(&en_port_group, &en_sb_port_group, NULL); + /* No need for an explicit handler for northd changes. Port changes + * that affect port_groups trigger updates to the NB.Port_Group + * table too (because of the explicit dependency in the schema). */ + engine_add_input(&en_port_group, &en_northd, engine_noop_handler); + /* en_sync_to_sb engine node syncs the SB database tables from * the NB database tables. - * Right now this engine only syncs the SB Address_Set table. + * Right now this engine syncs the SB Address_Set and Port_Group + * tables. */ engine_add_input(&en_sync_to_sb, &en_sync_to_sb_addr_set, NULL); + engine_add_input(&en_sync_to_sb, &en_port_group, NULL); engine_add_input(&en_sync_from_sb, &en_northd, sync_from_sb_northd_handler); diff --git a/northd/northd.c b/northd/northd.c index 04da75fa96..b695153805 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -17238,7 +17238,6 @@ northd_init(struct northd_data *data) ovn_datapaths_init(&data->lr_datapaths); hmap_init(&data->ls_ports); hmap_init(&data->lr_ports); - ls_port_group_table_init(&data->ls_port_groups); shash_init(&data->meter_groups); hmap_init(&data->lbs); hmap_init(&data->lb_groups); @@ -17270,8 +17269,6 @@ northd_destroy(struct northd_data *data) } hmap_destroy(&data->lb_groups); - ls_port_group_table_destroy(&data->ls_port_groups); - struct shash_node *node; SHASH_FOR_EACH_SAFE (node, &data->meter_groups) { shash_delete(&data->meter_groups, node); @@ -17410,9 +17407,6 @@ ovnnb_db_run(struct northd_input *input_data, ods_size(&data->ls_datapaths), ods_size(&data->lr_datapaths)); build_ipam(&data->ls_datapaths.datapaths, &data->ls_ports); - ls_port_group_table_build(&data->ls_port_groups, - input_data->nbrec_port_group_table, - &data->ls_ports); build_lrouter_groups(&data->lr_ports, &data->lr_list); build_ip_mcast(ovnsb_txn, input_data->sbrec_ip_multicast_table, input_data->sbrec_ip_mcast_by_dp, @@ -17430,9 +17424,6 @@ ovnnb_db_run(struct northd_input *input_data, sync_lbs(ovnsb_txn, input_data->sbrec_load_balancer_table, &data->ls_datapaths, &data->lbs); - ls_port_group_table_sync(&data->ls_port_groups, - input_data->sbrec_port_group_table, - ovnsb_txn); sync_meters(ovnsb_txn, input_data->nbrec_meter_table, input_data->nbrec_acl_table, input_data->sbrec_meter_table, &data->meter_groups); diff --git a/northd/northd.h b/northd/northd.h index da93a7c6a5..ba28ec63af 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -31,7 +31,6 @@ struct northd_input { const struct nbrec_load_balancer_table *nbrec_load_balancer_table; const struct nbrec_load_balancer_group_table *nbrec_load_balancer_group_table; - const struct nbrec_port_group_table *nbrec_port_group_table; const struct nbrec_meter_table *nbrec_meter_table; const struct nbrec_acl_table *nbrec_acl_table; const struct nbrec_static_mac_binding_table @@ -50,7 +49,6 @@ struct northd_input { const struct sbrec_fdb_table *sbrec_fdb_table; const struct sbrec_load_balancer_table *sbrec_load_balancer_table; const struct sbrec_service_monitor_table *sbrec_service_monitor_table; - const struct sbrec_port_group_table *sbrec_port_group_table; const struct sbrec_meter_table *sbrec_meter_table; const struct sbrec_dns_table *sbrec_dns_table; const struct sbrec_ip_multicast_table *sbrec_ip_multicast_table; @@ -109,7 +107,6 @@ struct northd_data { struct ovn_datapaths lr_datapaths; struct hmap ls_ports; struct hmap lr_ports; - struct ls_port_group_table ls_port_groups; struct shash meter_groups; struct hmap lbs; struct hmap lb_groups; diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index d5be3be75b..1a12513d7a 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -8923,11 +8923,9 @@ check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats check ovn-nbctl add port_group pg1 ports ${p1_uuid} wait_column '20.0.0.4' Address_Set addresses name=pg1_ip4 -# There should be recompute of the sync_to_sb_addr_set engine node since northd engine changes. -# There will be another recompute when the update message is received from the sb ovsdb-server. -# Once we add I-P for Port_Groups, there should be no recompute here. -recompute_stat=$(as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats sync_to_sb_addr_set recompute) -AT_CHECK([test $recompute_stat -ge 1]) +# There should be no recompute of the sync_to_sb_addr_set engine node. +AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats sync_to_sb_addr_set recompute], [0], [0 +]) # No change, no recompute check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats