From 11410523b484c24bfdea83837aa9f962366c30f3 Mon Sep 17 00:00:00 2001 From: Marko Vejnovic Date: Fri, 27 Nov 2026 02:37:24 -0800 Subject: [PATCH] fix(net): answer proxy NDP at once, so a VM's first SYN is not lost host_init turns on proxy NDP on the uplink so the host answers the router's neighbour solicitations for VM addresses, but Linux delays proxied answers by a random time up to proxy_delay, 0.8 s by default. The router drops what it holds for the address meanwhile, so the first connection to a new VM loses its SYN and waits for TCP to resend it after a second. On hypervm.sh every login paid that second: 1.08 to 1.11 s between usher handing sshpiperd the VM's address and the pipe to it coming up, and a capture on the node showed the answer 726 ms after the router asked. host_init now sets the uplink's proxy_delay to 0, through a new Sysctl::net().ipv6().neigh(link).no_proxy_delay(). The delay exists to spare a busy segment; a node proxies one address per VM. --- CHANGELOG.md | 6 ++++ docs/cookbook/install.md | 4 ++- native/hyperrs-linux/src/sysctl.rs | 47 ++++++++++++++++++++++++++++++ native/suidhelper/src/net/host.rs | 12 ++++++-- 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 031f901e..c8d2f409 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). value is now rejected with `INVALID_ARGUMENT`; `ListVms` is now paginated (`page_size` / `page_token` / `next_page_token`). +### Fixed +- A new VM's first inbound connection no longer waits a second. The host answers + for VM addresses by proxy NDP, which Linux delays by a random time up to 0.8 s; + the router dropped the SYN it held meanwhile, and TCP resent it after its 1 s + timeout. `host_init` now sets the uplink's `proxy_delay` to 0. + ## [0.1.0] First public release: a distributed orchestrator for Firecracker microVMs on the diff --git a/docs/cookbook/install.md b/docs/cookbook/install.md index 24da7746..38c26496 100644 --- a/docs/cookbook/install.md +++ b/docs/cookbook/install.md @@ -224,7 +224,9 @@ sudo sysctl -p /etc/sysctl.d/90-hyper.conf ``` The helper refuses to start with either off. It turns on proxy NDP on the uplink -itself. +itself, and has it answer at once (`net.ipv6.neigh..proxy_delay = 0`): +the router drops what it holds for a new VM's address while it waits, and the +default delay, up to 0.8 s, costs a VM's first inbound connection its SYN. #### Finding the uplink and its prefix diff --git a/native/hyperrs-linux/src/sysctl.rs b/native/hyperrs-linux/src/sysctl.rs index 6e78fce9..2a7c9fc2 100644 --- a/native/hyperrs-linux/src/sysctl.rs +++ b/native/hyperrs-linux/src/sysctl.rs @@ -105,6 +105,15 @@ impl Ipv6 { self.conf_dir(link.as_component()) } + /// `net/ipv6/neigh//`. + pub fn neigh(self, link: &IfName) -> Ipv6Neigh { + Ipv6Neigh( + self.0 + .child(StrictComponent::from_static("neigh")) + .child(link.as_component()), + ) + } + fn conf_dir(self, dir: &StrictComponent) -> Ipv6Conf { Ipv6Conf( self.0 @@ -152,6 +161,20 @@ impl Ipv6Conf { } } +/// `net/ipv6/neigh//`. +pub struct Ipv6Neigh(SysctlKey); + +impl Ipv6Neigh { + /// `net/ipv6/neigh//proxy_delay` at 0: a neighbour advertisement the link answers by + /// proxy goes out at once, not after a random delay of up to the default 0.8 s. + pub fn no_proxy_delay(self) -> Setting { + Setting { + key: self.0.child(StrictComponent::from_static("proxy_delay")), + value: "0", + } + } +} + /// A sysctl and the value to give it. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Setting { @@ -287,6 +310,30 @@ mod tests { assert_eq!(read(path), host); } + #[rstest] + fn no_proxy_delay_zeroes_only_the_namespace_it_is_written_in_as_root() { + let Some(ns) = ScratchNs::new("sysctl-proxy-delay") else { + return; + }; + let path = "net/ipv6/neigh/lo/proxy_delay"; + let host = read(path); + + let written = ns + .get() + .scoped(|| { + Sysctl::net() + .ipv6() + .neigh(&"lo".parse().unwrap()) + .no_proxy_delay() + .write() + .unwrap(); + read(path) + }) + .unwrap(); + + assert_eq!((written.as_str(), read(path)), ("0", host)); + } + #[rstest] fn accept_ra_reads_back_every_mode_it_is_set_to_as_root() { let Some(ns) = ScratchNs::new("sysctl-accept-ra") else { diff --git a/native/suidhelper/src/net/host.rs b/native/suidhelper/src/net/host.rs index 4e5c2dff..46ba4c05 100644 --- a/native/suidhelper/src/net/host.rs +++ b/native/suidhelper/src/net/host.rs @@ -42,8 +42,8 @@ pub struct HostNet<'a> { } impl HostNet<'_> { - /// Forward and proxy NDP for VMs, masquerade their IPv4 out of `uplink`, and - /// firewall them off from the host, its network, and inbound connections. + /// Forward and proxy NDP for VMs, answering at once, masquerade their IPv4 out of + /// `uplink`, and firewall them off from the host, its network, and inbound connections. pub fn init(&self, root: &Root<'_>, nft: &Nft) -> Result<(), HostNetError> { if Rtnl::open()?.link(self.uplink)?.is_none() { return Err(HostNetError::NoUplink(self.uplink.clone())); @@ -65,6 +65,14 @@ impl HostNet<'_> { .conf(self.uplink) .proxy_ndp(true) .write()?; + // The uplink's router asks for each new VM's address and drops what it holds for it + // meanwhile. Answered after the default random delay of up to 0.8 s, a VM's first inbound + // connection loses its SYN and waits a second for TCP to send it again. + Sysctl::net() + .ipv6() + .neigh(self.uplink) + .no_proxy_delay() + .write()?; nft.replace_table(root, &self.table())?; Ok(())