public icon indicating copy to clipboard operation
public copied to clipboard

Prefix mismatch in `openconfig-flexalgo` import of `openconfig-network-instance`

Open asadarafat opened this issue 6 months ago • 6 comments

Dear OpenConfig Team,

While reviewing the openconfig-flexalgo module (revision 2023-05-24), I noticed that it imports openconfig-network-instance using the prefix oc-ni:

import openconfig-network-instance {
  prefix "oc-ni";
}

Whereas in the openconfig-network-instance module itself, the declared prefix is oc-netinst.

While this is valid per [RFC 7950 §7.1.5](https://datatracker.ietf.org/doc/html/rfc7950#section-7.1.5), using a different prefix than the canonical one can be confusing for tooling, consumers, or validation logic that assumes consistency across OpenConfig modules.

Would you consider aligning this prefix to oc-netinst for consistency with the imported module?

Thank you for your excellent work on maintaining a high-quality, vendor-neutral YANG model library.

Best regards, Asad Arafat

asadarafat avatar Jul 03 '25 11:07 asadarafat

Yes, I think that is ok as a clean up effort. Would you like to submit a pull request to do the renaming and we'll review?

dplore avatar Jul 08 '25 01:07 dplore

Quick lazy audit and we have many more....

Mismatched prefix: module [openconfig-acl], import [openconfig-packet-match]. Expected "oc-pkt-match", Got: "oc-match"
Mismatched prefix: module [openconfig-packet-match], import [openconfig-mpls-types]. Expected "oc-mplst", Got: "oc-mpls"
Mismatched prefix: module [openconfig-aft-network-instance], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-aft-summary], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-ate-flow], import [openconfig-vlan-types]. Expected "oc-vlan-types", Got: "oc-vlan"
Mismatched prefix: module [openconfig-bfd], import [ietf-inet-types]. Expected "inet", Got: "ietf-if"
Mismatched prefix: module [openconfig-bgp], import [openconfig-rib-bgp]. Expected "oc-rib-bgp", Got: "oc-bgprib"
Mismatched prefix: module [openconfig-ethernet-segments], import [openconfig-yang-types]. Expected "oc-yang", Got: "oc-yang-types"
Mismatched prefix: module [openconfig-metadata], import [ietf-yang-metadata]. Expected "md", Got: "ietf-md"
Mismatched prefix: module [openconfig-flexalgo], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-gnsi], import [openconfig-system-grpc]. Expected "oc-sys-grpc", Got: "oc-grpc"
Mismatched prefix: module [openconfig-gribi], import [openconfig-system-grpc]. Expected "oc-sys-grpc", Got: "oc-grpc"
Mismatched prefix: module [openconfig-interfaces], import [ietf-interfaces]. Expected "if", Got: "ietf-if"
Mismatched prefix: module [openconfig-isis-lsp], import [openconfig-inet-types]. Expected "oc-inet", Got: "inet"
Mismatched prefix: module [openconfig-isis-policy], import [openconfig-routing-policy]. Expected "oc-rpol", Got: "rpol"
Mismatched prefix: module [openconfig-isis-policy], import [openconfig-isis-types]. Expected "oc-isis-types", Got: "isis-types"
Mismatched prefix: module [openconfig-local-routing-network-instance], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-local-routing], import [openconfig-inet-types]. Expected "oc-inet", Got: "inet"
Mismatched prefix: module [openconfig-local-routing], import [openconfig-policy-types]. Expected "oc-pol-types", Got: "oc-pt"
Mismatched prefix: module [openconfig-macsec], import [openconfig-macsec-types]. Expected "oc-macsect", Got: "macsec-types"
Mismatched prefix: module [openconfig-mpls-rsvp], import [openconfig-inet-types]. Expected "oc-inet", Got: "inet"
Mismatched prefix: module [openconfig-mpls-rsvp], import [openconfig-yang-types]. Expected "oc-yang", Got: "yang"
Mismatched prefix: module [openconfig-mpls-static], import [openconfig-inet-types]. Expected "oc-inet", Got: "inet"
Mismatched prefix: module [openconfig-mpls-te], import [openconfig-inet-types]. Expected "oc-inet", Got: "inet"
Mismatched prefix: module [openconfig-mpls-te], import [openconfig-mpls-sr]. Expected "oc-mpls-sr", Got: "oc-sr"
Mismatched prefix: module [openconfig-mpls-te], import [openconfig-yang-types]. Expected "oc-yang", Got: "yang"
Mismatched prefix: module [openconfig-network-instance-l3], import [openconfig-types]. Expected "oc-types", Got: "octypes"
Mismatched prefix: module [openconfig-programming-errors], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-openflow], import [openconfig-openflow-types]. Expected "openflow-types", Got: "of-types"
Mismatched prefix: module [openconfig-ospf-area], import [openconfig-ospf-types]. Expected "oc-ospf-types", Got: "oc-ospft"
Mismatched prefix: module [openconfig-ospf-global], import [openconfig-ospf-types]. Expected "oc-ospf-types", Got: "oc-ospft"
Mismatched prefix: module [openconfig-ospfv2-global], import [openconfig-ospf-types]. Expected "oc-ospf-types", Got: "oc-ospft"
Mismatched prefix: module [openconfig-ospfv3-area-interface], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-p4rt], import [openconfig-system-grpc]. Expected "oc-sys-grpc", Got: "oc-grpc"
Mismatched prefix: module [openconfig-pf-forwarding-policies], import [openconfig-packet-match]. Expected "oc-pkt-match", Got: "oc-pmatch"
Mismatched prefix: module [openconfig-pf-srte], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-rib-bgp-attributes], import [openconfig-bgp-types]. Expected "oc-bgp-types", Got: "oc-bgpt"
Mismatched prefix: module [openconfig-rib-bgp-attributes], import [openconfig-rib-bgp-types]. Expected "oc-bgprib-types", Got: "oc-bgprt"
Mismatched prefix: module [openconfig-rib-bgp-ext], import [openconfig-rib-bgp-types]. Expected "oc-bgprib-types", Got: "oc-bgpribt"
Mismatched prefix: module [openconfig-rib-bgp-ext], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-rib-bgp-table-attributes], import [openconfig-rib-bgp-types]. Expected "oc-bgprib-types", Got: "oc-bgpribt"
Mismatched prefix: module [openconfig-rib-bgp-tables], import [openconfig-bgp-types]. Expected "oc-bgp-types", Got: "oc-bgpt"
Mismatched prefix: module [openconfig-rib-bgp], import [openconfig-bgp-types]. Expected "oc-bgp-types", Got: "oc-bgpt"
Mismatched prefix: module [openconfig-rsvp-sr-ext], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-hashing], import [openconfig-interfaces]. Expected "oc-if", Got: "oc-intf"
Mismatched prefix: module [openconfig-system-grpc], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-system-logging], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-system], import [openconfig-network-instance]. Expected "oc-netinst", Got: "oc-ni"
Mismatched prefix: module [openconfig-access-points], import [openconfig-wifi-phy]. Expected "oc-wifi-phy", Got: "wifi-phy"
Mismatched prefix: module [openconfig-access-points], import [openconfig-wifi-mac]. Expected "oc-wifi-mac", Got: "wifi-mac"
Mismatched prefix: module [openconfig-ap-interfaces], import [openconfig-access-points]. Expected "access-points", Got: "oc-access-points"
Mismatched prefix: module [openconfig-ap-manager], import [openconfig-wifi-types]. Expected "oc-wifi-types", Got: "oc-wifi"

