diff mbox series

[bpf-next,2/2] bpftool: Probe for bounded loop support

Message ID CAHMuVOAjrhuQWe1P4edNfDoik8ieHEugmMdJ6uXe9OzBT2OMjg@mail.gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series [bpf-next,1/2] libbpf: Probe for bounded loop support | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail merge-conflict
netdev/tree_selection success Clearly marked for bpf-next
netdev/apply fail Patch does not apply to bpf-next

Commit Message

Paul Chaignon Dec. 17, 2021, 12:12 p.m. UTC
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 <quentin@isovalent.com>
Signed-off-by: Paul Chaignon <paul@isovalent.com>
---
 tools/bpf/bpftool/feature.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

--
2.25.1
diff mbox series

Patch

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();
 }