diff mbox series

[ovs-dev,11/15] Update port-up on main chassis only

Message ID 20220215035737.1820679-12-ihrachys@redhat.com
State Superseded, archived
Headers show
Series Support additional-chassis for ports | expand

Checks

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

Commit Message

Ihar Hrachyshka Feb. 15, 2022, 3:57 a.m. UTC
In a future patch, there will be a scenario where the same port has
attachments at multiple (specifically, 2) chassis, so make sure that
'up' property is updated by the main chassis only.

Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
---
 controller/binding.c        | 10 +++++++---
 controller/binding.h        |  2 ++
 controller/if-status.c      | 15 ++++++++++-----
 controller/if-status.h      |  1 +
 controller/ovn-controller.c |  4 ++--
 5 files changed, 22 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/controller/binding.c b/controller/binding.c
index 4d62b0858..c7a13d5d5 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -681,6 +681,7 @@  local_binding_is_down(struct shash *local_bindings, const char *pb_name)
 
 void
 local_binding_set_up(struct shash *local_bindings, const char *pb_name,
+                     const struct sbrec_chassis *chassis_rec,
                      const char *ts_now_str, bool sb_readonly,
                      bool ovs_readonly)
 {
@@ -700,8 +701,9 @@  local_binding_set_up(struct shash *local_bindings, const char *pb_name,
                                                     ts_now_str);
     }
 
