On Wed, Oct 1, 2025 at 11:51 PM Michal Vasko <mvasko=
[email protected]> wrote:

> Hi,
>
> I would just like to include the text that I think restricts this use of
> the augment-structure. It is in the description of this extension in RFC
> 8791 <https://datatracker.ietf.org/doc/html/rfc8791>.
>
> The mandatory 'path' parameter value identifies the YANG
> conceptual data node that is being augmented and is
> represented as an absolute-schema-nodeid string, where the
> first node in the absolute-schema-nodeid string identifies the
> YANG data structure to augment, and the rest of the nodes in
> the string identifies the node within the YANG structure to
> augment.
>
> It clearly mentions referencing a "conceptual data node", not a
> 'structure' extension. I think this is the reason we have not supported it
> in 'libyang'. Note that I do not mind adding support for this in libyang
> (we have already implemented it) but the wording is definitely misleading
> if the intention was for 'structure' to be allowed to be augmented
> directly. Maybe even deserves an errata.
>


It does not say the following nodes are required.

   and the rest of the nodes


INTENDED:


    and the rest of the nodes (if any)


It is true that the old RFC 8040 'yang-data' extension did require a
container in it, but that was changed in RFC 8791.

This was done in part to make groupings work better e.g. data node /foo/A

    grouping stuff {    leaf A { type string; }
  }

  rc:yang-data foo {
    container foo {
      uses stuff;
    }
  }

    sx:structure foo {
       uses stuff;
    }

    container foo {
        uses stuff;
    }


Regards,
> Michal
>


Andy


