Re: [netmod] Questions about how to assign default values with YANG

Andy Bierman <andy@yumaworks.com> Tue, 09 March 2021 17:55 UTC

Return-Path: <andy@yumaworks.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 877B63A14B3 for <netmod@ietfa.amsl.com>; Tue, 9 Mar 2021 09:55:38 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.887
X-Spam-Level:
X-Spam-Status: No, score=-1.887 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=yumaworks-com.20150623.gappssmtp.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 o8To3r3nW4td for <netmod@ietfa.amsl.com>; Tue, 9 Mar 2021 09:55:36 -0800 (PST)
Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 84C2E3A14B2 for <netmod@ietf.org>; Tue, 9 Mar 2021 09:55:35 -0800 (PST)
Received: by mail-lf1-x131.google.com with SMTP id d3so28481005lfg.10 for <netmod@ietf.org>; Tue, 09 Mar 2021 09:55:35 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yumaworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ytXs12rVFa2v2C3C+t7zjYHNy6OosMYnZZaWpQa/xII=; b=KGcA1nn7hqbUZFN8bgiRPklI0PdyCR4gMcdmbS6R3TtRt7OvO5Qo9yrrmiumJl2FOu 7LVmb8dlq1okZlcMAHkK8s5oBxHm0S4z4YuRr04Zb4pkgJp8J3qjsOstK+nHhjzCrOvi LS7xYc13wJvX48j9NC8mlO/sn/rtydMRP4FBJSJrNHUjuZXtDkQDE27BewH0NEWr6UAT GMiIALCunwMIXqHvfUDTfzXGklDBo/1nSO6kzzwxLXJUnwSkwxE071zFpjXGMsnzRiHZ wHGvvYHHF3LDsNu+HDw8nM/UCJWVWmwgp8Hwq0gF+4H5QLzNJgN6edEx/wy40VoqqsIm r/bg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ytXs12rVFa2v2C3C+t7zjYHNy6OosMYnZZaWpQa/xII=; b=KlSyEWZZu5Nmeq2o+ElvZlHj0oKIkqVTz5PLsJHVsQX+nwvoyaTANQzAnZFycynZYH PNzXiTHJSEE2r0qS7Y0JXUwmhLMEQIdid37gbeJKOuS6B3yS0UY60fl9nIk3cZ8Ip+8y jYZE2aFUqgSgY6cCsFhtsjgXuS1IiW0qh536mHdXq1dGFh26GPzjKyPzxxpMYHHiSGkE SduYpvhzg8iV3MieRxdbtkOvGQNVk/YV9uxzR1XEeRQwuz1vDctaPaZ2AnZ7mDi+DIkn zFXig81zuCVl6MOK12gGQRe0Vmu5qHNqarrg52YWjWJ4NFgC806U34DsRCWZIWy8rRcs 766w==
X-Gm-Message-State: AOAM533IjtiQqRrYGYHrTnDRPOs+w/bHlsdV9giWCNFv5y2mIF0ibf3D sqlzzjEwSiiTHU2zL8T/p5iGmwCcZMqa828IuKQMeg==
X-Google-Smtp-Source: ABdhPJxqYTDQU7aUh9Dq9GUfuchy8UtH+odzA+kLlGxVUV15dMv6IVxzNHSm6Q9VP1ICurqK8EA+V7t8fuQUyDg5XNU=
X-Received: by 2002:a05:6512:1195:: with SMTP id g21mr17633647lfr.512.1615312532615; Tue, 09 Mar 2021 09:55:32 -0800 (PST)
MIME-Version: 1.0
References: <a0c43ab5c3c1463a97a1aa594a80ceee@huawei.com> <20210120094737.g5l5pvfzligahrj6@anna.jacobs.jacobs-university.de> <2384a8f549c94ea0ac46d6c772fbca43@huawei.com> <20210120114446.ovih63db7vmv7c7s@anna.jacobs.jacobs-university.de> <0ed5638881af42148720dd7f4843c3e6@huawei.com> <20210120160517.hsg5dnpidvrprtso@anna.jacobs.jacobs-university.de> <521a9ccd02e14d178a6e62971b4809ea@huawei.com> <87sg54cm18.fsf@nic.cz> <CABCOCHQoxpxf4id8rSCxmY42KMzwyj69_GMG=8Eyi4RN5gir2A@mail.gmail.com> <a779473d-9012-3eea-25a5-d402eb37c5d2@nic.cz>
In-Reply-To: <a779473d-9012-3eea-25a5-d402eb37c5d2@nic.cz>
From: Andy Bierman <andy@yumaworks.com>
Date: Tue, 09 Mar 2021 09:55:21 -0800
Message-ID: <CABCOCHTkaxhtCJauHmsSaeSvsTijigzfjk_5htiAppC1npz2UA@mail.gmail.com>
To: Ladislav Lhotka <ladislav.lhotka@nic.cz>
Cc: Italo Busi <Italo.Busi@huawei.com>, Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>, "netmod@ietf.org" <netmod@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000b5466005bd1e41cb"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/EHwfiPE0ccv22-GnHcsxLl8AZ3s>
Subject: Re: [netmod] Questions about how to assign default values with YANG
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
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: Tue, 09 Mar 2021 17:55:39 -0000

