From a0828524dcc90169dc1dde36f1306d6f1921ea85 Mon Sep 17 00:00:00 2001
From: Dumitru Ceara <dceara@redhat.com>
Date: Sun, 11 Oct 2020 14:05:45 +0200
Subject: [PATCH 4/7] ofctrl.c: Do not change flow ordering when merging
opposite changes.
Instead of removing the old desired flow from the list and inserting the new
one at the end we now directly replace the old flow with the new one while
maintaining the same ordering.
For now order of the flows is not relevant but further commits require
maintaining the order of desired flows.
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Han Zhou <hzhou@ovn.org>
(cherry picked from upstream commit e49ce9a33f38f29c44e3c30afcc189b5f6a9ef8e)
Change-Id: I83e64763ed63cbc44def69d9ea23259e2035f518
---
controller/ofctrl.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/controller/ofctrl.c b/controller/ofctrl.c
index 24b55fc..20cf3ac 100644
--- a/controller/ofctrl.c
+++ b/controller/ofctrl.c
@@ -848,6 +848,26 @@ link_installed_to_desired(struct installed_flow *i, struct desired_flow *d)
d->installed_flow = i;
}
+/* Replaces 'old_desired' with 'new_desired' in the list of desired flows
+ * that have same match conditions as the installed flow.
+ *
+ * If 'old_desired' was the active flow, 'new_desired' becomes the active one.
+ */
+static void
+replace_installed_to_desired(struct installed_flow *i,
+ struct desired_flow *old_desired,
+ struct desired_flow *new_desired)
+{
+ ovs_assert(old_desired->installed_flow == i);
+ ovs_list_replace(&new_desired->installed_ref_list_node,
+ &old_desired->installed_ref_list_node);
+ old_desired->installed_flow = NULL;
+ new_desired->installed_flow = i;
+ if (i->desired_flow == old_desired) {
+ i->desired_flow = new_desired;
+ }
+}
+
static void
unlink_installed_to_desired(struct installed_flow *i, struct desired_flow *d)
{
@@ -1842,21 +1862,15 @@ merge_tracked_flows(struct ovn_desired_flow_table *flow_table)
* removed during track_flow_add_or_modify. */
ovs_assert(del_f->installed_flow);
- bool del_f_was_active = desired_flow_is_active(del_f);
if (!f->installed_flow) {
/* f is not installed yet. */
- struct installed_flow *i = del_f->installed_flow;
- unlink_installed_to_desired(i, del_f);
- link_installed_to_desired(i, f);
+ replace_installed_to_desired(del_f->installed_flow, del_f, f);
} else {
/* f has been installed before, and now was updated to exact
* the same flow as del_f. */
ovs_assert(f->installed_flow == del_f->installed_flow);
unlink_installed_to_desired(del_f->installed_flow, del_f);
}
- if (del_f_was_active) {
- desired_flow_set_active(f);
- }
hmap_remove(&deleted_flows, &del_f->match_hmap_node);
ovs_list_remove(&del_f->track_list_node);
desired_flow_destroy(del_f);
--
1.8.3.1