diff mbox series

[ovs-dev,v5,4/6] northd: Call build_mcast_groups() from build_lflows()

Message ID 20211109193607.31630-5-mrmarkgray@gmail.com
State Accepted
Delegated to: Han Zhou
Headers show
Series northd: Introduce incremental processing framework | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Mark Gray Nov. 9, 2021, 7:36 p.m. UTC
From: Mark Gray <mark.d.gray@redhat.com>

As 'mcast_groups' and 'igmp_groups' need to be modified by
build_lflows(), we move build_mcast_groups() to build_flows(). This
is in preparation for a later commit which will create an lflow
node. If these structures form part of the input of the new lflow
we should not modify them as they would not form part of the mutable
state of that node.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
---
 northd/en-northd.c |  1 -
 northd/northd.c    | 51 +++++++++++++++++++++++++++++-----------------
 2 files changed, 32 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/northd/en-northd.c b/northd/en-northd.c
index f39dbd9da3e0..adcc459a9d16 100644
--- a/northd/en-northd.c
+++ b/northd/en-northd.c
@@ -138,5 +138,4 @@  void *en_northd_init(struct engine_node *node OVS_UNUSED,
 void en_northd_cleanup(void *data)
 {
     northd_destroy(data);
-    free(data);
 }
diff --git a/northd/northd.c b/northd/northd.c
index 17b9d09a7887..1690d0d467a0 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -13404,12 +13404,23 @@  static ssize_t max_seen_lflow_size = 128;
 static bool needs_parallel_init = true;
 static bool reset_parallel = false;
 
+static void
+build_mcast_groups(struct northd_input *input_data,
+                   struct hmap *datapaths, struct hmap *ports,
+                   struct hmap *mcast_groups,
+                   struct hmap *igmp_groups);
+
 /* Updates the Logical_Flow and Multicast_Group tables in the OVN_SB database,
  * constructing their contents based on the OVN_NB database. */
 void build_lflows(struct northd_input *input_data,
                   struct northd_data *data, struct ovsdb_idl_txn *ovnsb_txn)
 {
     struct hmap lflows;
+    struct hmap mcast_groups;
+    struct hmap igmp_groups;
+
+    build_mcast_groups(input_data, &data->datapaths, &data->ports,
+                       &mcast_groups, &igmp_groups);
 
     if (reset_parallel) {
         /* Parallel build was disabled before, we need to
@@ -13431,7 +13442,7 @@  void build_lflows(struct northd_input *input_data,
     }
     build_lswitch_and_lrouter_flows(&data->datapaths, &data->ports,
                                     &data->port_groups, &lflows,
-                                    &data->mcast_groups, &data->igmp_groups,
+                                    &mcast_groups, &igmp_groups,
                                     &data->meter_groups, &data->lbs,
                                     &data->bfd_connections);
 
@@ -13703,19 +13714,19 @@  void build_lflows(struct northd_input *input_data,
 
         struct multicast_group group = { .name = sbmc->name,
                                          .key = sbmc->tunnel_key };
-        struct ovn_multicast *mc = ovn_multicast_find(&data->mcast_groups,
+        struct ovn_multicast *mc = ovn_multicast_find(&mcast_groups,
                                                       od, &group);
         if (mc) {
             ovn_multicast_update_sbrec(mc, sbmc);
-            ovn_multicast_destroy(&data->mcast_groups, mc);
+            ovn_multicast_destroy(&mcast_groups, mc);
         } else {
             sbrec_multicast_group_delete(sbmc);
         }
     }
     struct ovn_multicast *mc, *next_mc;
-    HMAP_FOR_EACH_SAFE (mc, next_mc, hmap_node, &data->mcast_groups) {
+    HMAP_FOR_EACH_SAFE (mc, next_mc, hmap_node, &mcast_groups) {
         if (!mc->datapath) {
-            ovn_multicast_destroy(&data->mcast_groups, mc);
+            ovn_multicast_destroy(&mcast_groups, mc);
             continue;
         }
         sbmc = sbrec_multicast_group_insert(ovnsb_txn);
@@ -13723,8 +13734,23 @@  void build_lflows(struct northd_input *input_data,
         sbrec_multicast_group_set_name(sbmc, mc->group->name);
         sbrec_multicast_group_set_tunnel_key(sbmc, mc->group->key);
         ovn_multicast_update_sbrec(mc, sbmc);
-        ovn_multicast_destroy(&data->mcast_groups, mc);
+        ovn_multicast_destroy(&mcast_groups, mc);
+    }
+
+    struct ovn_igmp_group *igmp_group, *next_igmp_group;
+
+    HMAP_FOR_EACH_SAFE (igmp_group, next_igmp_group, hmap_node,
+                    &igmp_groups) {
+        ovn_igmp_group_destroy(&igmp_groups, igmp_group);
     }
+
+    struct ovn_port_group *pg, *next_pg;
+    HMAP_FOR_EACH_SAFE (pg, next_pg, key_node, &data->port_groups) {
+        ovn_port_group_destroy(&data->port_groups, pg);
+    }
+
+    hmap_destroy(&igmp_groups);
+    hmap_destroy(&mcast_groups);
 }
 
 static void
@@ -14472,8 +14498,6 @@  northd_init(struct northd_data *data)
     hmap_init(&data->datapaths);
     hmap_init(&data->ports);
     hmap_init(&data->port_groups);
-    hmap_init(&data->mcast_groups);
-    hmap_init(&data->igmp_groups);
     shash_init(&data->meter_groups);
     hmap_init(&data->lbs);
     hmap_init(&data->bfd_connections);
@@ -14490,20 +14514,11 @@  northd_destroy(struct northd_data *data)
     }
     hmap_destroy(&data->lbs);
 
-    struct ovn_igmp_group *igmp_group, *next_igmp_group;
-
-    HMAP_FOR_EACH_SAFE (igmp_group, next_igmp_group, hmap_node,
-                        &data->igmp_groups) {
-        ovn_igmp_group_destroy(&data->igmp_groups, igmp_group);
-    }
-
     struct ovn_port_group *pg, *next_pg;
     HMAP_FOR_EACH_SAFE (pg, next_pg, key_node, &data->port_groups) {
         ovn_port_group_destroy(&data->port_groups, pg);
     }
 
-    hmap_destroy(&data->igmp_groups);
-    hmap_destroy(&data->mcast_groups);
     hmap_destroy(&data->port_groups);
     hmap_destroy(&data->bfd_connections);
 
@@ -14637,8 +14652,6 @@  ovnnb_db_run(struct northd_input *input_data,
     build_port_group_lswitches(input_data, &data->port_groups, &data->ports);
     build_lrouter_groups(&data->ports, &data->lr_list);
     build_ip_mcast(input_data, ovnsb_txn, &data->datapaths);
-    build_mcast_groups(input_data, &data->datapaths, &data->ports,
-                       &data->mcast_groups, &data->igmp_groups);
     build_meter_groups(input_data, &data->meter_groups);
     build_bfd_table(input_data,
                     ovnsb_txn, &data->bfd_connections, &data->ports);