Repository navigation
silkd: advanced network mode, tun0 over a vsock packet stream - #474
Merged
Merged
Conversation
tun_up/tun_down verbs on the control channel, a boot and reconnect hello on vsock 2051 where the host answers on or off, frames carrying virtio_net_hdr so GSO and USO packets cross whole, io_uring by default with epoll as the fallback. The e2e test runs both paths in two network namespaces behind a relay that rewrites addresses as the host will.
…pletion queue A restored VMM never resets the guest's old vsock stream, so a repeated tun_up ends it and dials again; tun_up replaces a boot link that has no route yet; a boot link stops on a failed hello; the offload set handed to TUNSETOFFLOAD drops combinations the kernel refuses; the completion queue holds every tun write one stream read can queue; a write that finds the peer gone ends the stream like an EOF.
… off on tun0, review tidy-ups A tun_up during a boot link's first session saw a stale configured copy and replaced a working tun0; the backoff reset on connect, so a host that closed before the hello got a dial every 50 ms; the ring's Drop cancels every possible entry, so a failed re-arm cannot leave a read uncancelled; compaction only moves a partial frame when a whole frame no longer fits; tun0 no longer sends IPv6 link-local traffic.
Two overlapping tun_down calls let the second answer done while the first was still tearing tun0 down.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Guest side of the advanced network mode (#471): silkd owns a
tun0and carries its raw IPv4 packets to the host over one vsock stream. The proxy path (default network mode) is unchanged. The sandboxd side follows in a separate PR.What changes
tun0:100.64.0.2/30in every guest, default route via100.64.0.1,IFF_VNET_HDR. The proxy variables stay set, so clients that honour them keep using127.0.0.1:3128over loopback. Everything else takestun0.tun_up/tun_downverbs on the 2048 control channel (Rust and Go wire types, fixtures 61 → 63).tun_upends the current stream and dials again, so the host can force a reconnect after a wake, unarchive or move.docs/advanced-network.md):u32 len | virtio_net_hdr | packet, so GSO/USO packets up to 64 KiB cross vsock whole.SILKD_TUN_IO=epollis set.tun_e2e. It covers both paths in two network namespaces, behind a relay that rewrites addresses the way the host will. The throughput case is skipped in CI.Tests
Linux container (privileged, linux/arm64;
cargo test --test tun_e2e -- --ignored):offanswer removestun0.Real guest (bare-metal x86_64 testbed, NUMA-fenced idle node; cocoon v0.7.8, CH dev acded4b0, guest kernel 6.18; rt:24.04 with this silkd; a test-only host stub ran in a scratch netns on the VM's
vsock.uds_2051):tun_upbrings uptun0:100.64.0.2/30, default route,vnet_hdr on. The guest offered offloads0x6f(USO included), and io_uring is enabled in the guest kernel.tun_uptun_up, IPv6 ontun_up, IPv6 off on tun0tun_upafter restoretun_upanswered in 39–46 msandroid-basecocoonbox image, redroid Android 16 in a Linux guest,--nics 0, this silkd copied in):tun_up, redroid's ICMP (RTT 0.35 ms) and UDP reach the host through docker NAT andtun0.iptables -t nat PREROUTING -i docker0 -p tcp -j REDIRECT --to-ports 3129), so TCP takes the proxy path as designed. With that rule removed, redroid TCP runs overtun0(~3 GB in 8 s down, 5 MB up). An image that should send TCP overtun0in the advanced mode has to skip that redirect.Review
A full-file review of the first commit found no memory-safety hole in the io_uring path. Applied fixes are in
0d7f0821:tun_upredials.tun_upreplaces a boot link that has no route yet.TUNSETOFFLOADaccepts.tun_upandtun_downrun off the tokio workers.Kept without code, both contrived: a failed re-arm after an SQ submit error, and a self-inflicted IPv6 GSO read error.
Not covered
tun_up.EvalFlow, enforcement and audit come in the next PR, per sandboxd: advanced network mode, an L3 tun path over VXLAN for none-lane claims (design) #471.Gates:
cargo fmt --check,cargo clippy --all-targets -D warningsandcargo teston mac and linux/arm64.go testforprotocol/wire.