From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF72C42D09; Tue, 20 Jun 2023 17:27:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C1AA1410D7; Tue, 20 Jun 2023 17:27:35 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 49C5540EDF for ; Tue, 20 Jun 2023 17:27:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687274852; x=1718810852; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=vCRm467NUXV5Xq2mBuU5eWKF8/7WYY4s+WUQ/3Nfef0=; b=nP51PeCmiY9i3B2xH0v9q8oDYWj+IA6latFIhnvJpAdKOOLmlhqfos+9 fAta2EJZPu+hy1NeKaqUGEW69yONVY1C0dov6hMYn8DSXDzuXvu3zXhuO jpYqictwrtmVCW7VEv+hdpxi4O4EmjzsQ2knQrv1RHjJmpoeGZDhg9zhe i/LOyMoSEIWDgO+fRDtkE5U93OLzjN3xTCtmpwJyH/BDu1FeAojDTBNig /9IJEzfe4wC8c2NlEJs6VYDJg0/O6yS857tjfiK1cl2a9rYK3aWl7hQ9/ cPJoYTfyu2gzQOsUVbsizHpwYea/vPIgSCnhtJsTi4pnEx4yW5UcSW0kY A==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="339505363" X-IronPort-AV: E=Sophos;i="6.00,257,1681196400"; d="scan'208,217";a="339505363" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2023 08:27:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="784104264" X-IronPort-AV: E=Sophos;i="6.00,257,1681196400"; d="scan'208,217";a="784104264" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga004.fm.intel.com with ESMTP; 20 Jun 2023 08:27:32 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 20 Jun 2023 08:27:31 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Tue, 20 Jun 2023 08:27:31 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.42) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Tue, 20 Jun 2023 08:27:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KSmKcgwfTfNKcnmXREpbShAuaSdW/jN0MKmf5NKSqe6XGRGj8Me0aQ6fnwOVLEpwnNvglVSvKFBVuvmMydxh7Sdc02Nn9ba+HwlpHj1wo0or3QlApIhYb2LBlBRMLJ+BvcBoY8zKGmuAQKusOAWQ5UFLHhihP7Ah7AfjkVZoNvmqrNkgdbQW8AFqPZCD5yBpi/3ZHVSc1tf2Kv1ovoaOC3BzCEhIESZWD4DreJ0LcmtR2rTByGUnvRrcY0pyOgoA8Zheq384RaecRjKtz8gqlE4sCX9qcFUKT0VbphmDZhkcrE+ePickn/iR40eDusQU9xpuc0ajCcIsnDufxkPp7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lvlz0jVefldQeQc8fhYKQZgwTJmw7NJ5EjL2b+hC404=; b=nS1EPy5NjFDRvFG6O07He5AMJQUyHkItbDu1LJyGbUvi01ckoxsYsdErX5a9+309J42PRERcMYrl3FFDUp1eXXHT5nlKctBZLRq33siZ6ENoTgdHBisVuKwm8JUOfyD7dXgzhpWunbl6/HJvkKKbpy2+/WHxDUyHxAjNOZigIjoBLLmze1KiFQIE8XEE9Lqdh3KGsw71HFq339x+19m4rb6JeZ4YknnoRH1rw6FMPL2JL+TaAzvOEs4AFOxP5mILKrBO99LT/W1ymqa3Ua87KSm3GRapNmMvlJYiL/e8uXR4OZSenDBE3J/OTRKC4VsE2pZt5aYxPmvjO+FZ+vbnkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3408.namprd11.prod.outlook.com (2603:10b6:805:bc::22) by SJ0PR11MB4800.namprd11.prod.outlook.com (2603:10b6:a03:2af::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Tue, 20 Jun 2023 15:27:29 +0000 Received: from SN6PR11MB3408.namprd11.prod.outlook.com ([fe80::121a:92cb:2f78:e53d]) by SN6PR11MB3408.namprd11.prod.outlook.com ([fe80::121a:92cb:2f78:e53d%5]) with mapi id 15.20.6500.036; Tue, 20 Jun 2023 15:27:29 +0000 From: "Ji, Kai" To: Stephen Hemminger , Fan Zhang CC: "dev@dpdk.org" Subject: Re: ring name length simplification in ipsec_mb_qp_create_processed_ops_ring Thread-Topic: ring name length simplification in ipsec_mb_qp_create_processed_ops_ring Thread-Index: AQHZk0956WkfdiFEf0uMowhlib/CBq+T8AaR Date: Tue, 20 Jun 2023 15:27:28 +0000 Message-ID: References: <20230530163457.665dd69a@hermes.local> In-Reply-To: <20230530163457.665dd69a@hermes.local> Accept-Language: en-GB, en-US, en-IE Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3408:EE_|SJ0PR11MB4800:EE_ x-ms-office365-filtering-correlation-id: df9b8e74-f99e-4856-a2e3-08db71a2dbd7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O83g874YhgS8Z9lVvhv1qLqMCtG2Ii5bJQzrLg0nOBSXvPkgHfOQlb6dTD8MCndpp24D8aa6Il+dy+gDNn/FMSe/VY26TUX5vmYMplF7wM5ox1CfLA8o6D6lbI4Ia6YWP+3R3tENzXvlz35/wfmY/GURPAne219zyvTVcGnQK6ggPef95otp67oy0j9kXF9yLnwWCMnIoYKm5t3OzwjUGxoC0aYwmVdJ8P4+bjV+6VR5WxGbq8LlF/gj8pcUrvSq15De/WJ5OZKK9gPCeQj7TZ0IDmFZs7mg/bV7gXzfWFJICJ6x2909dw5d5TiKY7mjl1pKB4p12ZrWk1vPY+XZOdCwbEaciWKdDkvQ1+0SlswZJ1/v2yFiKEW5pwYPCFI+yajYNrWb0sBivx7L1e4/cI/zkkw5BHRkAlQWlVEYDk6sBeHZ6O7tX14EZilCtIfsydDnleGVHiPHbLz6O+819YyPP0sZQkUvs+q+XIl39+s4b/v3NPAVuzLJth7vchuyxPbZalyCTr/S9BB1Ktf+6+qb1D3KzibK4eyeKA5EQswuAr4P5UGGpx7l9KBGv6VOX6WH+4LvS8560vTe6g7ANL2UtxU5w6WELuMyl6B7ERogEjls7GemHH8/U8LPxyTr x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3408.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(376002)(39860400002)(366004)(396003)(346002)(136003)(451199021)(478600001)(2906002)(7696005)(55016003)(110136005)(86362001)(33656002)(71200400001)(122000001)(38070700005)(52536014)(9686003)(26005)(186003)(6506007)(53546011)(8936002)(8676002)(66476007)(76116006)(66446008)(64756008)(66556008)(66946007)(91956017)(5660300002)(38100700002)(316002)(4326008)(83380400001)(82960400001)(19627405001)(41300700001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?9wzkAoKiQUlozwqasdZx7A9a0LLrkQRbp7JdPx+Zib4NCbljKTGWe3EWyd?= =?iso-8859-1?Q?jZ20z1IVCOH3yG1l7NI4Id/ejsnT6j/4b2OlVQUl0U7ZJOWVexzsPIGS8v?= =?iso-8859-1?Q?hx/9cENhQNSK76iSdf8ZHlO3vhdhx1x54p+tvosgEDdex+TRzT+83Dzb2O?= =?iso-8859-1?Q?j8FOvT9MF/brKzMIpFBqHhzLQI83AzMIX2DSkiv3UW4UJ1iAi7H5PM2k4F?= =?iso-8859-1?Q?f4PORWTB2KzvkgprkjYWV8KlB9KqHu7XPsXzvL9Z+SIN3Koe5tJTNeY0/F?= =?iso-8859-1?Q?Kg7lPtj+D5PwvfaBQ0sD7WGE0i6/x2jTBytm/mgV4m5fIYfqv4PFFnL72V?= =?iso-8859-1?Q?SrMQ2mS2xn7nNjuXcHafGjNySqq0Oz7afNS8k4YgpyDQ3fKw24P+w01Td7?= =?iso-8859-1?Q?Vgeukn6p8WQowsoROD+zTvfRYsQnKg97/dWVjY7pCF9TJZELv2u4PKpljw?= =?iso-8859-1?Q?v7r8TC56Sqt7MT0UaZM477ZZz/Xeg7/e+ipogrDzaqAPURZE4E4o0+1SPu?= =?iso-8859-1?Q?KEuSoWMdrKadS1nv1bfS+8f4SwgdfPnkB48hpYYBOK66Xx2QLnTT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tGbMCbuldcB4JhQzZHOBY78F/TaYdR3BUN/T0xA7kLvh?= =?iso-8859-1?Q?b7ccr1FXoAb/nU3GqhoIi7y7xlqs6WdwkApNRbIL6FzEnd2lRBX4yfjfZl?= =?iso-8859-1?Q?brfaM4UtQqWFmZf8ozpTmq+pZ1LDDOwzeUXf+ZXRDeGgFI8PEag72V+egO?= =?iso-8859-1?Q?6QAmInZi9HiT8=3D?= Content-Type: multipart/alternative; boundary="_000_SN6PR11MB34083F048E8BD1CB08108AA8815CASN6PR11MB3408namp_" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3408.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: df9b8e74-f99e-4856-a2e3-08db71a2dbd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jun 2023 15:27:28.9491 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: U2GqM2q7X7QjAkpwfWSGD8mS9hYB2QuAb0pnuvnHXsLPi9kpdXt5AWYi8VlHwAIu1s8ebTzocGmnvt4u8wDChA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4800 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org --_000_SN6PR11MB34083F048E8BD1CB08108AA8815CASN6PR11MB3408namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Can you fix the commit messages with signed-off and Fixes Acked-by: Kai Ji > ________________________________ From: Stephen Hemminger Sent: 31 May 2023 00:34 To: Fan Zhang Cc: dev@dpdk.org Subject: ring name length simplification in ipsec_mb_qp_create_processed_op= s_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 =3D rte_strlcpy(ring_name, qp->name, sizeof(ring_nam= e)); if (n >=3D sizeof(ring_name)) return NULL; r =3D rte_ring_lookup(ring_name); 1. The maximum length name allowed for rte_ring is 30 characters which come= s from RTE_MEMZONE_NAMESIZE- sizeof(RTE_RING_MZ_PREFIX) + 1 =3D 32 - 3 + 1 =3D 30 2. RTE_CRYPTODEV_NAME_MAX_LEN is 64, qp->name is in struct ipsec_mb_qp is a= lways the same size. 3. Ring create already does a copy of name, so making a copy here is not ne= eded. 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 =3D rte_strlcpy(ring_name, qp->name, sizeof(ring_nam= e)); - - if (n >=3D sizeof(ring_name)) - return NULL; + const char *ring_name =3D qp->name; r =3D rte_ring_lookup(ring_name); if (r) { --_000_SN6PR11MB34083F048E8BD1CB08108AA8815CASN6PR11MB3408namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Can you fix the commit messages with signed-off and Fixes

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


From: Stephen Hemminge= r <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_proce= ssed_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 strlcp= y 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_NAM= E_MAX_LEN];

        unsigned int n =3D rte_strlcpy(r= ing_name, qp->name, sizeof(ring_name));

        if (n >=3D sizeof(ring_name))=
            &nb= sp;   return NULL;

        r =3D rte_ring_lookup(ring_name)= ;

1. The maximum length name allowed for rte_ring is 30 characters which come= s from
RTE_MEMZONE_NAMESIZE- sizeof(RTE_RING_MZ_PREFIX) + 1 =3D 32 - 3 + 1 =3D 30<= br>
2. RTE_CRYPTODEV_NAME_MAX_LEN is 64, qp->name is in struct ipsec_mb_qp i= s always the same size.

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

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 =3D rte_strlcpy(ring_n= ame, qp->name, sizeof(ring_name));
-
-       if (n >=3D sizeof(ring_name))
-            &n= bsp;  return NULL;
+       const char *ring_name =3D qp->name= ;
 
        r =3D rte_ring_lookup(ring_name)= ;
        if (r) {
--_000_SN6PR11MB34083F048E8BD1CB08108AA8815CASN6PR11MB3408namp_--