This patch probes for bounded loop support and displays the results as
part of the miscellaneous section, as shown below.
$ bpftool feature probe | grep loops
Bounded loop support is available
$ bpftool feature probe macro | grep LOOPS
#define HAVE_BOUNDED_LOOPS
$ bpftool feature probe -j | jq .misc
{
"have_large_insn_limit": true,
"have_bounded_loops": true
}
Reviewed-by: Quentin Monnet <redacted>
Signed-off-by: Paul Chaignon <redacted>
---
Changes in v2:
- Resending to fix a format error.
tools/bpf/bpftool/feature.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c
index 5397077d0d9e..7aee920162e5 100644
--- a/tools/bpf/bpftool/feature.c
+++ b/tools/bpf/bpftool/feature.c
@@ -654,6 +654,18 @@ probe_large_insn_limit(const char *define_prefix, __u32 ifindex)
res, define_prefix);
}
+static void
+probe_bounded_loops(const char *define_prefix, __u32 ifindex)
+{
+ bool res;
+
+ res = bpf_probe_bounded_loops(ifindex);
+ print_bool_feature("have_bounded_loops",
+ "Bounded loop support",
+ "BOUNDED_LOOPS",
+ res, define_prefix);
+}
+
static void
section_system_config(enum probe_component target, const char *define_prefix)
{@@ -768,6 +780,7 @@ static void section_misc(const char *define_prefix, __u32 ifindex)
"/*** eBPF misc features ***/",
define_prefix);
probe_large_insn_limit(define_prefix, ifindex);
+ probe_bounded_loops(define_prefix, ifindex);
print_end_section();
}
--
2.25.1