Skip to content

net: xdp: XSKMAP improvements

Björn Töpel bpf netdev 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest2 patches 1 replyIn review
  2. v42 patches 6 repliesSuperseded
  3. v32 patches 2 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v22 patches3 repliesSuperseded
v12 patches3 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2xsk: remove AF_XDP socket from map when the socket is releasedinclude/net/xdp_sock.h kernel/bpf/xskmap.c net/xdp/xsk.c+173 -200 replies
2/2xsk: support BPF_EXIST and BPF_NOEXIST flags in XSKMAPkernel/bpf/xskmap.c+6 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/2] net: xdp: XSKMAP improvements

This series (v5 and counting) add two improvements for the XSKMAP, used by AF_XDP sockets.

1. Automatic cleanup when an AF_XDP socket goes out of scope/is released. Instead of require that the user manually clears the "released" state socket from the map, this is done automatically. Each socket tracks which maps it resides in, and remove itself from those maps at relase. A notable implementation change, is that the sockets references the map, instead of the map referencing the sockets. Which implies that when the XSKMAP is freed, it is by definition cleared of sockets.

2. The XSKMAP did not honor the BPF_EXIST/BPF_NOEXIST flag on insert, which this patch addresses.

Thanks,
Björn

v1->v2: Fixed deadlock and broken cleanup. (Daniel) v2->v3: Rebased onto bpf-next
v3->v4: {READ, WRITE}_ONCE consistency. (Daniel)
Socket release/map update race. (Daniel)
v4->v5: Avoid use-after-free on XSKMAP self-assignment [1]. (Daniel)
Removed redundant assignment in xsk_map_update_elem(). Variable name consistency; Use map_entry everywhere.

[1] https://lore.kernel.org/bpf/[email protected]/T/#mc68439e97bc07fa301dad9fc4850ed5aa392f385

Björn Töpel (2):
xsk: remove AF_XDP socket from map when the socket is released
xsk: support BPF_EXIST and BPF_NOEXIST flags in XSKMAP

 include/net/xdp_sock.h |  18 ++++++
 kernel/bpf/xskmap.c    | 133 ++++++++++++++++++++++++++++++++++-------
 net/xdp/xsk.c          |  50 ++++++++++++++++
 3 files changed, 179 insertions(+), 22 deletions(-)
Signature · 1 line
2.20.1