Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ pub const VPC_IPV6_PREFIX_LENGTH: u8 = 48;
/// The prefix length for all VPC subnets
pub const VPC_SUBNET_IPV6_PREFIX_LENGTH: u8 = 64;

/// Minimum prefix size supported in IPv4 VPC Subnets.
///
/// NOTE: This is the minimum _prefix_, which sets the maximum subnet size.
pub const MIN_VPC_IPV4_SUBNET_PREFIX: u8 = 8;

/// The number of reserved addresses at the beginning of a subnet range.
pub const NUM_INITIAL_RESERVED_IP_ADDRESSES: usize = 5;

/// The maximum prefix size by default.
///
/// There are 6 Oxide reserved IP addresses, 5 at the beginning for DNS and the
/// like, and the broadcast address at the end of the subnet. This size provides
/// room for 2 ** 6 - 6 = 58 IP addresses, which seems like a reasonable size
/// for the smallest subnet that's still useful in many contexts.
pub const MAX_VPC_IPV4_SUBNET_PREFIX: u8 = 26;

// The number of ports available to an SNAT IP.
// Note that for static NAT, this value isn't used, and all ports are available.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

//! Types shared between Nexus and Sled Agent.

use super::nexus::HostIdentifier;
use crate::{
address::NUM_SOURCE_NAT_PORTS,
api::external::{self, BfdMode, ImportExportPolicy, Name, Vni},
Expand All @@ -25,60 +26,11 @@ use std::{
use strum::EnumCount;
use uuid::Uuid;

use super::nexus::HostIdentifier;

/// The type of network interface
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
Ord,
PartialOrd,
Deserialize,
Serialize,
JsonSchema,
Hash,
Diffable,
)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum NetworkInterfaceKind {
/// A vNIC attached to a guest instance
Instance { id: Uuid },
/// A vNIC associated with an internal service
Service { id: Uuid },
/// A vNIC associated with a probe
Probe { id: Uuid },
}
pub mod network_interface;

/// Information required to construct a virtual network interface
#[derive(
Clone,
Debug,
Deserialize,
Serialize,
JsonSchema,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Diffable,
)]
pub struct NetworkInterface {
pub id: Uuid,
pub kind: NetworkInterfaceKind,
pub name: Name,
pub ip: IpAddr,
pub mac: external::MacAddr,
pub subnet: IpNet,
pub vni: Vni,
pub primary: bool,
pub slot: u8,
#[serde(default)]
pub transit_ips: Vec<IpNet>,
}
// Re-export latest version of all NIC-related types.
pub use network_interface::NetworkInterfaceKind;
pub use network_interface::*;

/// An IP address and port range used for source NAT, i.e., making
/// outbound network connections from guests or services.
Expand Down Expand Up @@ -780,7 +732,7 @@ impl TryFrom<&[ipnetwork::IpNetwork]> for IpAllowList {

/// A VPC route resolved into a concrete target.
#[derive(
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
)]
pub struct ResolvedVpcRoute {
pub dest: IpNet,
Expand Down
Loading
Loading