Localports should not be binded to any specific controller but should be
available to each hv however in the current codebase consider_iface_claim
routine is claiming the localport for a specific chassis.
Fix the issue skipping localports in consider_iface_claim routine.

https://bugzilla.redhat.com/show_bug.cgi?id=1937662

Reviewed-by: Mark D. Gray <mark.d.g...@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianc...@redhat.com>
---
Changes since v2:
- rebase on top of ovn master

Changes since v1:
- move lport_lookup before local_binding_find
- fix commit message
---
 controller/binding.c | 10 +++++++---
 tests/ovn.at         |  3 +++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/controller/binding.c b/controller/binding.c
index 514f5f33f..6e944f805 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -1875,6 +1875,13 @@ consider_iface_claim(const struct ovsrec_interface 
*iface_rec,
     update_local_lports(iface_id, b_ctx_out);
     smap_replace(b_ctx_out->local_iface_ids, iface_rec->name, iface_id);
 
+    const struct sbrec_port_binding *pb =
+        lport_lookup_by_name(b_ctx_in->sbrec_port_binding_by_name, iface_id);
+    if (pb && get_lport_type(pb) == LP_LOCALPORT) {
+        /* nothing to do for localports. */
+        return true;
+    }
+
     struct shash *local_bindings = &b_ctx_out->lbinding_data->bindings;
     struct shash *binding_lports = &b_ctx_out->lbinding_data->lports;
     struct local_binding *lbinding = local_binding_find(local_bindings,
@@ -1888,10 +1895,7 @@ consider_iface_claim(const struct ovsrec_interface 
*iface_rec,
     }
 
     struct binding_lport *b_lport = local_binding_get_primary_lport(lbinding);
-    const struct sbrec_port_binding *pb = NULL;
     if (!b_lport) {
-        pb = lport_lookup_by_name(b_ctx_in->sbrec_port_binding_by_name,
-                                  lbinding->name);
         if (pb && get_lport_type(pb) == LP_VIF) {
             b_lport = local_binding_add_lport(binding_lports, lbinding, pb,
                                               LP_VIF);
diff --git a/tests/ovn.at b/tests/ovn.at
index 4c3d76d57..3a53039c0 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -11698,6 +11698,9 @@ test_packet() {
     fi
 }
 
+# Check the localport is not claimed by the hvs
+chassis_lp=$(fetch_column port_binding chassis logical_port=lp01)
+AT_CHECK([$(fetch_column port_binding chassis logical_port=lp01)], [0])
 
 # lp11 and lp21 are on different hypervisors
 test_packet 11 f0:00:00:00:00:21 f0:00:00:00:00:11 1121 lp21 lp21
-- 
2.30.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to