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

From: Jernej Tuljak <[email-masked]>
Date: Mon, 12 Aug 2019 15:04:54 +0200

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.

?

Jernej

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 13 Aug 2019 11:47:28 +0200 (CEST)

Hi,

Jernej Tuljak <[email-masked]> wrote:
> which is under this pseudo-branch within the module: / get-data
> ("rpc") / input ("input") / origin-filters ("choice").
> 
> 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.
> 
> "origin-filters" for which the "when" expression is defined is clearly
> a substatement to an "input" statement in an "rpc" statement. Pseudo-
> The initial context node is determined by using the following bullet
> in Section 7.21.5:
> 
> "rpc". Therefore the expression is attempting to refer to a node that
> is undefined. It is expecting
> 
> (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:
> 

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

  <root>
      +- get-data
          +- datastore

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

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 15 Aug 2019 09:30:21 +0200

>>     +- // top-level data nodes of all modules

The rules may be easier to describe if we define schema root nodes (or similar name) as a special category of schema nodes. It makes sense also because all these schema root nodes have a corresponding instance node in the XPath tree - the invisible XPath root, rpc, input, output and notification.

Lada

> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

-- 
Ladislav Lhotka 
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67