public icon indicating copy to clipboard operation
public copied to clipboard

network-instance-ref path should have namespaces

Open iwanb opened this issue 7 years ago • 2 comments

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";

iwanb avatar Oct 02 '18 12:10 iwanb

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

jacossio avatar Jan 19 '22 09:01 jacossio

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.

robshakir avatar Jan 19 '22 16:01 robshakir

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.

github-actions[bot] avatar Jun 20 '24 02:06 github-actions[bot]