From patchwork Thu Jun 3 12:29:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1487215 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FwlZp55wWz9sXM for ; Thu, 3 Jun 2021 22:29:38 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E06E360B5A; Thu, 3 Jun 2021 12:29:35 +0000 (UTC) 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 b2Mo3MgHO7Jz; Thu, 3 Jun 2021 12:29:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTP id 7CA1460B3A; Thu, 3 Jun 2021 12:29:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5AA0AC0025; Thu, 3 Jun 2021 12:29:30 +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 1D667C0026 for ; Thu, 3 Jun 2021 12:29:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 76EC840536 for ; Thu, 3 Jun 2021 12:29:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uUvV1CsbcIXy for ; Thu, 3 Jun 2021 12:29:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp2.osuosl.org (Postfix) with ESMTPS id EAFCC40538 for ; Thu, 3 Jun 2021 12:29:23 +0000 (UTC) Received: (Authenticated sender: numans@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 98ECD60002; Thu, 3 Jun 2021 12:29:20 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 3 Jun 2021 08:29:17 -0400 Message-Id: <20210603122917.2066944-1-numans@ovn.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603122721.2066524-1-numans@ovn.org> References: <20210603122721.2066524-1-numans@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn v9 5/5] controller I-P: ct zone runtime data handler. 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" From: Numan Siddique This patch adds an handler for runtime data changes to the ct_zones engine node. Before this patch, the handler was NULL. With this patch we do a full recompute of ct_zones engine if: 1. runtime_data's local_lports change. 2. If a new datapath is added to the local datapaths. For all other changes of runtime data, there is no need to recompute ct_zones engine node. Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1962345 Signed-off-by: Numan Siddique --- controller/ovn-controller.c | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 5b55a45b7..4ab820ca9 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1271,8 +1271,10 @@ runtime_data_sb_port_binding_handler(struct engine_node *node, void *data) return false; } + rt_data->local_lports_changed = b_ctx_out.local_lports_changed; if (b_ctx_out.local_lport_ids_changed || b_ctx_out.non_vif_ports_changed || + b_ctx_out.local_lports_changed || !hmap_is_empty(b_ctx_out.tracked_dp_bindings)) { engine_set_node_state(node, EN_UPDATED); } @@ -1786,6 +1788,40 @@ ct_zones_datapath_binding_handler(struct engine_node *node, void *data) return true; } +static bool +ct_zones_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) +{ + struct ed_type_runtime_data *rt_data = + engine_get_input_data("runtime_data", node); + + /* There is no tracked data. Fall back to full recompute of ct_zones. */ + if (!rt_data->tracked) { + return false; + } + + /* If local_lports have changed then fall back to full recompute. */ + if (rt_data->local_lports_changed) { + return false; + } + + struct hmap *tracked_dp_bindings = &rt_data->tracked_dp_bindings; + struct tracked_binding_datapath *tdp; + HMAP_FOR_EACH (tdp, node, tracked_dp_bindings) { + if (tdp->is_new) { + /* A new datapath has been added. Fall back to full recompute. */ + return false; + } + + /* When an lport is claimed or released because of port binding, + * changes we don't have to compute the ct zone entries for these. + * That is because we generate the ct zone entries for each local + * OVS interface which has external_ids:iface-id set. For the local + * OVS interface changes, rt_data->local_ports_changed will be true. */ + } + + return true; +} + /* The data in the ct_zones node is always valid (i.e., no stale pointers). */ static bool en_ct_zones_is_valid(struct engine_node *node OVS_UNUSED) @@ -2812,7 +2848,8 @@ main(int argc, char *argv[]) engine_add_input(&en_ct_zones, &en_ovs_bridge, NULL); engine_add_input(&en_ct_zones, &en_sb_datapath_binding, ct_zones_datapath_binding_handler); - engine_add_input(&en_ct_zones, &en_runtime_data, NULL); + engine_add_input(&en_ct_zones, &en_runtime_data, + ct_zones_runtime_data_handler); engine_add_input(&en_runtime_data, &en_ofctrl_is_connected, NULL);