[yang] sonic-static-route: give STATIC_ROUTE_TEMPLATE_LIST the same non-key leaves as STATIC_ROUTE_LIST#28578
Open
bhouse-nexthop wants to merge 1 commit into
Conversation
…leaves as STATIC_ROUTE_LIST Signed-off-by: Brad House - Nexthop <bhouse@nexthop.ai>
bhouse-nexthop
requested review from
dgsudharsan,
praveen-li,
qiluo-msft and
venkatmahalingam
as code owners
July 22, 2026 15:32
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Collaborator
Author
|
/azpw run |
Collaborator
|
Retrying failed(or canceled) jobs... |
Collaborator
|
Retrying failed(or canceled) stages in build 1171962: ✅Stage Test:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
STATIC_ROUTE_TEMPLATE_LIST(key:prefix) andSTATIC_ROUTE_LIST(key:vrf_name prefix) model the same table for the two CONFIG_DB key shapes, but their non-key leaf sets had drifted apart.distance,nexthop-vrf,blackholeand thesidlistlist existed only on the two-component form.The daemons make no such distinction, so the model was describing less than the implementation supports:
bgpcfgd(bgpcfgd/managers_static_rt.py) splits the key first and then reads the fields unconditionally.split_keymaps a bare prefix onto('default', prefix), which is indistinguishable fromdefault|<prefix>— after that point nothing downstream can tell the two shapes apart.frrcfgd(frrcfgd/frrcfgd.py) rewrites a single-componentSTATIC_ROUTEkey to<default-vrf>|<key>before handling it, and declares its consumed field set per table, not per key shape.The practical effect: a one-component key can only match the template list, so every default-VRF static route carrying
distancewas rejected by YANG validation. That blocks the field on any device whose routes are stored in the collapsed form, and breaks restoring a saved configuration on such a device. It is not tool-specific — it reproduces throughsonic_yangdirectly, so it affects the Generic Config Updater equally.This also adds the route
tagattribute, whichfrrcfgdreads for both key shapes and renders into FRR'stag (1-4294967295)static-route parameter, but which neither list declared. Value0expresses the absence of a tag, matching howfrrcfgdrepresents an unset tag and mirroring the existingcolorleaf.Deliberately not added:
track.frrcfgd's static route map references it, but FRR's static route CLI has no such keyword —grep -c track staticd/static_vty.creturns0, and the only occurrences instaticdare internal nexthop-tracking flags. Modelling it would legitimise a field the backend cannot apply.How I did it
Every added leaf is copied verbatim from its sibling in
STATIC_ROUTE_LIST— same type, pattern, default and description — so the two lists now differ only by thevrf_namekey. The change is purely additive: it can only widen the accepted set and cannot invalidate a configuration that validates today.Separately, three descriptions now state that the leaf is a comma-separated per-nexthop list.
advertise,bfd*andcoloralready documented this;distance,nexthop-vrfandblackholedid not, so the multi-value encoding was only discoverable by reading the(X,)*Xpattern. This touches the pre-existingSTATIC_ROUTE_LISTcopies too, which keeps the two lists byte-identical apart from thevrf_namekey.Also adds the first test coverage for
STATIC_ROUTE_TEMPLATE_LIST, which had none. Every existing static-route case exercisedSTATIC_ROUTE_LIST, which is how the drift went unnoticed —bfd*andcolorwere each correctly added to both lists in a single commit, so keeping them in sync is the established convention.How to verify it
YANG model tests:
Verified end-to-end on gold218 (
main.Nexthop.122165, libyang3 3.12.2) againstsonic_yang— the reference validator the Generic Config Updater uses — by swapping only this model file in/usr/local/yang-models:{'10.99.0.0/16': {'nexthop': ..., 'distance': '1'}}{'10.99.1.0/24': {'nexthop': ..., 'blackhole': 'true'}}{'10.99.2.0/24': {'nexthop': ..., 'nexthop-vrf': 'default'}}{'10.99.3.0/24': {'nexthop': ..., 'tag': '1234'}}{'default|10.99.4.0/24': {..., 'distance': '1'}}{'10.99.5.0/24': {..., 'distance': '300'}}The last row is the important one: the invalid value is now rejected by the
distancepattern on the template list —— rather than the field being unreachable. The constraint is enforced, not merely accepted.
Consumers inherit the fix with no code change (models are loaded at runtime).
Which release branch to port
Tested branch (Please provide the tested image version)
Description for the changelog
[yang] sonic-static-route: allow distance, nexthop-vrf, blackhole and sidlist on default-VRF (bare-prefix) static routes, and add the route tag attribute to both key forms.
Link to config_db schema for YANG module changes
https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#static_route
A picture of a cute animal (not mandatory but encouraged)