diff mbox series

[ovs-dev,v9,5/5] controller I-P: ct zone runtime data handler.

Message ID 20210603122917.2066944-1-numans@ovn.org
State Accepted
Headers show
Series ovn-controller: Split logical flow and physical flow processing | expand

Commit Message

Numan Siddique June 3, 2021, 12:29 p.m. UTC
From: Numan Siddique <numans@ovn.org>

This patch adds an handler for runtime data changes to the ct_zones
engine node.  Before this patch, the handler was NULL.  With this patch
we do a full recompute of ct_zones engine if:

1. runtime_data's local_lports change.

2. If a new datapath is added to the local datapaths.

For all other changes of runtime data, there is no need to recompute
ct_zones engine node.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1962345
Signed-off-by: Numan Siddique <numans@ovn.org>
---
 controller/ovn-controller.c | 39 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 5b55a45b7..4ab820ca9 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -1271,8 +1271,10 @@  runtime_data_sb_port_binding_handler(struct engine_node *node, void *data)
         return false;
     }
 
+    rt_data->local_lports_changed = b_ctx_out.local_lports_changed;
     if (b_ctx_out.local_lport_ids_changed ||
             b_ctx_out.non_vif_ports_changed ||
+            b_ctx_out.local_lports_changed ||
             !hmap_is_empty(b_ctx_out.tracked_dp_bindings)) {
         engine_set_node_state(node, EN_UPDATED);
     }
@@ -1786,6 +1788,40 @@  ct_zones_datapath_binding_handler(struct engine_node *node, void *data)
     return true;
 }
 
+static bool
+ct_zones_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED)
+{
+    struct ed_type_runtime_data *rt_data =
+        engine_get_input_data("runtime_data", node);
+
+    /* There is no tracked data. Fall back to full recompute of ct_zones. */
+    if (!rt_data->tracked) {
+        return false;
+    }
+
+    /* If local_lports have changed then fall back to full recompute. */
+    if (rt_data->local_lports_changed) {
+        return false;
+    }
+
+    struct hmap *tracked_dp_bindings = &rt_data->tracked_dp_bindings;
+    struct tracked_binding_datapath *tdp;
+    HMAP_FOR_EACH (tdp, node, tracked_dp_bindings) {
+        if (tdp->is_new) {
+            /* A new datapath has been added. Fall back to full recompute. */
+            return false;
+        }
+
+        /* When an lport is claimed or released because of port binding,
+         * changes we don't have to compute the ct zone entries for these.
+         * That is because we generate the ct zone entries for each local
+         * OVS interface which has external_ids:iface-id set.  For the local
+         * OVS interface changes, rt_data->local_ports_changed will be true. */
+    }
+
+    return true;
+}
+
 /* The data in the ct_zones node is always valid (i.e., no stale pointers). */
 static bool
 en_ct_zones_is_valid(struct engine_node *node OVS_UNUSED)
@@ -2812,7 +2848,8 @@  main(int argc, char *argv[])
     engine_add_input(&en_ct_zones, &en_ovs_bridge, NULL);
     engine_add_input(&en_ct_zones, &en_sb_datapath_binding,
                      ct_zones_datapath_binding_handler);
-    engine_add_input(&en_ct_zones, &en_runtime_data, NULL);
+    engine_add_input(&en_ct_zones, &en_runtime_data,
+                     ct_zones_runtime_data_handler);
 
     engine_add_input(&en_runtime_data, &en_ofctrl_is_connected, NULL);