Re: [yang-doctors] guideline for enum and value?

Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> Thu, 25 January 2018 10:51 UTC

Return-Path: <j.schoenwaelder@jacobs-university.de>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 1E01A12DA05 for <yang-doctors@ietfa.amsl.com>; Thu, 25 Jan 2018 02:51:30 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=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 ZQ_qM0PzYSDa for <yang-doctors@ietfa.amsl.com>; Thu, 25 Jan 2018 02:51:27 -0800 (PST)
Received: from atlas5.jacobs-university.de (atlas5.jacobs-university.de [212.201.44.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id B49F5126CBF for <yang-doctors@ietf.org>; Thu, 25 Jan 2018 02:51:26 -0800 (PST)
Received: from localhost (demetrius5.irc-it.jacobs-university.de [10.70.0.222]) by atlas5.jacobs-university.de (Postfix) with ESMTP id 82B156BA; Thu, 25 Jan 2018 11:51:25 +0100 (CET)
X-Virus-Scanned: amavisd-new at jacobs-university.de
Received: from atlas5.jacobs-university.de ([10.70.0.217]) by localhost (demetrius5.jacobs-university.de [10.70.0.222]) (amavisd-new, port 10032) with ESMTP id wwWED-RZRk_p; Thu, 25 Jan 2018 11:51:24 +0100 (CET)
Received: from hermes.jacobs-university.de (hermes.jacobs-university.de [212.201.44.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hermes.jacobs-university.de", Issuer "Jacobs University CA - G01" (verified OK)) by atlas5.jacobs-university.de (Postfix) with ESMTPS; Thu, 25 Jan 2018 11:51:25 +0100 (CET)
Received: from localhost (demetrius3.jacobs-university.de [212.201.44.48]) by hermes.jacobs-university.de (Postfix) with ESMTP id 689202014B; Thu, 25 Jan 2018 11:51:25 +0100 (CET)
X-Virus-Scanned: amavisd-new at jacobs-university.de
Received: from hermes.jacobs-university.de ([212.201.44.23]) by localhost (demetrius3.jacobs-university.de [212.201.44.32]) (amavisd-new, port 10024) with ESMTP id Lr7U_tvPR_yE; Thu, 25 Jan 2018 11:51:24 +0100 (CET)
Received: from elstar.local (unknown [10.50.231.133]) by hermes.jacobs-university.de (Postfix) with ESMTP id 6DF9920149; Thu, 25 Jan 2018 11:51:24 +0100 (CET)
Received: by elstar.local (Postfix, from userid 501) id 5A33F422941C; Thu, 25 Jan 2018 11:51:24 +0100 (CET)
Date: Thu, 25 Jan 2018 11:51:24 +0100
From: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>
To: Benoit Claise <bclaise@cisco.com>
Cc: Martin Bjorklund <mbj@tail-f.com>, yang-doctors@ietf.org, "Einar Nilsen-Nygaard (einarnn)" <einarnn@cisco.com>
Message-ID: <20180125105124.a3c7qupkheejjf55@elstar.local>
Reply-To: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>
Mail-Followup-To: Benoit Claise <bclaise@cisco.com>, Martin Bjorklund <mbj@tail-f.com>, yang-doctors@ietf.org, "Einar Nilsen-Nygaard (einarnn)" <einarnn@cisco.com>
References: <c3d21c6e-8cc0-e109-4b81-278242d70071@cisco.com> <20180125083753.kngg2f3zysxq4qbm@elstar.local> <20180125.095921.224499312159563778.mbj@tail-f.com> <20180125091118.tjn5eiv2hzmc7k23@elstar.local> <dfb94426-c408-e215-e23b-539e127050a2@cisco.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <dfb94426-c408-e215-e23b-539e127050a2@cisco.com>
User-Agent: NeoMutt/20171215
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/N6uWBnMEJWDBa43s2jNo8WNS--I>
Subject: Re: [yang-doctors] guideline for enum and value?
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 25 Jan 2018 10:51:30 -0000

On Thu, Jan 25, 2018 at 11:26:05AM +0100, Benoit Claise wrote:
> 
> > On Thu, Jan 25, 2018 at 09:59:21AM +0100, Martin Bjorklund wrote:
> > > Hi,
> > > 
> > > Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de> wrote:
> > > > On Thu, Jan 25, 2018 at 09:18:27AM +0100, Benoit Claise wrote:
> > > > > Dear all,
> > > > > 
> > > > > Still busy with the RFC6087bis AD review, reviewing the enum sections now.
> > > > > 
> > > > > Do I recall correctly a guideline about not using "value" in enum?
> > > I think this was a discussion on YANG 1.1, not 6087bis (but I might be
> > > wrong).
> > > 
> > > > > Something to be inserted in RFC6087bis? At least a pros and cons discussion?
> > > > > 
> > > > I would rather say the opposite:
> > > > 
> > > >    YANG automatically assigns numeric values to enums if no values are
> > > >    specified. This automatic assignment requires that (a) the order of
> > > >    enums never changes and (b) additional enums are only appended but
> > > >    never prepended or inserted. This is subtle and using explicit value
> > > >    assignments, though more verbose, tends to be more robust when
> > > >    modules are revised.
> > > Is this a recommendation to always use the "value" statement?  I don't
> > > think now is the right time to add such an recommendation, and I don't
> > > think it should be recommended.  Maybe we could say something about
> > > taking care when adding an enum, but RFC 7950, section 11, bullet 1
> > > already says that value must not change, so we would essentially just
> > > say that you must follow the rules of 7950.
> > > 
> > The text I wrote explains the issue. It does not say you have to use
> > explicit value assignments (but if you want to be robust, then its
> > probably a good idea to use explicit assignments).
> > 
> > The fact that Benoit did not recall this correctly is likely an
> > indication that people not deeply involved in YANG do not necessarily
> > memorize this subtlety. Not everybody knows RFC 7950 by heart. (But
> > yes, not everybody will read RFC6087bis either and there are likely
> > quite a few things in RFC6087bis that are not strictly needed.)
> Investigating further, Einar mentioned:
> 
>    I don't advice "value" because the value doesn't appear on the wire
>    & is primarily something for the backend implementation. Thus it may
>    change, and having it in the model gives an opportunity for a change
>    that breaks RFC 7950 backwards compatibility rules. For something
>    that is irrelevant to the model consumer.

Yes, the XML and JSON encodings do not use the value. However, the
CBOR encoding does use the value [draft-ietf-core-yang-cbor-05]. So we
either make sure the values are stable or we tell the CBOR people that
they can't use the value for their encoding. [There may also be bad
side effects on backend implementations if values change but the IETF
could declare that this is not the module writer's problem but the
backend writers problem.]

> Granted, I read RFC 7950, section 11, bullet 1 multiple times by now, but I
> forgot. And finding that paragraph back is ... well challenging
> The point is to provide guidelines to YANG module designers. Yes, we wish
> everybody would read (and remember) all the RFCs beforehand. I believe we
> can help those YANG module designers reading RFC6087bis, looking up "enum"
> in the TOC, found "Enumeration and Bits" and boom, they would find a text
> expressing something such as:
> 
>   YANG automatically assigns numeric values to enums if no values are
>   specified. This automatic assignment requires that (a) the order of
>   enums never changes and (b) additional enums are only appended but
>   never prepended or inserted. Therefore, think carefully whether you
>   want to assign values to enumerations in YANG modules. On one side, though
>   more verbose, assigning values might be considered more robust when modules
>   are revised. On the other side, NETCONF and RESTCONF do not send the numeric
>   values on the wire due to the way the XML and JSON encodings are defined
>   (other protocols might), so assigning values is irrelevant to the model
>   consumer.

If the CBOR encoding goes forward as it is designed today, then there
is nothing that prevents to use CBOR with RESTCONF (this combination
actually makes sense in situations where you care about payload size
and encoding/decoding efficiency). What I am trying to say is that if
we allow the enum value to be used by encodings, then any protocol is
affected that can use that encoding. So listing specific protocols is
likely misleading since RESTCONF for sure can be affected (as it
supports multiple encodings).

Note, this is what RFC 7950 says on page 177:

   o  An "enumeration" type may have new enums added, provided the old
      enums's values do not change.  Note that inserting a new enum
      before an existing enum or reordering existing enums will result
      in new values for the existing enums, unless they have explicit
      values assigned to them.

My reading of the first sentence is that RFC 7950 does _not_ allow
enum value changes.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>