Keep concurrent overlays working and select faster data carriers

A second subnet on macOS could send with the first utun alias. Reconcile and verify each owned subnet route with its actual source, retry partially applied plans and expose host errors to clients. On Windows verify the alias and prefix on the intended adapter. Do not restart underlay sockets when the only network change is a local overlay address.

Compare mutually enabled carriers using authenticated data probes while the incumbent carries traffic. The dialler coordinates a generation-scoped decision after a sustained median RTT improvement. Old peers retain ordered fallback. Local IPC moves to v24 to report data RTT and the physical path independently of control RTT. The mesh wire versions, keys and saved network settings stay compatible.

Validated formatting, workspace Clippy and the workspace test suite on macOS, including bidirectional dual-network traffic and a live TLS-to-QUIC switch on loopback. Added focused native CI tests for macOS and Windows. The elevated utun test requires administrative access unavailable on the development host.
This commit is contained in:
Aleksandr Bogomiakov committed 2026-11-24 23:55:55 +02:00
1 parent 8d107cf0e9
commit 27e29cf8a7
34 files changed
+1569 -253

No files matched your search

+10
View File
@@ -58,3 +58,13 @@ wire formats are unchanged. The rootless real-endpoint regression is
`crates/tsunagi-core/tests/iroh_candidates.rs`; overlay subnet filtering for
introductions is also covered in the core. This prevents the recursive path;
it does not prove the historical cause of any particular high byte counter.
## Changes to the owned overlay interface
The optional `Builder::network_change_filter` receives consecutive netwatch
snapshots before iroh rechecks paths and rebinds sockets. Tsunagi suppresses
events caused solely by its own TUN. Adding a second network can then add an
address to the shared interface while the first network keeps its UDP sockets.
Physical interface changes, default-route changes and resume events still
reach iroh. The watcher advances its baseline even for a skipped event.
Keep this behaviour when updating the vendored dependency.
+21 -1
View File
@@ -127,7 +127,7 @@ pub use crate::{net_report::NetReportConfig, portmapper::PortmapperConfig};
/// new [`EndpointId`].
///
/// To create the [`Endpoint`] call [`Builder::bind`].
#[derive(Debug)]
#[derive(derive_more::Debug)]
pub struct Builder {
secret_key: Option<SecretKey>,
alpn_protocols: Vec<Vec<u8>>,
@@ -139,6 +139,8 @@ pub struct Builder {
/// [`Builder::address_lookup`].
addr_filter: Option<AddrFilter>,
direct_addr_filter: Option<AddrFilter>,
#[debug(skip)]
network_change_filter: Option<socket::NetworkChangeFilter>,
proxy_url: Option<Url>,
ca_tls_config: Option<CaTlsConfig>,
#[cfg(not(wasm_browser))]
@@ -208,6 +210,7 @@ impl Builder {
address_lookup_user_data: Default::default(),
addr_filter: None,
direct_addr_filter: None,
network_change_filter: None,
proxy_url: None,
ca_tls_config: None,
#[cfg(not(wasm_browser))]
@@ -274,6 +277,7 @@ impl Builder {
let sock_opts = socket::Options {
direct_addr_filter: self.direct_addr_filter,
network_change_filter: self.network_change_filter,
transports: self.transports,
secret_key,
address_lookup_user_data: self.address_lookup_user_data,
@@ -636,6 +640,22 @@ impl Builder {
self
}
/// Filters OS network changes before rechecking paths and rebinding transports.
///
/// Return false only when the change cannot affect this endpoint's underlay,
/// for example when an application adds an address to its own overlay interface.
/// The next change is compared with the latest snapshot even if this one is ignored.
pub fn network_change_filter(
mut self,
filter: impl Fn(&netwatch::netmon::State, &netwatch::netmon::State) -> bool
+ Send
+ Sync
+ 'static,
) -> Self {
self.network_change_filter = Some(Box::new(filter));
self
}
/// Clears the address filter, allowing all addresses to be published.
///
/// This removes any filter previously set via [`Self::addr_filter`], including
+18 -3
View File
@@ -157,10 +157,15 @@ impl From<mpsc::error::SendError<RemoteStateMessage>> for RemoteStateActorStoppe
}
}
pub(crate) type NetworkChangeFilter =
Box<dyn Fn(&netmon::State, &netmon::State) -> bool + Send + Sync>;
/// Contains options for `Socket::listen`.
#[derive(derive_more::Debug)]
pub(crate) struct Options {
pub(crate) direct_addr_filter: Option<address_lookup::AddrFilter>,
#[debug(skip)]
pub(crate) network_change_filter: Option<NetworkChangeFilter>,
/// The configuration for the different transports.
pub(crate) transports: Vec<TransportConfig>,
@@ -883,6 +888,7 @@ impl EndpointInner {
let Options {
direct_addr_filter,
network_change_filter,
secret_key,
transports: transport_configs,
address_lookup_user_data,
@@ -1093,6 +1099,7 @@ impl EndpointInner {
periodic_re_stun_timer: new_re_stun_timer(false),
network_monitor,
local_interfaces_watcher,
network_change_filter,
direct_addr_update_state,
transports_network_change,
direct_addr_done_rx,
@@ -1475,6 +1482,7 @@ struct Actor {
network_monitor: netmon::Monitor,
/// Watcher for changes to the local network interfaces, IP addresses and routes.
local_interfaces_watcher: n0_watcher::Direct<netmon::State>,
network_change_filter: Option<NetworkChangeFilter>,
transports_network_change: transports::NetworkChangeSender,
/// Indicates the direct addr update state.
direct_addr_update_state: DirectAddrUpdateState,
@@ -1608,14 +1616,19 @@ impl Actor {
self.sock.metrics.socket.actor_tick_other.inc();
continue;
};
let is_major = state.is_major_change(&current_netmon_state);
let previous = std::mem::replace(&mut current_netmon_state, state);
if let Some(filter) = &self.network_change_filter
&& !filter(&previous, &current_netmon_state)
{
continue;
}
let is_major = current_netmon_state.is_major_change(&previous);
event!(
target: "iroh::_events::link_change",
Level::DEBUG,
?state,
state = ?current_netmon_state,
is_major
);
current_netmon_state = state;
self.sock.metrics.socket.actor_link_change.inc();
self.handle_network_change(is_major);
}
@@ -2192,6 +2205,7 @@ mod tests {
static_config,
configured_addrs: Default::default(),
direct_addr_filter: None,
network_change_filter: None,
}
}
@@ -2609,6 +2623,7 @@ mod tests {
static_config,
configured_addrs: Default::default(),
direct_addr_filter: None,
network_change_filter: None,
};
let sock = EndpointInner::bind(opts).await?;
Ok(sock)