Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docs/cookbook/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<uplink>.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

Expand Down
47 changes: 47 additions & 0 deletions native/hyperrs-linux/src/sysctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ impl Ipv6 {
self.conf_dir(link.as_component())
}

/// `net/ipv6/neigh/<link>/`.
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
Expand Down Expand Up @@ -152,6 +161,20 @@ impl Ipv6Conf {
}
}

/// `net/ipv6/neigh/<link>/`.
pub struct Ipv6Neigh(SysctlKey);

impl Ipv6Neigh {
/// `net/ipv6/neigh/<link>/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 {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 10 additions & 2 deletions native/suidhelper/src/net/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -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(())
Expand Down
Loading