BPF List
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] Fix pinning devmaps
@ 2022-12-01  1:11 Pramukh Naduthota
  2022-12-01  1:11 ` [PATCH net-next v2 1/2] Ignore RDONLY_PROG for devmaps in libbpf to allow re-loading of pinned devmaps Pramukh Naduthota
  2022-12-01  1:11 ` [PATCH net-next v2 2/2] Add a selftest for devmap pinning Pramukh Naduthota
  0 siblings, 2 replies; 6+ messages in thread
From: Pramukh Naduthota @ 2022-12-01  1:11 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, Pramukh Naduthota

Fix devmap pinning and reloading. The kernel adds BPF_F_RDONLY_PROG to
all devmaps when created, but libbpf checks that user flags match pinned
map flags when using LIBBPF_PIN_BY_NAME, so reusing pinned devmaps
doesn't work, failing with an error like:

    libbpf: couldn't reuse pinned map at '/sys/fs/bpf/dev_map':
    parameter mismatch

Work around this by ignoring RDONLY_PROG in the compat check in libbpf.

Changes since v1:
- Fixed a broken import
- Fixed style issues


Pramukh Naduthota (2):
  Ignore RDONLY_PROG for devmaps in libbpf to allow re-loading of pinned
    devmaps
  Add a selftest for devmap pinning.

 tools/lib/bpf/libbpf.c                        |  8 +++++++-
 .../testing/selftests/bpf/prog_tests/devmap.c | 20 +++++++++++++++++++
 .../selftests/bpf/progs/test_pinned_devmap.c  | 17 ++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/devmap.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_pinned_devmap.c

-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-07  6:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-01  1:11 [PATCH net-next v2 0/2] Fix pinning devmaps Pramukh Naduthota
2022-12-01  1:11 ` [PATCH net-next v2 1/2] Ignore RDONLY_PROG for devmaps in libbpf to allow re-loading of pinned devmaps Pramukh Naduthota
2022-12-01  1:11 ` [PATCH net-next v2 2/2] Add a selftest for devmap pinning Pramukh Naduthota
2022-12-05 22:31   ` Daniel Borkmann
2022-12-07  0:42     ` Pramukh Naduthota
2022-12-07  6:43       ` John Fastabend

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox