From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CDB3AA034F; Thu, 14 May 2020 22:38:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CBD831D9CE; Thu, 14 May 2020 22:38:09 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by dpdk.org (Postfix) with ESMTP id 7EB1D1D956; Thu, 14 May 2020 22:38:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FSk3Oymp329CXxGHD4qwksKOql2erWV9r7S5Nnb9ZmjZVW2Nf79hVRgLoOlisqyGyFJTc1ihbL1MFuaSq/vFuQjV8/+J+mwiNn5X/6UFOMLaZ2PMsMrEAYJxxDlBUJVsVGqBDRYbrEnSqa+OqVAW1b507t/ZVmQZC8QssXqVpjjY/CoPjV2enhfCKf2NbSmdS7fBQS/fBvuZGeQrLQSH3uBlw5lDg/HPZMEcyQhZZDGX2/k+oJSCQktvCbR7eHQ7X1ozoDr8k5VHYzoogj7uOOnec4pcyAq2WF7SUElSqk+Z9MBsH0uHtq56kNn3LnuLCI5O/gopxgm7Dl9LSxyBgA== 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-SenderADCheck; bh=/nb3NkOsn9QWd+7Zx7wa1Vx1w75sGV6A8wvVjMv/qUI=; b=OX9uuc5l2SI3CPKf25xge1K5JXgoTE6/ZV9qrKsZQvy2C/m+/bDvMNOYvnTkmTm34jiQDYqqb/guD8ejdgkpQI/3FR7+LbpAhITGlnxEMkD2c2X3vUhHkjvyPcgoCoANDeagJD6P47RJKCo6bkEQCVrmJ/EITYligEuU9ytNzNjrvHITPS9h0/r442+MOxKKfYvQ5JPi2Vm6hpqiTPB8Y0mc8kpHgj8Cg3aIfrfcsTu8W20i570acBFLgfm42OQKgKs7Qa4J4Nvvajtdj6G8ie6Oe5YzX1Nk0QyZL9Yk8r9gnw2lMR07TG04ID5zrIDRmFjLQX5MCh9ZVzgEld8a8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=/nb3NkOsn9QWd+7Zx7wa1Vx1w75sGV6A8wvVjMv/qUI=; b=ZbqV3uvVoZmxLHi+cz9TD8fzEez54JgBkDiCBrT1Y/WNJaa8ZWdZzmIuPi805p/GJ72lqqKavraKYpkZs/m1t6PN7Tmpcnr2xeNcjdEqsl/ZAMIAu6y+w/GR/xkjfJ7m9ZW0KPfUqu5uIkuLmG9jkuRulVtrJKSHuAnEVHnqLqk= Received: from VI1PR05MB3278.eurprd05.prod.outlook.com (2603:10a6:802:1f::28) by VI1PR05MB5840.eurprd05.prod.outlook.com (2603:10a6:803:d4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.24; Thu, 14 May 2020 20:38:04 +0000 Received: from VI1PR05MB3278.eurprd05.prod.outlook.com ([fe80::dc31:eda3:1f30:48ce]) by VI1PR05MB3278.eurprd05.prod.outlook.com ([fe80::dc31:eda3:1f30:48ce%6]) with mapi id 15.20.2979.033; Thu, 14 May 2020 20:38:04 +0000 From: Slava Ovsiienko To: Alexander Kozyrev , "dev@dpdk.org" CC: Matan Azrad , Raslan Darawsheh , "stephen@networkplumber.org" , "stable@dpdk.org" Thread-Topic: [PATCH v2] common/mlx5: fix bogus assert Thread-Index: AQHWKgHuug2OxOuOEEms17ItaC1MV6ioCkSw Date: Thu, 14 May 2020 20:38:04 +0000 Message-ID: References: <20200331060247.10954-1-stephen@networkplumber.org> <1589440142-7197-1-git-send-email-viacheslavo@mellanox.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [95.164.10.10] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 40aaf515-5f30-43d1-626e-08d7f846b3bd x-ms-traffictypediagnostic: VI1PR05MB5840: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 040359335D x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: r7zgOPLHNnqom3g8n21gxcMCFGuJaeQ1OZ3lhf8yZm5a4fXVXGMiZ6oT5R7K/vC1PDHQVlEQAwm2LO22lbQ+md7cL8D8kaN6UUwq49j3gkElTY8kd6vrAA86Gc1KnIoUzHXSt4wCIh78nVo3p6bzs3TbSWwWNwTLVYpa23gYTXG2DK+B0fuHc/3yFuWeDxfke4yOoPiNk95OXLwPJ2xj1W9JxGiMfMod2My5C8jqHxzdN7VQqCrIXcGvi0OayXuulIzTozPgKaFy+PNRw0iDA3QWiZDZLxa8T9KBtRa0CDl/sBYGo5lN3b00TFEKrwHiwENuKFZji6bTGjSZcNspBQ3RDcCl1dWYY/JQW/d/t6lB2L8XWua+CKEadv9QUk6VSt8mZ00D7BHwv4or422KVXYEWMYV/O2wEbdlkouSXFSYpDi0GOtnH0jdZ0MKSXkseGU6uF4C3nc1Je24BajhoHgLQCXzuufDbH6g2Jwok2hgjNkgNA4MYEwZorvyqrga9IAViRpo6tue1cP5W6Ebig== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR05MB3278.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(366004)(346002)(396003)(39860400002)(136003)(33656002)(76116006)(7696005)(66556008)(966005)(53546011)(52536014)(8936002)(478600001)(66946007)(66476007)(64756008)(8676002)(9686003)(6506007)(66446008)(86362001)(186003)(45080400002)(26005)(55016002)(71200400001)(4326008)(2906002)(54906003)(5660300002)(83080400001)(316002)(110136005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: iAjWjRoj7eGy8/BfHfvD0huvje0TwVSQ+NXdGHZBg5ZOEW8V5/zqalnvWqa8UR7sUj1Ujk4DlmAksFg8a0nFHmbj+ctWMWDZYRom1Y3Q7LIyLbYYayv9asTmxvDaxil/HldkKZ+DCpcfx49+LDPtzcXo/7IOqomUX2tySKt9RU7ok0Zqs6IdHu7WHKYLOjuFJ9QZB2tS8QKMEtwigDBA3X01G2f2zN544Be/EMXYb/hGrCOYM4oPHiXf/mz2ac3jSnwiz0yKuxbm3r5ynrcYV0hLIcYy6susod2svsHUzHvp9mNb5k4DNTzhlsfHLs1kBaGErQ1oo424BHph6/rYU5zfGR3/t0K/9bOTEpF5cCx28mrrSlFTAKVavJHtmA1ZkdUvkQEGZYWX/njVlwiqj8WgDCh4bj9OY/JshzDLcl5W2xXTyDelkbvebzXxa9xnox4b6A9R3//Kr0z4QwMXYb02hWanQCctpEJF9V3EJi4= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40aaf515-5f30-43d1-626e-08d7f846b3bd X-MS-Exchange-CrossTenant-originalarrivaltime: 14 May 2020 20:38:04.0778 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: I9pe1KdRi0fiM4mujW3Zc3yJeK+NpWI4UoArCcSMJIe4lsIlPJJ49F37QCw0MrdZpO9CfPfLFlXdcqau/cB5RoIUeTdllmKjwEutHaHVRGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB5840 Subject: Re: [dpdk-dev] [PATCH v2] common/mlx5: fix bogus assert 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Alexander Kozyrev > Sent: Thursday, May 14, 2020 18:11 > To: Slava Ovsiienko ; dev@dpdk.org > Cc: Matan Azrad ; Raslan Darawsheh > ; stephen@networkplumber.org; stable@dpdk.org > Subject: RE: [PATCH v2] common/mlx5: fix bogus assert >=20 > These asserts seem redundant for me. Don't you think? > EINVAL is returned, why bother to assert the same condition? To stop the wrong conditions evolving on debug ? >=20 > Regards, > Alex >=20 > > -----Original Message----- > > From: Viacheslav Ovsiienko > > Sent: Thursday, May 14, 2020 3:09 > > To: dev@dpdk.org > > Cc: Matan Azrad ; Raslan Darawsheh > > ; stephen@networkplumber.org; Alexander > Kozyrev > > ; stable@dpdk.org > > Subject: [PATCH v2] common/mlx5: fix bogus assert > > > > The MLX5 device supports up to MLX5_MAX_MAC_ADDRESSES (256) MAC > > addresses. > > The code flushes all MAC devices. > > > > If DPDK is compiled with MLX5_DEBUG this would an assert. > > PANIC in mlx5_nl_mac_addr_flush(): > > line 775 assert "(size_t)(i) < sizeof(mac_own) * 8" failed > > > > The root cause is that mac_own is a pointer and is being used as a bitm= ap > array. > > The sizeof(mac_own) would therefore be 64 but the number of entries to > > be flushed would be 256. > > > > There is a whole set of asserts in MLX5 netlink code with the same > > bug; that should just be changed into proper error checks. > > > > Fixes: 8e46d4e18f09 ("common/mlx5: improve assert control") > > Cc: akozyrev@mellanox.com > > Cc: stable@dpdk.org > > > > Signed-off-by: Stephen Hemminger > > Signed-off-by: Viacheslav Ovsiienko > > > > --- > > v2: fix asserts > > v1: > > > https://eur03.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fpatch > > es.d > pdk.org%2Fpatch%2F67453%2F&data=3D02%7C01%7Cakozyrev%40mella > nox > > > .com%7C4f8e2cb5aacd4a33e22a08d7f7d5c7c4%7Ca652971c7d2e4d9ba6a4 > d14 > > > 9256f461b%7C0%7C0%7C637250369858023357&sdata=3DZI7CTCQDnnm > r6n > > pYXTOxOf4%2BBktSgmE%2F3rC4NG3QXxc%3D&reserved=3D0 > > --- > > drivers/common/mlx5/mlx5_nl.c | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/common/mlx5/mlx5_nl.c > > b/drivers/common/mlx5/mlx5_nl.c index c144223..65efcd3 100644 > > --- a/drivers/common/mlx5/mlx5_nl.c > > +++ b/drivers/common/mlx5/mlx5_nl.c > > @@ -671,7 +671,10 @@ struct mlx5_nl_ifindex_data { > > > > ret =3D mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 1); > > if (!ret) { > > - MLX5_ASSERT((size_t)(index) < sizeof(mac_own) * > CHAR_BIT); > > + MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); > > + if (index >=3D MLX5_MAX_MAC_ADDRESSES) > > + return -EINVAL; > > + > > BITFIELD_SET(mac_own, index); > > } > > if (ret =3D=3D -EEXIST) > > @@ -700,7 +703,10 @@ struct mlx5_nl_ifindex_data { > > mlx5_nl_mac_addr_remove(int nlsk_fd, unsigned int iface_idx, uint64_t > > *mac_own, > > struct rte_ether_addr *mac, uint32_t index) { > > - MLX5_ASSERT((size_t)(index) < sizeof(mac_own) * CHAR_BIT); > > + MLX5_ASSERT(index < MLX5_MAX_MAC_ADDRESSES); > > + if (index >=3D MLX5_MAX_MAC_ADDRESSES) > > + return -EINVAL; > > + > > BITFIELD_RESET(mac_own, index); > > return mlx5_nl_mac_addr_modify(nlsk_fd, iface_idx, mac, 0); } @@ > - > > 769,10 +775,12 @@ struct mlx5_nl_ifindex_data { { > > int i; > > > > + if (n <=3D 0 || n >=3D MLX5_MAX_MAC_ADDRESSES) > > + return; > > + > > for (i =3D n - 1; i >=3D 0; --i) { > > struct rte_ether_addr *m =3D &mac_addrs[i]; > > > > - MLX5_ASSERT((size_t)(i) < sizeof(mac_own) * CHAR_BIT); > > if (BITFIELD_ISSET(mac_own, i)) > > mlx5_nl_mac_addr_remove(nlsk_fd, iface_idx, > mac_own, m, > > i); > > -- > > 1.8.3.1