From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 4CDA937A2 for ; Thu, 7 Dec 2017 18:13:21 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id y82so1469546wmg.1 for ; Thu, 07 Dec 2017 09:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/twv6Z7ABC5ggNaYQBtsmmtkm8h52eGktU+hJTChKuE=; b=Hb35esBO7WiCKMJ+/Q65qgGVlndo16k3fZz52vZk1dJY0cSYmuTr8UwII72bxryVst VlcA94Kwr4FIq3ZEl3ewHRcbK61wWWcEQ56tVxoyO754zPjKDcOi+omDZhxZfrF0TEQ1 fS5Y1Q/4gJWKtDz7VHUMzfYi2YgyshsXNWZbF2GYhRQoSEPCl4TXzeHmzWuM6QdQCRlI 8x2X18+Tz/AnvVBCRsOg5u5l61V5h/igwxwqsB/NjcsnKesOCRiBmDtJRKZG3990OSBf 6U/uFlBOSpqeaEJFCJANrivPoKL4XaS3nFfxQR0fhkWd5vlpD8kgq00xnNh4CW20K9El lATQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/twv6Z7ABC5ggNaYQBtsmmtkm8h52eGktU+hJTChKuE=; b=ODUgWNF8U7w3VwphcaJj1V18u/l1fw48mCSn+Qlj7kExfXo7GnLUnus3moTwirXsOe yaGTP94oTJvfHRZJYFg9QHI9ex1r/VtRwDunvPdQbY+frItryY/Sf3oTG6uNyEAo+37j SfpSECT5XXkXqZqBmq9J8yXamOpS5IUPfv1HBB2MW3mpZlaMwZZWsszY+eUlGqJiwLG6 TssiHnnQ4+tocZdIqZUvOCtEFJqmTIy/KKFl/G+HdPIUUGkPfn0DEAImNanAsrJr79lP L1COZDbnto1A3a3BERkHJP2lFvyiI6PikSYTzBk74lp36NLuUGrmDgcLGG9OmORBsZvO yQSg== X-Gm-Message-State: AKGB3mLxt5zEhCoRDxGmB0Dfds94AP/MU4AxPPwTGI5wVlc1xGrS1h7Q DasaPX0N3AxU3VfvVXg30FPhJQ== X-Google-Smtp-Source: AGs4zMZesRl2GMw0I2Mp/apiwegZmOSZLUAgA0eHu+qZoBLu2O5Q4VCfv+7z2GBqeLALgWXvT8mHKA== X-Received: by 10.28.143.12 with SMTP id r12mr1712435wmd.44.1512666800926; Thu, 07 Dec 2017 09:13:20 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k11sm6273678wmi.18.2017.12.07.09.13.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 09:13:19 -0800 (PST) Date: Thu, 7 Dec 2017 18:13:07 +0100 From: Adrien Mazarguil To: "Xueming(Steven) Li" Cc: Olivier MATZ , "dev@dpdk.org" Message-ID: <20171207171307.GP4062@6wind.com> References: <20171115155402.9967-1-xuemingl@mellanox.com> <20171207144802.sgj33veeehxixhfk@glumotte.dev.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: init parse result memeory 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: , X-List-Received-Date: Thu, 07 Dec 2017 17:13:21 -0000 On Thu, Dec 07, 2017 at 03:35:24PM +0000, Xueming(Steven) Li wrote: > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xueming(Steven) Li > > Sent: Thursday, December 7, 2017 11:05 PM > > To: Olivier MATZ > > Cc: dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: init parse result memeory > > > > Hi Olivier, > > > > > -----Original Message----- > > > From: Olivier MATZ [mailto:olivier.matz@6wind.com] > > > Sent: Thursday, December 7, 2017 10:48 PM > > > To: Xueming(Steven) Li > > > Cc: dev@dpdk.org > > > Subject: Re: [PATCH] lib/cmdline: init parse result memeory > > > > > > On Wed, Nov 15, 2017 at 11:54:02PM +0800, Xueming Li wrote: > > > > Initialize binary result memory before parsing to avoid garbage in > > > > parsing result. > > > > > > > > Signed-off-by: Xueming Li > > > > --- > > > > lib/librte_cmdline/cmdline_parse.c | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/lib/librte_cmdline/cmdline_parse.c > > > > b/lib/librte_cmdline/cmdline_parse.c > > > > index 3e12ee54f..9124758f1 100644 > > > > --- a/lib/librte_cmdline/cmdline_parse.c > > > > +++ b/lib/librte_cmdline/cmdline_parse.c > > > > @@ -267,6 +267,8 @@ cmdline_parse(struct cmdline *cl, const char * buf) > > > > if (!cl || !buf) > > > > return CMDLINE_PARSE_BAD_ARGS; > > > > > > > > + memset(tmp_result.buf, 0, sizeof(tmp_result.buf)); > > > > + > > > > ctx = cl->ctx; > > > > > > > > /* > > > > > > > > > Did you see an issue (a bug or a crash) without the memset()? > > > Or is it to avoid filling unused fields in the parsed struct? > > Yes, I'm using same struct for some similar commands, have to avoid > > filling unused fields. > > > > > > > > I'm not sure if your patch is enough: cmdline_parse() calls > > > match_inst() for each registered command. If a command partially > > > matches (only the first tokens), the buffer is modified. So the next > > > one will start with a dirty buffer. > > > > > > I suggest to put the memset() in match_inst() instead. Something like > > this: > > > > > > if (resbuf != NULL) > > > memset(resbuf, 0, resbuf_size); > > > > > > > > > It will reset the buffer before using it. > > It was there for performance concern, since the buffer could be tainted, > > I'll upload a new version according to your suggestion, appreciate your > > suggestion. > Rte_flow CLI seems to be relying on modified buffer, add Adrien: > testpmd> flow create 0 ingress pattern eth / ipv4 / udp / vxlan / end actions rss queues 1 2 end level 1 / mark id 0x123456 / end > Caught error type 2 (flow rule (handle)): no valid action While the flow command relies on the contents of this buffer when parsing tokens, it doesn't expect it to be maintained across match_inst() calls. In fact another issue prevents Olivier's suggestion from working. Commit 9b3fbb051d2e ("cmdline: fix parsing") is supposed prevent further match_inst() calls after the right inst is found but doesn't break cmdline_parse()'s loop; subsequent iterations clear the result buffer. Here's a suggestion to try: diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 3e12ee5..e967410 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -338,8 +338,8 @@ cmdline_parse(struct cmdline *cl, const char * buf) err = CMDLINE_PARSE_AMBIGUOUS; f=NULL; debug_printf("Ambiguous cmd\n"); - break; } + break; } } -- Adrien Mazarguil 6WIND