bpftool: Probe for bounded loop support
authorPaul Chaignon <paul@isovalent.com>
Tue, 4 Jan 2022 17:59:57 +0000 (18:59 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 5 Jan 2022 12:31:40 +0000 (13:31 +0100)
commitc04fb2b0bd9275969be3b0a95f9c3ef76b1bfb73
treef722f5d8116e423f73b95c2ccfe2b4e9ba5c903a
parentb22bf1b9979a608827dea98c61ed9ec297bcc513
bpftool: Probe for bounded loop support

This patch introduces a new probe to check whether the verifier supports
bounded loops as introduced in commit 2589726d12a1 ("bpf: introduce
bounded loops"). This patch will allow BPF users such as Cilium to probe
for loop support on startup and only unconditionally unroll loops on
older kernels.

The results are displayed 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
  }

Signed-off-by: Paul Chaignon <paul@isovalent.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/f7807c0b27d79f48e71de7b5a99c680ca4bd0151.1641314075.git.paul@isovalent.com
tools/bpf/bpftool/feature.c