aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-11-13 14:22:03 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-11-13 14:22:03 +0100
commit00db1e3bbcb563cd58012f9cbc501e77007edc0f (patch)
tree857996d0acb598fa285fad9f366435a06499b5ef /src/main.rs
parent8b19a1f824d8d9ae423406e269fb75a98849ad44 (diff)
fix informing of netlinkd when the ppp link goes down0.7.3
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 14 insertions, 9 deletions
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();
}
}