From: "Ji, Kai" <kai.ji@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
Fan Zhang <fanzhang.oss@gmail.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: ring name length simplification in ipsec_mb_qp_create_processed_ops_ring
Date: Tue, 20 Jun 2023 15:27:28 +0000 [thread overview]
Message-ID: <SN6PR11MB34083F048E8BD1CB08108AA8815CA@SN6PR11MB3408.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230530163457.665dd69a@hermes.local>
[-- Attachment #1: Type: text/plain, Size: 2278 bytes --]
Can you fix the commit messages with signed-off and Fixes
Acked-by: Kai Ji <kai.ji@intel.com<mailto: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) {
[-- Attachment #2: Type: text/html, Size: 4361 bytes --]
prev parent reply other threads:[~2023-06-20 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 23:34 Stephen Hemminger
2023-06-20 15:27 ` Ji, Kai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SN6PR11MB34083F048E8BD1CB08108AA8815CA@SN6PR11MB3408.namprd11.prod.outlook.com \
--to=kai.ji@intel.com \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).