Skip to content

Commit ffe5aed

Browse files
committed
Martin KaFai Lau says: ==================== pull-request: bpf-next 2025-07-17 We've added 13 non-merge commits during the last 20 day(s) which contain a total of 4 files changed, 712 insertions(+), 84 deletions(-). The main changes are: 1) Avoid skipping or repeating a sk when using a TCP bpf_iter, from Jordan Rife. 2) Clarify the driver requirement on using the XDP metadata, from Song Yoong Siang * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: doc: xdp: Clarify driver implementation for XDP Rx metadata selftests/bpf: Add tests for bucket resume logic in established sockets selftests/bpf: Create iter_tcp_destroy test program selftests/bpf: Create established sockets in socket iterator tests selftests/bpf: Make ehash buckets configurable in socket iterator tests selftests/bpf: Allow for iteration over multiple states selftests/bpf: Allow for iteration over multiple ports selftests/bpf: Add tests for bucket resume logic in listening sockets bpf: tcp: Avoid socket skips and repeats during iteration bpf: tcp: Use bpf_tcp_iter_batch_item for bpf_tcp_iter_state batch items bpf: tcp: Get rid of st_bucket_done bpf: tcp: Make sure iter->batch always contains a full bucket snapshot bpf: tcp: Make mem flags configurable through bpf_iter_tcp_realloc_batch ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 797f080 + ef57dc6 commit ffe5aed

File tree

4 files changed

+712
-84
lines changed

4 files changed

+712
-84
lines changed

Documentation/networking/xdp-rx-metadata.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,39 @@ It is possible to query which kfunc the particular netdev implements via
120120
netlink. See ``xdp-rx-metadata-features`` attribute set in
121121
``Documentation/netlink/specs/netdev.yaml``.
122122

123+
Driver Implementation
124+
=====================
125+
126+
Certain devices may prepend metadata to received packets. However, as of now,
127+
``AF_XDP`` lacks the ability to communicate the size of the ``data_meta`` area
128+
to the consumer. Therefore, it is the responsibility of the driver to copy any
129+
device-reserved metadata out from the metadata area and ensure that
130+
``xdp_buff->data_meta`` is pointing to ``xdp_buff->data`` before presenting the
131+
frame to the XDP program. This is necessary so that, after the XDP program
132+
adjusts the metadata area, the consumer can reliably retrieve the metadata
133+
address using ``METADATA_SIZE`` offset.
134+
135+
The following diagram shows how custom metadata is positioned relative to the
136+
packet data and how pointers are adjusted for metadata access::
137+
138+
|<-- bpf_xdp_adjust_meta(xdp_buff, -METADATA_SIZE) --|
139+
new xdp_buff->data_meta old xdp_buff->data_meta
140+
| |
141+
| xdp_buff->data
142+
| |
143+
+----------+----------------------------------------------------+------+
144+
| headroom | custom metadata | data |
145+
+----------+----------------------------------------------------+------+
146+
| |
147+
| xdp_desc->addr
148+
|<------ xsk_umem__get_data() - METADATA_SIZE -------|
149+
150+
``bpf_xdp_adjust_meta`` ensures that ``METADATA_SIZE`` is aligned to 4 bytes,
151+
does not exceed 252 bytes, and leaves sufficient space for building the
152+
xdp_frame. If these conditions are not met, it returns a negative error. In this
153+
case, the BPF program should not proceed to populate data into the ``data_meta``
154+
area.
155+
123156
Example
124157
=======
125158

0 commit comments

Comments
 (0)