fix: address shared tun ci failures

This commit is contained in:
sijie.sun
2026-06-14 23:14:45 +08:00
parent a7ab60e0e4
commit d87624b353
6 changed files with 24 additions and 23 deletions
+3 -2
View File
@@ -953,8 +953,9 @@ mod manager {
return Vec::new();
};
let (first_id, Some(shared_dev_name)) = first else {
return vec![first.0];
let (first_id, shared_dev_name) = first;
let Some(shared_dev_name) = shared_dev_name else {
return vec![first_id];
};
let ids: Vec<uuid::Uuid> = self
@@ -519,7 +519,7 @@ impl MagicDnsServerInstance {
netns: Option<String>,
cost: Option<i32>,
) -> Result<(), anyhow::Error> {
let ifcfg = IfConfiger {};
let ifcfg = IfConfiger::default();
let _guard = NetNS::new(netns).guard();
match ifcfg.add_ipv4_route(tun_dev_name, fake_ip, 32, cost).await {
Err(EtError::IOError(err)) if err.kind() == io::ErrorKind::AlreadyExists => {
@@ -534,7 +534,7 @@ impl MagicDnsServerInstance {
}
async fn remove_fake_ip_route(tun_dev_name: &str, fake_ip: Ipv4Addr, netns: Option<String>) {
let ifcfg = IfConfiger {};
let ifcfg = IfConfiger::default();
let _guard = NetNS::new(netns).guard();
if let Err(err) = ifcfg.remove_ipv4_route(tun_dev_name, fake_ip, 32).await {
tracing::warn!(
+10 -12
View File
@@ -1737,18 +1737,16 @@ impl Instance {
.with_context(|| "add ip failed")?;
#[cfg(feature = "magic-dns")]
let magic_dns_runner = if let Some(ipv4) = global_ctx.get_ipv4() {
Self::create_magic_dns_runner(peer_manager.clone(), None, ipv4)
} else {
None
};
Self::use_new_nic_ctx(
nic_ctx.clone(),
new_nic_ctx,
#[cfg(feature = "magic-dns")]
magic_dns_runner,
)
.await;
{
let magic_dns_runner = if let Some(ipv4) = global_ctx.get_ipv4() {
Self::create_magic_dns_runner(peer_manager.clone(), None, ipv4)
} else {
None
};
Self::use_new_nic_ctx(nic_ctx.clone(), new_nic_ctx, magic_dns_runner).await;
}
#[cfg(not(feature = "magic-dns"))]
Self::use_new_nic_ctx(nic_ctx.clone(), new_nic_ctx).await;
Ok(())
}
+2 -2
View File
@@ -698,7 +698,7 @@ impl SharedVirtualNicMember {
}
pub fn member_id(&self) -> SharedVirtualNicMemberId {
self.member_id.clone()
self.member_id
}
pub fn shared_nic(&self) -> Arc<Mutex<SharedVirtualNic>> {
@@ -957,7 +957,7 @@ impl SharedVirtualNicRegistry {
let needs_new_entry = self
.nics
.get(&dev_name)
.map_or(true, |entry| !entry.is_valid());
.is_none_or(|entry| !entry.is_valid());
if needs_new_entry {
let entry = SharedVirtualNicRegistryEntry::new(SharedVirtualNic::new(config));
self.nics.insert(dev_name.clone(), entry);
+5 -2
View File
@@ -129,7 +129,7 @@ impl EasyTierLauncher {
let Some(tun_fd) = tun_fd_receiver.recv().await.flatten() else {
return;
};
let _ = Instance::setup_nic_ctx_for_mobile(
if let Err(err) = Instance::setup_nic_ctx_for_mobile(
nic_ctx.clone(),
global_ctx.clone(),
peer_mgr.clone(),
@@ -137,7 +137,10 @@ impl EasyTierLauncher {
shared_virtual_nic_registry.clone(),
tun_fd,
)
.await;
.await
{
tracing::error!(?err, tun_fd, "setup mobile nic ctx failed");
}
}
});
}
+2 -3
View File
@@ -345,12 +345,11 @@ async fn wait_proxy_route_to_peer(
wait_for_condition(
|| async {
let routes = mgr.list_routes().await;
let route_found = routes.iter().any(|route| {
routes.iter().any(|route| {
route.peer_id == dst_peer_id
&& route.ipv4_addr == Some(ipv4.parse().unwrap())
&& route.proxy_cidrs.contains(&proxy_cidr)
});
route_found
})
},
Duration::from_secs(8),
)