Skip to content

Commit

Permalink
ignore localhost IPs for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallagher committed Dec 16, 2024
1 parent 78d44c5 commit 64d2164
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ impl SledUnderlayIpAllocator {
) -> Result<(), SledUnderlayIpOutOfRange> {
// We intentionally ignore any internal DNS underlay IPs; they live
// outside the sled subnet and are allocated separately.
if zone_kind == ZoneKind::InternalDns {
//
// Also ignore `::1` and IPv6-mapped `127.0.0.1`, as they are used by
// the test suite. (Ideally we'd gate the localhost checks behind
// `#[cfg(test)]`, but that only works if _this_ crate is compiled in
// test mode. Checking for localhost in production should be harmless.)
if zone_kind == ZoneKind::InternalDns
|| ip.is_loopback()
|| ip.to_ipv4_mapped().map_or(false, |ip| ip.is_loopback())
{
return Ok(());
}

Expand Down

0 comments on commit 64d2164

Please sign in to comment.