diff --git a/easytier/src/connector/mod.rs b/easytier/src/connector/mod.rs index a5e72b89..584d080e 100644 --- a/easytier/src/connector/mod.rs +++ b/easytier/src/connector/mod.rs @@ -70,6 +70,8 @@ async fn set_bind_addr_for_peer_connector( let ips = global_ctx.get_ip_collector().collect_ip_addrs().await; if is_ipv4 { let mut bind_addrs = vec![]; + // Always include loopback so localhost connections work + bind_addrs.push(std::net::SocketAddr::from(([127, 0, 0, 1], 0))); for ipv4 in ips.interface_ipv4s { let socket_addr = SocketAddrV4::new(ipv4.into(), 0).into(); bind_addrs.push(socket_addr); diff --git a/scripts/setup-bench-netns.sh b/scripts/setup-bench-netns.sh new file mode 100755 index 00000000..441b3a97 --- /dev/null +++ b/scripts/setup-bench-netns.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +NS_NAME="et_bench" + +echo "=== Creating netns: $NS_NAME ===" +# Clean up old ns +sudo ip netns del "$NS_NAME" 2>/dev/null || true + +# Create namespace +sudo ip netns add "$NS_NAME" + +# Enable loopback inside namespace +sudo ip netns exec "$NS_NAME" ip link set lo up + +echo "=== netns $NS_NAME ready ===" +echo "Both instances will share this namespace's loopback." +echo "TCP/UDP connections to 127.0.0.1 will work inside it." +echo "" +echo "Now run the bench with HOTPATH_NETNS=$NS_NAME:" +echo " HOTPATH_TUNNEL=tcp HOTPATH_NETNS=$NS_NAME HOTPATH_BENCH_SECS=15 \\" +echo " cargo run --profile hotpath --features hotpath --example cpu_hotspot_ring"