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

Benoit Claise <bclaise@cisco.com> Thu, 25 January 2018 10:26 UTC

Return-Path: <bclaise@cisco.com>
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 12036126CBF for <yang-doctors@ietfa.amsl.com>; Thu, 25 Jan 2018 02:26:10 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.509
X-Spam-Level:
X-Spam-Status: No, score=-14.509 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cisco.com
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 6C8CmU7TZbFa for <yang-doctors@ietfa.amsl.com>; Thu, 25 Jan 2018 02:26:07 -0800 (PST)
Received: from aer-iport-3.cisco.com (aer-iport-3.cisco.com [173.38.203.53]) (using TLSv1.2 with cipher DHE-RSA-SEED-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 5550B12D84A for <yang-doctors@ietf.org>; Thu, 25 Jan 2018 02:26:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=9137; q=dns/txt; s=iport; t=1516875967; x=1518085567; h=subject:to:references:from:message-id:date:mime-version: in-reply-to; bh=r6RJ77s/YlEQ9pBqpkH8QF/nMrvoFDb6vO6krhOPOQw=; b=DORnJTCU0vyYNm9WLUeeGFV3Huv3G1R969S0nscvC7V1D6ZoqMQ6Hdva CBIMJbWSPBxC06Mge6kwWw2bclRzOXs3Oz9HMA8v/ZdbOriNd+4JuSIGR JRynFvq0QSI48dkCo/gQfbwQJTxOcb4V2Mn4p0OgFQar29RD7Nwe5t1p4 Q=;
X-IronPort-AV: E=Sophos;i="5.46,411,1511827200"; d="scan'208,217";a="1597092"
Received: from aer-iport-nat.cisco.com (HELO aer-core-2.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 10:26:05 +0000
Received: from [10.55.221.36] (ams-bclaise-nitro3.cisco.com [10.55.221.36]) by aer-core-2.cisco.com (8.14.5/8.14.5) with ESMTP id w0PAQ5wF010870; Thu, 25 Jan 2018 10:26:05 GMT
To: 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>
From: Benoit Claise <bclaise@cisco.com>
Message-ID: <dfb94426-c408-e215-e23b-539e127050a2@cisco.com>
Date: Thu, 25 Jan 2018 11:26:05 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2
MIME-Version: 1.0
In-Reply-To: <20180125091118.tjn5eiv2hzmc7k23@elstar.local>
Content-Type: multipart/alternative; boundary="------------8819E126663DD7BF581332FE"
Content-Language: en-US
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/Y3Xr4X82Z89YY8e4F-5fAdASgx0>
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:26:10 -0000

> 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.

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.

Do you believe it's useful guidance? I believe it is.
Btw, I trust the YANG doctor on the right text.

Regards, Benoit
> Anyway, I do not plan to spend more time on guessing whether this is
> helpful or not.
>
> /js
>