> On 2. 10. 2025 8:38, Phú Liên wrote:
>
>
>
> ---------- Forwarded message ---------
> From: Phú Liên <[email protected]>
> Date: Thu, Oct 2, 2025 at 1:36 PM
> Subject: Re: [netmod] Question about using augment-structure to augment
> the root node of a Yang data structure
> To: Andy Bierman <[email protected]>
>
>
> Hi Andy,
>
> Thank you for your confirmation. I can now request a bug fix for Yanglint.
>
> Best regards,
> Phu
>
> On Thu, Oct 2, 2025 at 12:02 AM Andy Bierman <[email protected]> wrote:
>
>>
>>
>> On Wed, Oct 1, 2025 at 12:56 AM Phú Liên <[email protected]> wrote:
>>
>>> Hi RFC 8791 authors,
>>>
>>> I have a question regarding YANG data structure extensions (RFC 8791)
>>> and the use of augment-structure. Specifically, is it possible to augment
>>> the root of a YANG data structure?
>>>
>>> For example, with the YANG model below, yanglint validates successfully
>>> if the last "sx:augment-structure /foo:mystruct" statement is commented
>>> out. However, if that statement is included, yanglint reports an error:
>>>
>>> * Yang model
>>>
>>> ```
>>> module foo {
>>>   namespace "foo";
>>>   prefix foo;
>>>
>>>   import ietf-yang-structure-ext { prefix sx; }
>>>
>>>   sx:structure mystruct {
>>>     container mycontainer {
>>>       leaf leaf1 {
>>>         type string;
>>>       }
>>>     }
>>>   }
>>>
>>>   sx:augment-structure /foo:mystruct/foo:mycontainer {
>>>     leaf leaf2 {
>>>       type string;
>>>     }
>>>   }
>>>
>>>   // Augment to the root of the structure, so `leaf3` will be a sibling
>>> of `mycontainer`.
>>>   sx:augment-structure /foo:mystruct {
>>>     leaf leaf3 {
>>>       type string;
>>>     }
>>>   }
>>> }
>>> ```
>>>
>>> * Yanglint error
>>>
>>> ```
>>> libyang err : Augment extension target node "/foo:mystruct" from module
>>> "foo" was not found.
>>> (/foo:{extension='sx:augment-structure'}/{augment='/foo:mystruct'})
>>> ```
>>>
>>> Moreover, if we cannot use augment-structure to add augments to the root
>>> of a structure, could you please suggest how to make the following leafref
>>> path valid in the YANG model below?
>>>
>>>
>>
>> I do not see any text in RFC 8791 that prohibits augmenting the structure.
>> A valid path argument is provided to the extension.
>>
>>     sx:augment-structure /foo:mystruct
>>
>> The structure 'mystruct' should be treated like a top-level NP container.
>> It shares the same namespace as real data-def-stmts.
>>
>>
>> Andy
>>
>> * a.yang
>>>
>>> ```
>>> module a {
>>>   namespace "urn:a";
>>>   prefix a;
>>>
>>>   import b {
>>>     prefix b;
>>>   }
>>>   import ietf-yang-structure-ext {
>>>     prefix sx;
>>>   }
>>>
>>>   grouping leafrefs {
>>>     leaf leaf1 {
>>>       type leafref {
>>>         path "/a:top/a:leaf2";
>>>       }
>>>     }
>>>   }
>>>
>>>   grouping leaves {
>>>     leaf leaf2 {
>>>       type string;
>>>     }
>>>   }
>>>
>>>   container top {
>>>     config false;
>>>     uses leaves;
>>>   }
>>>
>>>
>>>   // Augments 'a:leaf1' into '/b:mystruct/b:mycontainer'. This augmented
>>>   // 'a:leaf1' will be a sibling of 'b:myleaf'.
>>>   //
>>>   // XPath within a structure can only reference nodes inside the same
>>>   // structure. Therefore, '/a:top/a:leaf2' must also be augmented into
>>>   // 'b:mystruct' to satisfy the leafref path.
>>>   sx:augment-structure "/b:mystruct/b:mycontainer" {
>>>     uses leafrefs;
>>>   }
>>>
>>>   // This 'augment-structure' attempts to satisfy the leafref path by
>>> augmenting
>>>   // '/a:top/a:leaf2' into the root of '/b:mystruct'. However, yanglint
>>> reports
>>>   // an error because we are augmenting to the root of a structure.
>>>   sx:augment-structure "/b:mystruct" {
>>>     container top {
>>>       uses leaves;
>>>     }
>>>   }
>>>
>>>   // This 'augment-structure' is valid in yanglint but does not satisfy
>>> the
>>>   // leafref path because it augments '/b:top/a:leaf2', not
>>> '/a:top/a:leaf2'.
>>>   sx:augment-structure "/b:mystruct/b:top" {
>>>     uses leaves;
>>>   }
>>> }
>>> ```
>>>
>>> * b.yang
>>>
>>> ```
>>> module b {
>>>   namespace "urn:b";
>>>   prefix b;
>>>
>>>   import ietf-yang-structure-ext {
>>>     prefix sx;
>>>   }
>>>
>>>   sx:structure mystruct {
>>>     container mycontainer {
>>>       leaf myleaf {
>>>         type string;
>>>       }
>>>     }
>>>     container top { }
>>>   }
>>> }
>>> ```
>>>
>>> Yanglint reports the following error for the second augment-structure
>>> statement:
>>>
>>> ```
>>> libyang err : Augment extension target node "/b:mystruct" from module
>>> "a" was not found.
>>> (/a:{extension='sx:augment-structure'}/{augment='/b:mystruct'})
>>> ```
>>>
>>> And the following error for the third augment-structure statement:
>>>
>>> ```
>>> libyang err : Not found node "top" in path. (/b:mycontainer/a:leaf1)
>>> ```
>>>
>>> By the way, we found that this use of augment-structure is claimed to be
>>> supported in the following links:
>>>
>>> *
>>> https://docs.yumaworks.com/en/latest/yangauto/define-abstract-yang.html
>>> *
>>> https://dr2lopez.github.io/yang-provenance/draft-lopez-opsawg-yang-provenance.html
>>>
>>> BR/Phu
>>> _______________________________________________
>>> netmod mailing list -- [email protected]
>>> To unsubscribe send an email to [email protected]
>>>
>>
> _______________________________________________
> netmod mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
>
> _______________________________________________
> netmod mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
>
_______________________________________________
netmod mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to