From patchwork Thu Aug 3 19:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1816648 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=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4RGzSD0LdRz1yZl for ; Fri, 4 Aug 2023 05:29:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A92B760EAB; Thu, 3 Aug 2023 19:29:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A92B760EAB 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 Q-NvQX0DEflp; Thu, 3 Aug 2023 19:29:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id CD34A60A8D; Thu, 3 Aug 2023 19:29:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CD34A60A8D Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A0CA7C0072; Thu, 3 Aug 2023 19:29:27 +0000 (UTC) X-Original-To: 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 0E797C0032 for ; Thu, 3 Aug 2023 19:29:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D6A5760D4F for ; Thu, 3 Aug 2023 19:29:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D6A5760D4F 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 NTuxSfPMTyIW for ; Thu, 3 Aug 2023 19:29:24 +0000 (UTC) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5041660BF4 for ; Thu, 3 Aug 2023 19:29:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5041660BF4 Received: by mail.gandi.net (Postfix) with ESMTPSA id 36590240004; Thu, 3 Aug 2023 19:29:14 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Fri, 4 Aug 2023 00:59:05 +0530 Message-Id: <20230803192905.84512-1-numans@ovn.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn] northd: Fall back to 'northd' engine recompute for certain VIF scenarios. 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 When a logical switch has only router ports and if a new VIF port is added, both northd engine and lflow engine handle this change incrementally, but it misses out on adding a few logical flows where we have checks like : if (od->n_router_ports != od->nbs->n_ports) { ds_put_format(&actions, "clone {outport = %s; output; }; " "outport = \""MC_FLOOD_L2"\"; output;", patch_op->json_key); .... } else { ds_put_format(&actions, "outport = %s; output;", patch_op->json_key); } The same issue is seen when a VIF port is deleted and after which the logical switch has only router ports. This patch fixes this issue by falling back to full recompute of northd engine node. It is possible to handle these changes incrementally in northd engine node but fall back to full recompute in lflow engine node. But this patch goes for a simpler fix. This can be optimized later if required. Fixes: b337750e45be ("northd: Incremental processing of VIF changes in 'northd' node.") CC: Han Zhou Signed-off-by: Numan Siddique Acked-by: Han Zhou --- northd/northd.c | 10 ++++++++++ tests/ovn-northd.at | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/northd/northd.c b/northd/northd.c index b9605862e..462fa83ca 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -5120,6 +5120,11 @@ northd_handle_ls_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, op->visited = false; } + bool only_rports = (od->n_router_ports == hmap_count(&od->ports)); + if (only_rports) { + goto fail; + } + /* Compare the individual ports in the old and new Logical Switches */ for (size_t j = 0; j < changed_ls->n_ports; ++j) { struct nbrec_logical_switch_port *new_nbsp = changed_ls->ports[j]; @@ -5201,6 +5206,11 @@ northd_handle_ls_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, } } + only_rports = (od->n_router_ports == hmap_count(&od->ports)); + if (only_rports) { + goto fail_clean_deleted; + } + if (!ovs_list_is_empty(&ls_change->added_ports) || !ovs_list_is_empty(&ls_change->updated_ports) || !ovs_list_is_empty(&ls_change->deleted_ports)) { diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 3e06f14c9..912aa5431 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -9589,6 +9589,34 @@ check_recompute_counter 0 0 CHECK_NO_CHANGE_AFTER_RECOMPUTE +check ovn-nbctl --wait=hv ls-del ls0 +check ovn-nbctl ls-add ls0 +check ovn-nbctl --wait=sb lr-add lr0 +ovn-nbctl lrp-add lr0 lr0-ls0 00:00:00:00:ff:01 192.168.0.1/24 +ovn-nbctl lsp-add ls0 ls0-lr0 +ovn-nbctl lsp-set-type ls0-lr0 router +ovn-nbctl lsp-set-addresses ls0-lr0 router +check ovn-nbctl --wait=sb lsp-set-options ls0-lr0 router-port=lr0-ls0 + +CHECK_NO_CHANGE_AFTER_RECOMPUTE + +ovn-nbctl lb-add lb0 192.168.0.10:80 10.0.0.10:8080 +check ovn-nbctl --wait=sb ls-lb-add ls0 lb0 +CHECK_NO_CHANGE_AFTER_RECOMPUTE + +check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats +# Add a lsp. northd and lflow engine should recompute since this is +# the first lsp added after the router ports. +check ovn-nbctl --wait=hv lsp-add ls0 lsp0-1 -- lsp-set-addresses lsp0-1 "aa:aa:aa:00:00:01 192.168.0.11" +check_recompute_counter 1 1 +CHECK_NO_CHANGE_AFTER_RECOMPUTE + +# Delete the lsp. northd and lflow engine should recompute. +check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats +check ovn-nbctl lsp-del lsp0-1 +check_recompute_counter 1 1 +CHECK_NO_CHANGE_AFTER_RECOMPUTE + OVN_CLEANUP([hv1]) AT_CLEANUP ])