openconfig / public

Repository for publishing OpenConfig models, documentation, and other material for the community.
Apache License 2.0
897 stars 655 forks source link

network-instance-ref path should have namespaces #184

Closed iwanb closed 2 months ago

iwanb commented 6 years ago

In openconfig-network-instance there is this typedef:

  typedef network-instance-ref {
    type leafref {
      path "/network-instances/network-instance/config/name";
    }
    description
      "A re-usable type that can be referenced within other
       modules that references a network instance.";
  }

Which is used in openconfig-aft-network-instance:

grep network-instance-ref aft/* -C 2
aft/openconfig-aft-network-instance.yang-
aft/openconfig-aft-network-instance.yang-    leaf network-instance {
aft/openconfig-aft-network-instance.yang:      type oc-ni:network-instance-ref;
aft/openconfig-aft-network-instance.yang-      description
aft/openconfig-aft-network-instance.yang-        "The network-instance within which the next-hop should be resolved.
--
aft/openconfig-aft-network-instance.yang-
aft/openconfig-aft-network-instance.yang-    leaf origin-network-instance {
aft/openconfig-aft-network-instance.yang:      type oc-ni:network-instance-ref;
aft/openconfig-aft-network-instance.yang-      description
aft/openconfig-aft-network-instance.yang-        "If the AFT entry was imported from another network instance (e.g., it

But the leafref path is resolved in the namespace where it is used, not where it is defined. It's not very clear in the Yang 1.0 RFC but the 1.1 says explicitly:

   o  If the "path" statement is defined within a typedef, the context
      node is the leaf or leaf-list node in the data tree that
      references the typedef.

I found it using yanglint from libyang, which gives this error when trying to load openconfig-aft-network-instance: err : No resolvents found for leafref "/network-instances/network-instance/config/name". (/openconfig-network-instance:network-instances/openconfig-network-instance:network-instance/openconfig-network-instance:afts/openconfig-network-instance:next-hops/openconfig-network-instance:next-hop/openconfig-network-instance:state/network-instance)

So AFAIK the path should be: path "/oc-netinst:network-instances/oc-netinst:network-instance/oc-netinst:config/oc-netinst:name";

jacossio commented 2 years ago

Would it be possible to consider a fix for this issue? @OpenConfigBot

robshakir commented 2 years ago

Sure - per the CI, we observe that pyang, goyang and other toolchains do not see that this is an issue -- as long as the prefix resolution works in the correct way (since the context node may use different prefixes than the value defined in the openconfig-network-instance) module, then this should be a no-op change.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 180 days with no activity. If you wish to keep this issue active, please remove the stale label or add a comment, otherwise will be closed in 14 days.