aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs11
1 files changed, 11 insertions, 0 deletions
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),