From: Hangbin Liu <liuhangbin@gmail.com>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Jiri Benc" <jbenc@redhat.com>,
"Jesper Dangaard Brouer" <brouer@redhat.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Alexei Starovoitov" <ast@kernel.org>,
"Stephen Hemminger" <stephen@networkplumber.org>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"Hangbin Liu" <liuhangbin@gmail.com>
Subject: [PATCH bpf-next] libbpf: export bpf_object__reuse_map() to libbpf api
Date: Tue, 29 Sep 2020 11:18:45 +0800 [thread overview]
Message-ID: <20200929031845.751054-1-liuhangbin@gmail.com> (raw)
Besides bpf_map__reuse_fd(), which could let us reuse existing map fd.
bpf_object__reuse_map() could let us reuse existing pinned maps, which
is helpful.
This functions could also be used when we add iproute2 libbpf support,
so we don't need to re-use or re-implement new functions like
bpf_obj_get()/bpf_map_selfcheck_pinned() in iproute2.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
tools/lib/bpf/libbpf.c | 3 +--
tools/lib/bpf/libbpf.h | 1 +
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 32dc444224d8..e835d7a3437f 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -4033,8 +4033,7 @@ static bool map_is_reuse_compat(const struct bpf_map *map, int map_fd)
map_info.map_flags == map->def.map_flags);
}
-static int
-bpf_object__reuse_map(struct bpf_map *map)
+int bpf_object__reuse_map(struct bpf_map *map)
{
char *cp, errmsg[STRERR_BUFSIZE];
int err, pin_fd;
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index a750f67a23f6..4b9e615eb393 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -431,6 +431,7 @@ bpf_map__prev(const struct bpf_map *map, const struct bpf_object *obj);
/* get/set map FD */
LIBBPF_API int bpf_map__fd(const struct bpf_map *map);
LIBBPF_API int bpf_map__reuse_fd(struct bpf_map *map, int fd);
+LIBBPF_API int bpf_object__reuse_map(struct bpf_map *map);
/* get map definition */
LIBBPF_API const struct bpf_map_def *bpf_map__def(const struct bpf_map *map);
/* get map name */
--
2.25.4
next reply other threads:[~2020-09-29 3:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 3:18 Hangbin Liu [this message]
2020-09-29 3:30 ` [PATCH bpf-next] libbpf: export bpf_object__reuse_map() to libbpf api Andrii Nakryiko
2020-09-29 9:42 ` Hangbin Liu
2020-09-29 23:03 ` Andrii Nakryiko
2020-09-30 2:34 ` Hangbin Liu
2020-09-30 18:30 ` Andrii Nakryiko
2020-10-01 11:34 ` Hangbin Liu
2020-10-01 18:17 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200929031845.751054-1-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=jbenc@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=stephen@networkplumber.org \
--cc=toke@redhat.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox