MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / run_nft_stdin

Function run_nft_stdin

crates/openshell-driver-vm/src/runtime.rs:566–593  ·  view source on GitHub ↗
(ruleset: &str)

Source from the content-addressed store, hash-verified

564}
565
566fn run_nft_stdin(ruleset: &str) -> Result<(), String> {
567 use std::io::Write;
568
569 let mut child = StdCommand::new("nft")
570 .args(["-f", "-"])
571 .stdin(Stdio::piped())
572 .stdout(Stdio::piped())
573 .stderr(Stdio::piped())
574 .spawn()
575 .map_err(|e| format!("failed to run nft: {e}"))?;
576
577 if let Some(mut stdin) = child.stdin.take() {
578 stdin
579 .write_all(ruleset.as_bytes())
580 .map_err(|e| format!("failed to write nft ruleset: {e}"))?;
581 }
582
583 let output = child
584 .wait_with_output()
585 .map_err(|e| format!("failed to wait for nft: {e}"))?;
586
587 if output.status.success() {
588 Ok(())
589 } else {
590 let stderr = String::from_utf8_lossy(&output.stderr);
591 Err(format!("nft -f - failed: {stderr}"))
592 }
593}
594
595/// RAII guard that tears down TAP networking on drop.
596struct TapGuard {

Callers 1

setup_tap_networkingFunction · 0.85

Calls 2

spawnMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected