DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [RFC] net: be more restrictive in ether_unformat_addr
Date: Thu, 18 Jul 2019 11:29:57 -0700	[thread overview]
Message-ID: <20190718112957.3f7c5c73@xps13> (raw)
In-Reply-To: <20190718074703.7mjsnliicnx5eexq@platinum>

On Thu, 18 Jul 2019 09:47:03 +0200
Olivier Matz <olivier.matz@6wind.com> wrote:

> Hi,
> 
> I'm fine with a more strict version like you proposed here. I checked
> that the cmdline tests pass.
> 
> Few minor comments below.
> 
> On Wed, Jul 17, 2019 at 11:49:45AM -0700, Stephen Hemminger wrote:
> > The current code acts more like BSD ether_aton and allows leading zeros
> > which breaks the cmdline tests.
> > 
> > Change the code to be more restrictive and only allow the fully
> > expanded standard formats.
> > 
> > Fixes: 596d31092d32 ("net: add function to convert string to ethernet address")
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>  
> 
> Can you add the bugzilla id ?
> https://bugs.dpdk.org/show_bug.cgi?id=324

Sure, will do.
I wish there was a one week delay during development and reserve Bugzilla
for stuff in released code.

> > +	for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) {
> > +		int8_t x;
> > +
> > +		x = get_xdigit(*s++);
> > +		if (x < 0)
> > +			return false;
> > +		ea->addr_bytes[i] = x << 4;
> > +		x = get_xdigit(*s++);
> > +		if (x < 0)
> > +			return false;
> > +		ea->addr_bytes[i] |= x;  
> 
> Maybe we should say in the API doc that ether address can be modified
> even if parsing fails.
> 


No. Standard practice is that the state of returned data is undefined in any 
function that returns an error.

> > -	} else {
> > -		/* unknown format */
> > -		rte_errno = EINVAL;
> > +	if  (get_ether_addr6(s, ea) || get_ether_addr3(s, ea))
> > +		return 0;
> > +	else {
> > +		rte_errno = -EINVAL;
> >  		return -1;  
> 
> rte_errno should be positive

Will fix.
 


  reply	other threads:[~2019-07-18 18:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 18:49 Stephen Hemminger
2019-07-18  7:47 ` Olivier Matz
2019-07-18 18:29   ` Stephen Hemminger [this message]
2019-07-18 18:35 ` [dpdk-dev] [PATCH v2] net: be more restrictive in accepted ether string formats Stephen Hemminger
2019-07-19 13:42   ` Olivier Matz
2019-07-19 17:46     ` Ferruh Yigit

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=20190718112957.3f7c5c73@xps13 \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.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).