On Tue, Mar 9, 2021 at 9:32 AM Ladislav Lhotka <ladislav.lhotka@nic.cz>
wrote:

> On 09. 03. 21 17:58, Andy Bierman wrote:
> >
> >
> > On Tue, Mar 9, 2021 at 8:46 AM Ladislav Lhotka <ladislav.lhotka@nic.cz
> > <mailto:ladislav.lhotka@nic.cz>> wrote:
> >
> >     Italo Busi <Italo.Busi@huawei.com <mailto:Italo.Busi@huawei.com>>
> >     writes:
> >
> >     > Hi Juergen,
> >     >
> >     > Thanks again for your clear explanation on this topic
> >     >
> >     > I have found a similar but slightly different issue. In this case,
> >     a YANG default statement exists in the base module but the intention
> >     with the augmentation is to "overwrite" the default value on the
> >     basis of another attribute, defined in the module which augments the
> >     base module.
> >     >
> >     > For example, I am wondering whether such a code is valid:
> >
> >     Yes, this is valid, I'd just suggest:
> >
> >
> > I do not agree.
> > I do not see how the description-stmt for /foo can change the default
> > leaf processing for /bar
> >
>
> Are you saying that the (computed) default values specified in
> description strings (as in ietf-ipv6-router-advertisements) are illegal?
>
>
Of course not.
In this case there MUST NOT be a YANG default-stmt in use for the leaf or
leaf-list.

If the leaf or leaf-list does have a YANG default-stmt that MUST be used,
then
no description-stmt can undo the requirements in 7.6.1



> Lada
>
>

Andy


