public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Andreas Henriksson <andreas@fatal.se>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] iproute2: support dotted-quad netmask notation.
Date: Thu, 6 Dec 2007 11:53:50 -0800	[thread overview]
Message-ID: <20071206115350.18e9204f@freepuppy.rosehill> (raw)
In-Reply-To: <20071204135818.GA24419@scream.fatal.se>

On Tue, 4 Dec 2007 14:58:18 +0100
Andreas Henriksson <andreas@fatal.se> wrote:

> Suggested patch for allowing netmask to be specified in dotted quad format.
> See http://bugs.debian.org/357172
> 
> (Known problem: this will not prevent some invalid syntaxes,
> ie. "255.0.255.0" will be treated as "255.255.255.0")
> 
> Comments? Suggestions? Improvements?

Fix the bug you mentioned?

/* a valid netmask must be 2^n - 1 (n = 1..31) */
static int is_valid_netmask(const inet_prefix *addr)
{
	uint32_t host;

	if (addr->family != AF_INET)
		return 0;

	host = ~ntohl(addr->data[0]);
	if (host == 0 || ~host == 0)
		return 0;

	return (host & (host + 1)) == 0;
}

  reply	other threads:[~2007-12-06 19:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-04 13:58 [PATCH] iproute2: support dotted-quad netmask notation Andreas Henriksson
2007-12-06 19:53 ` Stephen Hemminger [this message]
2007-12-07 23:41   ` Andreas Henriksson
2007-12-09 17:10     ` Andreas Henriksson
2007-12-12  1:14       ` Stephen Hemminger
2007-12-12 11:55         ` Andreas Henriksson
2007-12-12 16:40           ` Stephen Hemminger

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=20071206115350.18e9204f@freepuppy.rosehill \
    --to=shemminger@linux-foundation.org \
    --cc=andreas@fatal.se \
    --cc=netdev@vger.kernel.org \
    /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