diff mbox series

[ovs-dev,v2,14/14] northd: Ignore "up" column change if ignore_lsp_down is true.

Message ID 20230602041150.3019311-15-hzhou@ovn.org
State Accepted
Headers show
Series ovn-northd incremental processing for VIF changes | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_ovn-kubernetes success github build: passed
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Han Zhou June 2, 2023, 4:11 a.m. UTC
This change avoids the unnecessary change handling in "lflow" when
NB_Global:options:ignore_lsp_down is true (default) if the only change
of the LSP is the column "up". This further reduces the number of
recompute of "lflow" to zero for the VIF creation-and-binding scenario.

Signed-off-by: Han Zhou <hzhou@ovn.org>
Reviewed-by: Ales Musil <amusil@redhat.com>
---
 northd/northd.c     | 46 +++++++++++++++++++++++++++++++++++++++++++++
 tests/ovn-northd.at |  4 ++--
 2 files changed, 48 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/northd/northd.c b/northd/northd.c
index ddbc1bf389c8..20440551694a 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -4979,6 +4979,44 @@  check_ls_changes_other_than_lsp(const struct nbrec_logical_switch *ls)
     return false;
 }
 
+static bool
+check_lsp_changes_other_than_up(const struct nbrec_logical_switch_port *nbsp)
+{
+    /* Check if the columns are changed in this row. */
+    enum nbrec_logical_switch_port_column_id col;
+    for (col = 0; col < NBREC_LOGICAL_SWITCH_PORT_N_COLUMNS; col++) {
+        if (nbrec_logical_switch_port_is_updated(nbsp, col) &&
+            col != NBREC_LOGICAL_SWITCH_PORT_COL_UP) {
+            return true;
+        }
+    }
+
+    /* Check if the referenced rows are changed.
+       XXX: Need a better OVSDB IDL interface for this check. */
+    if (nbsp->dhcpv4_options &&
+        nbrec_dhcp_options_row_get_seqno(nbsp->dhcpv4_options,
+                                         OVSDB_IDL_CHANGE_MODIFY) > 0) {
+        return true;
+    }
+    if (nbsp->dhcpv6_options &&
+        nbrec_dhcp_options_row_get_seqno(nbsp->dhcpv6_options,
+                                         OVSDB_IDL_CHANGE_MODIFY) > 0) {
+        return true;
+    }
+    if (nbsp->ha_chassis_group &&
+        nbrec_ha_chassis_group_row_get_seqno(nbsp->ha_chassis_group,
+                                             OVSDB_IDL_CHANGE_MODIFY) > 0) {
+        return true;
+    }
+    for (size_t i = 0; i < nbsp->n_mirror_rules; i++) {
+        if (nbrec_mirror_row_get_seqno(nbsp->mirror_rules[i],
+                                       OVSDB_IDL_CHANGE_MODIFY) > 0) {
+            return true;
+        }
+    }
+    return false;
+}
+
 /* Return true if changes are handled incrementally, false otherwise.
  * When there are any changes, try to track what's exactly changed and set
  * northd_data->change_tracked accordingly: change tracked - true, otherwise,
@@ -5059,6 +5097,14 @@  northd_handle_ls_changes(struct ovsdb_idl_txn *ovnsb_idl_txn,
                      * by this change. Fallback to recompute. */
                     goto fail;
                 }
+                if (!check_lsp_is_up &&
+                    !check_lsp_changes_other_than_up(new_nbsp)) {
+                    /* If the only change is the "up" column while the
+                     * "ignore_lsp_down" is set to true, just ignore this
+                     * change. */
+                    op->visited = true;
+                    continue;
+                }
                 ovn_port_destroy(&nd->ls_ports, op);
                 op = ls_port_create(ovnsb_idl_txn, &nd->ls_ports,
                                     new_nbsp->name, new_nbsp, od, sb,
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index d5436136b809..999166cd427e 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -9506,14 +9506,14 @@  check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats
 check ovn-nbctl --wait=hv lsp-add ls0 lsp0-1 -- lsp-set-addresses lsp0-1 "aa:aa:aa:00:00:01 192.168.0.11"
 AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats northd recompute], [0], [0
 ])
-AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats lflow recompute], [0], [2
+AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats lflow recompute], [0], [0
 ])
 
 check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats
 check ovn-nbctl --wait=hv lsp-add ls0 lsp0-2 -- lsp-set-addresses lsp0-2 "aa:aa:aa:00:00:02 192.168.0.12"
 AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats northd recompute], [0], [0
 ])
-AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats lflow recompute], [0], [2
+AT_CHECK([as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats lflow recompute], [0], [0
 ])
 
 check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats