[ovs-dev] [RFC v2 10/10] ovn-controller: incremental processing for multicast group changes

Han Zhou zhouhan at gmail.com
Thu Mar 22 18:42:27 UTC 2018


---
 ovn/controller/ovn-controller.c | 31 ++++++++++++++++++++++++++++++-
 ovn/controller/physical.c       | 22 ++++++++++++++++++++++
 ovn/controller/physical.h       |  6 +++++-
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index b3324e1..ee7e030 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -814,6 +814,35 @@ flow_output_sb_port_binding_handler(struct engine_node *node)
     return true;
 }
 
+static bool
+flow_output_sb_multicast_group_handler(struct engine_node *node)
+{
+    struct controller_ctx *ctx = (struct controller_ctx *)node->context;
+    struct ed_type_runtime_data *data =
+        (struct ed_type_runtime_data *)engine_get_input(
+                "runtime_data", node)->data;
+    struct hmap *local_datapaths = data->local_datapaths;
+    const struct ovsrec_bridge *br_int = get_br_int(ctx);
+
+    const char *chassis_id = get_chassis_id(ctx->ovs_idl);
+
+
+    const struct sbrec_chassis *chassis = NULL;
+    if (chassis_id) {
+        chassis = get_chassis(ctx->ovnsb_idl, chassis_id);
+    }
+
+    ovs_assert(br_int && chassis);
+
+    enum mf_field_id mff_ovn_geneve = ofctrl_get_mf_field_id();
+    physical_handle_mc_group_changes(ctx, mff_ovn_geneve,
+                                     chassis, ctx->ct_zones,
+                                     local_datapaths);
+    node->changed = true;
+    return true;
+
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -945,7 +974,7 @@ main(int argc, char *argv[])
     engine_add_input(&en_flow_output, &en_sb_chassis, NULL);
     engine_add_input(&en_flow_output, &en_sb_encap, NULL);
     engine_add_input(&en_flow_output, &en_sb_address_set, NULL);
-    engine_add_input(&en_flow_output, &en_sb_multicast_group, NULL);
+    engine_add_input(&en_flow_output, &en_sb_multicast_group, flow_output_sb_multicast_group_handler);
     engine_add_input(&en_flow_output, &en_sb_datapath_binding, NULL);
     engine_add_input(&en_flow_output, &en_sb_port_binding, flow_output_sb_port_binding_handler);
     engine_add_input(&en_flow_output, &en_sb_mac_binding, NULL);
diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
index cda40de..756fbd3 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -917,6 +917,28 @@ physical_handle_port_binding_changes(struct controller_ctx *ctx,
 }
 
 void
+physical_handle_mc_group_changes(struct controller_ctx *ctx,
+                                 enum mf_field_id mff_ovn_geneve,
+                                 const struct sbrec_chassis *chassis,
+                                 const struct simap *ct_zones,
+                                 struct hmap *local_datapaths)
+{
+    const struct sbrec_multicast_group *mc;
+    SBREC_MULTICAST_GROUP_FOR_EACH_TRACKED (mc, ctx->ovnsb_idl) {
+        if (sbrec_multicast_group_is_deleted(mc)) {
+            ofctrl_remove_flows(&mc->header_.uuid);
+        } else {
+            if (!sbrec_multicast_group_is_new(mc)) {
+                ofctrl_remove_flows(&mc->header_.uuid);
+            }
+            consider_mc_group(mff_ovn_geneve, ct_zones, local_datapaths,
+                              chassis, mc);
+        }
+    }
+}
+
+
+void
 physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
              const struct ovsrec_bridge *br_int,
              const struct sbrec_chassis *chassis,
diff --git a/ovn/controller/physical.h b/ovn/controller/physical.h
index e0b31a4..2eee833 100644
--- a/ovn/controller/physical.h
+++ b/ovn/controller/physical.h
@@ -57,5 +57,9 @@ void physical_handle_port_binding_changes(struct controller_ctx *ctx, enum mf_fi
              struct hmap *local_datapaths,
              struct chassis_index *chassis_index,
              struct sset *active_tunnels);
-
+void physical_handle_mc_group_changes(struct controller_ctx *ctx,
+                                      enum mf_field_id mff_ovn_geneve,
+                                      const struct sbrec_chassis *chassis,
+                                      const struct simap *ct_zones,
+                                      struct hmap *local_datapaths);
 #endif /* ovn/physical.h */
-- 
2.1.0



More information about the dev mailing list