If the conversion of efd name to ring name gets truncated, then log it. And if the ring name than causes collision, make sure that log message includes error reason.
Signed-off-by: Stephen Hemminger <[email protected]> --- lib/efd/rte_efd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c index ebf1e0655f..bbd565f404 100644 --- a/lib/efd/rte_efd.c +++ b/lib/efd/rte_efd.c @@ -517,13 +517,20 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); if (online_cpu_socket_bitmask == 0) { - EFD_LOG(ERR, "At least one CPU socket must be enabled " - "in the bitmask"); + EFD_LOG(ERR, "At least one CPU socket must be enabled in the bitmask"); + rte_errno = EINVAL; return NULL; } if (max_num_rules == 0) { EFD_LOG(ERR, "Max num rules must be higher than 0"); + rte_errno = EINVAL; + return NULL; + } + + if (strlen(name) >= RTE_EFD_NAMESIZE) { + EFD_LOG(ERR, "Name is too long"); + rte_errno = ENAMETOOLONG; return NULL; } @@ -698,12 +705,15 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, TAILQ_INSERT_TAIL(efd_list, te, next); rte_mcfg_tailq_write_unlock(); - snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name); + if (snprintf(ring_name, sizeof(ring_name), "HT_%s", table->name) + >= (int)sizeof(ring_name)) + EFD_LOG(NOTICE, "EFD ring name truncated to '%s'", ring_name); + /* Create ring (Dummy slot index is not enqueued) */ r = rte_ring_create(ring_name, rte_align32pow2(table->max_num_rules), offline_cpu_socket, 0); if (r == NULL) { - EFD_LOG(ERR, "memory allocation failed"); + EFD_LOG(ERR, "ring creation failed: %s", rte_strerror(rte_errno)); rte_efd_free(table); return NULL; } -- 2.51.0

