@@ -54,6 +54,7 @@ use illumos_utils::running_zone::{
5454} ;
5555use illumos_utils:: smf_helper:: SmfHelper ;
5656use illumos_utils:: zfs:: ZONE_ZFS_RAMDISK_DATASET_MOUNTPOINT ;
57+ use illumos_utils:: zone:: AddressRequest ;
5758use illumos_utils:: zpool:: { PathInPool , ZpoolName } ;
5859use illumos_utils:: { execute, PFEXEC } ;
5960use internal_dns_resolver:: Resolver ;
@@ -541,18 +542,6 @@ struct SwitchZoneConfigLocal {
541542 root : Utf8PathBuf ,
542543}
543544
544- /// Service that sets up common networking across zones
545- struct ZoneNetworkSetupService { }
546-
547- impl illumos_utils:: smf_helper:: Service for ZoneNetworkSetupService {
548- fn service_name ( & self ) -> String {
549- "zone-network-setup" . to_string ( )
550- }
551- fn smf_name ( & self ) -> String {
552- format ! ( "svc:/oxide/{}" , self . service_name( ) )
553- }
554- }
555-
556545/// Describes either an Omicron-managed zone or the switch zone, used for
557546/// functions that operate on either one or the other
558547enum ZoneArgs < ' a > {
@@ -4298,52 +4287,58 @@ impl ServiceManager {
42984287 ) ;
42994288 * request = new_request;
43004289
4301- // Add SMF properties here and restart zone-network-setup service
43024290 let first_address = request. addresses . get ( 0 ) ;
43034291 let address = first_address
43044292 . map ( |addr| addr. to_string ( ) )
43054293 . unwrap_or_else ( || "" . to_string ( ) ) ;
43064294
4307- // Set new properties for the network set up service and refresh
4308- let nw_setup_svc = ZoneNetworkSetupService { } ;
4309- let nsmfh = SmfHelper :: new ( & zone, & nw_setup_svc) ;
4310-
4311- nsmfh. delpropvalue ( "config/gateway" , "*" ) ?;
4312- nsmfh. delpropvalue ( "config/static_addr" , "*" ) ?;
4313-
4314- if let Some ( info) = self . inner . sled_info . get ( ) {
4315- nsmfh. addpropvalue_type (
4316- "config/gateway" ,
4317- & info. underlay_address ,
4318- "astring" ,
4319- ) ?;
4320- } else {
4321- // It should be impossible for the `sled_info` not to be set here.
4322- // When the request addresses have changed this means the underlay is
4323- // available as well.
4324- error ! (
4295+ for addr in & request. addresses {
4296+ if * addr == Ipv6Addr :: LOCALHOST {
4297+ continue ;
4298+ }
4299+ info ! (
43254300 self . inner. log,
4326- concat!(
4327- "sled agent info is not present," ,
4328- " even though underlay address exists"
4329- )
4301+ "Ensuring address {} exists" ,
4302+ addr. to_string( )
4303+ ) ;
4304+ let addr_request =
4305+ AddressRequest :: new_static ( IpAddr :: V6 ( * addr) , None ) ;
4306+ zone. ensure_address ( addr_request) . await ?;
4307+ info ! (
4308+ self . inner. log,
4309+ "Ensuring address {} exists - OK" ,
4310+ addr. to_string( )
43304311 ) ;
43314312 }
43324313
4333- for address in & request. addresses {
4334- if * address != Ipv6Addr :: LOCALHOST {
4335- nsmfh. addpropvalue_type (
4336- "config/static_addr" ,
4337- & address,
4338- "astring" ,
4339- ) ?;
4340- }
4314+ // When the request addresses have changed this means the underlay is
4315+ // available now as well.
4316+ if let Some ( info) = self . inner . sled_info . get ( ) {
4317+ info ! (
4318+ self . inner. log,
4319+ "Ensuring there is a default route" ;
4320+ "gateway" => ?info. underlay_address,
4321+ ) ;
4322+ match zone. add_default_route ( info. underlay_address ) . map_err (
4323+ |err| Error :: ZoneCommand {
4324+ intent : "Adding Route" . to_string ( ) ,
4325+ err,
4326+ } ,
4327+ ) {
4328+ Ok ( _) => ( ) ,
4329+ Err ( e) => {
4330+ if e. to_string ( ) . contains ( "entry exists" ) {
4331+ info ! (
4332+ self . inner. log,
4333+ "Default route already exists" ;
4334+ "gateway" => ?info. underlay_address,
4335+ )
4336+ } else {
4337+ return Err ( e) ;
4338+ }
4339+ }
4340+ } ;
43414341 }
4342- nsmfh. refresh ( ) ?;
4343- info ! (
4344- self . inner. log,
4345- "refreshed zone-network-setup service with new configuration"
4346- ) ;
43474342
43484343 for service in & request. services {
43494344 let smfh = SmfHelper :: new ( & zone, service) ;
0 commit comments