All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next] libbpf: Add bpf_map__pin_path function
@ 2021-07-23 22:15 Evgeniy Litvinenko
  2021-07-23 23:58 ` Andrii Nakryiko
  2021-07-24  0:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Evgeniy Litvinenko @ 2021-07-23 22:15 UTC (permalink / raw)
  To: bpf, ast, andrii, daniel

Add bpf_map__pin_path, so that the inconsistently named
bpf_map__get_pin_path can be deprecated later. This is part of the
effort towards libbpf v1.0: https://github.com/libbpf/libbpf/issues/307

Also, add a selftest for the new function.

Signed-off-by: Evgeniy Litvinenko <evgeniyl@fb.com>
---
v1->v2:
 - Fix a rookie whitespace issue.

 tools/lib/bpf/libbpf.c                           | 5 +++++
 tools/lib/bpf/libbpf.h                           | 1 +
 tools/lib/bpf/libbpf.map                         | 1 +
 tools/testing/selftests/bpf/prog_tests/pinning.c | 9 +++++++++
 4 files changed, 16 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index e595816b8b76..a53ca29b44ab 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8511,6 +8511,11 @@ const char *bpf_map__get_pin_path(const struct bpf_map *map)
 	return map->pin_path;
 }
 
+const char *bpf_map__pin_path(const struct bpf_map *map)
+{
+	return map->pin_path;
+}
+
 bool bpf_map__is_pinned(const struct bpf_map *map)
 {
 	return map->pinned;
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 9ec6b7244889..1271d99bb7aa 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -499,6 +499,7 @@ LIBBPF_API bool bpf_map__is_offload_neutral(const struct bpf_map *map);
 LIBBPF_API bool bpf_map__is_internal(const struct bpf_map *map);
 LIBBPF_API int bpf_map__set_pin_path(struct bpf_map *map, const char *path);
 LIBBPF_API const char *bpf_map__get_pin_path(const struct bpf_map *map);
+LIBBPF_API const char *bpf_map__pin_path(const struct bpf_map *map);
 LIBBPF_API bool bpf_map__is_pinned(const struct bpf_map *map);
 LIBBPF_API int bpf_map__pin(struct bpf_map *map, const char *path);
 LIBBPF_API int bpf_map__unpin(struct bpf_map *map, const char *path);
diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
index 887d372a3f27..c240d488eb5e 100644
--- a/tools/lib/bpf/libbpf.map
+++ b/tools/lib/bpf/libbpf.map
@@ -371,6 +371,7 @@ LIBBPF_0.4.0 {
 LIBBPF_0.5.0 {
 	global:
 		bpf_map__initial_value;
+		bpf_map__pin_path;
 		bpf_map_lookup_and_delete_elem_flags;
 		bpf_program__attach_kprobe_opts;
 		bpf_object__gen_loader;
diff --git a/tools/testing/selftests/bpf/prog_tests/pinning.c b/tools/testing/selftests/bpf/prog_tests/pinning.c
index fcf54b3a1dd0..d4b953ae3407 100644
--- a/tools/testing/selftests/bpf/prog_tests/pinning.c
+++ b/tools/testing/selftests/bpf/prog_tests/pinning.c
@@ -125,6 +125,10 @@ void test_pinning(void)
 	if (CHECK(err, "pin maps", "err %d errno %d\n", err, errno))
 		goto out;
 
+	/* get pinning path */
+	if (!ASSERT_STREQ(bpf_map__pin_path(map), pinpath, "get pin path"))
+		goto out;
+
 	/* set pinning path of other map and re-pin all */
 	map = bpf_object__find_map_by_name(obj, "nopinmap");
 	if (CHECK(!map, "find map", "NULL map"))
@@ -134,6 +138,11 @@ void test_pinning(void)
 	if (CHECK(err, "set pin path", "err %d errno %d\n", err, errno))
 		goto out;
 
+	/* get pinning path after set */
+	if (!ASSERT_STREQ(bpf_map__pin_path(map), custpinpath,
+			  "get pin path after set"))
+		goto out;
+
 	/* should only pin the one unpinned map */
 	err = bpf_object__pin_maps(obj, NULL);
 	if (CHECK(err, "pin maps", "err %d errno %d\n", err, errno))
-- 
2.30.2


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

* Re: [PATCH v2 bpf-next] libbpf: Add bpf_map__pin_path function
  2021-07-23 22:15 [PATCH v2 bpf-next] libbpf: Add bpf_map__pin_path function Evgeniy Litvinenko
@ 2021-07-23 23:58 ` Andrii Nakryiko
  2021-07-24  0:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2021-07-23 23:58 UTC (permalink / raw)
  To: Evgeniy Litvinenko
  Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann

On Fri, Jul 23, 2021 at 3:16 PM Evgeniy Litvinenko <evgeniyl@fb.com> wrote:
>
> Add bpf_map__pin_path, so that the inconsistently named
> bpf_map__get_pin_path can be deprecated later. This is part of the
> effort towards libbpf v1.0: https://github.com/libbpf/libbpf/issues/307
>
> Also, add a selftest for the new function.
>
> Signed-off-by: Evgeniy Litvinenko <evgeniyl@fb.com>
> ---
> v1->v2:
>  - Fix a rookie whitespace issue.

Congrats with the first kernel patch!

LGTM, applied to bpf-next.

>
>  tools/lib/bpf/libbpf.c                           | 5 +++++
>  tools/lib/bpf/libbpf.h                           | 1 +
>  tools/lib/bpf/libbpf.map                         | 1 +
>  tools/testing/selftests/bpf/prog_tests/pinning.c | 9 +++++++++
>  4 files changed, 16 insertions(+)
>

[...]

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

* Re: [PATCH v2 bpf-next] libbpf: Add bpf_map__pin_path function
  2021-07-23 22:15 [PATCH v2 bpf-next] libbpf: Add bpf_map__pin_path function Evgeniy Litvinenko
  2021-07-23 23:58 ` Andrii Nakryiko
@ 2021-07-24  0:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-24  0:00 UTC (permalink / raw)
  To: Evgeniy Litvinenko; +Cc: bpf, ast, andrii, daniel

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Fri, 23 Jul 2021 15:15:11 -0700 you wrote:
> Add bpf_map__pin_path, so that the inconsistently named
> bpf_map__get_pin_path can be deprecated later. This is part of the
> effort towards libbpf v1.0: https://github.com/libbpf/libbpf/issues/307
> 
> Also, add a selftest for the new function.
> 
> Signed-off-by: Evgeniy Litvinenko <evgeniyl@fb.com>
> 
> [...]

Here is the summary with links:
  - [v2,bpf-next] libbpf: Add bpf_map__pin_path function
    https://git.kernel.org/bpf/bpf-next/c/e244d34d0ea1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2021-07-24  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 22:15 [PATCH v2 bpf-next] libbpf: Add bpf_map__pin_path function Evgeniy Litvinenko
2021-07-23 23:58 ` Andrii Nakryiko
2021-07-24  0:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.