> >
> >
> >
> >     - remove the default statement for "foo", as it may be confusing to
> >     both humans and tools
> >
> >
> > sec 7.3.4:
> >
> >    If the base type has a default value and the new derived type does
> >    not specify a new default value, the base type's default value is
> >    also the default value of the new derived type.
> >
> >
> >
> > sec 7.6.1
> >
> >
> >    The default value of a leaf is the value that the server uses if the
> >    leaf does not exist in the data tree.  The usage of the default value
> >    depends on the leaf's closest ancestor node in the schema tree that
> >    is not a non-presence container (see Section 7.5.1 <
> https://tools.ietf.org/html/rfc7950#section-7.5.1>):
> >
> >    o  If no such ancestor exists in the schema tree, the default value
> >       MUST be used.
> >
> >    o  Otherwise, if this ancestor is a case node, the default value MUST
> >       be used if any node from the case exists in the data tree or the
> >       case node is the choice's default case, and if no nodes from any
> >       other case exist in the data tree.
> >
> >    o  Otherwise, the default value MUST be used if the ancestor node
> >       exists in the data tree.
> >
> >
> >
> >
> >     - specify the default (both cases) in the description of "foo"
> >
> >     A similar example is in the module ietf-ipv6-router-advertisements,
> >     e.g. leaf "min-rtr-adv-interval":
> >
> >     https://www.rfc-editor.org/rfc/rfc8349.html#section-9.1
> >     <https://www.rfc-editor.org/rfc/rfc8349.html#section-9.1>
> >
> >     Lada
> >
> >
> >
> > Andy
> >
> >
> >
> >     >
> >     > module example-base {
> >     >   container example {
> >     >     leaf foo {
> >     >       type uint8;
> >     >       default 0;
> >     >     }
> >     >   }
> >     > }
> >     >
> >     > module example-augment {
> >     >   import example {
> >     >     prefix ex;
> >     >   }
> >     >
> >     >   augment "ex:example" {
> >     >     leaf bar {
> >     >       type empty;
> >     >       description
> >     >         "When present, the default value for foo is 10.";
> >     >     }
> >     >   }
> >     > }
> >     >
> >     >
> >     > In this case, when the leaf foo is not configured but the leaf bar
> >     is present, the value of foo in the operational datastore should be
> >     10 (rather than 0).
> >     >
> >     > In this case, I think that it would be better/cleaner if the
> >     origin is marked as system.
> >     >
> >     > Maybe a better YANG description for bar could be: "When present,
> >     the system overrides the default value of foo to 10."
> >     >
> >     > What is your and/or WG opinion?
> >     >
> >     > Thanks again
> >     >
> >     > Italo
> >     >
> >     >> -----Original Message-----
> >     >> From: Juergen Schoenwaelder
> >     [mailto:j.schoenwaelder@jacobs-university.de
> >     <mailto:j.schoenwaelder@jacobs-university.de>]
> >     >> Sent: mercoledì 20 gennaio 2021 17:05
> >     >> To: Italo Busi <Italo.Busi@huawei.com <mailto:
> Italo.Busi@huawei.com>>
> >     >> Cc: 'netmod@ietf.org <mailto:netmod@ietf.org>' <netmod@ietf.org
> >     <mailto:netmod@ietf.org>>
> >     >> Subject: Re: [netmod] Questions about how to assign default
> >     values with
> >     >> YANG
> >     >>
> >     >> On Wed, Jan 20, 2021 at 02:41:39PM +0000, Italo Busi wrote:
> >     >> >
> >     >> > What about the case the leaf is not conditional (but still
> >     mandatory false
> >     >> since a YANG default statement is defined)?
> >     >> >
> >     >> > May the server still decide not to use/implement this leaf in
> >     the operational
> >     >> datastore?
> >     >> >
> >     >> > For example, in appendix C.1 of RFC8342, auto-negotiation is
> >     enabled by
> >     >> default.
> >     >> > What should be the behavior of a system which does not
> >     implement auto-
> >     >> negotiation?
> >     >> > Return the value false or no value (in the operational
> datastore)?
> >     >> >
> >     >>
> >     >> Here are some of the rules I personally like:
> >     >>
> >     >>  - <operational> is the ground truth about what a system has and
> does
> >     >>  - do not implement leafs that do not apply
> >     >>
> >     >> Hence, interfaces supporting auto-negotiation have either auto-
> >     >> negotiation/enabled = true or auto-negotiation/enabled = false in
> >     >> <operational>. And interfaces not supporting auto-negotiation
> >     have nothing
> >     >> to report about auto-negotiation. Yes, I do not want to see auto-
> >     >> negotiation/enabled = false on a loopback interface.
> >     >>
> >     >> My historic Ethernet interface from the last century would also
> >     not report
> >     >> auto-negotiation/enabled in <operational>. You may hit
> >     applications that love
> >     >> to have auto-negotiation/enabled available on all Ethernet
> >     interfaces and then
> >     >> you end in a debate where the application developers tell you
> that no
> >     >> information in <operational> may have many reasons
> >     (instrumentation not
> >     >> implemented, access control rules, whatever and by reporting
> >     enabled=false
> >     >> you do them a favor) but the true answer in such a debate is
> >     often that
> >     >> modeling things as a boolean is simplistic since there are often
> >     more than
> >     >> exactly two states (in this case, enabled, disabled, failed,
> >     not-available, ...).
> >     >> So you settle on blaming the model writer. ;-)
> >     >>
> >     >> /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/ <
> https://www.jacobs-university.de/>>
> >     >
> >     > _______________________________________________
> >     > netmod mailing list
> >     > netmod@ietf.org <mailto:netmod@ietf.org>
> >     > https://www.ietf.org/mailman/listinfo/netmod
> >     <https://www.ietf.org/mailman/listinfo/netmod>
> >
> >     --
> >     Ladislav Lhotka
> >     Head, CZ.NIC Labs
> >     PGP Key ID: 0xB8F92B08A9F76C67
> >
> >     _______________________________________________
> >     netmod mailing list
> >     netmod@ietf.org <mailto:netmod@ietf.org>
> >     https://www.ietf.org/mailman/listinfo/netmod
> >     <https://www.ietf.org/mailman/listinfo/netmod>
> >
> >
> > _______________________________________________
> > netmod mailing list
> > netmod@ietf.org
> > https://www.ietf.org/mailman/listinfo/netmod
> >
>
> --
> Ladislav Lhotka
> Head, CZ.NIC Labs
> PGP Key ID: 0xB8F92B08A9F76C67
>