[ovs-dev,v3,10/16] ovn-controller: incremental processing for multicast group changes

Message ID 1527874926-40450-11-git-send-email-hzhou8@ebay.com
State New
Headers show
Series
  • ovn-controller incremental processing
Related show

Commit Message

Han Zhou June 1, 2018, 5:42 p.m.
Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
 ovn/controller/ovn-controller.c | 37 ++++++++++++++++++++++++++++++++++++-
 ovn/controller/physical.c       | 23 +++++++++++++++++++++++
 ovn/controller/physical.h       |  7 ++++++-
 3 files changed, 65 insertions(+), 2 deletions(-)

Patch

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index e4506c2..56902ff 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -977,6 +977,41 @@  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;
+    struct simap *ct_zones = &data->ct_zones;
+    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);
+
+    struct ed_type_flow_output *fo =
+        (struct ed_type_flow_output *)node->data;
+    struct ovn_desired_flow_table *flow_table = &fo->flow_table;
+
+    enum mf_field_id mff_ovn_geneve = ofctrl_get_mf_field_id();
+    physical_handle_mc_group_changes(flow_table,
+                                     ctx, mff_ovn_geneve,
+                                     chassis, ct_zones,
+                                     local_datapaths);
+    node->changed = true;
+    return true;
+
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -1060,7 +1095,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_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 d860686..de75f4a 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -937,6 +937,29 @@  physical_handle_port_binding_changes(struct ovn_desired_flow_table *flow_table,
 }
 
 void
+physical_handle_mc_group_changes(struct ovn_desired_flow_table *flow_table,
+                                 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(flow_table, &mc->header_.uuid);
+        } else {
+            if (!sbrec_multicast_group_is_new(mc)) {
+                ofctrl_remove_flows(flow_table, &mc->header_.uuid);
+            }
+            consider_mc_group(flow_table, mff_ovn_geneve, ct_zones,
+                              local_datapaths, chassis, mc);
+        }
+    }
+}
+
+
+void
 physical_run(struct ovn_desired_flow_table *flow_table,
              struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
              const struct ovsrec_bridge *br_int,
diff --git a/ovn/controller/physical.h b/ovn/controller/physical.h
index 88c5cda..eb3f8df 100644
--- a/ovn/controller/physical.h
+++ b/ovn/controller/physical.h
@@ -60,5 +60,10 @@  void physical_handle_port_binding_changes(struct ovn_desired_flow_table *,
                                           struct hmap *local_datapaths,
                                           struct chassis_index *,
                                           struct sset *active_tunnels);
-
+void physical_handle_mc_group_changes(struct ovn_desired_flow_table *,
+                                      struct controller_ctx *ctx,
+                                      enum mf_field_id mff_ovn_geneve,
+                                      const struct sbrec_chassis *,
+                                      const struct simap *ct_zones,
+                                      struct hmap *local_datapaths);
 #endif /* ovn/physical.h */