[PATCH v10 06/18] efd: handle possible name truncation
Stephen Hemminger
stephen at networkplumber.org
Tue Jan 13 21:21:45 CET 2026
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 <stephen at networkplumber.org>
---
doc/guides/rel_notes/release_26_03.rst | 2 +-
lib/efd/rte_efd.c | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/doc/guides/rel_notes/release_26_03.rst b/doc/guides/rel_notes/release_26_03.rst
index b966ce7b49..91b1808455 100644
--- a/doc/guides/rel_notes/release_26_03.rst
+++ b/doc/guides/rel_notes/release_26_03.rst
@@ -92,7 +92,7 @@ API Changes
* lpm: name must be less than RTE_LPM_NAMESIZE.
* hash: name parameter must be less than RTE_HASH_NAMESIZE.
-
+ * efd: name must be less than RTE_EFD_NAMESIZE.
ABI Changes
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
More information about the dev
mailing list