From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>,
Dave Marchevsky <davemarchevsky@fb.com>
Subject: [PATCH bpf-next 3/3] bpftool: reimplement large insn size limit feature probing
Date: Wed, 15 Dec 2021 23:04:42 -0800 [thread overview]
Message-ID: <20211216070442.1492204-4-andrii@kernel.org> (raw)
In-Reply-To: <20211216070442.1492204-1-andrii@kernel.org>
Reimplement bpf_probe_large_insn_limit() in bpftool, as that libbpf API
is scheduled for deprecation in v0.8.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/bpf/bpftool/feature.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c
index 5397077d0d9e..6719b9282eca 100644
--- a/tools/bpf/bpftool/feature.c
+++ b/tools/bpf/bpftool/feature.c
@@ -642,12 +642,32 @@ probe_helpers_for_progtype(enum bpf_prog_type prog_type, bool supported_type,
printf("\n");
}
-static void
-probe_large_insn_limit(const char *define_prefix, __u32 ifindex)
+/*
+ * Probe for availability of kernel commit (5.3):
+ *
+ * c04c0d2b968a ("bpf: increase complexity limit and maximum program size")
+ */
+static void probe_large_insn_limit(const char *define_prefix, __u32 ifindex)
{
+ LIBBPF_OPTS(bpf_prog_load_opts, opts,
+ .prog_ifindex = ifindex,
+ );
+ struct bpf_insn insns[BPF_MAXINSNS + 1];
bool res;
+ int i, fd;
+
+ for (i = 0; i < BPF_MAXINSNS; i++)
+ insns[i] = BPF_MOV64_IMM(BPF_REG_0, 1);
+ insns[BPF_MAXINSNS] = BPF_EXIT_INSN();
+
+ errno = 0;
+ fd = bpf_prog_load(BPF_PROG_TYPE_SCHED_CLS, NULL, "GPL",
+ insns, ARRAY_SIZE(insns), &opts);
+ res = fd >= 0 || (errno != E2BIG && errno != EINVAL);
+
+ if (fd >= 0)
+ close(fd);
- res = bpf_probe_large_insn_limit(ifindex);
print_bool_feature("have_large_insn_limit",
"Large program size limit",
"LARGE_INSN_LIMIT",
--
2.30.2
next prev parent reply other threads:[~2021-12-16 7:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 7:04 [PATCH bpf-next 0/3] Revamp and fix libbpf's feature-probing APIs Andrii Nakryiko
2021-12-16 7:04 ` [PATCH bpf-next 1/3] libbpf: rework " Andrii Nakryiko
2021-12-17 0:10 ` Dave Marchevsky
2021-12-17 0:41 ` Andrii Nakryiko
2021-12-17 7:07 ` Dave Marchevsky
2021-12-16 7:04 ` [PATCH bpf-next 2/3] selftests/bpf: add libbpf feature-probing API selftests Andrii Nakryiko
2021-12-17 0:21 ` Dave Marchevsky
2021-12-17 0:42 ` Andrii Nakryiko
2021-12-17 17:09 ` Andrii Nakryiko
2021-12-16 7:04 ` Andrii Nakryiko [this message]
2021-12-17 0:36 ` [PATCH bpf-next 3/3] bpftool: reimplement large insn size limit feature probing Dave Marchevsky
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=20211216070442.1492204-4-andrii@kernel.org \
--to=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davemarchevsky@fb.com \
--cc=kernel-team@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