Skip to content

Commit 07c508c

Browse files
ppennaCopilot
andcommitted
sandbox: name the runtime identity and gateway without the old store and plan
Two of the shared sandbox modules still reached old APIs for values that the new interface already owns. `sandbox/mod.rs` named the artifacts' runtime identity through `host::store`, which only re-exports `host::runtime::RuntimeIdentity`, and `sandbox/options.rs` found the gateway of `--net` through `host::sandbox::plan::guest_gateway`, the old plan's wrapper around `net::guest_gateway`. `sandbox/mod.rs` now imports `RuntimeIdentity` from `host::runtime`. `sandbox_network` checks `--net` with `Ipv4Cidr::parse`, whose refusal is the plan's word for word, `guest network "ADDRESS" must be an IPv4 address with a /1 to /30 prefix that is not its network's network, broadcast, or gateway (first) address`, with the same code, and takes the gateway from `net::guest_gateway`, which finds one for every address that parses. The order of the refusals does not change, and `SandboxNetwork::new` still checks the network. This is the first step of SL3.10b, whose split was approved once its measured scope came to about ten times its estimate: SL3.10c moves the sandbox network to `NetworkConfig`, and SL3.10d moves the launch off `SandboxLaunch`, `SandboxSettings` and `SandboxUpper`. Tests: `network_policies_that_the_planner_refuses_fail_before_launch` in tests/cli.rs keeps checking, word for word, that `sandbox run --dry-run` and `sandbox provision` refuse `--net 10.0.0.1/24` before they launch or record anything. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ccea875 commit 07c508c

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎nvx-rs/src/host/cli/sandbox/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ use super::{Exit, Result, io_error, output};
2929
use crate::ErrorCode;
3030
use crate::host::artifacts::{Guest, KERNEL_NAME, require_artifact};
3131
use crate::host::paths;
32+
use crate::host::runtime::RuntimeIdentity;
3233
use crate::host::sandbox::distro::DistroFormat;
3334
use crate::host::sandbox::mount::{plan_mounts, validate_mounts};
3435
use crate::host::sandbox::options::{
3536
SandboxOperation, SandboxOptions, sandbox_mounts, validate_sandbox_systemd_policy,
3637
};
3738
use crate::host::sandbox::{SandboxLaunch, SandboxSettings, SandboxUpper};
38-
use crate::host::store::RuntimeIdentity;
3939
use crate::protocol::root::RootUpper;
4040

4141
pub(crate) use self::lifecycle::ProvisionConfig;

‎nvx-rs/src/host/cli/sandbox/options.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use crate::host::paths;
1414
use crate::host::sandbox::distro::DistroFormat;
1515
use crate::host::sandbox::mount::{MountOwner, PolicyKind};
1616
use crate::host::sandbox::options::{PolicyPathOption, SandboxOperation};
17-
use crate::host::sandbox::plan::guest_gateway;
1817
use crate::host::sandbox::{
1918
DEFAULT_ENTRYPOINT, DEFAULT_HOSTNAME, DEFAULT_WORKLOAD_IDENTITY, SandboxLayer, SandboxNetwork,
2019
parse_workload_identity,
2120
};
21+
use crate::net::{Ipv4Cidr, guest_gateway};
2222
use crate::protocol::root::RootUpper;
2323

2424
/// The usage and help of the parser.
@@ -431,7 +431,10 @@ pub(in crate::host::cli) fn sandbox_network(
431431
}
432432
return Ok(None);
433433
};
434-
let gateway = guest_gateway(net)?;
434+
// `Ipv4Cidr` gives a guest network's refusal, and one that it accepts has a gateway: its
435+
// network's first address.
436+
Ipv4Cidr::parse(net).map_err(|message| Exit::error(ErrorCode::Unsupported, message))?;
437+
let gateway = guest_gateway(net).expect("a guest network that parses has a gateway");
435438
if network.network_egress.is_none() && (!rules.allow.is_empty() || !rules.deny.is_empty()) {
436439
return Err(Exit::error(
437440
ErrorCode::Unsupported,

0 commit comments

Comments
 (0)