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 <[email protected]> --- controller/binding.c | 29 ++--------------------------- controller/lport.c | 25 +++++++++++++++++++++++++ controller/lport.h | 3 +++ 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index aac96694a..ecfddced5 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1054,31 +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. */ - const char *requested_chassis_option = smap_get(&pb->options, - "requested-chassis"); - if (requested_chassis_option && requested_chassis_option[0] - && !pb->requested_chassis) { - /* The requested-chassis option is set, but the requested_chassis - * column is not filled. This means that the chassis the option - * points to is currently not running, or is in the process of starting - * up. In this case we must fall back to comparing the strings to - * avoid release/claim thrashing. */ - return !strcmp(requested_chassis_option, chassis_rec->name) - || !strcmp(requested_chassis_option, chassis_rec->hostname); - } - return !requested_chassis_option || !requested_chassis_option[0] - || chassis_rec == pb->requested_chassis; -} - /* Returns 'true' if the 'lbinding' has binding lports of type LP_CONTAINER, * 'false' otherwise. */ static bool @@ -1181,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, @@ -1296,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..5ad40f6d3 100644 --- a/controller/lport.c +++ b/controller/lport.c @@ -108,6 +108,31 @@ 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. */ + const char *requested_chassis_option = smap_get(&pb->options, + "requested-chassis"); + if (requested_chassis_option && requested_chassis_option[0] + && !pb->requested_chassis) { + /* The requested-chassis option is set, but the requested_chassis + * column is not filled. This means that the chassis the option + * points to is currently not running, or is in the process of starting + * up. In this case we must fall back to comparing the strings to + * avoid release/claim thrashing. */ + return !strcmp(requested_chassis_option, chassis_rec->name) + || !strcmp(requested_chassis_option, chassis_rec->hostname); + } + return !requested_chassis_option || !requested_chassis_option[0] + || 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); -- 2.32.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