-    if (!sb_readonly && lbinding && b_lport && b_lport->pb->n_up
-            && !b_lport->pb->up[0]) {
+    if (!sb_readonly && lbinding && b_lport && b_lport->pb->n_up &&
+            !b_lport->pb->up[0] &&
+            (!b_lport->pb->chassis || b_lport->pb->chassis == chassis_rec)) {
         VLOG_INFO("Setting lport %s up in Southbound", pb_name);
         binding_lport_set_up(b_lport, sb_readonly);
         LIST_FOR_EACH (b_lport, list_node, &lbinding->binding_lports) {
@@ -712,6 +714,7 @@  local_binding_set_up(struct shash *local_bindings, const char *pb_name,
 
 void
 local_binding_set_down(struct shash *local_bindings, const char *pb_name,
+                       const struct sbrec_chassis *chassis_rec,
                        bool sb_readonly, bool ovs_readonly)
 {
     struct local_binding *lbinding =
@@ -726,7 +729,8 @@  local_binding_set_down(struct shash *local_bindings, const char *pb_name,
                                                     OVN_INSTALLED_EXT_ID);
     }
 
-    if (!sb_readonly && b_lport && b_lport->pb->n_up && b_lport->pb->up[0]) {
+    if (!sb_readonly && b_lport && b_lport->pb->n_up && b_lport->pb->up[0] &&
+            (!b_lport->pb->chassis || b_lport->pb->chassis == chassis_rec)) {
         VLOG_INFO("Setting lport %s down in Southbound", pb_name);
         binding_lport_set_down(b_lport, sb_readonly);
         LIST_FOR_EACH (b_lport, list_node, &lbinding->binding_lports) {
diff --git a/controller/binding.h b/controller/binding.h
index 430a8d9b1..46f88aff7 100644
--- a/controller/binding.h
+++ b/controller/binding.h
@@ -154,9 +154,11 @@  ofp_port_t local_binding_get_lport_ofport(const struct shash *local_bindings,
 bool local_binding_is_up(struct shash *local_bindings, const char *pb_name);
 bool local_binding_is_down(struct shash *local_bindings, const char *pb_name);
 void local_binding_set_up(struct shash *local_bindings, const char *pb_name,
+                          const struct sbrec_chassis *chassis_rec,
                           const char *ts_now_str, bool sb_readonly,
                           bool ovs_readonly);
 void local_binding_set_down(struct shash *local_bindings, const char *pb_name,
+                            const struct sbrec_chassis *chassis_rec,
                             bool sb_readonly, bool ovs_readonly);
 
 void binding_register_ovs_idl(struct ovsdb_idl *);
diff --git a/controller/if-status.c b/controller/if-status.c
index fa4c8bd94..ee00f2cc6 100644
--- a/controller/if-status.c
+++ b/controller/if-status.c
@@ -115,6 +115,7 @@  static void ovs_iface_set_state(struct if_status_mgr *, struct ovs_iface *,
 
 static void if_status_mgr_update_bindings(
     struct if_status_mgr *mgr, struct local_binding_data *binding_data,
+    const struct sbrec_chassis *,
     bool sb_readonly, bool ovs_readonly);
 
 struct if_status_mgr *
@@ -311,6 +312,7 @@  if_status_mgr_update(struct if_status_mgr *mgr,
 void
 if_status_mgr_run(struct if_status_mgr *mgr,
                   struct local_binding_data *binding_data,
+                  const struct sbrec_chassis *chassis_rec,
                   bool sb_readonly, bool ovs_readonly)
 {
     struct ofctrl_acked_seqnos *acked_seqnos =
@@ -335,8 +337,8 @@  if_status_mgr_run(struct if_status_mgr *mgr,
     ofctrl_acked_seqnos_destroy(acked_seqnos);
 
     /* Update binding states. */
-    if_status_mgr_update_bindings(mgr, binding_data, sb_readonly,
-                                  ovs_readonly);
+    if_status_mgr_update_bindings(mgr, binding_data, chassis_rec,
+                                  sb_readonly, ovs_readonly);
 }
 
 static void
@@ -397,6 +399,7 @@  ovs_iface_set_state(struct if_status_mgr *mgr, struct ovs_iface *iface,
 static void
 if_status_mgr_update_bindings(struct if_status_mgr *mgr,
                               struct local_binding_data *binding_data,
+                              const struct sbrec_chassis *chassis_rec,
                               bool sb_readonly, bool ovs_readonly)
 {
     if (!binding_data) {
@@ -412,7 +415,8 @@  if_status_mgr_update_bindings(struct if_status_mgr *mgr,
     HMAPX_FOR_EACH (node, &mgr->ifaces_per_state[OIF_INSTALL_FLOWS]) {
         struct ovs_iface *iface = node->data;
 
-        local_binding_set_down(bindings, iface->id, sb_readonly, ovs_readonly);
+        local_binding_set_down(bindings, iface->id, chassis_rec,
+                               sb_readonly, ovs_readonly);
     }
 
     /* Notifiy the binding module to set "up" all bindings that have had
@@ -423,7 +427,7 @@  if_status_mgr_update_bindings(struct if_status_mgr *mgr,
     HMAPX_FOR_EACH (node, &mgr->ifaces_per_state[OIF_MARK_UP]) {
         struct ovs_iface *iface = node->data;
 
-        local_binding_set_up(bindings, iface->id, ts_now_str,
+        local_binding_set_up(bindings, iface->id, chassis_rec, ts_now_str,
                              sb_readonly, ovs_readonly);
     }
     free(ts_now_str);
@@ -434,7 +438,8 @@  if_status_mgr_update_bindings(struct if_status_mgr *mgr,
     HMAPX_FOR_EACH (node, &mgr->ifaces_per_state[OIF_MARK_DOWN]) {
         struct ovs_iface *iface = node->data;
 
-        local_binding_set_down(bindings, iface->id, sb_readonly, ovs_readonly);
+        local_binding_set_down(bindings, iface->id, chassis_rec,
+                               sb_readonly, ovs_readonly);
     }
 }
 
diff --git a/controller/if-status.h b/controller/if-status.h
index ff4aa760e..bb8a3950d 100644
--- a/controller/if-status.h
+++ b/controller/if-status.h
@@ -33,6 +33,7 @@  void if_status_mgr_delete_iface(struct if_status_mgr *, const char *iface_id);
 
 void if_status_mgr_update(struct if_status_mgr *, struct local_binding_data *);
 void if_status_mgr_run(struct if_status_mgr *mgr, struct local_binding_data *,
+                       const struct sbrec_chassis *,
                        bool sb_readonly, bool ovs_readonly);
 void if_status_mgr_get_memory_usage(struct if_status_mgr *mgr,
                                     struct simap *usage);
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 8631bccbc..4d13f11ec 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -3783,8 +3783,8 @@  main(int argc, char *argv[])
                                    time_msec());
                     stopwatch_start(IF_STATUS_MGR_RUN_STOPWATCH_NAME,
                                     time_msec());
-                    if_status_mgr_run(if_mgr, binding_data, !ovnsb_idl_txn,
-                                      !ovs_idl_txn);
+                    if_status_mgr_run(if_mgr, binding_data, chassis,
+                                      !ovnsb_idl_txn, !ovs_idl_txn);
                     stopwatch_stop(IF_STATUS_MGR_RUN_STOPWATCH_NAME,
                                    time_msec());
                 }