Skip to content

Commit a326f3f

Browse files
committed
Allocate sim SP IP address on the etherstub VNIC
1 parent 6fd7c47 commit a326f3f

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

sled-agent/src/sp.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
//! Interface to a (currently simulated) SP / RoT.
66
77
use crate::config::Config as SledConfig;
8+
use crate::illumos;
9+
use crate::illumos::dladm::CreateVnicError;
810
use crate::illumos::dladm::Dladm;
9-
use crate::illumos::dladm::FindPhysicalLinkError;
1011
use crate::zone::EnsureGzAddressError;
1112
use crate::zone::Zones;
1213
use slog::Logger;
@@ -36,8 +37,10 @@ use thiserror::Error;
3637
pub enum SpError {
3738
#[error("Simulated SP config specifies distinct IP addresses ({0}, {1})")]
3839
SimulatedSpMultipleIpAddresses(Ipv6Addr, Ipv6Addr),
39-
#[error("Can't access physical link, and none in config: {0}")]
40-
FindPhysicalLinkError(#[from] FindPhysicalLinkError),
40+
#[error("Could not access etherstub for simulated SP: {0}")]
41+
CreateEtherstub(illumos::ExecutionError),
42+
#[error("Could not access etherstub VNIC device for simulated SP: {0}")]
43+
CreateEtherstubVnic(CreateVnicError),
4144
#[error("Could not ensure IP address {addr} in global zone for simulated SP: {err}")]
4245
EnsureGlobalZoneAddressError { addr: Ipv6Addr, err: EnsureGzAddressError },
4346
#[error("Could not start simualted SP: {0}")]
@@ -130,16 +133,19 @@ async fn start_simulated_sp(
130133
}
131134

132135
// Ensure we have the global zone IP address we need for the SP.
133-
let data_link = if let Some(link) = sled_config.data_link.clone() {
134-
link
135-
} else {
136-
Dladm::find_physical()?
137-
};
138-
Zones::ensure_has_global_zone_v6_address(data_link, *sp_addr, "simsp")
139-
.map_err(|err| SpError::EnsureGlobalZoneAddressError {
140-
addr: *sp_addr,
141-
err,
142-
})?;
136+
let etherstub =
137+
Dladm::create_etherstub().map_err(SpError::CreateEtherstub)?;
138+
let etherstub_vnic = Dladm::create_etherstub_vnic(&etherstub)
139+
.map_err(SpError::CreateEtherstubVnic)?;
140+
Zones::ensure_has_global_zone_v6_address(
141+
etherstub_vnic,
142+
*sp_addr,
143+
"simsp",
144+
)
145+
.map_err(|err| SpError::EnsureGlobalZoneAddressError {
146+
addr: *sp_addr,
147+
err,
148+
})?;
143149
}
144150

145151
// Start up the simulated SP.

0 commit comments

Comments
 (0)