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 F068DA0613 for ; Tue, 30 Jul 2019 15:48:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 90DAA1C199; Tue, 30 Jul 2019 15:48:14 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50042.outbound.protection.outlook.com [40.107.5.42]) by dpdk.org (Postfix) with ESMTP id 6B34C1C134; Tue, 30 Jul 2019 15:48:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eMr6WFAEjmE5bATZz8WHwFJ+C1VSOSJaLe9ikoBN5u17hRCmWatvgFi2kBEwphkwCaxOZIMhURJ3csR7l6kGV/v7QLtdh04GFGlDMQzDBVIPZKYDb00BZ7jlcV/IXpqgfj+ejd9IDJ+emwIYjCaRS18fkon4lk++X6wUxJwBMghEU3c2pfWYsOepB1NMXi/6crSZQf2sZA+Ri0Eo0Hlt3leEsVL4s0jPOCtrLZwiPFoT5qvHEVvSz3+d9gaPXBCk2XrlafaoQJEkJ9xt6tDZ7sFNx03un41QU7zzxUUJgekClvS/n52mxvNyuWxHFN40xcmzNo81H5AZRts+0x1cwA== 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=w6dzJYFnln0n0F5O1N+XkKRKaxmMN5IsbaIEsU8TO10=; b=Vc9FWUJ+pkZ8qxAylb/e0C/y/y0voUx6xTZT//oJYtNfb/EAlD3InxHsXstmi1VDiKvpGNdGIDyfNFWkTNTvWjyGYTX7HsXy6lgMp0iSNYp9Fe0VCBZZIrWyq45u4oc6S4YZ2ngUMRynJscNLeExuLjngMBw4ZNkrQYsr8AW3IcK7t4g78WFxtvBfiA0ydd8c0ZJnFc4rC0MQhaO0X00rAYbGdOpfLi3bzzIXsFWMH5glPhHbOszTprS61yCT0NkL9snz+LWHwEh3UccMMAWYnGamcwBFIihMlg/SU7JGefdsq8PuO1R/EwoqQBfOI6vXZGvEJg7OkcpdOxTmWSfqA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w6dzJYFnln0n0F5O1N+XkKRKaxmMN5IsbaIEsU8TO10=; b=ElK4aduBxhaX/ZiBcLzUDTTRWCdzHIq1W7jVpgM/O7wc+JHccnwwZh3jWJoLUCxecPT+FrMiM3r7p6Crc65yXaP6d0C0YJizEoBI8zReXW68hve6VDB/ePh+ExUyBSIWw4fzbzE3QoRCDtzbA3wgpUBiQHMHXoCeshIsLF0g6VE= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (52.133.39.139) by AM0PR0502MB3908.eurprd05.prod.outlook.com (52.133.50.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2115.13; Tue, 30 Jul 2019 13:48:07 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::ccc2:2dd4:ca86:7639]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::ccc2:2dd4:ca86:7639%3]) with mapi id 15.20.2115.005; Tue, 30 Jul 2019 13:48:07 +0000 From: Matan Azrad To: Stephen Hemminger , Shahaf Shuler , Yongseok Koh , Slava Ovsiienko CC: "dev@dpdk.org" , "sju@paloaltonetworks.com" , "stable@dpdk.org" Thread-Topic: [PATCH 1/2] net/mlx4: fix crash in dev_info_get in secondary process Thread-Index: AQHVOP9UUsCuXfcYFUqM0gSGhV6foqbjROwA Date: Tue, 30 Jul 2019 13:48:07 +0000 Message-ID: References: <20190712205425.17781-1-stephen@networkplumber.org> <20190712205425.17781-2-stephen@networkplumber.org> In-Reply-To: <20190712205425.17781-2-stephen@networkplumber.org> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c07ce32e-0650-4a2c-dce2-08d714f48d53 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR0502MB3908; x-ms-traffictypediagnostic: AM0PR0502MB3908: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:272; x-forefront-prvs: 0114FF88F6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(51914003)(199004)(189003)(64756008)(478600001)(6436002)(6636002)(102836004)(110136005)(6246003)(6116002)(9686003)(74316002)(2906002)(52536014)(66446008)(3846002)(8936002)(66946007)(6506007)(66066001)(76176011)(86362001)(33656002)(5660300002)(66556008)(71190400001)(486006)(71200400001)(25786009)(11346002)(54906003)(7696005)(76116006)(14454004)(4326008)(81166006)(186003)(446003)(55016002)(68736007)(81156014)(476003)(8676002)(53936002)(26005)(99286004)(7736002)(229853002)(305945005)(66476007)(316002)(256004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0502MB3908; H:AM0PR0502MB4019.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TbhicbIbwMZP1iPmGy9ec6UQnpauIr+yYy8gh7OT+VxGbnGf+wiUR0Fija3evRPIc/vtZFEYRwdPg35mWuyONPalaffJajeodRqqS6nJXOIfwSOpYgM2DpAcJBmci1wfYxX4FNAjZ39hbsa0aqzcOIvA2QtK0dOPEKyA1HdzV5OxvbiKkQjHFcfrUtgQVjMO/2b+9FqhCGE6Ql3IvbKBDPRPe2XuX+FM5E5rQfTwdAEMz7EYdnsK/PM5ll7L6B20NEUvdLpSFf/h4mX4VZz+EKoE+4iAMOFhDv+gtqFnzWs1vjNbUUl9hdvGhUaB1tkjIltot9xHRdScO0+lX8qDaDAeDJ1VbbBBQs0oeilDWnDVWB4wHrzilhdBtF2uU+KAGlijLJjkxFQVo1mS6Mu0Dkuy9/4Tmx9NGhcVrkkttQU= 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: c07ce32e-0650-4a2c-dce2-08d714f48d53 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jul 2019 13:48:07.1004 (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: matan@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3908 Subject: Re: [dpdk-dev] [PATCH 1/2] net/mlx4: fix crash in dev_info_get in secondary process 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" Hi Stephen From: Stephen Hemminger > mlx4_dev_info_get calls mlx4_get_ifname, but mlx4_get_ifname uses priv- > >ctx which is not a valid pointer in a secondary process. The fix is to c= ache the > value in primary. >=20 > In the primary process, get and store the interface index of the device s= o > that secondary process can see it. >=20 > Bugzilla ID:320 > Fixes: 61cbdd419478 ("net/mlx4: separate device control functions") > Cc: stable@dpdk.org > Reported-by: Suyang Ju > Signed-off-by: Stephen Hemminger Acked-by: Matan Azrad Thanks for the fix. > --- > drivers/net/mlx4/mlx4.c | 19 +++++++++---------- > drivers/net/mlx4/mlx4.h | 1 + > drivers/net/mlx4/mlx4_ethdev.c | 4 +--- > 3 files changed, 11 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index > 2e169b0887a7..bab2cadbe519 100644 > --- a/drivers/net/mlx4/mlx4.c > +++ b/drivers/net/mlx4/mlx4.c > @@ -763,6 +763,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct > rte_pci_device *pci_dev) > }; > unsigned int vf; > int i; > + char ifname[IF_NAMESIZE]; >=20 > (void)pci_drv; > err =3D mlx4_init_once(); > @@ -1002,17 +1003,15 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, > struct rte_pci_device *pci_dev) > mac.addr_bytes[4], mac.addr_bytes[5]); > /* Register MAC address. */ > priv->mac[0] =3D mac; > -#ifndef NDEBUG > - { > - char ifname[IF_NAMESIZE]; > - > - if (mlx4_get_ifname(priv, &ifname) =3D=3D 0) > - DEBUG("port %u ifname is \"%s\"", > - priv->port, ifname); > - else > - DEBUG("port %u ifname is unknown", priv- > >port); > + > + if (mlx4_get_ifname(priv, &ifname) =3D=3D 0) { > + DEBUG("port %u ifname is \"%s\"", > + priv->port, ifname); > + priv->if_index =3D if_nametoindex(ifname); > + } else { > + DEBUG("port %u ifname is unknown", priv->port); > } > -#endif > + > /* Get actual MTU if possible. */ > mlx4_mtu_get(priv, &priv->mtu); > DEBUG("port %u MTU is %u", priv->port, priv->mtu); diff --git > a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index > cd0d637ac2bf..81b529ee8030 100644 > --- a/drivers/net/mlx4/mlx4.h > +++ b/drivers/net/mlx4/mlx4.h > @@ -159,6 +159,7 @@ struct mlx4_priv { > struct ibv_device_attr device_attr; /**< Device properties. */ > struct ibv_pd *pd; /**< Protection Domain. */ > /* Device properties. */ > + unsigned int if_index; /**< Associated network device index */ > uint16_t mtu; /**< Configured MTU. */ > uint8_t port; /**< Physical port number. */ > uint32_t started:1; /**< Device started, flows enabled. */ diff --git > a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index > ceef921620a8..5d28c0116d21 100644 > --- a/drivers/net/mlx4/mlx4_ethdev.c > +++ b/drivers/net/mlx4/mlx4_ethdev.c > @@ -616,7 +616,6 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct > rte_eth_dev_info *info) { > struct mlx4_priv *priv =3D dev->data->dev_private; > unsigned int max; > - char ifname[IF_NAMESIZE]; >=20 > /* FIXME: we should ask the device for these values. */ > info->min_rx_bufsize =3D 32; > @@ -637,8 +636,7 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct > rte_eth_dev_info *info) > info->rx_queue_offload_capa =3D mlx4_get_rx_queue_offloads(priv); > info->rx_offload_capa =3D (mlx4_get_rx_port_offloads(priv) | > info->rx_queue_offload_capa); > - if (mlx4_get_ifname(priv, &ifname) =3D=3D 0) > - info->if_index =3D if_nametoindex(ifname); > + info->if_index =3D priv->if_index; > info->hash_key_size =3D MLX4_RSS_HASH_KEY_SIZE; > info->speed_capa =3D > ETH_LINK_SPEED_1G | > -- > 2.20.1