Subject: Re: [yang-doctors] ?==?utf-8?q? ?==?utf-8?q? Fwd: Re: Issue with [email-masked] and yangdump-pro

From: Michal Vaško <[email-masked]>
Date: Tue, 02 Jan 2018 09:28:04 +0100

Hello everyone,

we would like to clarify a few things from this discussion. We are displaying some warnings in case of some almost-certainly invalid XPath expressions so we were wondering if it makes sense to add another if we detect an equality comparison of an identityref and an identity name without the use of derived-from(-or-self)() functions.

Another issue, "local module" has no formal definition as was mentioned. One can infer it is the module where the statement in question is defined but a definition would be appreciated. The same problem is with the term "current module" which it seems can be used interchangeably. Lastly, "current node" has no definition either and so we assumed it to be the node returned by the function current().

Kind regards,
Michal

On Monday, December 25, 2017 20:14 CET, Andy Bierman <[email-masked]> wrote: 
 
> On Mon, Dec 25, 2017 at 10:53 AM, Ladislav Lhotka <[email-masked]> wrote:
> 
> > On Sun, 2017-12-24 at 18:54 -0300, Mahesh Jethanandani wrote:
> > > > On Dec 23, 2017, at 10:49 AM, Martin Bjorklund <[email-masked]> wrote:
> > > >
> > > > Ladislav Lhotka <[email-masked]> wrote:
> > > > > > On Sat, 2017-12-23 at 13:01 +0100, Martin Bjorklund wrote:
> > > > > > Andy Bierman <[email-masked]> wrote:
> > > > > > > > On Sat, Dec 23, 2017 at 2:21 AM, Martin Bjorklund <
> > [email-masked]>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > See section 9.10.3 in RFC 7950:
> > > > > > > >
> > > > > > > >   The string value of a node of type "identityref" in a "must"
> > or
> > > > > > > >   "when" XPath expression is the referred identity's qualified
> > name
> > > > > > > >   with the prefix present.
> > > > > > > >
> > > > > > > > and re. the prefix:
> > > > > > > >
> > > > > > > >   If the referred identity is defined in an
> > > > > > > >   imported module, the prefix in the string value is the prefix
> > > > > > > > defined
> > > > > > > >   in the corresponding "import" statement.  Otherwise, the
> > prefix in
> > > > > > > >   the string value is the prefix for the current module.
> > > > > > > >
> > > > > > > >
> > > > > > > > I most cases you should consider using derived-from-or-self
> > instead
> > > > > > > > of
> > > > > > > > equality test for identiyrefs.
> > > > > > >
> > > > > > > So what is "the current module"?
> > > > > > > What is the resolution of 'X'? Is it foo:X or bar:X?
> > > > > >
> > > > > > foo:X
> > > > >
> > > > > No, the resolution of 'X' is 'X'
> > > >
> > > > Yes!  Sorry, I misread the question.  I though the question was what
> > > > prefix should be used.
> > >
> > > The question started with a 'when' statement (which I understand should
> > be
> > > changed to 'derived-from') using a identity name that is defined in the
> > other
> > > (bar) module. Should the 'derived-from' statement reference the identity
> > using
> > > the prefix 'b:X' or just 'X', using Andy's example?
> >
> > Both are possible in Andy's example, the former refers to the identity "X"
> > defined in module "bar", the latter refers to the identity "X" defined in
> > the
> > local module ("foo").
> >
> >
> I see the term "local module" used 11 times in RFC 7950, but it is not
> defined anywhere.
> IMO the only intuitive solution is that all scoped names are resolved in
> the same module,
> which is the module defining the actual statements. Is that the local
> module?
> 
> 
> Lada
> >
> 
> 
> Andy
> 
> 
> >
> > >
> > > >
> > > >
> > > > /martin
> > > >
> > > >
> > > > > because it is an XPath 1.0 string and XPath
> > > > > knows nothing about YANG identities. Because of the rule of sec.
> > 9.10.3,
> > > > > the
> > > > > equality expression is always false.
> > > > >
> > > > > That's why we introduced the new XPath functions derived-from() and
> > > > > derived-
> > > > > from-or-self() in YANG 1.1.
> > > > >
> > > > > Lada
> > > > >
> > > > > >
> > > > > >
> > > > > > /martin
> > > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > /martin
> > > > > > >
> > > > > > > Andy
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Andy Bierman <[email-masked]> wrote:
> > > > > > > > > > On Fri, Dec 15, 2017 at 4:38 AM, Radek Krejčí <
> > [email-masked]
> > > > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > Hi,
> > > > > > > > > > I'm adding Michal Vasko to cc, he knows better how these
> > things
> > > > > > > > > > are
> > > > > > > > > > checked in libyang.
> > > > > > > > > >
> > > > > > > > > > It seems to me that Andy refers the text which does not
> > apply
> > > > > > > > > > here.
> > > > > > > > > > The
> > > > > > > > > > identity name was used as part of XPath expresion
> > (when-stmt),
> > > > > > > > > > so the
> > > > > > > > > > definition of the context nodes for the when-stmt (RFC
> > 7950, sec
> > > > > > > >
> > > > > > > > 7.21.5)
> > > > > > > > > > and XPath context rules should apply here. Not the rules
> > for the
> > > > > > > > > > identityref's base statement. In this case, the when-stmt
> > is in
> > > > > > > >
> > > > > > > > augment so
> > > > > > > > > > the context node (which we also understand as the current
> > node
> > > > > > > > > > in this
> > > > > > > > > > case) is the augment's target node. And according to XPath
> > > > > > > > > > context
> > > > > > > >
> > > > > > > > rules
> > > > > > > > > > (RFC 7950, sec 6.4.1):
> > > > > > > > > >
> > > > > > > > > > o  Names without a namespace prefix belong to the same
> > namespace
> > > > > > > > > > as
> > > > > > > >
> > > > > > > > the
> > > > > > > > > > identifier of the current node.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I cc:ed YANG doctors to get more opinions...
> > > > > > > > >
> > > > > > > > > The current node is the augment-stmt.
> > > > > > > > > Note that it does not say context node, which is the target
> > of the
> > > > > > > >
> > > > > > > > augment.
> > > > > > > > > I think prefixes (and default prefix) are resolved in the
> > module
> > > > > > > >
> > > > > > > > containing
> > > > > > > > > the statement.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > module foo {
> > > > > > > > >
> > > > > > > > >   import bar { prefix b; }
> > > > > > > > >   identity X;
> > > > > > > > >
> > > > > > > > >   augment b:/some-node {
> > > > > > > > >      leaf test {
> > > > > > > > >         type string;
> > > > > > > > >         when "/b:some-node/b:other-node = 'X'";
> > > > > > > > >      }
> > > > > > > > >   }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > module bar {
> > > > > > > > >
> > > > > > > > >   identity W;
> > > > > > > > >   identity X { base W; }
> > > > > > > > >   container some-node {
> > > > > > > > >       leaf other-node {
> > > > > > > > >         type identityref { base W; }
> > > > > > > > >       }
> > > > > > > > >   }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > Q) Does other-node = 'X' resolve to foo:X or bar:X?  IMO:
> > foo:X
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Andy
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > In this particular case, the augment node with the
> > when-stmt
> > > > > > > > > > augments
> > > > > > > >
> > > > > > > > the
> > > > > > > > > > same module which defines napt44, so they are in the
> > correct
> > > > > > > > > > namespace
> > > > > > > >
> > > > > > > > and
> > > > > > > > > > the identity name can be used without the prefix. So it
> > should
> > > > > > > > > > be
> > > > > > > > > > fine,
> > > > > > > > > > while I believe that using prefix in the cases of
> > identities is
> > > > > > > > > > always
> > > > > > > > > > better approach. From the first sight (it may be
> > challenging for
> > > > > > > > > > human
> > > > > > > >
> > > > > > > > to
> > > > > > > > > > correctly resolve the context/current node in some cases),
> > I
> > > > > > > > > > would
> > > > > > > > > > also
> > > > > > > > > > expect prefix.
> > > > > > > > > >
> > > > > > > > > > I propose to keep the change in the draft (added nat
> > prefix),
> > > > > > > > > > since it
> > > > > > > > > > improves readability of the expression. But I don't think
> > that
> > > > > > > > > > it is
> > > > > > > > > > an
> > > > > > > > > > error to ommit the prefix.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Radek
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Dne 19.11.2017 v 20:42 Benoit Claise napsal(a):
> > > > > > > > > > > Hi Radek,
> > > > > > > > > > >
> > > > > > > > > > > Here is a bug report for you.
> > > > > > > > > > >
> > > > > > > > > > > Regards, Benoit
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -------- Forwarded Message --------
> > > > > > > > > > > Subject:      Re: Issue with [email-masked]
> > and
> > > > > > > > > >
> > > > > > > > > > yangdump-pro
> > > > > > > > > > > Date:         Sat, 18 Nov 2017 13:22:58 -0800
> > > > > > > > > > > From:         Andy Bierman <[email-masked]>
> > > > > > > > > > > To:   Benoit Claise <[email-masked]>
> > > > > > > > > > > CC:   [email-masked] <
> > > > > > > > > >
> > > > > > > > > > [email-masked]>, Mahesh
> > Jethanandani <
> > > > > > > > > > [email-masked]>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Hi,
> > > > > > > > > > >
> > > > > > > > > > > yangdump-pro is correct. Every other compiler missed
> > it...
> > > > > > > > > > >
> > > > > > > > > > > 9.10.2.  The identityref's "base" Statement
> > > > > > > > > > >
> > > > > > > > > > >   The "base" statement, which is a substatement to the
> > "type"
> > > > > > > > > > >   statement, MUST be present at least once if the type is
> > > > > > > > > > >   "identityref".  The argument is the name of an
> > identity, as
> > > > > > > >
> > > > > > > > defined
> > > > > > > > > > >   by an "identity" statement.  If a prefix is present on
> > the
> > > > > > > >
> > > > > > > > identity
> > > > > > > > > > >   name, it refers to an identity defined in the module
> > that
> > > > > > > > > > > was
> > > > > > > > > > >   imported with that prefix.  *Otherwise, an identity
> > with the
> > > > > > > >
> > > > > > > > matching
> > > > > > > > > > name MUST be defined in the current module or an included
> > > > > > > > > > submodule.*
> > > > > > > > > > >
> > > > > > > > > > > Using [email-masked] and
> > [email-masked]
> > > > > > > > > > >
> > > > > > > > > > > When I change 'natp44' to 'nat:natp44' in both
> > when-stmts:
> > > > > > > > > > >
> > > > > > > > > > > andy@andy-homedev:~/Desktop/FD1289/IETF$ yangdump-pro
> > > > > > > > > >
> > > > > > > > > > [email-masked] modpath=.
> > > > > > > > > > >
> > > > > > > > > > > *** /home/andy/Desktop/FD1289/
> > IETF/[email-masked]
> > > > > > > > > > > *** 0 Errors, 0 Warnings
> > > > > > > > > > >
> > > > > > > > > > > andy@andy-homedev:~/Desktop/FD1289/IETF$
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Andy
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On Sat, Nov 18, 2017 at 11:07 AM, Benoit Claise
> > <bclaise@cisco
> > > > > > > > > > > .com
> > > > > > > > > >
> > > > > > > > > > <mailto:[email-masked]>> wrote:
> > > > > > > > > > >
> > > > > > > > > > >    Hi Andy,
> > > > > > > > > > >
> > > > > > > > > > >    Can you please have a look at
> > [email-masked]
> > > > > > > > > > > at
> > > > > > > > > >
> > > > > > > > > > http://www.claise.be/IETFYANGPageCompilation.html <
> > > > > > > >
> > > > > > > > http://www.claise.be/
> > > > > > > > > > IETFYANGPageCompilation.html> .
> > > > > > > > > > >    yangdump-pro reports a new error, while the other
> > > > > > > > > > > validators are
> > > > > > > > > >
> > > > > > > > > > fine.
> > > > > > > > > > >
> > > > > > > > > > >    Copying Mahesh, as YANG doctor.
> > > > > > > > > > >
> > > > > > > > > > >    Regards, Benoit
> > > > > >
> > > > > > _______________________________________________
> > > > > > yang-doctors mailing list
> > > > > > [email-masked]
> > > > > > https://www.ietf.org/mailman/listinfo/yang-doctors
> > > > >
> > > > > --
> > > > > Ladislav Lhotka
> > > > > Head, CZ.NIC Labs
> > > > > PGP Key ID: 0xB8F92B08A9F76C67
> > > >
> > > > _______________________________________________
> > > > yang-doctors mailing list
> > > > [email-masked]
> > > > https://www.ietf.org/mailman/listinfo/yang-doctors
> > --
> > Ladislav Lhotka
> > Head, CZ.NIC Labs
> > PGP Key ID: 0xB8F92B08A9F76C67
> >
> > _______________________________________________
> > yang-doctors mailing list
> > [email-masked]
> > https://www.ietf.org/mailman/listinfo/yang-doctors
> >

---

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 22 Jan 2018 16:36:50 +0100

Michal Vaško <[email-masked]> writes:

> Hello everyone,
>
> we would like to clarify a few things from this discussion. We are
> displaying some warnings in case of some almost-certainly invalid
> XPath expressions so we were wondering if it makes sense to add
> another if we detect an equality comparison of an identityref and an
> identity name without the use of derived-from(-or-self)() functions.

Certainly for YANG 1.1 modules.

>
> Another issue, "local module" has no formal definition as was
> mentioned. One can infer it is the module where the statement in
> question is defined but a definition would be appreciated. The same
> problem is with the term "current module" which it seems can be used
> interchangeably. Lastly, "current node" has no definition either and
> so we assumed it to be the node returned by the function current().

As I already proposed, it would be better to declare the result of such
comparisons as undefined.

Lada

---

From: Andy Bierman <[email-masked]>
Date: Mon, 22 Jan 2018 08:27:12 -0800

> comparisons as undefined.
Declaring policy based on undefined terms seems like a bad idea.
We have customers who have used "var = 'identity'" hundreds of  times
already
in their YANG modules.   Not a chance that I am going to tell them
to change the YANG or have the YANG compiler start rejecting
this most intuitive and common construct.

Lada
Andy