Skip to content

Nexus external API: Use stronger types for BgpPeer addresses#10122

Open
jgallagher wants to merge 26 commits intomainfrom
john/stronger-unnumbered-types-2
Open

Nexus external API: Use stronger types for BgpPeer addresses#10122
jgallagher wants to merge 26 commits intomainfrom
john/stronger-unnumbered-types-2

Conversation

@jgallagher
Copy link
Contributor

@jgallagher jgallagher commented Mar 23, 2026

This is a followup to #10082, and extends the stronger RouterPeerType out from the internal API to the Nexus external API. The primary changes here are:

  • Change fields of BgpPeer to give stronger guarantees:
    • BgpPeer::addr is now RouterPeerType instead of Option<IpAddr> (which permitted three distinct representations of "unnumbered": None, Some(0.0.0.0), and Some(::)).
    • BgpPeer::router_lifetime moved from being a top-level field to being nested inside the RouterPeerType::Unnumbered variant, and its type is now RouterLifetimeConfig instead of u16, adding enforcement of bounds.
  • Remove BgpPeer::interface_name (closes BgpPeer::interface_name isn't faithfully persisted in the db - we should remove it #10104).
  • Define new versions of types that transitively include BgpPeer:
    • BgpPeerConfig
    • SwitchPortSettings
    • SwitchPortSettingsCreate

The bulk of the diff is defining new versions of all these types and unit tests for the conversions they implement. The rest is fallout where these types touch other areas (e.g., datastore methods and bg tasks) and should be relatively straightforward.

Base automatically changed from john/stronger-unnumbered-types-1 to main March 24, 2026 01:21
@jgallagher jgallagher force-pushed the john/stronger-unnumbered-types-2 branch from 9f59688 to 56e7ddf Compare March 24, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BgpPeer::interface_name isn't faithfully persisted in the db - we should remove it

1 participant