From: Shuyi Cheng <chengshuyi@linux.alibaba.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
"open list:BPF (Safe dynamic programs and tools)"
<netdev@vger.kernel.org>,
"open list:BPF (Safe dynamic programs and tools)"
<bpf@vger.kernel.org>
Subject: [PATCH bpf-next] libbpf: Skip the pinning of global data map for old kernels.
Date: Thu, 9 Dec 2021 16:44:16 +0800 [thread overview]
Message-ID: <9eb3216b-a785-9024-0f1d-e5a14dfb025b@linux.alibaba.com> (raw)
Fix error: "failed to pin map: Bad file descriptor, path:
/sys/fs/bpf/_rodata_str1_1."
In the old kernel, the global data map will not be created, see [0]. So
we should skip the pinning of the global data map to avoid
bpf_object__pin_maps returning error.
[0]: https://lore.kernel.org/bpf/20211123200105.387855-1-andrii@kernel.org
Signed-off-by: Shuyi Cheng <chengshuyi@linux.alibaba.com>
---
tools/lib/bpf/libbpf.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 6db0b5e8540e..d96cf49cebab 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -7884,6 +7884,10 @@ int bpf_object__pin_maps(struct bpf_object *obj,
const char *path)
char *pin_path = NULL;
char buf[PATH_MAX];
+ if (bpf_map__is_internal(map) &&
+ !kernel_supports(obj, FEAT_GLOBAL_DATA))
+ continue;
+
if (path) {
int len;
--
2.19.1.6.gb485710b
next reply other threads:[~2021-12-09 8:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 8:44 Shuyi Cheng [this message]
2021-12-09 17:26 ` [PATCH bpf-next] libbpf: Skip the pinning of global data map for old kernels Andrii Nakryiko
2021-12-10 3:02 ` Shuyi Cheng
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=9eb3216b-a785-9024-0f1d-e5a14dfb025b@linux.alibaba.com \
--to=chengshuyi@linux.alibaba.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.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