aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2025-04-06 13:02:31 +0200
committerHimbeer <himbeer@disroot.org>2025-04-06 13:02:31 +0200
commitb9241b987ad7a6a7553451dbeffdffd51a9b8176 (patch)
tree656f184c188a359d075d989dcb2275c91c82f51b
parent8295db3fbb6717f82b795c0ba4f20eb5d6aa55a2 (diff)
Wait for link to be created before adding routes over itHEADmain
This fixes an issue where routes fail to be added if the interface is created by a service, such as WireGuard links.
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs11
2 files changed, 12 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 2e436f3..0275656 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-rsdsl_netlinklib = { git = "https://github.com/rsdsl/netlinklib.git", version = "0.6.0", features = ["blocking", "rule"] }
+rsdsl_netlinklib = { git = "https://github.com/rsdsl/netlinklib.git", version = "0.6.0", features = ["blocking", "link", "rule"] }
diff --git a/src/main.rs b/src/main.rs
index 0754003..a6901c7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -251,6 +251,13 @@ impl RouteDef {
Ok(())
}
+
+ fn link(&self) -> &str {
+ match self {
+ Self::V4(r) => &r.link,
+ Self::V6(r) => &r.link,
+ }
+ }
}
impl fmt::Display for RouteDef {
@@ -842,6 +849,10 @@ fn run() -> Result<(), Error> {
Err(e) => println!("[warn] del {}: {}", route, e),
}
+ println!("[info] wait for link {}", route.def.link());
+ conn.link_wait_exists(route.def.link().to_string())
+ .map_err(SetupError::from)?;
+
if !route.delete {
match route.def.clone().add(&conn) {
Ok(_) => println!("[info] add {}", route),