Re: [netmod] RFC8526 and 'derived-from-or-self(datastore, "ds:operational")'

Martin Bjorklund <mbj@tail-f.com> Tue, 13 August 2019 09:47 UTC

Return-Path: <mbj@tail-f.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 802B512008F for <netmod@ietfa.amsl.com>; Tue, 13 Aug 2019 02:47:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, 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 Hb7WgnEtes_y for <netmod@ietfa.amsl.com>; Tue, 13 Aug 2019 02:47:32 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 86F7F1200F1 for <netmod@ietf.org>; Tue, 13 Aug 2019 02:47:32 -0700 (PDT)
Received: from localhost (h-46-233.A165.priv.bahnhof.se [46.59.46.233]) by mail.tail-f.com (Postfix) with ESMTPSA id C27DE1AE0983; Tue, 13 Aug 2019 11:47:29 +0200 (CEST)
Date: Tue, 13 Aug 2019 11:47:28 +0200 (CEST)
Message-Id: <20190813.114728.2262411490998285952.mbj@tail-f.com>
To: jernej.tuljak@mg-soft.si
Cc: netmod@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <8e19f280-5b63-c2d4-003b-e5e5370e9ea1@mg-soft.si>
References: <8e19f280-5b63-c2d4-003b-e5e5370e9ea1@mg-soft.si>
X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/55MglgTICObxD_e089woAtlcSXA>
Subject: Re: [netmod] RFC8526 and 'derived-from-or-self(datastore, "ds:operational")'
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, 13 Aug 2019 09:47:35 -0000

Hi,

Jernej Tuljak <jernej.tuljak@mg-soft.si>; wrote:
> Hi,
> 
> I'm trying to determine who is at fault, our YANG validator
> implementation or the module ietf-netconf-nmda in RFC8526 .
> 
> There is a "when" expression at line 193 within this module
> 
> when 'derived-from-or-self(datastore, "ds:operational") ';
> 
> which is under this pseudo-branch within the module: / get-data
> ("rpc") / input ("input") / origin-filters ("choice").
> 
> Our implementation claims that the initial context node of the
> expression does not contain a "datastore" child, resulting in a
> warning for this expression, which seemed like an obvious bug at
> first, but does not anymore.
> 
> The accessible tree for this expression is built using the following
> bullet in Section 6.4.1:
> 
>    o  If the XPath expression is defined in a substatement to an "input"
>       statement in an "rpc" or "action" statement, the accessible tree
>       is the RPC or action operation instance, all state data in the
>       server, and the running configuration datastore.  The root node
>       has top-level data nodes in all modules as children.
>       Additionally, for an RPC, the root node also has the node
>       representing the RPC operation being defined as a child.  The node
>       representing the operation being defined has the operation's input
>       parameters as children.
> 
> 
> "origin-filters" for which the "when" expression is defined is clearly
> a substatement to an "input" statement in an "rpc" statement. Pseudo-
> accessible tree below (matches what our implementation does).
> 
> <root>
>     +- get-data
>         +- datastore
>         +- // other data node siblings of datastore
>     +- // top-level data nodes of all modules
> 
> The initial context node is determined by using the following bullet
> in Section 7.21.5:
> 
>    o  If the "when" statement is a child of a "uses", "choice", or
>       "case" statement, then the context node is the closest ancestor
>       node to the node with the "when" statement that is also a data
>       node.  If no such node exists, the context node is the root node.
>       The accessible tree is tentatively altered during the processing
>       of the XPath expression by removing all instances (if any) of the
>       nodes added by the "uses", "choice", or "case" statement.
> 
> 
> The "when" statement in question is clearly a child of a "choice"
> statement without a data node ancestor. Neither "input" nor "rpc"
> represent data nodes, as per Terminology section:
> 
>    o  data node: A node in the schema tree that can be instantiated in a
>       data tree.  One of container, leaf, leaf-list, list, anydata, and
>       anyxml.
> 
> 
> To our implementation this means that the initial context node is the
> root node of the accessible tree, not the node that represents the
> "rpc". Therefore the expression is attempting to refer to a node that
> is undefined. It is expecting
> 
> when 'derived-from-or-self(get-data/datastore, "ds:operational") ';
> 
> or something along those lines instead.
> 
> Either way, something doesn't add up between RFC7950 and RFC8526.
> 
> There is a suspicious verified RFC7950 errata
> (https://www.rfc-editor.org/errata/eid4794) dealing with initial
> context nodes under augments, but there's nothing for the UCC ("uses",
> "choice", "case") corner case. Perhaps there should be? Should Section
> 7.21.5 say
> 
> NEW:
> 
>    o  If the "when" statement is a child of a "uses", "choice", or
>       "case" statement, then the context node is the closest ancestor
>       node to the node with the "when" statement that is also a data
>       node, rpc, action or notification.  If no such node exists, the
>       context node is the root node. The accessible tree is tentatively
>       altered during the processing of the XPath expression by removing
>       all instances (if any) of the nodes added by the "uses",
>       "choice", or "case" statement.
> 
> OLD:
> 
>    o  If the "when" statement is a child of a "uses", "choice", or
>       "case" statement, then the context node is the closest ancestor
>       node to the node with the "when" statement that is also a data
>       node.  If no such node exists, the context node is the root node.
>       The accessible tree is tentatively altered during the processing
>       of the XPath expression by removing all instances (if any) of the
>       nodes added by the "uses", "choice", or "case" statement.
> 
> ?

I think this matches the intent.  As you note above, since the
accessible tree is:

  <root>
      +- get-data
          +- datastore
          +- // other data node siblings of datastore
      +- // top-level data nodes of all modules

the context node for the "when" statement in the "choice" is supposed
to be "get-data".

This also makes it consistent with augment:

  augment /get-data/input {
    choice origin-filters {
      when 'derived-from-or-self(datastore, "ds:operational")';
      ...
    }
  }



/martin