Re: [PATCH bpf-next,v3 1/2] doc: enhance explanation of XDP Rx metadata layout and METADATA_SIZE
From: Daniel Borkmann
Date: Thu Jul 03 2025 - 12:00:33 EST
On 7/2/25 6:57 PM, Song Yoong Siang wrote:
[...]
+It is important to note that some devices may utilize the ``data_meta`` area for
+their own purposes. For example, the IGC device utilizes ``IGC_TS_HDR_LEN``
+bytes of the ``data_meta`` area for receiving hardware timestamps. Therefore,
+the XDP program should ensure that it does not overwrite any existing metadata.
+The metadata layout of such device is depicted below::
+
+ +----------+-----------------+--------------------------+------+
+ | headroom | custom metadata | device-reserved metadata | data |
+ +----------+-----------------+--------------------------+------+
+ ^ ^
+ | |
+ xdp_buff->data_meta xdp_buff->data
Imho, this section is misleading to developers. Suppose you're a XDP program writer
and you want to implement a generic native BPF program (independent of the underlying
NIC). Does this mean, the expectation is to dig into driver code to gather whether
or not a driver is prepopulating and how much of it? What are the implications if the
data is overwritten? For example, in Cilium today we use the buffer described here
as device-reserved metadata and override it. How will users know what breaks?