Skip to content

Fix pining maps after reuse map fd

Hangbin Liu bpf netdev 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (refs/heads/master):

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 1 replyApplied 3/3
  2. v23 patches 3 repliesSuperseded

Changes in v3 from the cover letter

for selftest: use CHECK() for bpf_object__open_file() and close map fd on error

Patches in v3 All 3 applied

#Subject and filesSizeRepliesApplied
1/3libbpf: close map fd if init map slots failedtools/lib/bpf/libbpf.c+34 -210 repliesApplied
2/3libbpf: check if pin_path was set even map fd existtools/lib/bpf/libbpf.c+18 -190 repliesApplied
3/3selftest/bpf: test pinning map with reused map fdtools/testing/selftests/bpf/prog_tests/pinning.c+48 -11 replyApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchAndrii Nakryiko
1/3A-b
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 [PATCHv3 bpf 0/3] Fix pining maps after reuse map fd

When a user reuse map fd after creating a map manually and set the pin_path, then load the object via libbpf. bpf_object__create_maps() will skip pinning map if map fd exist. Fix it by add moving bpf creation to else condition and go on checking map pin_path after that.

v3:
for selftest: use CHECK() for bpf_object__open_file() and close map fd on error

v2:
a) close map fd if init map slots failed
b) add bpf selftest for this scenario

Hangbin Liu (3):
libbpf: close map fd if init map slots failed
libbpf: check if pin_path was set even map fd exist selftest/bpf: test pinning map with reused map fd

 tools/lib/bpf/libbpf.c                        | 80 +++++++++++--------
 .../selftests/bpf/prog_tests/pinning.c        | 49 +++++++++++-
 2 files changed, 94 insertions(+), 35 deletions(-)
Signature · 1 line
2.25.4