From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0077.outbound.protection.outlook.com [104.47.2.77]) by dpdk.org (Postfix) with ESMTP id 9969B2BA7; Thu, 3 May 2018 09:07:55 +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; bh=3xJHu1nz5TD3BRuETIZvCFpzqAH8Bv6quRoKm0rkCgk=; b=fh472NOkQpXzTBZbA1Rvk65sgcOwj0t3VndzdvKgb6vpkeMPaJ5apvlrDqXguyaJPPdhGjTUjb8s1YJ4H7Gs7G+WcDy8hrWgkF02S1a4Sz48vK8/HL6awSdQjfK3mWW0SXOM5vl5vEZLIwuq5K7F0dM5uuQiZ321KaZemX7mHBE= Received: from DB7PR05MB4426.eurprd05.prod.outlook.com (52.134.109.15) by DB7PR05MB4427.eurprd05.prod.outlook.com (52.134.109.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.23; Thu, 3 May 2018 07:07:54 +0000 Received: from DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::f116:5be4:ba29:fed8]) by DB7PR05MB4426.eurprd05.prod.outlook.com ([fe80::f116:5be4:ba29:fed8%13]) with mapi id 15.20.0715.024; Thu, 3 May 2018 07:07:54 +0000 From: Shahaf Shuler To: =?iso-8859-1?Q?N=E9lio_Laranjeiro?= , "dev@dpdk.org" , Adrien Mazarguil , Yongseok Koh CC: "stable@dpdk.org" Thread-Topic: [dpdk-stable] [PATCH] net/mlx5: fix: flow validation Thread-Index: AQHT4iO8898+NHRxt0uH4l0+xuftOqQdij7A Date: Thu, 3 May 2018 07:07:54 +0000 Message-ID: References: In-Reply-To: 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; DB7PR05MB4427; 7:tEgcVD8kFjJUhoC1BxZGD4Kfav1/klhp0EZWnvKRajRF2DtJi2A/fjEPsvOjYhAv7wAuIEe8sl6JE8OrBZIoUhVdcKLyc5NWQu3fMg54QBGnRU67sn6yR1/NNj8JYGNRp/gdDWUaAVH80TTc51weQNFlAqGIrXkJJUoyS5101cTe0z2DZo2OL3z67diX1BJOF5yUXJeM0ghHXB3jTWrCzIh5kL8lAV0aW1BSz7gsWJ91dEky4lSX5R0srIWN1j1U x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4427; x-ms-traffictypediagnostic: DB7PR05MB4427: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(3002001)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:DB7PR05MB4427; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4427; x-forefront-prvs: 066153096A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(39380400002)(346002)(376002)(396003)(366004)(199004)(189003)(2501003)(2900100001)(14454004)(86362001)(4326008)(106356001)(446003)(6246003)(97736004)(575784001)(55016002)(68736007)(478600001)(316002)(3660700001)(105586002)(8936002)(9686003)(2906002)(33656002)(3280700002)(53936002)(6116002)(11346002)(229853002)(486006)(66066001)(7736002)(26005)(476003)(5660300001)(305945005)(74316002)(110136005)(8676002)(6636002)(6436002)(3846002)(76176011)(6506007)(81156014)(59450400001)(7696005)(81166006)(186003)(99286004)(102836004)(5250100002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4427; H:DB7PR05MB4426.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Xh/xLCvan7hU2GXRvsA5S3N86KIb7pTMG7hmmjqxzSMQJMxymy4lyGPAeieb2PwiKMZoAxVbMSFfvDiGvmth/Hl2I9IglO583ydpS7FowaYbnw/Yy5mWOTSb3FmbN0wDZLPINwugXrXJJszVJjmF9u3vFAq5/JOAp3o1zTnFSsJRI0H60bybXgMZxiF4LkEY spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 854f2f94-e3a7-428e-e791-08d5b0c4978c X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 854f2f94-e3a7-428e-e791-08d5b0c4978c X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2018 07:07:54.4059 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4427 Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] net/mlx5: fix: flow validation 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: Thu, 03 May 2018 07:07:55 -0000 Hi Nelio, Wednesday, May 2, 2018 5:43 PM, Nelio Laranjeiro: > Subject: [dpdk-stable] [PATCH] net/mlx5: fix: flow validation The title is wrong the : after the fix should be removed.=20 >=20 > Item spec and last are wrongly compared to the NIC capability causing a > validation failure when the mask is null. > This validation function should only verify the user is not configuring > unsupported matching fields. >=20 > Fixes: 2097d0d1e2cc ("net/mlx5: support basic flow items and actions") > Cc: stable@dpdk.org >=20 > Signed-off-by: Nelio Laranjeiro > --- > drivers/net/mlx5/mlx5_flow.c | 73 +++++++++++------------------------- > 1 file changed, 22 insertions(+), 51 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index 129311d50..5d4995783 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -555,60 +555,31 @@ static int > mlx5_flow_item_validate(const struct rte_flow_item *item, > const uint8_t *mask, unsigned int size) { > - if (!item->spec && (item->mask || item->last)) { > - rte_errno =3D EINVAL; > - return -rte_errno; > - } > - if (item->spec && !item->mask) { > - unsigned int i; > - const uint8_t *spec =3D item->spec; > - > - for (i =3D 0; i < size; ++i) > - if ((spec[i] | mask[i]) !=3D mask[i]) { > - rte_errno =3D EINVAL; > - return -rte_errno; > - } > - } > - if (item->last && !item->mask) { > - unsigned int i; > - const uint8_t *spec =3D item->last; > - > - for (i =3D 0; i < size; ++i) > - if ((spec[i] | mask[i]) !=3D mask[i]) { > - rte_errno =3D EINVAL; > - return -rte_errno; > - } > - } > - if (item->mask) { > - unsigned int i; > - const uint8_t *spec =3D item->spec; > - > - for (i =3D 0; i < size; ++i) > - if ((spec[i] | mask[i]) !=3D mask[i]) { > - rte_errno =3D EINVAL; > - return -rte_errno; > - } > - } > - if (item->spec && item->last) { > - uint8_t spec[size]; > - uint8_t last[size]; > - const uint8_t *apply =3D mask; > - unsigned int i; > - int ret; > + unsigned int i; > + const uint8_t *spec =3D item->spec; > + const uint8_t *last =3D item->last; > + const uint8_t *m =3D item->mask ? item->mask : mask; >=20 > - if (item->mask) > - apply =3D item->mask; > - for (i =3D 0; i < size; ++i) { > - spec[i] =3D ((const uint8_t *)item->spec)[i] & apply[i]; > - last[i] =3D ((const uint8_t *)item->last)[i] & apply[i]; > - } > - ret =3D memcmp(spec, last, size); > - if (ret !=3D 0) { > - rte_errno =3D EINVAL; > - return -rte_errno; > - } > + if (!spec && (item->mask || last)) > + goto error; > + if (!spec) > + return 0; > + for (i =3D 0; i < size; i++) { I think inline comment which explains what each code section below verifies= would much help. > + if (spec) > + if (((spec[i] & m[i]) | mask[i]) !=3D mask[i]) > + goto error; Am wondering.=20 Which the below check of m ... > + if (last) > + if ((((last[i] & m[i]) | mask[i]) !=3D mask[i]) || > + ((spec[i] & m[i]) !=3D (last[i] & m[i]))) > + goto error; > + if (m) > + if ((m[i] | mask[i]) !=3D mask[i]) > + goto error; Do we really need to spec check?=20 Meaning if above one passes it is guarantee m is contained in mask. And if = so, then the spec check will always succeed.=20 > } > return 0; > +error: > + rte_errno =3D ENOTSUP; > + return -rte_errno; > } >=20 > /** > -- > 2.17.0