[Nexthop][fboss2-dev] Add delete switch admin-distance and icmpv4-unavailable-src-addr - #1523
Open
vybhav-nexthop wants to merge 2 commits into
Open
[Nexthop][fboss2-dev] Add delete switch admin-distance and icmpv4-unavailable-src-addr#1523vybhav-nexthop wants to merge 2 commits into
vybhav-nexthop wants to merge 2 commits into
Conversation
…c-addr delete switch admin-distance <client-id> removes a routing client's entry from sw.clientIdToAdminDistance. Once the entry is gone, getAdminDistanceForClientId() finds no mapping and returns AdminDistance::MAX_ADMIN_DISTANCE (255) for that client; the per-client default in switch_config.thrift only applies when the whole map is absent from the config. Saved at coldboot level because the map is consulted only at route-program time and existing routes are not re-stamped. Client-ids 1-4 (STATIC_ROUTE, INTERFACE_ROUTE, LINKLOCAL_ROUTE, REMOTE_INTERFACE_ROUTE) are refused: their distances are hardcoded in the agent, mirroring the refusal in config switch admin-distance. The client-id parsing and forbidden-client check are shared with the config command via parseAdminDistanceClientId(). delete switch icmpv4-unavailable-src-addr clears the optional sw.icmpV4UnavailableSrcAddress field, returning it to its unset default. Hitless.
vybhav-nexthop
force-pushed
the
delete-switch-admin-distance
branch
from
August 17, 2026 13:30
a071842 to
34859c2
Compare
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.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
Background: what admin distance is and what deleting an entry means
When two routing clients (BGP, OpenR, static config, ...) offer routes to the same prefix, admin distance decides who wins: the route with the lowest distance is programmed.
sw.clientIdToAdminDistancemaps a client-id to its distance, and the agent consults it throughgetAdminDistanceForClientId()each time it programs a route for that client.Deleting a client's entry does not resurrect a per-client default: the thrift default map applies only when the whole field is absent from the config. A client with no entry gets
AdminDistance::MAX_ADMIN_DISTANCE(255, least preferred), and the agent logs an error per lookup. Client-ids 1 through 4 (STATIC_ROUTE, INTERFACE_ROUTE, LINKLOCAL_ROUTE, REMOTE_INTERFACE_ROUTE) never consult the map at all; their distances are compile-time constants in the agent.What: Two delete commands under a new
delete switchbranch, mirroringconfig switch:admin-distanceremoves the client's entry fromsw.clientIdToAdminDistance. Saved at coldboot level, for the same reason as the config counterpart: the map is consulted only at route-program time, and existing routes are not re-stamped when it changes. Client-ids 1 through 4 are refused, mirroring the refusal inconfig switch admin-distance, since removing an entry the agent never reads would only pretend to do something.icmpv4-unavailable-src-addrclears the optionalsw.icmpV4UnavailableSrcAddressfield, returning it to its unset default. Hitless.Why:
config switch admin-distanceandconfig switch icmpv4-unavailable-src-addrcould set these values but nothing could remove them.How: Both leaves follow the single-positional-arg pattern of the existing delete commands. The client-id parsing and forbidden-client check are shared with the config command via
parseAdminDistanceClientId()next to the existingforbiddenAdminDistanceClients(), so the config and delete commands cannot drift apart. The success message states the consequence: routes from the client will useMAX_ADMIN_DISTANCE(255) until a new entry is set, and a coldboot applies the change to existing routes.Sample usage
Test Plan
Validation ran in our internal tree, which carries this same change. The upstream tree itself was not built locally; this PR's CI is the build verification.
Unit (
cmd_config_test): arg validation (arity, non-integer, negative), forbidden-client refusal (ids 1 through 4 refused, entry kept), delete existing entry, delete missing entry throws, plus the icmpv4 set/clear paths:Integration (
ConfigAdminDistanceTest, run on a DUT): set an entry for an unused client-id, delete it, verify the running config returns exactly to baseline; forbidden client-ids rejected symmetrically by config and delete.Review Findings
Pre-publication review (5 reviewers + verifier) raised one finding, fixed before push: the delete argument type duplicated the config command's client-id parse/validate block, now extracted into the shared
parseAdminDistanceClientId().