BUGFIX: Static routes flapping due to missing comparison logic#9907
Merged
internet-diglett merged 2 commits intomainfrom Feb 24, 2026
Merged
BUGFIX: Static routes flapping due to missing comparison logic#9907internet-diglett merged 2 commits intomainfrom
internet-diglett merged 2 commits intomainfrom
Conversation
cb42f30 to
88e8f90
Compare
taspelund
approved these changes
Feb 24, 2026
jgallagher
requested changes
Feb 24, 2026
| // is happening. | ||
| let priority = match route.rib_priority { | ||
| Some(v) => Some(v.0), | ||
| None => Some(DEFAULT_RIB_PRIORITY_STATIC), |
Contributor
There was a problem hiding this comment.
This change looks correct to me, but I think it's a little fragile. We're mostly working in terms of this type:
#[derive(PartialEq, Eq, Hash, Debug)]
enum SwitchStaticRoute {
V4(SwitchStaticRouteV4),
V6(SwitchStaticRouteV6),
}where the priority field inside SwitchStaticRouteV{4,6} is optional. That means we have to do conversions in multiple places:
static_routes_on_switch()has to wrap the non-optional priority we get from mgd inSome(_)static_routes_in_db()has to replace anyNones withSome(DEFAULT)(new in this PR)static_routes_to_del()andstatic_routes_to_add()both have to.unwrap_or(DEFAULT)the priority fields to convert back to the mgd types; but per the previous two points, the values it's operating on should always beSome(_)
It would be a slightly larger (but not that large, I think?) change, but I'd suggest instead we change SwitchStaticRouteV{4,6} to have non-optional priority fields. These are private types in this task so it wouldn't affect any APIs, and it would clean up 2/3 of the previous points:
static_routes_on_switch()would no longer need to wrap the values from mgd inSome(_)static_routes_to_del()andstatic_routes_to_add()would no longer need.unwrap_or()sstatic_routes_in_db()would still have to replaceNonewithDEFAULT, but it's limited to just this one function
jgallagher
approved these changes
Feb 24, 2026
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.
It was found that the switch sync background task was removing and adding the same route repeatedly. This is due to the static route being stored in the DB with no value set for the
rib_priorityfield, which deserializes toNone. We need to fill this value in with the default value before comparing it to the route that is active inmgd, as the mgd route will have the default value instead ofNone.It the future we plan to make this less cumbersome by putting stronger types around this data, but we need bootstore versioning before implementing such types.
Testing
Changes were tested using a local single node deployment of
omicronBefore
After