Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sled agent] Add default routes, using GZ addresses as gateways #1147

Merged
merged 8 commits into from
Jun 5, 2022
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
9 changes: 5 additions & 4 deletions sled-agent/src/illumos/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::illumos::zone::{AddressRequest, ZONE_PREFIX};
use crate::opte::OptePort;
use ipnetwork::IpNetwork;
use slog::Logger;
use std::net::Ipv6Addr;
use std::path::PathBuf;

#[cfg(test)]
Expand Down Expand Up @@ -171,17 +172,17 @@ impl RunningZone {
Ok(network)
}

pub async fn add_route(
pub async fn add_default_route(
&self,
destination: ipnetwork::Ipv6Network,
gateway: Ipv6Addr,
) -> Result<(), RunCommandError> {
self.run_cmd(&[
"/usr/sbin/route",
"add",
"-inet6",
&format!("{}/{}", destination.network(), destination.prefix()),
"default",
"-inet6",
&destination.ip().to_string(),
&gateway.to_string(),
])?;
Ok(())
}
Expand Down
17 changes: 9 additions & 8 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use crate::illumos::vnic::VnicAllocator;
use crate::illumos::zone::AddressRequest;
use crate::params::{ServiceEnsureBody, ServiceRequest};
use crate::zone::Zones;
use ipnetwork::Ipv6Network;
use omicron_common::address::{AZ_PREFIX, DNS_PORT, DNS_SERVER_PORT};
use omicron_common::address::{DNS_PORT, DNS_SERVER_PORT};
use slog::Logger;
use std::collections::HashSet;
use std::iter::FromIterator;
Expand Down Expand Up @@ -229,7 +228,7 @@ impl ServiceManager {
})?;
}

let gz_route_subnet = if !service.gz_addresses.is_empty() {
let gateway = if !service.gz_addresses.is_empty() {
// If this service supplies its own GZ address, add a route.
//
// This is currently being used for the DNS service.
Expand All @@ -238,16 +237,18 @@ impl ServiceManager {
// can be supplied - now that we're actively using it, we
// aren't really handling the "many GZ addresses" case, and it
// doesn't seem necessary now.
Ipv6Network::new(service.gz_addresses[0], AZ_PREFIX).unwrap()
service.gz_addresses[0]
} else {
// Otherwise, add a route to the global Zone's sled address for
// everything within the AZ.
Ipv6Network::new(self.underlay_address, AZ_PREFIX).unwrap()
self.underlay_address
};
running_zone.add_route(gz_route_subnet).await.map_err(|err| {

running_zone.add_default_route(gateway).await.map_err(|err| {
Error::ZoneCommand { intent: "Adding Route".to_string(), err }
})?;

// TODO: Related to
// https://github.com/oxidecomputer/omicron/pull/1124 , should we
// avoid importing this manifest?
debug!(self.log, "importing manifest");

running_zone
Expand Down
9 changes: 4 additions & 5 deletions sled-agent/src/storage_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use crate::params::DatasetKind;
use futures::stream::FuturesOrdered;
use futures::FutureExt;
use futures::StreamExt;
use ipnetwork::Ipv6Network;
use nexus_client::types::{DatasetPutRequest, ZpoolPutRequest};
use omicron_common::address::AZ_PREFIX;
use omicron_common::api::external::{ByteCount, ByteCountRangeError};
use omicron_common::backoff;
use schemars::JsonSchema;
Expand Down Expand Up @@ -497,9 +495,10 @@ async fn ensure_running_zone(

zone.ensure_address(address_request).await?;

let gz_subnet =
Ipv6Network::new(underlay_address, AZ_PREFIX).unwrap();
zone.add_route(gz_subnet).await.map_err(Error::ZoneCommand)?;
let gateway = underlay_address;
zone.add_default_route(gateway)
.await
.map_err(Error::ZoneCommand)?;

dataset_info
.start_zone(log, &zone, dataset_info.address, do_format)
Expand Down