Skip to content

Commit

Permalink
Clear XDE underlay when destroying virtual hardware (#5602)
Browse files Browse the repository at this point in the history
OPTE now prevents itself from being unloaded if its underlay state is
set. Currently, underlay setup is performed only once, and it seems to
be the case that XDE can be unloaded in some scenarios (e.g., `a4x2`
setup).

However, a consequence is that removing the driver requires an extra
operation to explicitly clear the underlay state. This PR adds this
operation to the `cargo xtask virtual-hardware destroy` command.

Closes #5314.
  • Loading branch information
FelixMcFelix authored May 31, 2024
1 parent 6dee6ee commit 152f61c
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/buildomat/jobs/a4x2-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#:
#: name = "a4x2-deploy"
#: variety = "basic"
#: target = "lab-2.0-opte-0.29"
#: target = "lab-2.0-opte-0.31"
#: output_rules = [
#: "/out/falcon/*.log",
#: "/out/falcon/*.err",
Expand Down
3 changes: 2 additions & 1 deletion .github/buildomat/jobs/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#:
#: name = "helios / deploy"
#: variety = "basic"
#: target = "lab-2.0-opte-0.29"
#: target = "lab-2.0-opte-0.31"
#: output_rules = [
#: "%/var/svc/log/oxide-sled-agent:default.log*",
#: "%/zone/oxz_*/root/var/svc/log/oxide-*.log*",
Expand Down Expand Up @@ -50,6 +50,7 @@ _exit_trap() {
dump-state
pfexec /opt/oxide/opte/bin/opteadm list-ports
pfexec /opt/oxide/opte/bin/opteadm dump-v2b
pfexec /opt/oxide/opte/bin/opteadm dump-v2p
z_swadm link ls
z_swadm addr list
z_swadm route list
Expand Down
32 changes: 10 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ macaddr = { version = "1.0.1", features = ["serde_std"] }
maplit = "1.0.2"
mockall = "0.12"
newtype_derive = "0.1.6"
mg-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "025389ff39d594bf2b815377e2c1dc4dd23b1f96" }
ddm-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "025389ff39d594bf2b815377e2c1dc4dd23b1f96" }
mg-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "5630887d0373857f77cb264f84aa19bdec720ce3" }
ddm-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "5630887d0373857f77cb264f84aa19bdec720ce3" }
multimap = "0.10.0"
nexus-client = { path = "clients/nexus-client" }
nexus-config = { path = "nexus-config" }
Expand Down Expand Up @@ -351,14 +351,14 @@ omicron-sled-agent = { path = "sled-agent" }
omicron-test-utils = { path = "test-utils" }
omicron-zone-package = "0.11.0"
oxide-client = { path = "clients/oxide-client" }
oxide-vpc = { git = "https://github.com/oxidecomputer/opte", rev = "194a8d1d6443f78d59702a25849607dba33db732", features = [ "api", "std" ] }
oxide-vpc = { git = "https://github.com/oxidecomputer/opte", rev = "d6177ca84f23e60a661461bb4cece475689502d2", features = [ "api", "std" ] }
once_cell = "1.19.0"
openapi-lint = { git = "https://github.com/oxidecomputer/openapi-lint", branch = "main" }
openapiv3 = "2.0.0"
# must match samael's crate!
openssl = "0.10"
openssl-sys = "0.9"
opte-ioctl = { git = "https://github.com/oxidecomputer/opte", rev = "194a8d1d6443f78d59702a25849607dba33db732" }
opte-ioctl = { git = "https://github.com/oxidecomputer/opte", rev = "d6177ca84f23e60a661461bb4cece475689502d2" }
oso = "0.27"
owo-colors = "4.0.0"
oximeter = { path = "oximeter/oximeter" }
Expand Down
12 changes: 11 additions & 1 deletion dev-tools/xtask/src/virtual_hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const IPADM: &'static str = "/usr/sbin/ipadm";
const MODINFO: &'static str = "/usr/sbin/modinfo";
const MODUNLOAD: &'static str = "/usr/sbin/modunload";
const NETSTAT: &'static str = "/usr/bin/netstat";
const OPTEADM: &'static str = "/opt/oxide/opte/bin/opteadm";
const PFEXEC: &'static str = "/usr/bin/pfexec";
const PING: &'static str = "/usr/sbin/ping";
const SWAP: &'static str = "/usr/sbin/swap";
Expand Down Expand Up @@ -247,8 +248,17 @@ fn unload_xde_driver() -> Result<()> {
println!("xde driver already unloaded");
return Ok(());
};
println!("unloading xde driver");
println!("unloading xde driver:\na) clearing underlay...");
let mut cmd = Command::new(PFEXEC);
cmd.args([OPTEADM, "clear-xde-underlay"]);
if let Err(e) = execute(cmd) {
// This is explicitly non-fatal: the underlay is only set when
// sled-agent is running. We still need to be able to tear
// down the driver if we immediately call create->destroy.
println!("\tFailed or already unset: {e}");
}

