diff mbox series

[ovs-dev,v6,06/12] binding: Move can_bind helper to lport module

Message ID 20210928155325.2290444-7-frode.nordahl@canonical.com
State Changes Requested
Headers show
Series Introduce infrastructure for plug providers | 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

Frode Nordahl Sept. 28, 2021, 3:53 p.m. UTC
The `can_bind_on_this_chassis` helper is useful outside of the
binding module.  Since it is related to lports renaming it to
`lport_can_bind_on_this_chassis` and putting it into the lport
module appears to be appropriate.

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
---
 controller/binding.c | 17 ++---------------
 controller/lport.c   | 14 ++++++++++++++
 controller/lport.h   |  3 +++
 3 files changed, 19 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/controller/binding.c b/controller/binding.c
index a2eb86c89..ecfddced5 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -1054,19 +1054,6 @@  is_binding_lport_this_chassis(struct binding_lport *b_lport,
             b_lport->pb->chassis == chassis);
 }
 
-static bool
-can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec,
-                         const struct sbrec_port_binding *pb)
-{
-    /* We need to check for presence of the requested-chassis option in
-     * addittion to checking the pb->requested_chassis column because this
-     * column will be set to NULL whenever the option points to a non-existent
-     * chassis.  As the controller routinely clears its own chassis record this
-     * might occur more often than one might think. */
-    return !smap_get(&pb->options, "requested-chassis")
-           || chassis_rec == pb->requested_chassis;
-}
-
 /* Returns 'true' if the 'lbinding' has binding lports of type LP_CONTAINER,
  * 'false' otherwise. */
 static bool
@@ -1169,7 +1156,7 @@  consider_vif_lport(const struct sbrec_port_binding *pb,
                    struct local_binding *lbinding,
                    struct hmap *qos_map)
 {
-    bool can_bind = can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb);
+    bool can_bind = lport_can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb);
 
     if (!lbinding) {
         lbinding = local_binding_find(&b_ctx_out->lbinding_data->bindings,
@@ -1284,7 +1271,7 @@  consider_container_lport(const struct sbrec_port_binding *pb,
     }
 
     ovs_assert(parent_b_lport && parent_b_lport->pb);
-    bool can_bind = can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb);
+    bool can_bind = lport_can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb);
 
     return consider_vif_lport_(pb, can_bind, b_ctx_in, b_ctx_out,
                                container_b_lport, qos_map);
diff --git a/controller/lport.c b/controller/lport.c
index 25b4ef200..f6cab3c7c 100644
--- a/controller/lport.c
+++ b/controller/lport.c
@@ -108,6 +108,20 @@  lport_get_l3gw_peer(const struct sbrec_port_binding *pb,
     return get_peer_lport(pb, sbrec_port_binding_by_name);
 }
 
+bool
+lport_can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec,
+                               const struct sbrec_port_binding *pb)
+{
+    /* We need to check for presence of the requested-chassis option in
+     * addittion to checking the pb->requested_chassis column because this
+     * column will be set to NULL whenever the option points to a non-existent
+     * chassis.  As the controller routinely clears its own chassis record this
+     * might occur more often than one might think. */
+    return !smap_get(&pb->options, "requested-chassis")
+           || chassis_rec == pb->requested_chassis;
+}
+
+
 const struct sbrec_datapath_binding *
 datapath_lookup_by_key(struct ovsdb_idl_index *sbrec_datapath_binding_by_key,
                        uint64_t dp_key)
diff --git a/controller/lport.h b/controller/lport.h
index 43b3d714d..4716c58f9 100644
--- a/controller/lport.h
+++ b/controller/lport.h
@@ -43,6 +43,9 @@  const struct sbrec_port_binding *lport_lookup_by_key(
     struct ovsdb_idl_index *sbrec_port_binding_by_key,
     uint64_t dp_key, uint64_t port_key);
 
+bool lport_can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec,
+                                   const struct sbrec_port_binding *pb);
+
 const struct sbrec_datapath_binding *datapath_lookup_by_key(
     struct ovsdb_idl_index *sbrec_datapath_binding_by_key, uint64_t dp_key);