All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Chaignon <paul@isovalent.com>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Quentin Monnet <quentin@isovalent.com>
Subject: [PATCH bpf-next 2/2] bpftool: Probe for bounded loop support
Date: Fri, 17 Dec 2021 13:12:44 +0100	[thread overview]
Message-ID: <CAHMuVOAjrhuQWe1P4edNfDoik8ieHEugmMdJ6uXe9OzBT2OMjg@mail.gmail.com> (raw)

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(+)

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

                 reply	other threads:[~2021-12-17 12:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAHMuVOAjrhuQWe1P4edNfDoik8ieHEugmMdJ6uXe9OzBT2OMjg@mail.gmail.com \
    --to=paul@isovalent.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=quentin@isovalent.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.