Re: [netmod] Pattern statements [was Re: Query about augmenting module from submodule in YANG 1.0]

Vladimir Vassilev <vladimir@transpacket.com> Wed, 23 August 2017 18:10 UTC

Return-Path: <vladimir@transpacket.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id E54511329C1 for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 11:10:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8O3u4wC5UtxA for <netmod@ietfa.amsl.com>; Wed, 23 Aug 2017 11:10:00 -0700 (PDT)
Received: from mail.transpacket.com (s91205186171.blix.com [91.205.186.171]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 81EF213239C for <netmod@ietf.org>; Wed, 23 Aug 2017 11:10:00 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id 15BB61403A8A; Wed, 23 Aug 2017 20:09:58 +0200 (CEST)
Received: from mail.transpacket.com ([127.0.0.1]) by localhost (mail.transpacket.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cY-zaagLKdRe; Wed, 23 Aug 2017 20:09:58 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id E57291403A88; Wed, 23 Aug 2017 20:09:57 +0200 (CEST)
Received: from mail.transpacket.com ([127.0.0.1]) by localhost (mail.transpacket.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZEMLRQVfOKpX; Wed, 23 Aug 2017 20:09:57 +0200 (CEST)
Received: from [192.168.209.122] (s1853520235.blix.com [185.35.202.35]) by mail.transpacket.com (Postfix) with ESMTPSA id C2DB0140395E; Wed, 23 Aug 2017 20:09:57 +0200 (CEST)
From: Vladimir Vassilev <vladimir@transpacket.com>
To: Robert Wilton <rwilton@cisco.com>, "netmod@ietf.org" <netmod@ietf.org>
References: <E3378E0605547F4E854DEE0CB1116AB0210631@gbcdcmbx03.intl.att.com> <defe35bb-bb8b-f1f0-d8c4-2d2d0f23731b@transpacket.com> <1502290869.16638.15.camel@nic.cz> <20170809151312.GC42207@elstar.local> <6ef68131-f731-0edc-b731-d7ec85924f03@cisco.com> <E3378E0605547F4E854DEE0CB1116AB021CE2D@gbcdcmbx03.intl.att.com> <D5C05EB3.C2681%acee@cisco.com> <7614040f-9f8f-09c2-1854-63ad9ffb6be1@cisco.com> <5929631c-e51d-ae66-52d1-cbc87ca3506b@transpacket.com> <321a45fb-77e1-23c7-184b-d3bff9d41c39@cisco.com> <20170823133657.76s5wbcxbpgjfkiy@elstar.local>
Message-ID: <9fc4b41f-5994-79f6-43dc-f3ba5b09f36d@transpacket.com>
Date: Wed, 23 Aug 2017 20:09:57 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0
MIME-Version: 1.0
In-Reply-To: <20170823133657.76s5wbcxbpgjfkiy@elstar.local>
Content-Type: text/plain; charset="windows-1252"; format="flowed"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/mtHhc2eI4vCuU6Kei2k4NNY8xLI>
Subject: Re: [netmod] Pattern statements [was Re: Query about augmenting module from submodule in YANG 1.0]
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Aug 2017 18:10:03 -0000

On 08/23/2017 03:36 PM, Juergen Schoenwaelder wrote:

> On Wed, Aug 23, 2017 at 02:23:12PM +0100, Robert Wilton wrote:
>> 1) Email address.  I understand that the full regex to validate all email
>> addresses is very complex, but checking that it at least contains an @
>> symbol still has benefit.  It would seem that a short imperfect regex is
>> better than a complete perfect regex.
> What is your definition of 'better'? A stricter pattern catches more
> errors. An imperfect pattern is better than none.
In the case of e-mail address string pattern complying without 
exceptions to rfc5322#section-3.4 specification a ~500 characters of 
pattern expression is needed. There is value in defining data types that 
can be automatically verified by YANG. IMO in this case a strict pattern 
is justified.
>> 2) A list of VLAN ranges, e.g. want to allow strings that look like this:
>> "1-10,20-400,600,2000-3000", but only with non overlapping values in
>> ascending order.  It is easy to write a regex to check that the structure is
>> right, but AFAIK it is hard (impossible?) to write a regex that ensures that
>> the ranges don't overlap and are specified in ascending order.
> So what. Does this provide a helpful argument whether patterns should
> be strict or imperfect?
IMO loading strings with semantics instead of using YANG is example of 
bad model design. There is no RFC (like in the e-mail example) that 
mandates use of string with complex format instead of YANG to model 
range configuration. Complex strings can and should be avoided in cases 
like this one.
>> So, I propose that we use regexes for checking that the string is
>> structurally correct, but don't use regexes to perform numerical range
>> checks of string encoded numbers, since it makes the regexes hard to
>> read/verify, and doesn't improve the readability of the YANG file either.
> So here is the point I think:
> c.
>     It is desirable that regexes are as strict as they can be.
>     However, if regexes become so complicated that they become a
>     verification and maintenance problem by themself, then less strict
>     regexes may be a better choice.
I agree. But it is the enthropy of having configuration that can not be 
strictly validated by model aware automation tools that has been the 
reason for introduction of leafref, must, when, range, pattern etc. So 
giving up the goal of handling validation in automated model driven way 
to the advantage of readability is a tough compromise.

I agree with Rob that the pattern in draft-ietf-rtgwg-routing-types-09 
is complicated to read. I have the feeling the design can be improved 
without compromising the strictnes of the data type. Redefinig the 
typedef as a union of 5 string based types with seperate strict patterns 
is one suggestion for moving logic from the string type to YANG.

Vladimir
> /js
>