Skip to content

Add BTF-defined map-in-map support to libbpf

Andrii Nakryiko bpf netdev 3 versions – Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 1 replyApplied
  2. v23 patches 4 repliesSuperseded
  3. v11 patch 2 repliesSuperseded

v1->v2 from the cover letter

- rename __inner to __array (Alexei).

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/3libbpf: refactor BTF-defined map definition parsing logictools/lib/bpf/libbpf.c+103 -920 replies
2/3libbpf: refactor map creation logic and fix cleanup leaktools/lib/bpf/libbpf.c+121 -1050 replies
3/3libbpf: add BTF-defined map-in-map supporttools/lib/bpf/bpf_helpers.h tools/lib/bpf/libbpf.c tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c +1 more+384 -230 replies

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchToke Høiland-Jørgensen
1/3
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 bpf-next 0/3] Add BTF-defined map-in-map support to libbpf

This patch set teaches libbpf how to declare and initialize ARRAY_OF_MAPS and HASH_OF_MAPS maps. See patch #3 for all the details.

Patch #1 refactors parsing BTF definition of map to re-use it cleanly for inner map definition parsing.

Patch #2 refactors map creation and destruction logic for reuse. It also fixes existing bug with not closing successfully created maps when bpf_object map creation overall fails.

Patch #3 adds support for an extension of BTF-defined map syntax, as well as parsing, recording, and use of relocations to allow declaratively initialize outer maps with references to inner maps.

v1->v2:
- rename __inner to __array (Alexei).

Andrii Nakryiko (3):
libbpf: refactor BTF-defined map definition parsing logic
libbpf: refactor map creation logic and fix cleanup leak
libbpf: add BTF-defined map-in-map support

 tools/lib/bpf/bpf_helpers.h                   |   1 +
 tools/lib/bpf/libbpf.c                        | 698 ++++++++++++------
 .../selftests/bpf/prog_tests/btf_map_in_map.c |  49 ++
 .../selftests/bpf/progs/test_btf_map_in_map.c |  76 ++
 4 files changed, 606 insertions(+), 218 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_btf_map_in_map.c
Signature · 1 line
2.24.1