From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <reshma.pattan@intel.com>
Received: from mga06.intel.com (mga06.intel.com [134.134.136.31])
 by dpdk.org (Postfix) with ESMTP id A664E374F
 for <dev@dpdk.org>; Wed, 28 Sep 2016 16:03:58 +0200 (CEST)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by orsmga104.jf.intel.com with ESMTP; 28 Sep 2016 07:03:57 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.30,410,1470726000"; d="scan'208";a="1063453404"
Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3])
 by fmsmga002.fm.intel.com with ESMTP; 28 Sep 2016 07:03:56 -0700
Received: from irsmsx109.ger.corp.intel.com ([169.254.13.6]) by
 IRSMSX108.ger.corp.intel.com ([169.254.11.164]) with mapi id 14.03.0248.002;
 Wed, 28 Sep 2016 15:03:56 +0100
From: "Pattan, Reshma" <reshma.pattan@intel.com>
To: "Kerlin, MarcinX" <marcinx.kerlin@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
CC: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>,
 "thomas.monjalon@6wind.com" <thomas.monjalon@6wind.com>, "Kerlin, MarcinX"
 <marcinx.kerlin@intel.com>
Thread-Topic: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against
 overwrite device data
Thread-Index: AQHSGLFeMtQL81mItkSL8tsNcWCPBKCO78AQ
Date: Wed, 28 Sep 2016 14:03:54 +0000
Message-ID: <3AEA2BF9852C6F48A459DA490692831F010A91F9@IRSMSX109.ger.corp.intel.com>
References: <1474901586-8706-2-git-send-email-marcinx.kerlin@intel.com>
 <1474974783-4861-1-git-send-email-marcinx.kerlin@intel.com>
 <1474974783-4861-2-git-send-email-marcinx.kerlin@intel.com>
In-Reply-To: <1474974783-4861-2-git-send-email-marcinx.kerlin@intel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzBhNWNjOGEtOGVmMy00NDlkLTg2ZTctYTZjMzFmZTQyNjY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImxFemw2b0oxVkZwelhXMGdaeDdmam9yaEVWRHRVdUxoalorTHBLV0xtUnM9In0=
x-ctpclassification: CTP_IC
x-originating-ip: [163.33.239.182]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection
	against	overwrite device data
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 28 Sep 2016 14:03:59 -0000



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marcin Kerlin
> Sent: Tuesday, September 27, 2016 12:13 PM
> To: dev@dpdk.org
> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> thomas.monjalon@6wind.com; Kerlin, MarcinX <marcinx.kerlin@intel.com>
> Subject: [dpdk-dev] [PATCH v4 1/2] librte_ether: add protection against
> overwrite device data
>=20
> +int
> +rte_eth_dev_release_dev_data(uint8_t port_id) {
> +	char device[RTE_ETH_NAME_MAX_LEN];
> +	struct rte_eth_dev_data *eth_dev_data =3D NULL;
> +
> +
> @@ -631,6 +691,8 @@ int
>  rte_eth_dev_detach(uint8_t port_id, char *name)  {
>  	struct rte_pci_addr addr;
> +	struct rte_eth_dev_data *eth_dev_data =3D NULL;
> +	char device[RTE_ETH_NAME_MAX_LEN];
>  	int ret =3D -1;
>=20
>  	if (name =3D=3D NULL) {
> @@ -642,6 +704,15 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
>  	if (rte_eth_dev_is_detachable(port_id))
>  		goto err;
>=20
> +	/* get device name by port id */
> +	if (rte_eth_dev_get_name_by_port(port_id, device))
> +		goto err;
> +
> +	/* look for an entry in the shared device data */
> +	eth_dev_data =3D rte_eth_dev_get_dev_data_by_name(device);
> +	if (eth_dev_data =3D=3D NULL)
> +		goto err;
> +
>  	if (rte_eth_dev_get_device_type(port_id) =3D=3D RTE_ETH_DEV_PCI) {
>  		ret =3D rte_eth_dev_get_addr_by_port(port_id, &addr);
>  		if (ret < 0)
> @@ -661,6 +732,9 @@ rte_eth_dev_detach(uint8_t port_id, char *name)
>  			goto err;
>  	}
>=20
> +	/* clear an entry in the shared device data */
> +	memset(eth_dev_data, 0, sizeof(struct rte_eth_dev_data));
> +
>  	return 0;
>=20

In this function, the new code chunks  together is nothing but the function=
 " rte_eth_dev_release_dev_data()".
So u can call the function itself rather than a duplicate code. =20

Thanks,
Reshma