netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Krzysztof Oledzki <ole@ans.pl>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	netdev@vger.kernel.org
Subject: Re: Error: an inet prefix is expected rather than "0/0".
Date: Tue, 14 Oct 2008 20:38:10 +0100	[thread overview]
Message-ID: <1224013090.3984.165.camel@achroite> (raw)
In-Reply-To: <20081014121855.2f931be0@extreme>

On Tue, 2008-10-14 at 12:18 -0700, Stephen Hemminger wrote:
> On Tue, 14 Oct 2008 21:15:18 +0200 (CEST)
> Krzysztof Oledzki <ole@ans.pl> wrote:
> 
> > 
> > 
> > On Tue, 14 Oct 2008, Stephen Hemminger wrote:
[...]
> > > Busted cases:
> > >                           correct           incorrect
> > > Original code: 127.2   =>  127.0.0.2         127.2.0.0
> > > inet_pton:     10.0    =>  10.0.0.0          fails invalid
> > > inet_aton:     10      =>  10.0.0.0          0.0.0.10
> > >
> > > The problem was Alexey (or Jamal) invented their own abbreviation format
> > > and did not follow unix standard conventions.
> > 
> > It seems that the original code followed the unix standard:
> > 
> > # telnet 127.2
> > Trying 127.0.0.2...
> > telnet: connect to address 127.0.0.2: Connection refused
> 
> The incorrect column lists the actual result for each of the routines.
> Original code converted 127.2 to 127.2.0.0
[...]

If only the one-component case needs to be treated specially then you
should be able to use something like:

	/* For backward compatibility, if name is all digits we treat it as
	 * the top 8 bits of an IPv4 address. */
	if (strspn(name, "0123456789") == strlen(name))
		addr->data[0] = atoi(name);
	else if (inet_aton(name, addr->data) > 0)
		;
	else
 		return -1;

But if people also rely on e.g. 192.168/16 working then it gets
trickier.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  reply	other threads:[~2008-10-14 19:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08 21:05 Error: an inet prefix is expected rather than "0/0" Krzysztof Oledzki
2008-10-08 21:32 ` Krzysztof Oledzki
2008-10-14 14:01   ` Herbert Xu
2008-10-14 17:46     ` Stephen Hemminger
2008-10-14 19:15       ` Krzysztof Oledzki
2008-10-14 19:18         ` Stephen Hemminger
2008-10-14 19:38           ` Ben Hutchings [this message]
2008-10-14 21:52       ` Patrick McHardy
2008-10-14 21:54         ` Patrick McHardy
2008-10-15  1:46       ` Herbert Xu
2008-10-15 15:35         ` Krzysztof Halasa
2008-10-15 16:07           ` Ben Hutchings
2008-10-15 18:52             ` Krzysztof Halasa
2008-10-27 17:39               ` Stephen Hemminger
2008-10-28  1:51                 ` Herbert Xu

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=1224013090.3984.165.camel@achroite \
    --to=bhutchings@solarflare.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@vger.kernel.org \
    --cc=ole@ans.pl \
    --cc=shemminger@vyatta.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).