fix(sonic): keep AF admin_status true/false - #2654
Merged
Merged
Conversation
The vendored community YANG types BGP_NEIGHBOR_AF.admin_status as the up/down enumeration shared with PORT, so the validator flags every generated address-family row. Reading that as a defect in the generator points at the wrong fix: emitting the model's spelling would produce a config the switches do not act on. The table belongs to the unified FRR management interface, and that feature's own ConfigDB schema types the leaf as a boolean, in the same document where PORT is up/down. Its consumer agrees: in frrcfgd the address-family admin_status entries of nbr_af_key_map are bound to the token pair true/false, and a value outside that pair yields no command at all -- the neighbor is never activated for the address family, and a config that reads correctly produces a peering that carries no routes. Upstream resolved the contradiction in the consumer rather than in the model, teaching frrcfgd up/down in addition to true/false so that existing deployments keep working; that change is in community master and 202505 but not in 202411 or older, which covers the builds in the field today. So the generator's true/false is right and the model is the wrong side here. Opting the whole table out via PLATFORM_DIVERGENT_TABLES would also give up the neighbor leafref and every other field, so add a field-granular list beside it: PLATFORM_DIVERGENT_FIELDS retypes one leaf to what the platform accepts and emits the reason as a comment on the generated field. The rest of the table stays validated, and so does the leaf -- against the platform rather than against the model, which makes re-introducing the model's spelling an error rather than a silent regression. The documentation records what would let the entry be dropped again -- switches running builds whose frrcfgd carries the upstream change, established on a device rather than from a version number, since no published mapping ties an Enterprise build to its community branch -- and that both sides have to move together. DocImpact Assisted-by: Claude:claude-opus-5 Signed-off-by: Roger Luethi <luethi@osism.tech>
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the platform actually expects up/down, this validation change could allow generated true/false values that leave BGP address families inactive, disrupting route exchange and potentially causing a production network outage. Reverting the validator would not undo any already-applied configuration, so affected devices would require a separate configuration correction.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Problem
The vendored community YANG types
BGP_NEIGHBOR_AF.admin_statusasstypes:admin_status— theup/downenumeration shared withPORT— so the ConfigDB validator flags every address-family row the configgenerator writes.
Reading that as a defect in the generator points at the wrong fix. Emitting
the model's spelling produces a config the switches do not act on.
Why
true/falseis the correct valueBGP_NEIGHBOR_AFbelongs to the unified FRR management interface, and thatfeature's own ConfigDB schema types the leaf as a boolean — in the same
document where
PORTand the interface tables areup/down:—
SONiC_Design_Doc_Unified_FRR_Mgmt_Interface.md§3.2.1.7The consumer agrees. In
frrcfgd, the address-familyadmin_statusentriesof
nbr_af_key_mapare bound to a bool token pair,['true', 'false', False]on 202411 and older:
—
frrcfgd.pyA value outside that pair does not fall back to anything:
get_command_cmnlogs and returns
None, so no vtysh command is produced at all.Upstream resolved the contradiction in the consumer rather than in the model.
frrcfgdwas taughtup/downin addition totrue/false, explicitly sothat existing deployments keep working (sonic-buildimage#21697, merged
2025-03-12). That change is in community
masterand202505; it is notin
202411,202405or202311.Measured
Driving
BGPConfigDaemondirectly on both revisions —swsscommonmocked,g_run_commandcaptured, aBGP_GLOBALSrow followed by aBGP_NEIGHBOR_AFrow:
frrcfgdadmin_status: "true"admin_status: "up"neighbor 10.0.0.1 activateneighbor 10.0.0.1 activateneighbor 10.0.0.1 activateThe 202411
upcase logs, and does nothing else:That last line caches the value as if it had been applied, so rewriting the
unchanged row never retries; only a
frrcfgdrestart re-reads CONFIG_DB fromscratch. The visible result on a switch is two syslog lines and a BGP peering
that carries no routes.
An independent cross-check:
osism/network-designsonic-l3-core-vrf/*/config_db.json, taken off Accton hardware withfrr_mgmt_framework_config: true, carriesPORT.admin_status: "up"andBGP_NEIGHBOR_AF.admin_status: "true"in the same file. Those are notgenerator output — the default-VRF
BGP_NEIGHBORrows lack thev6onlythisgenerator always writes,
BGP_GLOBALS_AFlacksibgp_equal_cluster_lengthandthe l2vpn
advertise-*pair, andalways_compare_medisfalsewhere thegenerator hardcodes
true.What this changes
The generator already emits
true. This makes the validator agree, withoutgiving up the table.
PLATFORM_DIVERGENT_TABLESis table-granular: using it here would drop theschema for the whole table, including the
neighborleafref and every otherfield. So this adds a field-granular sibling.
PLATFORM_DIVERGENT_FIELDSmaps(table, leaf)to the annotation the platform accepts plus a reason, which isemitted as a comment beside the generated field:
The rest of the table stays validated, and so does the leaf — against the
platform rather than against the model. Emitting the model's spelling is now a
test failure rather than a silent regression.
docs/sonic-config-validation.mdrecords the rationale and, more usefully,what would let the entry be dropped again: switches running builds whose
frrcfgdcarries the upstream change, established on a device rather thanfrom a version number, since no published mapping ties an Enterprise build to
its community branch. Both sides have to move together when that happens.
Tests
Three assertions in the validator test module: the platform value accepted,
the model's spelling rejected, and a bad
send_communityin the same tablestill flagged — that last one is what distinguishes this from opting the table
out.
3244 passed, 3 pre-existing xfailsintests/unit, flake8 and blackclean. Regenerating the schemas reproduces the committed output exactly.
Note for reviewers
main: feat(sonic): validate BGP_NEIGHBOR_AF key references #2619upfor this table. They were foldedinto that series' history while it was expected to land after fix(sonic): emit up/down for BGP_NEIGHBOR_AF #2618, so they
need regenerating rather than editing — and that series is 68 commits behind
main, predating the merged LAG peer resolution, so it needs rebasing first.Until then its goldens would also fail the artifact test added in fix(sonic): make the ConfigDB validator usable as a gate #2626.