Skip to content

Commit 2033231

Browse files
committed
Add dual-stack IP config for internal NICs
- Add dual-stack VPC private address configuration type and include it in the shared NetworkInterface type. - Add database model support for reading / writing the dual-stack NIC type to the database, handling serialization into optional fields. - Update all the callsites to handle the new dual-stack-aware type. - Add a bunch of conversions for the APIs which rely on that new type, of which there are many. This also adds the conversions and older types into the `sled-agent-types` crate, so they can be used in a few places that don't directly depend on the `sled-agent-api` crate itself, notably reconfigurator and `nexus-inventory`. - Update the sled-agent reconciler to deserialize previous versions of its sled-configuration ledgers, convert them, and write them out again as the new versions. - Updates the OPTE `PortManager` type with the new dual-stack support. This is only for private IP addresses, though. We still need some work to support OPTE ports with dual stack external addresses. This is about half of #9247, the VPC-private part. - Closes #9246
1 parent e02810b commit 2033231

File tree

47 files changed

+12064
-1021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+12064
-1021
lines changed

common/src/api/internal/shared.rs renamed to common/src/api/internal/shared/mod.rs

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
//! Types shared between Nexus and Sled Agent.
66
7+
use super::nexus::HostIdentifier;
78
use crate::{
89
address::NUM_SOURCE_NAT_PORTS,
910
api::external::{self, BfdMode, ImportExportPolicy, Name, Vni},
@@ -21,60 +22,11 @@ use std::{
2122
use strum::EnumCount;
2223
use uuid::Uuid;
2324

24-
use super::nexus::HostIdentifier;
25-
26-
/// The type of network interface
27-
#[derive(
28-
Clone,
29-
Copy,
30-
Debug,
31-
Eq,
32-
PartialEq,
33-
Ord,
34-
PartialOrd,
35-
Deserialize,
36-
Serialize,
37-
JsonSchema,
38-
Hash,
39-
Diffable,
40-
)]
41-
#[serde(tag = "type", rename_all = "snake_case")]
42-
pub enum NetworkInterfaceKind {
43-
/// A vNIC attached to a guest instance
44-
Instance { id: Uuid },
45-
/// A vNIC associated with an internal service
46-
Service { id: Uuid },
47-
/// A vNIC associated with a probe
48-
Probe { id: Uuid },
49-
}
25+
pub mod network_interface;
5026

51-
/// Information required to construct a virtual network interface
52-
#[derive(
53-
Clone,
54-
Debug,
55-
Deserialize,
56-
Serialize,
57-
JsonSchema,
58-
PartialEq,
59-
Eq,
60-
PartialOrd,
61-
Ord,
62-
Hash,
63-
Diffable,
64-
)]
65-
pub struct NetworkInterface {
66-
pub id: Uuid,
67-
pub kind: NetworkInterfaceKind,
68-
pub name: Name,
69-
pub ip: IpAddr,
70-
pub mac: external::MacAddr,
71-
pub subnet: IpNet,
72-
pub vni: Vni,
73-
pub primary: bool,
74-
pub slot: u8,
75-
#[serde(default)]
76-
pub transit_ips: Vec<IpNet>,
77-
}
27+
// Re-export latest version of all NIC-related types.
28+
pub use network_interface::NetworkInterfaceKind;
29+
pub use network_interface::v2::*;
7830

7931
/// An IP address and port range used for source NAT, i.e., making
8032
/// outbound network connections from guests or services.
@@ -776,7 +728,7 @@ impl TryFrom<&[ipnetwork::IpNetwork]> for IpAllowList {
776728

777729
/// A VPC route resolved into a concrete target.
778730
#[derive(
779-
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
731+
Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
780732
)]
781733
pub struct ResolvedVpcRoute {
782734
pub dest: IpNet,
@@ -973,12 +925,12 @@ impl JsonSchema for DatasetKind {
973925
}
974926

975927
fn json_schema(
976-
gen: &mut schemars::gen::SchemaGenerator,
928+
generator: &mut schemars::gen::SchemaGenerator,
977929
) -> schemars::schema::Schema {
978930
// The schema is a bit more complicated than this -- it's either one of
979931
// the fixed values or a string starting with "zone/" -- but this is
980932
// good enough for now.
981-
let mut schema = <String>::json_schema(gen).into_object();
933+
let mut schema = <String>::json_schema(generator).into_object();
982934
schema.metadata().description = Some(
983935
"The kind of dataset. See the `DatasetKind` enum \
984936
in omicron-common for possible values."
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Shared network-interface types.
6+
7+
use daft::Diffable;
8+
use schemars::JsonSchema;
9+
use serde::Deserialize;
10+
use serde::Serialize;
11+
use uuid::Uuid;
12+
13+
pub mod v1;
14+
pub mod v2;
15+
16+
/// The type of network interface
17+
#[derive(
18+
Clone,
19+
Copy,
20+
Debug,
21+
Eq,
22+
PartialEq,
23+
Ord,
24+
PartialOrd,
25+
Deserialize,
26+
Serialize,
27+
JsonSchema,
28+
Hash,
29+
Diffable,
30+
)]
31+
#[serde(tag = "type", rename_all = "snake_case")]
32+
pub enum NetworkInterfaceKind {
33+
/// A vNIC attached to a guest instance
34+
Instance { id: Uuid },
35+
/// A vNIC associated with an internal service
36+
Service { id: Uuid },
37+
/// A vNIC associated with a probe
38+
Probe { id: Uuid },
39+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Network interface types version 1
6+
7+
use std::net::IpAddr;
8+
9+
use crate::api::external;
10+
use crate::api::external::Name;
11+
use crate::api::external::Vni;
12+
use crate::api::internal::shared::NetworkInterfaceKind;
13+
use daft::Diffable;
14+
use oxnet::IpNet;
15+
use schemars::JsonSchema;
16+
use serde::Deserialize;
17+
use serde::Serialize;
18+
use uuid::Uuid;
19+
20+
/// Information required to construct a virtual network interface
21+
#[derive(
22+
Clone,
23+
Debug,
24+
Deserialize,
25+
Serialize,
26+
JsonSchema,
27+
PartialEq,
28+
Eq,
29+
PartialOrd,
30+
Ord,
31+
Hash,
32+
Diffable,
33+
)]
34+
pub struct NetworkInterface {
35+
pub id: Uuid,
36+
pub kind: NetworkInterfaceKind,
37+
pub name: Name,
38+
pub ip: IpAddr,
39+
pub mac: external::MacAddr,
40+
pub subnet: IpNet,
41+
pub vni: Vni,
42+
pub primary: bool,
43+
pub slot: u8,
44+
#[serde(default)]
45+
pub transit_ips: Vec<IpNet>,
46+
}

0 commit comments

Comments
 (0)