Module peek

Module peek 

Source
Expand description

§Peeking at Descriptors in XDP Rings

§Purpose

This file provides the logic for “peeking” at descriptors in an XDP ring. Peeking allows the application to get a reference to the data buffer (UMEM frame) associated with a descriptor without advancing the ring’s consumer or producer indices. This is useful for inspecting or modifying data before committing to sending it (for TX) or after receiving it but before releasing the descriptor (for RX).

§How it works

It implements methods on Socket<_TX> and Socket<_RX> that allow access to the underlying UMEM data buffers.

For _TX, the methods return a mutable slice (&mut [u8]) to a UMEM frame, allowing the application to write packet data into the buffer before it is sent. The len of the data to be sent must be specified.

For _RX, the methods return a slice (&[u8]) to a UMEM frame containing a received packet, allowing the application to read the data.

§Main components

  • impl Socket<_TX>: Provides peek, peek_at, and seek_and_peek for transmit sockets.
  • impl Socket<_RX>: Provides peek, peek_at, and seek_and_peek for receive sockets.