Always reboot the router after toggling of any kind
The linklocal address listener bug is very persistant, but this should
slay it for all cases.
@@ -312,20 +312,25 @@ pub fn ethernet_transform_mode(
error_occured = true;
}
}
+ let locally_owned_ifname = ifname.to_string();
if error_occured {
let res = KI.uci_revert("network");
bail!("Error running UCI commands! Revert attempted: {:?}", res);
} else if mesh_add {
- trace!("Mesh add! going to sleep for 60 seconds to get a local fe80 address");
- let when = Instant::now() + Duration::from_secs(60);
- let locally_owned_ifname = ifname.to_string();
-
- // repeated in Listen added here to prevent config inconsistency
SETTING
.get_network_mut()
.peer_interfaces
.insert(locally_owned_ifname.clone());
+ }
+ KI.uci_commit(&"network")?;
+ KI.openwrt_reset_network()?;
+ SETTING.write().unwrap().write(&ARGS.flag_config)?;
+
+ // We edited disk contents, force global sync
+ KI.fs_sync()?;
+ trace!("Successsfully transformed ethernet mode, rebooting in 60 seconds");
+ let when = Instant::now() + Duration::from_secs(60);
let fut = Delay::new(when)
.map_err(|e| warn!("timer failed; err={:?}", e))
.and_then(move |_| {
@@ -339,15 +344,6 @@ pub fn ethernet_transform_mode(
});
Arbiter::spawn(fut);
- }
-
- KI.uci_commit(&"network")?;
- KI.openwrt_reset_network()?;
- SETTING.write().unwrap().write(&ARGS.flag_config)?;
-
- // We edited disk contents, force global sync
- KI.fs_sync()?;
- trace!("Successsfully transformed ethernet mode, rebooting in 60 seconds");
Ok(())
}
@@ -466,8 +462,23 @@ pub fn wlan_transform_mode(ifname: &str, a: InterfaceMode, b: InterfaceMode) ->
res_b
);
} else if mesh_add {
- let when = Instant::now() + Duration::from_millis(60000);
+ let locally_owned_ifname = ifname.to_string();
+ SETTING
+ .get_network_mut()
+ .peer_interfaces
+ .insert(locally_owned_ifname.clone());
+ }
+
+ KI.uci_commit(&"wireless")?;
+ KI.uci_commit(&"network")?;
+ KI.openwrt_reset_network()?;
+ KI.openwrt_reset_wireless()?;
+ SETTING.write().unwrap().write(&ARGS.flag_config)?;
+
+ // We edited disk contents, force global sync
+ KI.fs_sync()?;
+ let when = Instant::now() + Duration::from_millis(60000);
let fut = Delay::new(when)
.map_err(|e| warn!("timer failed; err={:?}", e))
.and_then(move |_| {
@@ -480,16 +491,6 @@ pub fn wlan_transform_mode(ifname: &str, a: InterfaceMode, b: InterfaceMode) ->
});
Arbiter::spawn(fut);
- }
-
- KI.uci_commit(&"wireless")?;
- KI.uci_commit(&"network")?;
- KI.openwrt_reset_network()?;
- KI.openwrt_reset_wireless()?;
- SETTING.write().unwrap().write(&ARGS.flag_config)?;
-
- // We edited disk contents, force global sync
- KI.fs_sync()?;
Ok(())
}
