Skip to main content

Module stack

Module stack 

Source
Expand description

Host-side smoltcp runtime for the virtio-net backend.

§Context

This file is the in-process “gateway” that sits behind the guest’s virtio NIC. It does not configure the guest interface; that already happened inside smolvm-agent. Instead, this module:

  • receives raw Ethernet frames coming out of libkrun
  • feeds them into smoltcp as if smolvm were the guest’s next-hop gateway
  • forwards guest DNS queries to a host UDP socket
  • relays guest TCP streams to host TcpStreams

Conceptually, it plays the role of a tiny virtual router/NAT-side gateway:

guest eth0
  -> Ethernet frame
  -> Frame queues
  -> smoltcp Interface (gateway MAC/IP)
  -> protocol-specific handling:
       - TCP  -> host relay threads
       - DNS  -> host UDP socket
       - other supported egress -> future phases
  -> outbound network

Poll-loop-centric view:

guest_to_host queue
  -> VirtioNetworkDevice::stage_next_frame()
  -> classify_guest_frame()
  -> smoltcp ingress
  -> protocol-specific side effects
       - TCP SYN  -> create relay/socket state
       - DNS UDP  -> gateway UDP socket
       - other UDP-> drop for now
  -> smoltcp egress
  -> host_to_guest queue
  -> FrameStream writer

Runtime control flow:

new guest frame         -> guest_wake  -> poll loop
host relay has data     -> relay_wake  -> poll loop
published host connect  -> relay_wake  -> poll loop
smoltcp emitted frames  -> host_wake   -> frame writer

Structs§

VirtioPollConfig
Resolved network parameters for one guest NIC.

Functions§

start_network_stack
Start the dedicated smoltcp poll thread for the virtio-net backend.