From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0067.outbound.protection.outlook.com [104.47.0.67]) by dpdk.org (Postfix) with ESMTP id BD0051C01 for ; Wed, 25 Jul 2018 15:10:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HbEx0c8ovr+r28bPxuhMIZrK80sXVHoNRhOjY1N69oY=; b=LNDBW1jQk8F9FBEOUPG4ZFG/qP1Xb4t78aHwvwmhgd3OztielvN5lNH4GRZN/Zwi/TK8iRB1HCWC7M7Td3nEij7T/DC45EIrb+yPPWYq5yFwvr1Y5ECwyUdiQTVDeCCKlkpVglfZt5oc84DIgXrWjB/clJ4z1kdQtwJvfdeKRzM= Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by DB7PR05MB4954.eurprd05.prod.outlook.com (20.176.235.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Wed, 25 Jul 2018 13:10:09 +0000 Received: from DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::52a:650b:ae10:fc3]) by DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::52a:650b:ae10:fc3%3]) with mapi id 15.20.0952.022; Wed, 25 Jul 2018 13:10:09 +0000 From: Shahaf Shuler To: =?iso-8859-1?Q?N=E9lio_Laranjeiro?= , Yongseok Koh CC: "dev@dpdk.org" Thread-Topic: [PATCH] net/mlx5: fix possible endless loop when clearing flow flags Thread-Index: AQHUIrLhLjUw7xnnQE2I7Vz40k6cSqSd8dUAgAD4j4CAAJohAIAAZ5yA Date: Wed, 25 Jul 2018 13:10:09 +0000 Message-ID: References: <20180723182744.1179-1-yskoh@mellanox.com> <20180724065742.xynuw5ddr5pnesju@laranjeiro-vm.dev.6wind.com> <6FFD0DAF-8C3A-471E-A7B0-47A8478D1702@mellanox.com> <20180725065858.wx74u2jcxuysigee@laranjeiro-vm.dev.6wind.com> In-Reply-To: <20180725065858.wx74u2jcxuysigee@laranjeiro-vm.dev.6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR05MB4954; 6:1sglKNUgo9lMxiytCvzXB4KgWhqPG8QR1OaXbwxLZ06Nq6GUWI8zZ6CDoLwr+KIylva/yamubZsCGeTnFCVlp+ehekzn8CsqfEsbQJ8Y5fRyRVaiQDgLUCsxoT3ds+/XwZz6EmFlijhjfxSdURKHIKyMnwhplzx5n9MVZR2o/+ymOPnRxEGCw5g+Q3bZ3w7UrkE3qk3zguvA4u9q4dSvxl7hZURw3mPshUu/u1zii5y9UlZKN/AA7kKY8HU4Rdl8MavcoVWxb31d1mazUXKDyfUC4nZnGVRuVHbgFh6flEi0IA0eSxWoK2suyImV2au/+WMya5UIwwrzKhrzOaQq4YWIo2tx71KYYSFqFwVzLlFRzf8N7voHXkJDysF36tIpxf7Vwc9920RF3yPqbJx41UyCtYRB8nYBW4RGGu5eEdBmB7wQUiBAVSTxoEP5dG5QGczzBWGNtynqr5Lz4+Jziw==; 5:wOzx6plx5Z2NkEHjHtH9uwxnjrSXqaBQ9y5uRTC97Kq/iVLumXqwaS4G1w/4qREiD1BY7bPHpLGQ7E696qCeZ3529EfoYUyAr59sRny16hcEd22yaXNN2+5Xgxkkwa2zkluEXMPo/ka1dGHbRR77FjRhfzJKlecKphdq6x6fDiY=; 7:gJVm1w++oKv1N+97greo2ojC1NaAaDeZLJWgCaDeR+mCNTdByjv7VVYFogw//JucUA3KqcNzbgF2C2kaTGGhPZ+dZPhPYnj6SpeFenUcunSfSUaWrAeDIZuM11uMldxAjYXF52KPbKD2SmEs8YD/FsViUudMhqT2ucZ5dFmMBYNQjGUPwiN+HFd5EQmA66KPQngCuzu07YFifP/8LCWZakN9OEJiNFjWd+wgdaIoYUoUioevQTaTyIwZZYpeLTDz x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: d197406c-ce72-4b6b-5fdd-08d5f22ff30b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4954; x-ms-traffictypediagnostic: DB7PR05MB4954: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4954; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4954; x-forefront-prvs: 0744CFB5E8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(136003)(366004)(39860400002)(376002)(189003)(199004)(14454004)(9686003)(2900100001)(106356001)(55016002)(105586002)(7736002)(66066001)(97736004)(229853002)(110136005)(2906002)(6436002)(305945005)(5660300001)(93886005)(486006)(6246003)(8936002)(53546011)(81156014)(81166006)(76176011)(7696005)(476003)(256004)(6506007)(316002)(186003)(68736007)(6116002)(102836004)(6636002)(74316002)(446003)(53936002)(5250100002)(33656002)(26005)(4326008)(11346002)(99286004)(25786009)(8676002)(86362001)(3846002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4954; H:DB7PR05MB4426.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: dGwhRkdONNbmnzLG/9IB/s9ZLuSCBtUXjL9lCfD1P7ciGnu8VxlLjSVsMh5+Spm49/bi5Aum1GX6pPv81zbEK0eqSVBw54OOMmSOejjjDhXe74J6L+B84JKoF4VCNvEsbUkNitlFwxp8oRnh7DfTEaYBe8E2Kdey0E0uFJ0EkQz9StqR4bEKuM2/arxzIRQwy8tzF23kgiPeEPG4CCLRiAFhraY2IgjbjSqx5CDqocHVRKdVfHaoNmwgYQQceDdB6ByWOdxGKzFYF26+wNi/kilcaJUxSaTV6ARh8IwJDqc8x9gX2wWCTQvWC2yPbhbOixcFgcNahozZ3+Asyn6ehHwArGk/8iHtaDwC5nVJltc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d197406c-ce72-4b6b-5fdd-08d5f22ff30b X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2018 13:10:09.7005 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4954 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix possible endless loop when clearing flow flags X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2018 13:10:12 -0000 Wednesday, July 25, 2018 9:59 AM, N=E9lio Laranjeiro: > Subject: Re: [PATCH] net/mlx5: fix possible endless loop when clearing fl= ow > flags >=20 > On Tue, Jul 24, 2018 at 09:47:19PM +0000, Yongseok Koh wrote: > > > > > On Jul 23, 2018, at 11:57 PM, N=E9lio Laranjeiro > wrote: > > > > > > On Mon, Jul 23, 2018 at 11:27:44AM -0700, Yongseok Koh wrote: > > >> If one of (*priv->rxqs)[] is null, the for loop can iterate > > >> infinitely as idx can't be increased. > > >> > > >> Fixes: cd24d526395e ("net/mlx5: add mark/flag flow action") > > >> Cc: Nelio Laranjeiro > > >> > > >> Signed-off-by: Yongseok Koh > > >> --- > > >> drivers/net/mlx5/mlx5_flow.c | 8 +++----- > > >> 1 file changed, 3 insertions(+), 5 deletions(-) > > >> > > >> diff --git a/drivers/net/mlx5/mlx5_flow.c > > >> b/drivers/net/mlx5/mlx5_flow.c index 32854198b..c156f01eb 100644 > > >> --- a/drivers/net/mlx5/mlx5_flow.c > > >> +++ b/drivers/net/mlx5/mlx5_flow.c > > >> @@ -2762,22 +2762,20 @@ mlx5_flow_rxq_flags_clear(struct > > >> rte_eth_dev *dev) { > > >> struct priv *priv =3D dev->data->dev_private; > > >> unsigned int i; > > >> - unsigned int idx; > > >> > > >> - for (idx =3D 0, i =3D 0; idx !=3D priv->rxqs_n; ++i) { > > >> + for (i =3D 0; i !=3D priv->rxqs_n; ++i) { > > >> struct mlx5_rxq_ctrl *rxq_ctrl; > > >> unsigned int j; > > >> > > >> - if (!(*priv->rxqs)[idx]) > > >> + if (!(*priv->rxqs)[i]) > > >> continue; > > >> - rxq_ctrl =3D container_of((*priv->rxqs)[idx], > > >> + rxq_ctrl =3D container_of((*priv->rxqs)[i], > > >> struct mlx5_rxq_ctrl, rxq); > > >> rxq_ctrl->flow_mark_n =3D 0; > > >> rxq_ctrl->rxq.mark =3D 0; > > >> for (j =3D 0; j !=3D MLX5_FLOW_TUNNEL; ++j) > > >> rxq_ctrl->flow_tunnels_n[j] =3D 0; > > >> rxq_ctrl->rxq.tunnel =3D 0; > > >> - ++idx; > > >> } > > >> } > > >> > > >> -- > > >> 2.11.0 > > > > > > This patch is wrong, (*priv->rxqs)[i] may un-initialised by the > > > application, the number of queues says how are in used, it does not > > > mean they are contiguous in the rxqs arrays and this due to the DPDK > > > API which configure the number of queues with > > > rte_eth_dev_configure() whereas queues are instantiated with > > > rte_eth_rx_queue_setup() which takes an position in the array as > parameter. > > > > > > Indeed this code is wrong, idx should always increase whereas i > > > should only increase if the (*priv->rxqs)[idx] is non null. > > > > I don't understand what you mean. In rte_eth_rx_queue_setup(), > > rx_queue_id is checked against dev->data->nb_rx_queues. > > > > if (rx_queue_id >=3D dev->data->nb_rx_queues) { > > RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=3D%u\n", > rx_queue_id); > > return -EINVAL; > > } > > > > This means the index should be [0, priv->rxqs_n) anyway. There is the > > same check in mlx5_rx_queue_setup(). If user mistakenly doesn't > > configure some of queues, then the corresponding slots could be null > > but indexes are still within the range. > > > > Then, what's your point of having both i and idx? >=20 > I remember I've face some issue while I've re-write the PMD to work on to= p > of flow API. That's why I've introduce such logic, but it seems not nece= ssary > as it comply with the documentation of the function and the code itself. >=20 > Acked-by: Nelio Laranjeiro Applied to next-net-mlx, thanks.=20 >=20 > -- > N=E9lio Laranjeiro > 6WIND