DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: "Xueming(Steven) Li" <xuemingl@mellanox.com>
Cc: Olivier MATZ <olivier.matz@6wind.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] lib/cmdline: init parse result memeory
Date: Thu, 7 Dec 2017 18:13:07 +0100	[thread overview]
Message-ID: <20171207171307.GP4062@6wind.com> (raw)
In-Reply-To: <VI1PR0502MB40795CFEF8A79D18E991BC15AC330@VI1PR0502MB4079.eurprd05.prod.outlook.com>

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 <olivier.matz@6wind.com>
> > 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 <xuemingl@mellanox.com>
> > > 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 <xuemingl@mellanox.com>
> > > > ---
> > > >  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

  reply	other threads:[~2017-12-07 17:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 15:54 Xueming Li
2017-12-07 14:48 ` Olivier MATZ
2017-12-07 15:05   ` Xueming(Steven) Li
2017-12-07 15:35     ` Xueming(Steven) Li
2017-12-07 17:13       ` Adrien Mazarguil [this message]
2017-12-08  7:02 ` [dpdk-dev] [PATCH v1] lib/cmdline: init parse result memory Xueming Li
2017-12-08 12:27   ` Adrien Mazarguil
2017-12-08 13:51     ` Olivier MATZ
2017-12-08 14:50       ` Xueming(Steven) Li
2017-12-08 15:04       ` Adrien Mazarguil
2017-12-08 15:26         ` Olivier MATZ
2017-12-09 15:39 ` [dpdk-dev] [PATCH v2] lib/cmdline: init CLI parsing memory Xueming Li
2017-12-14 15:35   ` Olivier MATZ
2017-12-18 10:51     ` Adrien Mazarguil
2017-12-18 13:44       ` Xueming(Steven) Li
2017-12-26 12:57     ` Xueming(Steven) Li
2018-01-16 12:45       ` Olivier Matz
2018-01-18  4:29         ` Xueming(Steven) Li
2018-01-19  9:07           ` Olivier Matz
2018-01-19 18:18             ` Xueming(Steven) Li
2018-01-19 18:16 ` [dpdk-dev] [PATCH v3] cmdline: fix dynamic tokens parsing Xueming Li
2018-01-22 13:13   ` Olivier Matz
2018-01-25 22:14     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171207171307.GP4062@6wind.com \
    --to=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=xuemingl@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).