From: Numan Siddique <num...@ovn.org> Suggested-by: Dumitru Ceara <dce...@redhat.com> Signed-off-by: Numan Siddique <num...@ovn.org> --- controller/binding.c | 8 ++++---- controller/lflow.c | 8 ++++---- lib/ovn-util.h | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/controller/binding.c b/controller/binding.c index 77ed7441a..0a7803583 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -522,8 +522,8 @@ update_local_lport_ids(struct binding_ctx_out *b_ctx, const struct sbrec_port_binding *pb) { char buf[16]; - snprintf(buf, sizeof(buf), "%"PRId64"_%"PRId64, - pb->datapath->tunnel_key, pb->tunnel_key); + get_unique_lport_key(pb->datapath->tunnel_key, pb->tunnel_key, + buf, sizeof(buf)); if (sset_add(b_ctx->local_lport_ids, buf) != NULL) { b_ctx->local_lport_ids_changed = true; @@ -542,8 +542,8 @@ remove_local_lport_ids(struct binding_ctx_out *b_ctx, const struct sbrec_port_binding *pb) { char buf[16]; - snprintf(buf, sizeof(buf), "%"PRId64"_%"PRId64, - pb->datapath->tunnel_key, pb->tunnel_key); + get_unique_lport_key(pb->datapath->tunnel_key, pb->tunnel_key, + buf, sizeof(buf)); if (sset_find_and_delete(b_ctx->local_lport_ids, buf)) { b_ctx->local_lport_ids_changed = true; diff --git a/controller/lflow.c b/controller/lflow.c index eb6be0100..546658c60 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -130,7 +130,7 @@ is_chassis_resident_cb(const void *c_aux_, const char *port_name) /* Store the port_name to lflow reference. */ int64_t dp_id = pb->datapath->tunnel_key; char buf[16]; - snprintf(buf, sizeof(buf), "%"PRId64"_%"PRId64, dp_id, pb->tunnel_key); + get_unique_lport_key(dp_id, pb->tunnel_key, buf, sizeof(buf)); lflow_resource_add(c_aux->lfrr, REF_TYPE_PORTBINDING, buf, &c_aux->lflow->header_.uuid); @@ -664,7 +664,7 @@ consider_logical_flow(const struct sbrec_logical_flow *lflow, if (port_id) { int64_t dp_id = lflow->logical_datapath->tunnel_key; char buf[16]; - snprintf(buf, sizeof(buf), "%"PRId64"_%"PRId64, dp_id, port_id); + get_unique_lport_key(dp_id, port_id, buf, sizeof(buf)); lflow_resource_add(l_ctx_out->lfrr, REF_TYPE_PORTBINDING, buf, &lflow->header_.uuid); if (!sset_contains(l_ctx_in->local_lport_ids, buf)) { @@ -927,8 +927,8 @@ lflow_handle_flows_for_lport(const struct sbrec_port_binding *pb, { int64_t dp_id = pb->datapath->tunnel_key; char pb_ref_name[16]; - snprintf(pb_ref_name, sizeof(pb_ref_name), "%"PRId64"_%"PRId64, - dp_id, pb->tunnel_key); + get_unique_lport_key(dp_id, pb->tunnel_key, pb_ref_name, + sizeof(pb_ref_name)); bool changed = true; return lflow_handle_changed_ref(REF_TYPE_PORTBINDING, pb_ref_name, l_ctx_in, l_ctx_out, &changed); diff --git a/lib/ovn-util.h b/lib/ovn-util.h index e13cf4d78..eba2948ff 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -114,6 +114,14 @@ bool ovn_tnlid_in_use(const struct hmap *set, uint32_t tnlid); uint32_t ovn_allocate_tnlid(struct hmap *set, const char *name, uint32_t min, uint32_t max, uint32_t *hint); +static inline void +get_unique_lport_key(uint64_t dp_tunnel_key, uint64_t lport_tunnel_key, + char *buf, size_t buf_size) +{ + snprintf(buf, buf_size, "%"PRId64"_%"PRId64, dp_tunnel_key, + lport_tunnel_key); +} + char *ovn_chassis_redirect_name(const char *port_name); void ovn_set_pidfile(const char *name); -- 2.26.2 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev