From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id CD3D8DE0 for ; Mon, 21 Dec 2015 12:40:23 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 21 Dec 2015 03:40:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,459,1444719600"; d="scan'208";a="845708811" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by orsmga001.jf.intel.com with ESMTP; 21 Dec 2015 03:40:22 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.23]) by IRSMSX109.ger.corp.intel.com ([169.254.13.96]) with mapi id 14.03.0248.002; Mon, 21 Dec 2015 11:40:21 +0000 From: "Iremonger, Bernard" To: "Qiu, Michael" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] librte_ether: fix crashes in rte_ethdev functions. Thread-Index: AQHROO/UmpUTQo5ZyUOEPvtR/E1pS57VT/kw Date: Mon, 21 Dec 2015 11:40:20 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C219F9120C@IRSMSX108.ger.corp.intel.com> References: <1450373016-16356-1-git-send-email-bernard.iremonger@intel.com> <533710CFB86FA344BFBF2D6802E6028622EFB065@SHSMSX101.ccr.corp.intel.com> In-Reply-To: <533710CFB86FA344BFBF2D6802E6028622EFB065@SHSMSX101.ccr.corp.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGJiYTQ4NmItZDkzYi00OWUwLTlkMTMtNDQ5OGM5NzNhMmEzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNS40LjEwLjE5IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ik8zc0JraWNaRm9ERG9GMGc4emMwenJmV3dpS3FYeWNEQStadThKTk9IZms9In0= x-ctpclassification: CTP_PUBLIC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] librte_ether: fix crashes in rte_ethdev functions. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2015 11:40:24 -0000 Hi Michael, > -----Original Message----- > From: Qiu, Michael > Sent: Monday, December 21, 2015 9:03 AM > To: Iremonger, Bernard ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] librte_ether: fix crashes in rte_ethdev > functions. >=20 > On 2015/12/18 1:24, Bernard Iremonger wrote: > > The nb_rx_queues and nb_tx_queues are initialised before the tx_queue > > and rx_queue arrays are allocated. The arrays are allocated when the > > ethdev port is started. > > > > If any of the following functions are called before the ethdev port is > > started there is a segmentation fault: > > > > rte_eth_stats_get > > rte_eth_stats_reset > > rte_eth_xstats_get > > rte_eth_xstats_reset > > > > Fixes: af75078fece3 ("first public release") > > Fixes: ce757f5c9a4d ("ethdev: new method to retrieve extended > > statistics") > > Fixes: d4fef8b0d5e5 ("ethdev: expose generic and driver specific stats > > in xstats") > > Signed-off-by: Bernard Iremonger > > --- > > lib/librte_ether/rte_ethdev.c | 16 ++++++++++++---- > > 1 file changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/lib/librte_ether/rte_ethdev.c > > b/lib/librte_ether/rte_ethdev.c index ed971b4..a0ee84d 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -1441,7 +1441,10 @@ rte_eth_stats_get(uint8_t port_id, struct > rte_eth_stats *stats) > > memset(stats, 0, sizeof(*stats)); > > > > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, - > ENOTSUP); > > - (*dev->dev_ops->stats_get)(dev, stats); > > + > > + if (dev->data->dev_started) > > + (*dev->dev_ops->stats_get)(dev, stats); > > + >=20 > My question is should we mark an error or a warning here and return an > error so that the caller knows what happens? >=20 > Thanks, > Michael In other cases in rte_ethdev.c where there is a check on "dev->data->dev_st= arted" there is a RTE_PMD_DEBUG_TRACE() line. I will add a RTE_PMD_DEBUG_T= RACE() line. The rte_eth_stats_reset() and rte_eth_xstats_reset() functions return void. Not sure if an error is required for the rte_eth_stats_get() and rte_eth_xs= tats_get() functions as the stats information returned is all zero's at pre= sent. Regards, Bernard.