println!("b) unloading module...");
let mut cmd = Command::new(PFEXEC);
cmd.arg(MODUNLOAD);
cmd.arg("-i");
Expand Down
16 changes: 8 additions & 8 deletions package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@ source.repo = "maghemite"
# `tools/maghemite_openapi_version`. Failing to do so will cause a failure when
# building `ddm-admin-client` (which will instruct you to update
# `tools/maghemite_openapi_version`).
source.commit = "23b0cf439f9f62b9a4933e55cc72bcaddc9596cd"
source.commit = "5630887d0373857f77cb264f84aa19bdec720ce3"
# The SHA256 digest is automatically posted to:
# https://buildomat.eng.oxide.computer/public/file/oxidecomputer/maghemite/image/<commit>/maghemite.sha256.txt
source.sha256 = "1ea0e73e149a68bf91b5ce2e0db2a8a1af50dcdbbf381b672aa9ac7e36a3a181"
# https://buildomat.eng.oxide.computer/public/file/oxidecomputer/maghemite/image/<commit>/mg-ddm-gz.sha256.txt
source.sha256 = "28965f303a64f49cf5b83322babe1e0ceb4cfe33fb2df8c8d452d8c3ec02d933"
output.type = "tarball"

[package.mg-ddm]
Expand All @@ -564,10 +564,10 @@ source.repo = "maghemite"
# `tools/maghemite_openapi_version`. Failing to do so will cause a failure when
# building `ddm-admin-client` (which will instruct you to update
# `tools/maghemite_openapi_version`).
source.commit = "23b0cf439f9f62b9a4933e55cc72bcaddc9596cd"
source.commit = "5630887d0373857f77cb264f84aa19bdec720ce3"
# The SHA256 digest is automatically posted to:
# https://buildomat.eng.oxide.computer/public/file/oxidecomputer/maghemite/image/<commit>/mg-ddm.sha256.txt
source.sha256 = "3334b0a9d5956e3117a6b493b9a5a31220391fab1ecbfb3a4bd8e94d7030771a"
source.sha256 = "6fa53be6fc5ad6273e0ca5e969c882ea40c473722415b060dfea420e962d4f8e"
output.type = "zone"
output.intermediate_only = true

Expand All @@ -579,10 +579,10 @@ source.repo = "maghemite"
# `tools/maghemite_openapi_version`. Failing to do so will cause a failure when
# building `ddm-admin-client` (which will instruct you to update
# `tools/maghemite_openapi_version`).
source.commit = "23b0cf439f9f62b9a4933e55cc72bcaddc9596cd"
source.commit = "5630887d0373857f77cb264f84aa19bdec720ce3"
# The SHA256 digest is automatically posted to:
# https://buildomat.eng.oxide.computer/public/file/oxidecomputer/maghemite/image/<commit>/mg-ddm.sha256.txt
source.sha256 = "e0907de39ca9f8ab45d40d361a1dbeed4bd8e9b157f8d3d8fe0a4bc259d933bd"
# https://buildomat.eng.oxide.computer/public/file/oxidecomputer/maghemite/image/<commit>/mgd.sha256.txt
source.sha256 = "6ae4bc3b332e91706c1c6633a7fc218aac65b7feff5643ee2dbbe79b841e0df3"
output.type = "zone"
output.intermediate_only = true

Expand Down
2 changes: 1 addition & 1 deletion tools/maghemite_ddm_openapi_version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
COMMIT="025389ff39d594bf2b815377e2c1dc4dd23b1f96"
COMMIT="5630887d0373857f77cb264f84aa19bdec720ce3"
SHA2="004e873e4120aa26460271368485266b75b7f964e5ed4dbee8fb5db4519470d7"
2 changes: 1 addition & 1 deletion tools/maghemite_mg_openapi_version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
COMMIT="23b0cf439f9f62b9a4933e55cc72bcaddc9596cd"
COMMIT="5630887d0373857f77cb264f84aa19bdec720ce3"
SHA2="fdb33ee7425923560534672264008ef8948d227afce948ab704de092ad72157c"
4 changes: 2 additions & 2 deletions tools/maghemite_mgd_checksums
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CIDL_SHA256="e0907de39ca9f8ab45d40d361a1dbeed4bd8e9b157f8d3d8fe0a4bc259d933bd"
MGD_LINUX_SHA256="903413ddaab89594ed7518cb8f2f27793e96cd17ed2d6b3fe11657ec4375cb19"
CIDL_SHA256="6ae4bc3b332e91706c1c6633a7fc218aac65b7feff5643ee2dbbe79b841e0df3"
MGD_LINUX_SHA256="7930008cf8ce535a8b31043fc3edde0e825bd54d75f73234929bd0037ecc3a41"
2 changes: 1 addition & 1 deletion tools/opte_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.29.250
0.31.259
4 changes: 2 additions & 2 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ workspace = true
[dependencies]
ahash = { version = "0.8.11" }
aho-corasick = { version = "1.1.3" }
anyhow = { version = "1.0.83", features = ["backtrace"] }
anyhow = { version = "1.0.86", features = ["backtrace"] }
base16ct = { version = "0.2.0", default-features = false, features = ["alloc"] }
bit-set = { version = "0.5.3" }
bit-vec = { version = "0.6.3" }
Expand Down Expand Up @@ -124,7 +124,7 @@ zeroize = { version = "1.7.0", features = ["std", "zeroize_derive"] }
[build-dependencies]
ahash = { version = "0.8.11" }
aho-corasick = { version = "1.1.3" }
anyhow = { version = "1.0.83", features = ["backtrace"] }
anyhow = { version = "1.0.86", features = ["backtrace"] }
base16ct = { version = "0.2.0", default-features = false, features = ["alloc"] }
bit-set = { version = "0.5.3" }
bit-vec = { version = "0.6.3" }
Expand Down

0 comments on commit 152f61c

Please sign in to comment.