Can you fix the commit messages with signed-off and Fixes

Acked-by: Kai Ji <kai.ji@intel.com>


From: Stephen Hemminger <stephen@networkplumber.org>
Sent: 31 May 2023 00:34
To: Fan Zhang <fanzhang.oss@gmail.com>
Cc: dev@dpdk.org <dev@dpdk.org>
Subject: ring name length simplification in ipsec_mb_qp_create_processed_ops_ring
 
I was looking at places in DPDK that are using rte_strlcpy which should be using strlcpy
directly instead.  Looking at this code in ipsec_mb, the use of strlcpy is actually
not needed at all.

/** Create a ring to place processed operations on */
static struct rte_ring
*ipsec_mb_qp_create_processed_ops_ring(
        struct ipsec_mb_qp *qp, unsigned int ring_size, int socket_id)
{
        struct rte_ring *r;
        char ring_name[RTE_CRYPTODEV_NAME_MAX_LEN];

        unsigned int n = rte_strlcpy(ring_name, qp->name, sizeof(ring_name));

        if (n >= sizeof(ring_name))
                return NULL;

        r = rte_ring_lookup(ring_name);

1. The maximum length name allowed for rte_ring is 30 characters which comes from
RTE_MEMZONE_NAMESIZE- sizeof(RTE_RING_MZ_PREFIX) + 1 = 32 - 3 + 1 = 30

2. RTE_CRYPTODEV_NAME_MAX_LEN is 64, qp->name is in struct ipsec_mb_qp is always the same size.

3. Ring create already does a copy of name, so making a copy here is not needed.

Therefore copying the name is not going to ever catch any errors. And if qp->name is
too long it won't fail until ring_create().

Would be better to just do something simpler like:

diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
index 3e52f9567401..4af6592f12c5 100644
--- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
+++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c
@@ -185,12 +185,7 @@ static struct rte_ring
        struct ipsec_mb_qp *qp, unsigned int ring_size, int socket_id)
 {
        struct rte_ring *r;
-       char ring_name[RTE_CRYPTODEV_NAME_MAX_LEN];
-
-       unsigned int n = rte_strlcpy(ring_name, qp->name, sizeof(ring_name));
-
-       if (n >= sizeof(ring_name))
-               return NULL;
+       const char *ring_name = qp->name;
 
        r = rte_ring_lookup(ring_name);
        if (r) {