From b20075e3dca788e968d758b247242e92970eadb2 Mon Sep 17 00:00:00 2001 From: KKRainbow <443152178@qq.com> Date: Sat, 25 Apr 2026 21:26:16 +0800 Subject: [PATCH] fix: allow self virtual IP loopback (#2161) --- easytier/src/peers/peer_manager.rs | 8 ++++++-- easytier/src/tests/three_node.rs | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/easytier/src/peers/peer_manager.rs b/easytier/src/peers/peer_manager.rs index 3fa73f59..ccb2f9c1 100644 --- a/easytier/src/peers/peer_manager.rs +++ b/easytier/src/peers/peer_manager.rs @@ -1657,8 +1657,12 @@ impl PeerManager { #[cfg(not(target_env = "ohos"))] { - if not_send_to_self && *peer_id == self.my_peer_id { - // the packet may be sent to vpn portal, so we just set flags instead of drop it + if not_send_to_self + && *peer_id == self.my_peer_id + && !self.global_ctx.is_ip_local_virtual_ip(&ip_addr) + { + // Keep the loop-prevention flags for proxy-induced self-delivery where + // the destination is not this node's own virtual IP. hdr.set_not_send_to_tun(true); hdr.set_no_proxy(true); } diff --git a/easytier/src/tests/three_node.rs b/easytier/src/tests/three_node.rs index 849e1440..abe40a71 100644 --- a/easytier/src/tests/three_node.rs +++ b/easytier/src/tests/three_node.rs @@ -475,6 +475,26 @@ pub async fn basic_three_node_test( drop_insts(insts).await; } +#[tokio::test] +#[serial_test::serial] +pub async fn ping_own_virtual_ip_should_work() { + let insts = init_three_node("udp").await; + + wait_for_condition( + || async { ping_test("net_a", "10.144.144.1", None).await }, + Duration::from_secs(5), + ) + .await; + + wait_for_condition( + || async { ping6_test("net_a", "fd00::1", None).await }, + Duration::from_secs(5), + ) + .await; + + drop_insts(insts).await; +} + #[tokio::test] #[serial_test::serial] pub async fn subnet_proxy_loop_prevention_test() {