Skip to content

Configuration of BFD needs more strict validation #10657

Open

Description

@jgallagher

This came up while writing property-based tests for BFD reconciliation as a part of the #10167 work. I think we currently assume operators are doing something reasonable with these settings, but proptests tend to do unreasonable things and expose gaps in validation; I wanted to jot these down here as a "should be fixed at some point".

Currently, RackNetworkConfig contains the complete BFD configuration as a Vec of peers:

/// BFD configuration for connecting the rack to external networks
#[serde(default)]
pub bfd: Vec<v1::BfdPeerConfig>,

each of which is defined as:

#[derive(
Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash, JsonSchema,
)]
pub struct BfdPeerConfig {
pub local: Option<IpAddr>,
pub remote: IpAddr,
pub detection_threshold: u8,
pub required_rx: u64,
pub mode: BfdMode,
pub switch: SwitchSlot,
}

Things that are allowed by these structures that shouldn't be:

  1. detection_threshold must be nonzero (should switch to NonZeroU8)
  2. required_rx is a timeout value in microseconds that eventually gets sent on wire as a u32. Any value greater than u32::MAX isn't representable, so maghemite has to either cast it to a u32 (incorrectly wrapping around, as it does today on main) or saturate it. (I'm not sure whether 0 is a reasonable value here.)
  3. BFD peers are uniquely identified by their remote IP address. Vec<BfdPeerConfig> allows multiple entries with the same remote address.
  4. Maghemite's local API is non-optional; omicron converts None into Ipv4Addr::UNSPECIFIED, which is itself incorrect: if remote is an IPv6 address, this should be Ipv6Addr::UNSPECIFIED. But that means None and Some(0.0.0.0) are identical - do we need None at all? (Relevant to the next point: is binding on "all addresses" even a thing we want to expose?)
  5. local controls the local address on which mgd will bind a socket; allowing any arbitrary IP here is not correct. Completely nonsense IPs (e.g., IPs that aren't associated with any uplink port) will fail to bind, but there are other IPs that will succeed to bind that we presumably don't want to allow (e.g., internal addresses like the underlay or bootstrap addrs).

Activity

  1. added a commit that references this issue on Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions