{"id":2095641,"url":"http://patchwork.ozlabs.org/api/patches/2095641/?format=json","web_url":"http://patchwork.ozlabs.org/project/ovn/patch/20250609173539.1636916-15-mmichels@redhat.com/","project":{"id":68,"url":"http://patchwork.ozlabs.org/api/projects/68/?format=json","name":"Open Virtual Network development","link_name":"ovn","list_id":"ovs-dev.openvswitch.org","list_email":"ovs-dev@openvswitch.org","web_url":"http://openvswitch.org/","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20250609173539.1636916-15-mmichels@redhat.com>","list_archive_url":null,"date":"2025-06-09T17:35:33","name":"[ovs-dev,14/14] lflows: Remove ovn_datapath parameter when adding lflows.","commit_ref":null,"pull_url":null,"state":"deferred","archived":false,"hash":"9569e5bc44c9cf6e20b4a7cdff39b732e59f89b9","submitter":{"id":71978,"url":"http://patchwork.ozlabs.org/api/people/71978/?format=json","name":"Mark Michelson","email":"mmichels@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/ovn/patch/20250609173539.1636916-15-mmichels@redhat.com/mbox/","series":[{"id":460139,"url":"http://patchwork.ozlabs.org/api/series/460139/?format=json","web_url":"http://patchwork.ozlabs.org/project/ovn/list/?series=460139","date":"2025-06-09T17:35:19","name":"Logical Flow Sync Refactor.","version":1,"mbox":"http://patchwork.ozlabs.org/series/460139/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2095641/comments/","check":"success","checks":"http://patchwork.ozlabs.org/api/patches/2095641/checks/","tags":{},"related":[],"headers":{"Return-Path":"<ovs-dev-bounces@openvswitch.org>","X-Original-To":["incoming@patchwork.ozlabs.org","dev@openvswitch.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","ovs-dev@lists.linuxfoundation.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=U3EABftZ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org)","smtp1.osuosl.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=U3EABftZ","smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","smtp4.osuosl.org;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.a=rsa-sha256 header.s=mimecast20190719 header.b=U3EABftZ"],"Received":["from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4bGJxx2M1wz1yDx\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 10 Jun 2025 03:36:37 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id 8A03782F80;\n\tMon,  9 Jun 2025 17:36:49 +0000 (UTC)","from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id DKTEg2iDv1d9; Mon,  9 Jun 2025 17:36:47 +0000 (UTC)","from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp1.osuosl.org (Postfix) with ESMTPS id 4444E82128;\n\tMon,  9 Jun 2025 17:36:43 +0000 (UTC)","from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 13B5AC0AC7;\n\tMon,  9 Jun 2025 17:36:43 +0000 (UTC)","from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 0C83EC0AC4\n for <dev@openvswitch.org>; Mon,  9 Jun 2025 17:36:41 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id B852441D20\n for <dev@openvswitch.org>; Mon,  9 Jun 2025 17:36:07 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id GFWFqea2lnMR for <dev@openvswitch.org>;\n Mon,  9 Jun 2025 17:36:03 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by smtp4.osuosl.org (Postfix) with ESMTPS id 2092341CCE\n for <dev@openvswitch.org>; Mon,  9 Jun 2025 17:35:56 +0000 (UTC)","from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-226-bgS7eygKMc-Xo3c4w_cG3A-1; Mon,\n 09 Jun 2025 13:35:52 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id D15AB180136B\n for <dev@openvswitch.org>; Mon,  9 Jun 2025 17:35:51 +0000 (UTC)","from localhost.localdomain.com (unknown [10.22.58.15])\n by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 5FF171800284\n for <dev@openvswitch.org>; Mon,  9 Jun 2025 17:35:51 +0000 (UTC)"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections -\n client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4444E82128","OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2092341CCE"],"Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=mmichels@redhat.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp4.osuosl.org 2092341CCE","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1749490555;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=OviyXbfnTRf4e3bDWlGUFGg6vm7y8y6jOv+4VQV+x10=;\n b=U3EABftZWXPv5Po7ijP9hNSPHV6rTAOs7sBQ9NUjby1/Wdo3Tm0p7ahcmkyfR0EAMr7yYb\n Lw7kJHfTPoAuw7VJa27N/LKYRCpPMFhRlY7ZwpiXYQ/YkvjhGydfOHvMM0Hv2o9C4T69dC\n KxZC/Fu7okkvrocTioZYiJPkSpHd6RA=","X-MC-Unique":"bgS7eygKMc-Xo3c4w_cG3A-1","X-Mimecast-MFC-AGG-ID":"bgS7eygKMc-Xo3c4w_cG3A_1749490551","To":"dev@openvswitch.org","Date":"Mon,  9 Jun 2025 13:35:33 -0400","Message-ID":"<20250609173539.1636916-15-mmichels@redhat.com>","In-Reply-To":"<20250609173539.1636916-1-mmichels@redhat.com>","References":"<20250609173539.1636916-1-mmichels@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"cEbhEY0x3CBjL48slGFMYtJcagohBVD2Kett_rrlViI_1749490551","X-Mimecast-Originator":"redhat.com","Subject":"[ovs-dev] [PATCH ovn 14/14] lflows: Remove ovn_datapath parameter\n when adding lflows.","X-BeenThere":"ovs-dev@openvswitch.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"<ovs-dev.openvswitch.org>","List-Unsubscribe":"<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>","List-Archive":"<http://mail.openvswitch.org/pipermail/ovs-dev/>","List-Post":"<mailto:ovs-dev@openvswitch.org>","List-Help":"<mailto:ovs-dev-request@openvswitch.org?subject=help>","List-Subscribe":"<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>","From":"Mark Michelson via dev <ovs-dev@openvswitch.org>","Reply-To":"Mark Michelson <mmichels@redhat.com>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"ovs-dev-bounces@openvswitch.org","Sender":"\"dev\" <ovs-dev-bounces@openvswitch.org>"},"content":"This commit makes lflow_table_add_lflow no longer require an\novn_datapath to be passed in. Instead, a datapath index value can be\nused for the same purpose.\n\nThis patch compromises by only updating the core function, not the\nmacros that northd tends to use to add logical flows. Those macros\ncould be updated, but it would make the diff much larger, and it make\nbackports more difficult in northd.c.\n\nSigned-off-by: Mark Michelson <mmichels@redhat.com>\n---\n northd/lflow-mgr.c | 42 +++++++++++++++++++-----------------------\n northd/lflow-mgr.h | 26 ++++++++++++++++----------\n 2 files changed, 35 insertions(+), 33 deletions(-)","diff":"diff --git a/northd/lflow-mgr.c b/northd/lflow-mgr.c\nindex 1e4614873..35d6c0985 100644\n--- a/northd/lflow-mgr.c\n+++ b/northd/lflow-mgr.c\n@@ -77,7 +77,7 @@ static void ovn_dp_group_release(struct hmap *dp_groups,\n                                  struct ovn_dp_group *);\n static void ovn_dp_group_destroy(struct ovn_dp_group *dpg);\n static void ovn_dp_group_add_with_reference(struct ovn_lflow *,\n-                                            const struct ovn_datapath *od,\n+                                            size_t dp_index,\n                                             const unsigned long *dp_bitmap,\n                                             size_t bitmap_len);\n \n@@ -637,8 +637,8 @@ lflow_ref_sync_lflows(struct lflow_ref *lflow_ref,\n  */\n void\n lflow_table_add_lflow(struct lflow_table *lflow_table,\n-                      const struct ovn_datapath *od,\n-                      const unsigned long *dp_bitmap, size_t dp_bitmap_len,\n+                      size_t dp_index,\n+                      const unsigned long *dp_bitmap, size_t num_datapaths,\n                       const struct ovn_stage *stage, uint16_t priority,\n                       const char *match, const char *actions,\n                       const char *io_port, const char *ctrl_meter,\n@@ -650,9 +650,6 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,\n     struct ovs_mutex *hash_lock;\n     uint32_t hash;\n \n-    ovs_assert(!od ||\n-               ovn_stage_to_datapath_type(stage) == ovn_datapath_get_type(od));\n-\n     hash = ovn_logical_flow_hash(ovn_stage_get_table(stage),\n                                  ovn_stage_get_pipeline(stage),\n                                  priority, match,\n@@ -660,8 +657,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,\n \n     hash_lock = lflow_hash_lock(&lflow_table->entries, hash);\n     struct ovn_lflow *lflow =\n-        do_ovn_lflow_add(lflow_table,\n-                         od ? ods_size(od->datapaths) : dp_bitmap_len,\n+        do_ovn_lflow_add(lflow_table, num_datapaths,\n                          hash, stage, priority, match, actions,\n                          io_port, ctrl_meter, stage_hint, where, flow_desc);\n \n@@ -672,7 +668,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,\n             lrn = xzalloc(sizeof *lrn);\n             lrn->lflow = lflow;\n             lrn->lflow_ref = lflow_ref;\n-            lrn->dp_bitmap_len = od ? ods_size(od->datapaths) : dp_bitmap_len;\n+            lrn->dp_bitmap_len = num_datapaths;\n             lrn->dp_bitmap = bitmap_allocate(lrn->dp_bitmap_len);\n             ovs_list_insert(&lflow->referenced_by, &lrn->ref_list_node);\n             hmap_insert(&lflow_ref->lflow_ref_nodes, &lrn->ref_node, hash);\n@@ -681,25 +677,25 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,\n         /* Add refcounts for any datapaths already being used by this\n          * lflow.\n          */\n-        if (od) {\n-            bitmap_set1(lrn->dp_bitmap, od->index);\n-            if (bitmap_is_set(lflow->dpg_bitmap, od->index)) {\n-                dp_refcnt_use(&lflow->dp_refcnts_map, od->index);\n-            }\n-        } else {\n+        if (dp_bitmap) {\n             size_t index;\n-            BITMAP_FOR_EACH_1 (index, dp_bitmap_len, dp_bitmap) {\n+            BITMAP_FOR_EACH_1 (index, num_datapaths, dp_bitmap) {\n                 bitmap_set1(lrn->dp_bitmap, index);\n                 /* Allocate a reference counter only if already used. */\n                 if (bitmap_is_set(lflow->dpg_bitmap, index)) {\n                     dp_refcnt_use(&lflow->dp_refcnts_map, index);\n                 }\n             }\n+        } else {\n+            bitmap_set1(lrn->dp_bitmap, dp_index);\n+            if (bitmap_is_set(lflow->dpg_bitmap, dp_index)) {\n+                dp_refcnt_use(&lflow->dp_refcnts_map, dp_index);\n+            }\n         }\n         lrn->linked = true;\n     }\n \n-    ovn_dp_group_add_with_reference(lflow, od, dp_bitmap, dp_bitmap_len);\n+    ovn_dp_group_add_with_reference(lflow, dp_index, dp_bitmap, num_datapaths);\n \n     lflow_hash_unlock(hash_lock);\n }\n@@ -711,7 +707,8 @@ lflow_table_add_lflow_default_drop(struct lflow_table *lflow_table,\n                                    const char *where,\n                                    struct lflow_ref *lflow_ref)\n {\n-    lflow_table_add_lflow(lflow_table, od, NULL, 0, stage, 0, \"1\",\n+    lflow_table_add_lflow(lflow_table, od->index, NULL,\n+                          ods_size(od->datapaths), stage, 0, \"1\",\n                           debug_drop_action(), NULL, NULL, NULL,\n                           where, NULL, lflow_ref);\n }\n@@ -1214,21 +1211,20 @@ ovn_sb_insert_or_update_logical_dp_group(\n     return dp_group;\n }\n \n-/* Adds an OVN datapath to a datapath group of existing logical flow.\n+/* Adds a datapath index to a datapath group of existing logical flow.\n  * Version to use when hash bucket locking is NOT required or the corresponding\n  * hash lock is already taken. */\n static void\n ovn_dp_group_add_with_reference(struct ovn_lflow *lflow_ref,\n-                                const struct ovn_datapath *od,\n+                                size_t dp_index,\n                                 const unsigned long *dp_bitmap,\n                                 size_t bitmap_len)\n     OVS_REQUIRES(fake_hash_mutex)\n {\n-    if (od) {\n-        bitmap_set1(lflow_ref->dpg_bitmap, od->index);\n-    }\n     if (dp_bitmap) {\n         bitmap_or(lflow_ref->dpg_bitmap, dp_bitmap, bitmap_len);\n+    } else {\n+        bitmap_set1(lflow_ref->dpg_bitmap, dp_index);\n     }\n }\n \ndiff --git a/northd/lflow-mgr.h b/northd/lflow-mgr.h\nindex 80e7965c8..bd0aa9ae7 100644\n--- a/northd/lflow-mgr.h\n+++ b/northd/lflow-mgr.h\n@@ -72,7 +72,7 @@ bool lflow_ref_sync_lflows(struct lflow_ref *,\n                            const struct sbrec_logical_dp_group_table *);\n \n \n-void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *,\n+void lflow_table_add_lflow(struct lflow_table *, size_t dp_index,\n                            const unsigned long *dp_bitmap,\n                            size_t dp_bitmap_len, const struct ovn_stage *stage,\n                            uint16_t priority, const char *match,\n@@ -91,20 +91,22 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,\n #define ovn_lflow_add_with_hint__(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \\\n                                   ACTIONS, IN_OUT_PORT, CTRL_METER, \\\n                                   STAGE_HINT, LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \\\n+    lflow_table_add_lflow(LFLOW_TABLE, (OD)->index, NULL, \\\n+                          ods_size((OD)->datapaths), STAGE, PRIORITY, MATCH, \\\n                           ACTIONS, IN_OUT_PORT, CTRL_METER, STAGE_HINT, \\\n                           OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)\n \n #define ovn_lflow_add_with_hint(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \\\n                                 ACTIONS, STAGE_HINT, LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \\\n-                          ACTIONS, NULL, NULL, STAGE_HINT,  \\\n+    lflow_table_add_lflow(LFLOW_TABLE, (OD)->index, NULL, \\\n+                          ods_size((OD)->datapaths), STAGE, PRIORITY, MATCH, \\\n+                          ACTIONS, NULL, NULL, STAGE_HINT, \\\n                           OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)\n \n #define ovn_lflow_add_with_dp_group(LFLOW_TABLE, DP_BITMAP, DP_BITMAP_LEN, \\\n                                     STAGE, PRIORITY, MATCH, ACTIONS, \\\n                                     STAGE_HINT, LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, NULL, DP_BITMAP, DP_BITMAP_LEN, STAGE, \\\n+    lflow_table_add_lflow(LFLOW_TABLE, 0, DP_BITMAP, DP_BITMAP_LEN, STAGE, \\\n                           PRIORITY, MATCH, ACTIONS, NULL, NULL, STAGE_HINT, \\\n                           OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)\n \n@@ -126,27 +128,31 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,\n #define ovn_lflow_add_with_lport_and_hint(LFLOW_TABLE, OD, STAGE, PRIORITY, \\\n                                           MATCH, ACTIONS, IN_OUT_PORT, \\\n                                           STAGE_HINT, LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \\\n+    lflow_table_add_lflow(LFLOW_TABLE, (OD)->index, NULL, \\\n+                          ods_size((OD)->datapaths), STAGE, PRIORITY, MATCH, \\\n                           ACTIONS, IN_OUT_PORT, NULL, STAGE_HINT, \\\n                           OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)\n \n #define ovn_lflow_add(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \\\n                       LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \\\n+    lflow_table_add_lflow(LFLOW_TABLE, (OD)->index, NULL, \\\n+                          ods_size((OD)->datapaths), STAGE, PRIORITY, MATCH, \\\n                           ACTIONS, NULL, NULL, NULL, OVS_SOURCE_LOCATOR, \\\n                           NULL, LFLOW_REF)\n \n #define ovn_lflow_add_drop_with_desc(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \\\n                                      DESCRIPTION, LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \\\n-                          debug_drop_action(), NULL, NULL, NULL,  \\\n+    lflow_table_add_lflow(LFLOW_TABLE, (OD)->index, NULL, \\\n+                          ods_size((OD)->datapaths), STAGE, PRIORITY, MATCH, \\\n+                          debug_drop_action(), NULL, NULL, NULL, \\\n                           OVS_SOURCE_LOCATOR, DESCRIPTION, LFLOW_REF)\n \n #define ovn_lflow_add_drop_with_lport_hint_and_desc(LFLOW_TABLE, OD, STAGE, \\\n                                                     PRIORITY, MATCH,  \\\n                                                     IN_OUT_PORT, STAGE_HINT, \\\n                                                     DESCRIPTION, LFLOW_REF) \\\n-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \\\n+    lflow_table_add_lflow(LFLOW_TABLE, (OD)->index, NULL, \\\n+                          ods_size((OD)->datapaths), STAGE, PRIORITY, MATCH, \\\n                           debug_drop_action(), IN_OUT_PORT, NULL, STAGE_HINT, \\\n                           OVS_SOURCE_LOCATOR, DESCRIPTION, LFLOW_REF)\n \n","prefixes":["ovs-dev","14/14"]}