pub struct VirtioNetworkDevice { /* private fields */ }Expand description
smoltcp Device backed by shared frame queues.
staged_guest_frame exists because the poll loop sometimes needs to inspect
a frame before handing it to smoltcp. In particular, the stack wants to
classify guest TCP SYN and DNS packets before consumption so it can prepare
relay/socket state.
The staging pattern looks like:
queue -> staged_guest_frame -> RxToken -> smoltcpImplementations§
Source§impl VirtioNetworkDevice
impl VirtioNetworkDevice
Sourcepub fn new(queues: Arc<NetworkFrameQueues>, mtu: usize) -> Self
pub fn new(queues: Arc<NetworkFrameQueues>, mtu: usize) -> Self
Create a new device for the given queues and MTU.
mtu here is the guest IP MTU, not the full Ethernet frame size.
capabilities() translates it to the Ethernet-frame convention expected
by smoltcp.
Sourcepub fn stage_next_frame(&mut self) -> Option<&[u8]>
pub fn stage_next_frame(&mut self) -> Option<&[u8]>
Stage one guest frame so the poll loop can inspect it before smoltcp consumes it.
Why staging exists:
- the frame arrives first in
guest_to_host - the poll loop may need to classify it before calling
Interface::poll_ingress_single - once smoltcp calls
receive(), ownership moves into an RX token
So staging gives the poll loop a temporary peek at the next frame
without losing the normal smoltcp Device flow.
This is the key reason the adapter is not just a direct queue.pop()
inside receive().
Sourcepub fn drop_staged_frame(&mut self)
pub fn drop_staged_frame(&mut self)
Drop the currently staged guest frame.
This is used when the poll loop decides not to pass a frame into smoltcp, for example when the MVP intentionally drops unsupported UDP.