|
5 | 5 | //! Interface to a (currently simulated) SP / RoT.
|
6 | 6 |
|
7 | 7 | use crate::config::Config as SledConfig;
|
| 8 | +use crate::illumos; |
| 9 | +use crate::illumos::dladm::CreateVnicError; |
8 | 10 | use crate::illumos::dladm::Dladm;
|
9 |
| -use crate::illumos::dladm::FindPhysicalLinkError; |
10 | 11 | use crate::zone::EnsureGzAddressError;
|
11 | 12 | use crate::zone::Zones;
|
12 | 13 | use slog::Logger;
|
@@ -36,8 +37,10 @@ use thiserror::Error;
|
36 | 37 | pub enum SpError {
|
37 | 38 | #[error("Simulated SP config specifies distinct IP addresses ({0}, {1})")]
|
38 | 39 | 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), |
41 | 44 | #[error("Could not ensure IP address {addr} in global zone for simulated SP: {err}")]
|
42 | 45 | EnsureGlobalZoneAddressError { addr: Ipv6Addr, err: EnsureGzAddressError },
|
43 | 46 | #[error("Could not start simualted SP: {0}")]
|
@@ -130,16 +133,19 @@ async fn start_simulated_sp(
|
130 | 133 | }
|
131 | 134 |
|
132 | 135 | // 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(ðerstub) |
| 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 | + })?; |
143 | 149 | }
|
144 | 150 |
|
145 | 151 | // Start up the simulated SP.
|
|
0 commit comments