From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9A70FC498 for ; Thu, 23 Jun 2016 13:24:08 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 23 Jun 2016 04:24:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,509,1459839600"; d="scan'208";a="993577883" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.220.161]) by fmsmga001.fm.intel.com with SMTP; 23 Jun 2016 04:24:05 -0700 Received: by (sSMTP sendmail emulation); Thu, 23 Jun 2016 12:24:05 +0025 Date: Thu, 23 Jun 2016 12:24:04 +0100 From: Bruce Richardson To: Nelson Escobar Cc: dev@dpdk.org, johndale@cisco.com Message-ID: <20160623112404.GF5024@bricha3-MOBL3> References: <1465948348-10333-1-git-send-email-neescoba@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1465948348-10333-1-git-send-email-neescoba@cisco.com> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] enic: fix name of hash table used for enic classifiers 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: Thu, 23 Jun 2016 11:24:09 -0000 On Tue, Jun 14, 2016 at 04:52:28PM -0700, Nelson Escobar wrote: > The enic_clsf_init() function is called once per enic instance, but it > used a static name to create the hash table. Consequently when using > more than one enic instance, there was a name collision which caused > errors: > > EAL: memzone_reserve_aligned_thread_unsafe(): > memzone already exists > RING: Cannot reserve memory > HASH: memory allocation failed > PMD: rte_enic_pmd: Init of hash table for clsf failed. > Flow director feature will not work > > This patch changes the name to be unique per enic instance. > > Fixes: fefed3d1e62c ("enic: new driver") > > Signed-off-by: Nelson Escobar > Reviewed-by: John Daley > --- > drivers/net/enic/enic_clsf.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c > index edb56e1..2ec77f5 100644 > --- a/drivers/net/enic/enic_clsf.c > +++ b/drivers/net/enic/enic_clsf.c > @@ -239,15 +239,16 @@ void enic_clsf_destroy(struct enic *enic) > > int enic_clsf_init(struct enic *enic) > { > + char clsf_name[RTE_HASH_NAMESIZE]; > struct rte_hash_parameters hash_params = { > - .name = "enicpmd_clsf_hash", > + .name = clsf_name, > .entries = ENICPMD_CLSF_HASH_ENTRIES, > .key_len = sizeof(struct rte_eth_fdir_filter), > .hash_func = DEFAULT_HASH_FUNC, > .hash_func_init_val = 0, > .socket_id = SOCKET_ID_ANY, > }; > - > + sprintf(clsf_name, "enic_clsf_%s", enic->bdf_name); To avoid buffer overflow it's safer to use snprintf rather than sprintf. snprintf(clsf_name, sizeof(clsf_name), .... ); /Bruce > enic->fdir.hash = rte_hash_create(&hash_params); > memset(&enic->fdir.stats, 0, sizeof(enic->fdir.stats)); > enic->fdir.stats.free = ENICPMD_FDIR_MAX; > -- > 2.7.0 >