earies avatar Jul 08 '25 02:07 earies

Just my $0.02. This is something that tooling has to be able to handle. It's not something in the style guide. We already had to handle this in most tooling. We can go change it, but I'd question where it ends up being confusing practically.

robshakir avatar Jul 10 '25 12:07 robshakir

Just my $0.02. This is something that tooling has to be able to handle. It's not something in the style guide. We already had to handle this in most tooling. We can go change it, but I'd question where it ends up being confusing practically.

Agreed tooling should handle this at a minimum. Any correction of prefixes would be merely to follow a consistent protocol and potentially reduce confusion for the human reader is all.

The question is - Is it worth correction and consistent protocol going fwd? Does anyone envision any negative impact?

earies avatar Jul 10 '25 17:07 earies

Since our toolchain handles the prefix names defined in each module individually (which seems like the right thing to do) I suppose the only reason to have consistency is for human readability and fixing lint warnings. The reason not to do it is whether or not we think the effort has a positive impact.

I did a little history search on this as I was curious and the subject of lint errors was brought up in the OC Community meeting. We haven't made pyang --strict --lint output block PR's, but 10 years ago, the style guide asserted this should be done

There are 282 findings. Ironically, they do not include 'Mismatched prefix'. (Pardon my naivety, but which tool is providing those findings? Even with the --ietf flag I don't see them? )

(venv) dloher-mac:public dloher$ pyang --version
pyang 2.6.1
(venv) dloher-mac:public dloher$ pyang --lint --strict -p release/models/*/* 2>&1 | wc -l
     282

256 of which are keyword "<insert_keyword_here>" not in canonical order (RFC 6020, Section 12)

How badly do we want to fix these? I figure if someone is willing to do the work, we should accept it. But I'm not sure if this should be made mandatory to be fixed.

A strategy in featureprofiles has been to incrementally enforce new requirements via changed/new files in PRs. This way we don't make the issue worse and as modules are updated, we would organically address this technical debt. Thoughts?

dplore avatar Jul 10 '25 19:07 dplore

By no means mandatory or a big deal - it's a SHOULD for best practice is all and reason why strict linters likely won't flag

   To improve readability of YANG modules, the prefix defined by a module
   SHOULD be used when the module is imported, unless there is a
   conflict.  If there is a conflict, i.e., two different modules that
   both have defined the same prefix are imported, at least one of them
   MUST be imported with a different prefix.

earies avatar Jul 10 '25 19:07 earies