diff mbox series

[ovs-dev,v3,16/16] ovn-controller: Incremental processing for port-group changes.

Message ID 1527874926-40450-17-git-send-email-hzhou8@ebay.com
State Superseded
Headers show
Series ovn-controller incremental processing | expand

Commit Message

Han Zhou June 1, 2018, 5:42 p.m. UTC
Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
 ovn/controller/lflow.h          |  3 ++-
 ovn/controller/ovn-controller.c | 54 ++++++++++++++++++++++++++++++++---------
 2 files changed, 44 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/ovn/controller/lflow.h b/ovn/controller/lflow.h
index a5c42f1..b20838a 100644
--- a/ovn/controller/lflow.h
+++ b/ovn/controller/lflow.h
@@ -67,7 +67,8 @@  struct uuid;
 #define LOG_PIPELINE_LEN 24
 
 enum ref_type {
-    REF_TYPE_ADDRSET
+    REF_TYPE_ADDRSET,
+    REF_TYPE_PORTGROUP
 };
 
 /* Maintains the relationship for a pair of named resource and
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index aa32284..02a64e0 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -1136,7 +1136,8 @@  flow_output_sb_multicast_group_handler(struct engine_node *node)
 }
 
 static bool
-flow_output_addr_sets_handler(struct engine_node *node)
+_flow_output_resource_ref_handler(struct engine_node *node,
+                                 enum ref_type ref_type)
 {
     struct controller_ctx *ctx = (struct controller_ctx *)node->context;
     struct ed_type_runtime_data *data =
@@ -1175,11 +1176,28 @@  flow_output_addr_sets_handler(struct engine_node *node)
     struct lflow_resource_ref *lfrr = &fo->lflow_resource_ref;
 
     bool changed;
-    const char *as;
+    const char *ref_name;
+    struct sset *new, *updated, *deleted;
+
+    switch (ref_type) {
+        case REF_TYPE_ADDRSET:
+            new = &as_data->new;
+            updated = &as_data->updated;
+            deleted = &as_data->deleted;
+            break;
+        case REF_TYPE_PORTGROUP:
+            new = &pg_data->new;
+            updated = &pg_data->updated;
+            deleted = &pg_data->deleted;
+            break;
+        default:
+            OVS_NOT_REACHED();
+    }
+
 
-    SSET_FOR_EACH (as, &as_data->deleted) {
-        if (!lflow_handle_changed_ref(flow_table, lfrr, REF_TYPE_ADDRSET,
-                      as, ctx, chassis, chassis_index, local_datapaths,
+    SSET_FOR_EACH (ref_name, deleted) {
+        if (!lflow_handle_changed_ref(flow_table, lfrr, ref_type, ref_name,
+                      ctx, chassis, chassis_index, local_datapaths,
                       group_table, meter_table, addr_sets, port_groups,
                       active_tunnels, local_lport_ids, conj_id_ofs,
                       &changed)) {
@@ -1187,9 +1205,9 @@  flow_output_addr_sets_handler(struct engine_node *node)
         }
         node->changed = changed || node->changed;
     }
-    SSET_FOR_EACH (as, &as_data->updated) {
-        if (!lflow_handle_changed_ref(flow_table, lfrr, REF_TYPE_ADDRSET,
-                      as, ctx, chassis, chassis_index, local_datapaths,
+    SSET_FOR_EACH (ref_name, updated) {
+        if (!lflow_handle_changed_ref(flow_table, lfrr, ref_type, ref_name,
+                      ctx, chassis, chassis_index, local_datapaths,
                       group_table, meter_table, addr_sets, port_groups,
                       active_tunnels, local_lport_ids, conj_id_ofs,
                       &changed)) {
@@ -1197,9 +1215,9 @@  flow_output_addr_sets_handler(struct engine_node *node)
         }
         node->changed = changed || node->changed;
     }
-    SSET_FOR_EACH (as, &as_data->new) {
-        if (!lflow_handle_changed_ref(flow_table, lfrr, REF_TYPE_ADDRSET,
-                      as, ctx, chassis, chassis_index, local_datapaths,
+    SSET_FOR_EACH (ref_name, new) {
+        if (!lflow_handle_changed_ref(flow_table, lfrr, ref_type, ref_name,
+                      ctx, chassis, chassis_index, local_datapaths,
                       group_table, meter_table, addr_sets, port_groups,
                       active_tunnels, local_lport_ids, conj_id_ofs,
                       &changed)) {
@@ -1211,6 +1229,18 @@  flow_output_addr_sets_handler(struct engine_node *node)
     return true;
 }
 
+static bool
+flow_output_addr_sets_handler(struct engine_node *node)
+{
+    return _flow_output_resource_ref_handler(node, REF_TYPE_ADDRSET);
+}
+
+static bool
+flow_output_port_groups_handler(struct engine_node *node)
+{
+    return _flow_output_resource_ref_handler(node, REF_TYPE_PORTGROUP);
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -1296,7 +1326,7 @@  main(int argc, char *argv[])
     engine_add_input(&en_port_groups, &en_sb_port_group, NULL);
 
     engine_add_input(&en_flow_output, &en_addr_sets, flow_output_addr_sets_handler);
-    engine_add_input(&en_flow_output, &en_port_groups, NULL);
+    engine_add_input(&en_flow_output, &en_port_groups, flow_output_port_groups_handler);
     engine_add_input(&en_flow_output, &en_runtime_data, NULL);
 
     engine_add_input(&en_flow_output, &en_ovs_port, NULL);