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 EA3A9A0471 for ; Mon, 15 Jul 2019 09:41:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CAB83326C; Mon, 15 Jul 2019 09:41:32 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40088.outbound.protection.outlook.com [40.107.4.88]) by dpdk.org (Postfix) with ESMTP id 61B4E3256 for ; Mon, 15 Jul 2019 09:41:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pco77uzXvatlkl6zhy+L2pL1Jiry3KIUzQzRvWzL6QLyTyoQr3McSp1qa0pkZx3yP1EC9OjNi1IL+t758qVswFCWPpRW4lzH4lXj/o3gzaWIYBNBGZhZ5uJXT+jlF8TPlvyowagbiVeT69llu5mWXpWFBScg+d76TspuJgNXLFsC5Suhn658E03gkIp7uuphRCAwYqiKP38ILfmbq/UeDh6GfhTFR6MKULi+B7xJRMDL+RtoWlgHDxMMavaYNAI96pwILBPeq94/MnHOPU7I7oju76s0x1GPCOhPpuAmpqxyTECO7m4TkGKX+DkZ7JLbZEXuxl/WjmN25DVoQ0uGRw== 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=yUhrB06OzJHFhMtBudQmBHAAfoZku1PTiK/AEM5pn84=; b=PAjE7bZ5kr16evTtkYI+t8pS2DZ6d7NBbPHfY8qznN07n6vVbJK9mThJDiVSBFD3CvkkiOYJxdNTFwo2bdAIpeIi5jeGkelmoUWvjt44qXMQTQu9wKbMMpWVHDQi268XQCNXPjGZfeyEOkp2fk13esjOk+7K1KGFwKTEL6Tnrb+Uure8uhF4Ma/EkYpQ7DzaYsZC4xDyWWVjZ09O0sLFThmAUrgPhiMYLpcoYV+6K4Re6pRBF9zwDEy44F0UWa3/b6rLx27FMzwKJS4iwRzu9wwqZckPpqBrSSm9S5XqfmmCAh1lBeIZYWntN2tSRWUaa2efDx7cXglFQL7xaf0MvQ== 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=yUhrB06OzJHFhMtBudQmBHAAfoZku1PTiK/AEM5pn84=; b=lilD4Z7B1MioYp5nc42zbUXVZMgH3Ei1J/0oSlpdDLi58GjKtQtBly8qEQX+1PURAHINHLRef2LV78PKISAQvY4uiycWAY3wrK+sXl9satr6wfENDMVdys/6UbmaVCUjTgbdtdln1mn5YNgHsD0PcPxYcNwW+S3x8Vc1LKc0iTM= Received: from AM4PR05MB3265.eurprd05.prod.outlook.com (10.171.188.154) by AM4PR05MB3348.eurprd05.prod.outlook.com (10.171.187.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Mon, 15 Jul 2019 07:41:30 +0000 Received: from AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::1442:fc4d:41ad:29d2]) by AM4PR05MB3265.eurprd05.prod.outlook.com ([fe80::1442:fc4d:41ad:29d2%5]) with mapi id 15.20.2073.012; Mon, 15 Jul 2019 07:41:30 +0000 From: Slava Ovsiienko To: Stephen Hemminger , Matan Azrad , Shahaf Shuler , Yongseok Koh CC: "dev@dpdk.org" , "sju@paloaltonetworks.com" Thread-Topic: [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary process Thread-Index: AQHVOP9UpLkj6QdILkqjyBQ/M4Ux6abLR1rQ Date: Mon, 15 Jul 2019 07:41:30 +0000 Message-ID: References: <20190712205425.17781-1-stephen@networkplumber.org> <20190712205425.17781-3-stephen@networkplumber.org> In-Reply-To: <20190712205425.17781-3-stephen@networkplumber.org> 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=viacheslavo@mellanox.com; x-originating-ip: [95.67.35.250] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0d435dee-148a-4c09-adf4-08d708f7d9ef 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:AM4PR05MB3348; x-ms-traffictypediagnostic: AM4PR05MB3348: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:238; x-forefront-prvs: 00997889E7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(396003)(39860400002)(366004)(376002)(346002)(13464003)(189003)(199004)(2906002)(186003)(25786009)(102836004)(26005)(53936002)(76176011)(6506007)(53546011)(68736007)(3846002)(6116002)(8676002)(81166006)(81156014)(7736002)(6246003)(229853002)(33656002)(305945005)(7696005)(8936002)(6636002)(66066001)(55016002)(74316002)(9686003)(486006)(6436002)(476003)(11346002)(446003)(478600001)(256004)(66446008)(66476007)(64756008)(66556008)(99286004)(76116006)(86362001)(66946007)(5660300002)(71200400001)(71190400001)(4326008)(110136005)(54906003)(52536014)(316002)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3348; H:AM4PR05MB3265.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: s8Zt3kwSOyZWYRmmq5wqnhIKOnBANCz63bTap6gmJAkwq+ZQzjmYOK1XH3INi9wXaiBEWFNPqfgAiqcoFfCgoMI3iCSqJdvIy6wO+yOJI0g/5wlx78zB8LlVDljNlnrALD+vFqNv0VRJwIPnCN7BYDjl1fwdMBXnRuh4d/wWUAEh1z8Aj1Tq2h0BSHSY4042MTNKFu+cznhnW4wIs6+t8vGx7i3X+HtkpmQRN19SzyCj/BwA3uo1Jc1Dkgz8jmQtMHypKym3OTyzSsTI8PZo44UNcQTMIQavBO3ajycl9GcMAatbB9dWc/yvym42l6KhUbBTWJbf1PkGmiTOqvZAvB3RJ/aelgrlGMqtvm2w4ih8Ju0uasf+kbJvGpnjOS+7Z1HDUn7Mh74/Br7KoYxp10Dl59i3jwgIC4j8valmP10= 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: 0d435dee-148a-4c09-adf4-08d708f7d9ef X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jul 2019 07:41:30.1482 (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: viacheslavo@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3348 Subject: Re: [dpdk-dev] [PATCH 2/2] net/mlx5: 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 >mlx5_get_ifname uses priv->ctx which is not a valid pointer in a secondary= process. 1. Sorry, mlx5_priv structure does not contain ctx field. Do you mean priv= ->sh (shared context) ? This one is allocated with rte_zmalloc(), that supposes shared memory alloc= ation and shared context structure should be valid within secondary process context. It seems there is another issue - mlx5_get_ifname() uses priv->nl_socket_rd= ma which is process-specific socket handle (fd), so routine may fail. 2. Generally I'm OK with caching ifindex in priv structure - it seems the i= findex is permanent=20 throughout interface lifetime. The mlx5_dev_spawn has a parameter mlx5_dev_= spawn_data *spawn, it contains the successfully queried ifindex of the device being spawned - = no need to query again. The cached valued should be retrieved by mlx5_ifindex() routine and mlx5_g= et_ifname() should be refactored to use mlx5_ifindex(). WBR, Slava > -----Original Message----- > From: Stephen Hemminger > Sent: Friday, July 12, 2019 23:54 > To: Matan Azrad ; Shahaf Shuler > ; Yongseok Koh ; Slava > Ovsiienko > Cc: dev@dpdk.org; sju@paloaltonetworks.com; Stephen Hemminger > > Subject: [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary > process >=20 > mlx5_dev_info_get calls mlx5_get_ifname, but mlx5_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 > Fixes: e60fbd5b24fc ("mlx5: add device configure/start/stop") > Signed-off-by: Stephen Hemminger > --- > drivers/net/mlx5/mlx5.c | 17 ++++++++--------- > drivers/net/mlx5/mlx5.h | 1 + > drivers/net/mlx5/mlx5_ethdev.c | 4 +--- > 3 files changed, 10 insertions(+), 12 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index > d93f92db56b5..27c5ef9b1763 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -1105,6 +1105,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, > int own_domain_id =3D 0; > uint16_t port_id; > unsigned int i; > + char ifname[IF_NAMESIZE]; >=20 > /* Determine if this port representor is supposed to be spawned. */ > if (switch_info->representor && dpdk_dev->devargs) { @@ -1479,18 > +1480,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, > mac.addr_bytes[0], mac.addr_bytes[1], > mac.addr_bytes[2], mac.addr_bytes[3], > mac.addr_bytes[4], mac.addr_bytes[5]); -#ifndef NDEBUG > - { > - char ifname[IF_NAMESIZE]; >=20 > - if (mlx5_get_ifname(eth_dev, &ifname) =3D=3D 0) > - DRV_LOG(DEBUG, "port %u ifname is \"%s\"", > + if (mlx5_get_ifname(eth_dev, &ifname) =3D=3D 0) { > + priv->if_index =3D if_nametoindex(ifname); > + DRV_LOG(DEBUG, "port %u ifname is \"%s\"", > eth_dev->data->port_id, ifname); > - else > - DRV_LOG(DEBUG, "port %u ifname is unknown", > - eth_dev->data->port_id); > + } else { > + DRV_LOG(DEBUG, "port %u ifname is unknown", > + eth_dev->data->port_id); > } > -#endif > + > /* Get actual MTU if possible. */ > err =3D mlx5_get_mtu(eth_dev, &priv->mtu); > if (err) { > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index > 5af3f413cdcb..a06ffd444255 100644 > --- a/drivers/net/mlx5/mlx5.h > +++ b/drivers/net/mlx5/mlx5.h > @@ -342,6 +342,7 @@ struct mlx5_priv { > uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */ > unsigned int vlan_filter_n; /* Number of configured VLAN filters. */ > /* Device properties. */ > + unsigned int if_index; /* Associated kernel network device index. */ > uint16_t mtu; /* Configured MTU. */ > unsigned int isolated:1; /* Whether isolated mode is enabled. */ > unsigned int representor:1; /* Device is a port representor. */ diff -- > git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > index eeefe4df3cd4..41e58db5e573 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -605,7 +605,6 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct > rte_eth_dev_info *info) > struct mlx5_priv *priv =3D dev->data->dev_private; > struct mlx5_dev_config *config =3D &priv->config; > unsigned int max; > - char ifname[IF_NAMESIZE]; >=20 > /* FIXME: we should ask the device for these values. */ > info->min_rx_bufsize =3D 32; > @@ -626,8 +625,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct > rte_eth_dev_info *info) > info->rx_offload_capa =3D (mlx5_get_rx_port_offloads() | > info->rx_queue_offload_capa); > info->tx_offload_capa =3D mlx5_get_tx_port_offloads(dev); > - if (mlx5_get_ifname(dev, &ifname) =3D=3D 0) > - info->if_index =3D if_nametoindex(ifname); > + info->if_index =3D priv->if_index; > info->reta_size =3D priv->reta_idx_n ? > priv->reta_idx_n : config->ind_table_max_size; > info->hash_key_size =3D MLX5_RSS_HASH_KEY_LEN; > -- > 2.20.1