Expand description
Network backend traits and infrastructure.
This crate defines the abstraction boundary between network frontends (guest-facing devices) and network backends (host-side packet I/O). The key types are:
-
Endpoint— a backend factory. One per NIC, responsible for creatingQueueobjects when the frontend activates the device. -
Queue— a single TX/RX data path. Backends implement this to send and receive packets. A device may have multiple queues (RSS). -
BufferAccess— owned by the frontend, provides access to guest memory receive buffers. Passed by&mutreference to everyQueuemethod that needs it, so the frontend retains exclusive ownership and no internal locking is required.
§Lifecycle
- The frontend creates a
BufferAccessimplementation and oneQueueConfigper desired queue (containing just a driver). - It calls
Endpoint::get_queues, which returns boxedQueueobjects. - The frontend posts initial receive buffers by calling
Queue::rx_availwith itsBufferAccess. - The main loop polls
Queue::poll_readyfor backend events, then callsQueue::rx_poll/Queue::tx_avail/Queue::tx_pollto exchange packets—always passing&mut dyn BufferAccess. - On shutdown, queues are dropped and
Endpoint::stopis called.
Modules§
- loopback
- Loopback endpoint implementation, which reflects all transmits back as receives.
- null
- Null (disconnected) endpoint.
- resolve
- Resolver-related definitions for networking backends.
- tests
- Types to help test backends.
Structs§
- Disconnectable
Endpoint - Disconnectable
Endpoint Cached State - Disconnectable
Endpoint Control - Multi
Queue Support - Multi-queue related support.
- Queue
Config - Per-queue configuration passed to
Endpoint::get_queues. - RssConfig
- RxBuffer
Segment - An individual segment in guest memory of a receive buffer.
- RxId
- A receive buffer ID.
- RxMetadata
- Receive packet metadata.
- TxFlags
- Flags affecting transmit behavior.
- TxId
- A transmit ID. This may be used by multiple segments at the same time.
- TxMetadata
- Transmit packet metadata.
- TxOffload
Support - The set of supported transmit offloads.
- TxSegment
- A transmit packet segment.
Enums§
- Endpoint
Action - L3Protocol
- The “L3” protocol: the IP layer.
- L4Protocol
- The “L4” protocol: the TCP/UDP layer.
- RxChecksum
State - The receive checksum state for a packet.
- TxError
- TxSegment
Type - The segment type.
Traits§
- Backend
Queue Stats - Buffer
Access - Frontend-owned access to guest receive buffers.
- Endpoint
- A network endpoint — the backend side of a NIC.
- Queue
- A single TX/RX data path for sending and receiving network packets.
Functions§
- linearize
- Linearizes the next packet in a list of segments, returning the buffer data and advancing the segment list.
- next_
packet - Gets the next packet from a list of segments, returning the packet metadata, the segments in the packet, and the remaining segments.
- packet_
count - Computes the number of packets in
segments.