Re: [netmod] 6991bis: address-with-prefix-length

"Rob Wilton (rwilton)" <> Tue, 23 April 2019 16:45 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 417C312011A for <>; Tue, 23 Apr 2019 09:45:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -14.501
X-Spam-Status: No, score=-14.501 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: (amavisd-new); dkim=pass (1024-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id 64NMbDWO5ixR for <>; Tue, 23 Apr 2019 09:45:55 -0700 (PDT)
Received: from ( []) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id BFADB12021D for <>; Tue, 23 Apr 2019 09:45:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;;; l=7567; q=dns/txt; s=iport; t=1556037955; x=1557247555; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=bpC6YIq69u6PTU0yDdkptXADRquyOrYaekr7dcFm2jY=; b=B5gOmDZgRZFnUM5PeYR039ewXef5+7DJAa92tfu2az8vAQmPvmeshD6p 4byNAPSjZ+UxnPdWMhpyThJ/nEc7GT4gUrGgdnULSqEIxla7utBvkjNVB yeAUXhrgWUpTCxBLVQ99o1v2NEg4D7L35UwIj/7YopOC9iUSWpn2PPyU1 U=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AFAAA1QL9c/4oNJK1mGQEBAQEBAQE?= =?us-ascii?q?BAQEBAQcBAQEBAQGBUgMBAQEBAQsBghBogQQoCpk7mEuBew4BARgNhAJGAoY?= =?us-ascii?q?nIzUIDgEDAQEEAQECAQJtHAyFSgEBAQMBAQE4NAsFBwQCAQgOAgEEAQEBHhA?= =?us-ascii?q?nCx0IAgQBDQUIE4MIgXkPD6pJhDYChW4GgTIBi0kXgUA/hCM+gmEBAQOBN4Y?= =?us-ascii?q?IBIprCDIDiE6RfGQJAoIIhg+MEyOVFIwEhj2NfgIRFYEwIQE1gVZwFTuCbIE?= =?us-ascii?q?YgQMXiGCFP0ExjiCBMYEhAQE?=
X-IronPort-AV: E=Sophos;i="5.60,386,1549929600"; d="scan'208";a="266108934"
Received: from ([]) by with ESMTP/TLS/DHE-RSA-SEED-SHA; 23 Apr 2019 16:45:54 +0000
Received: from ( []) by (8.15.2/8.15.2) with ESMTPS id x3NGjs6G010976 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 23 Apr 2019 16:45:54 GMT
Received: from ( by ( with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 23 Apr 2019 11:45:53 -0500
Received: from ([]) by ([]) with mapi id 15.00.1473.003; Tue, 23 Apr 2019 11:45:53 -0500
From: "Rob Wilton (rwilton)" <>
To: Martin Bjorklund <>, "" <>
CC: "" <>
Thread-Topic: [netmod] 6991bis: address-with-prefix-length
Date: Tue, 23 Apr 2019 16:45:53 +0000
Message-ID: <>
References: <> <> <> <>
In-Reply-To: <>
Accept-Language: en-GB, en-US
Content-Language: en-US
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: []
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Archived-At: <>
Subject: Re: [netmod] 6991bis: address-with-prefix-length
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 23 Apr 2019 16:45:58 -0000

I'm with Kristian on this. :-)

I also think that "" contains an IP addresses, and the length of the IP prefix.

For me, the natural encoding of:
  ip-address-and-prefix would be ""
  ip-address-and-prefix-mask would be ""
  ip-address-and-prefix-len would be ""

I think that only the first one actually contains both the IP address and the prefix.  For the other two the prefix is derived from the provided values.


I also think that it is useful to define this type, because types like this are being used in various vendor models.

However, I do have a concern that we may be opening IETF up for inconsistency with the IETF YANG models if different protocols define this in different ways.  Perhaps the answer is to define both the combined type and the equivalent grouping, and also perhaps highlight in the description of the grouping of the two alternative representations that are available.


-----Original Message-----
From: netmod <> On Behalf Of Martin Bjorklund
Sent: 23 April 2019 11:55
Subject: Re: [netmod] 6991bis: address-with-prefix-length

Kristian Larsson <> wrote:
> On 2019-04-18 14:18, Martin Bjorklund wrote:
> > Juergen Schoenwaelder <> wrote:
> >> On Thu, Apr 18, 2019 at 10:41:11AM +0200, Ladislav Lhotka wrote:
> >>>>>
> >>>>> I am not in favour of adding this type. Having ip-prefix next to 
> >>>>> ip-address-and-prefix is confusing.
> >>>>
> >>>> Confusing or not, they are NOT interchangeable and actually do 
> >>>> different things, which is why both are needed. There's plenty of 
> >>>> precedence to
> >>>
> >>> I actually agree with you. It is a historical accident that these 
> >>> two different things got mixed up (and some vendors contributed to 
> >>> this). I would argue that
> >>>
> >>> - IP prefix is a set of IP addresses, and as such can be thought of
> >>>    as a single entity.
> >>>
> >>> - IP address and subnet mask/prefix are two separate things, the
> >>>    latter being an instruction for routing to *other* destination
> >>>    addresses.
> >>
> >> I think we should be pragmatic. There are other common types that 
> >> are in fact constructed out of simpler types, date-and-time is a 
> >> prime example of a type constructed out of a date value and a time value.
> > I think that date-and-time represents one thing - a single point in 
> > time.
> Convenient for users to enter a single point in time in terms of year, 
> month, day, hours, minutes and seconds, perhaps. But not as convenient 
> for a program that needs to compare two date-and-times.

Actually, *comparing* works quite ok, but calculating diff is not as easy.

> Clearly for a
> program comparing times against each other we must represent a point 
> in time as the number of vibrations of cesium since an arbitrarily 
> chosen epoch.

We do have yang:timeticks as well.  In some cases that's a better type than yang:date-and-time.

> >> is sometimes convenient to treat something that is in fact 
> >> constructed as an atomic value.
> > Convenient for users that enter these values, perhaps.  But not as 
> > convenient for a program (or a filter) that needs one of the 
> > combined values.
> Really? Are you using a text representation of IP addresses when you 
> handle them in your program?
> If you are to deal with IP addresses, prefixes etc in a robust way in 
> your program, you need an internal datatype that understands what an 
> address is - it needs to handle it as bits and massage it to any other 
> presentation you want. It needs to understand relevant comparisons and 
> operations, like is prefix A contained in prefix B?

I agree.  Note that I wrote *filter* above.  It also extends to must/when expressions.  The problem is that these mechanisms use XPath, and XPath is quite limited when it comes to "understanding"
types.  I even wrote a (now expired) draft with a proposed solution:

> Or if we are dealing with time, then a class that understands leap 
> years, leap seconds, time zones etc can be fairly useful so you don't 
> have to fall in any of those pitfalls.
> I don't think we choose a format or representation in our YANG models 
> primarily to suit the algorithmic needs of a computer program, in that 
> case an IPv4 address would just be a uint32 and not the dotted quad 
> format we have today.
> >  For example, suppose I want to find all entries with a given 
> > prefix; that is non-trivial with a combined ip-address-and-prefix 
> > type.
> This seems like a very weird example since it doesn't support your 
> case; it is not easier with two separate leaves!?
> The alternative to using ip-address-and-prefix-length would be to use 
> two leaves; one for the address and the other for the subnet mask / 
> prefix-length.
> combined:
> ip-address-and-prefix-length: 
> split:
> address:
> prefix-length: 24
> Say we have another interface with address '' (prefix-length 24 
> still). In what way is it easier to determine these are part of the 
> same IP prefix / subnetwork by having the values split in two leaves?

As have been said before in this thread, it is not an address and a prefix length, it is an address and a prefix.  So the split model would have a leaf "ip-prefix:", which can be compared.

> There is no text operation that can easily do this for us - we need to 
> parse the values with some class / type in our programming language 
> that helps us make this comparison so in what way is 
> ip-address-and-prefix-length worse?
> Let us look at some examples how this is typically done. Again, 
> postgresql has the 'inet' type. From the docs:
> "The input format for this type is address/y where address is an IPv4 
> or IPv6 address and y is the number of bits in the netmask. If the /y 
> portion is missing, the netmask is 32 for IPv4 and 128 for IPv6, so 
> the value represents just a single host. On display, the /y portion is 
> suppressed if the netmask specifies a single host."
> It wants it combined, which means the two leaves need to be formatted 
> into something that looks like
> Python ipaddress.IPv4, from example:
>   interface = IPv4Interface('')
> Same thing. Rust ipaddress? Same thing. Go net? Same. Our internal 
> classes that compute IP addressing? Same thing. It seems most of the 
> datatypes that natively handle this kind of information takes a text 
> format like as input (and not as separate fields), which is 
> what is being suggested we have a datatype for.

Is your point that there exist libraries that _can_ handle "<addr>/<plen>", or are you suggesting that it is problematic to have separate objects b/c libraries _only_ handle "<addr>/<plen>"?

If it is the former, I agree.  There exist functions that can handle this format.


netmod mailing list