diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-13 14:22:03 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-13 14:22:03 +0100 |
commit | 00db1e3bbcb563cd58012f9cbc501e77007edc0f (patch) | |
tree | 857996d0acb598fa285fad9f366435a06499b5ef | |
parent | 8b19a1f824d8d9ae423406e269fb75a98849ad44 (diff) |
fix informing of netlinkd when the ppp link goes down0.7.3
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/main.rs | 23 |
3 files changed, 16 insertions, 11 deletions
@@ -462,7 +462,7 @@ dependencies = [ [[package]] name = "rsdsl_netlinkd" -version = "0.7.2" +version = "0.7.3" dependencies = [ "bitfield", "futures", @@ -1,6 +1,6 @@ [package] name = "rsdsl_netlinkd" -version = "0.7.2" +version = "0.7.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index f09685f..70d491d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,12 +107,17 @@ fn configure_wan_logged() { fn configure_wan() -> Result<()> { if let Some(ds_config) = read_ds_config_optional() { - link::set_mtu("ppp0".to_string(), 1492)?; - link::up("ppp0".to_string())?; - - // Deconfigure everything, just to be safe. - addr::flush("ppp0".to_string())?; - route::flush("ppp0".to_string())?; + // Only initialize the interface if an NCP is opened. + // This not being the case is a good indicator + // of the interface not being present due to not having a PPP session. + if ds_config.v4.is_some() || ds_config.v6.is_some() { + link::set_mtu("ppp0".to_string(), 1492)?; + link::up("ppp0".to_string())?; + + // Deconfigure everything, just to be safe. + addr::flush("ppp0".to_string())?; + route::flush("ppp0".to_string())?; + } if let Some(v4) = ds_config.v4 { addr::add("ppp0".to_string(), v4.addr.into(), 32)?; @@ -183,10 +188,10 @@ fn configure_wan() -> Result<()> { println!("[info] config dslite0 {}/29", ADDR_B4); } - } else { - // Deconfiguration is critical too, forward event to dhcp6. - inform_dhcp6(); } + } else { + // Deconfiguration is critical too, forward event to dhcp6. + inform_dhcp6(); } } |