All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/6] skip verifier/map tests if kernel support is missing
@ 2018-12-17 18:25 Stanislav Fomichev
  2018-12-17 18:25 ` [PATCH bpf-next v2 1/6] selftests/bpf: add map/prog type probe helpers Stanislav Fomichev
                   ` (6 more replies)
  0 siblings, 7 replies; 17+ messages in thread
From: Stanislav Fomichev @ 2018-12-17 18:25 UTC (permalink / raw)
  To: netdev, ast; +Cc: davem, daniel, ecree, quentin.monnet, Stanislav Fomichev

If test_maps/test_verifier is running against the kernel which doesn't
have _all_ BPF features enabled, it fails with an error. This patch
series tries to probe kernel support for each failed test and skip
it instead. This lets users run BPF selftests in the not-all-bpf-yes
environments and received correct PASS/NON-PASS result.

See https://www.spinics.net/lists/netdev/msg539331.html for more
context.

The series goes like this:

* patch #1 adds bpf_prog_type_supported() and
  bpf_map_type_supported() which query the kernel (insert 'return 0'
  program or try to create empty map with correct key/value sizes) and
  return supported/unsupported.
  Note: this functionality can later be reimplemented on top of Quentin's
  recent 'bpftool feature' patchset if he decides to move the probes
  into libbpf.
* patch #2 skips sockmap tests in test_maps.c if BPF_MAP_TYPE_SOCKMAP
  map is not supported (if bpf_create_map fails, we probe the kernel
  for support)
* patch #3 skips verifier tests if test->prog_type is not supported (if
  bpf_verify_program fails, we probe the kernel for support)
* patch #4 skips verifier tests if test fixup map is not supported (if
  create_map fails, we probe the kernel for support)
  Note: we can probably move this probe into create_map helper and
  return some argument instead of adding skip_unsupported_map()
  to each fixup; but I'm not sure it's better.
  Also note: in current implementation we still print 'Failed to
  create hash map' from the create_map, but still skip the test.
* next patches fix various small issues that arise from the first four:
  * patch #5 sets "unknown func bpf_trace_printk#6" prog_type to
    BPF_PROG_TYPE_TRACEPOINT so it is correctly skipped in
    CONFIG_BPF_EVENTS=n case
  * patch #6 exposes BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} only when
    CONFIG_CGROUP_BPF=y, this makes verifier correctly skip appropriate
    tests

v2 changes:

* don't sprinkle "ifdef CONFIG_CGROUP_BPF" all around net/core/filter.c,
  doing it only in the bpf_types.h is enough to disable
  BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} prog types for non-cgroup
  enabled kernels

Stanislav Fomichev (6):
  selftests/bpf: add map/prog type probe helpers
  selftests/bpf: skip sockmap in test_maps if kernel doesn't have
    support
  selftests/bpf: skip verifier tests for unsupported program types
  selftests/bpf: skip verifier tests for unsupported map types
  selftests/bpf: mark verifier test that uses bpf_trace_printk as
    BPF_PROG_TYPE_TRACEPOINT
  bpf: BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} require cgroups enabled

 include/linux/bpf_types.h                   |  2 +
 tools/testing/selftests/bpf/Makefile        |  2 +
 tools/testing/selftests/bpf/probe_helpers.c | 68 +++++++++++++++++++++
 tools/testing/selftests/bpf/probe_helpers.h | 10 +++
 tools/testing/selftests/bpf/test_maps.c     | 14 ++++-
 tools/testing/selftests/bpf/test_verifier.c | 44 +++++++++++--
 6 files changed, 135 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/probe_helpers.c
 create mode 100644 tools/testing/selftests/bpf/probe_helpers.h

-- 
2.20.0.405.gbc1bbc6f85-goog

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-12-20 22:51 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 18:25 [PATCH bpf-next v2 0/6] skip verifier/map tests if kernel support is missing Stanislav Fomichev
2018-12-17 18:25 ` [PATCH bpf-next v2 1/6] selftests/bpf: add map/prog type probe helpers Stanislav Fomichev
2018-12-18 23:21   ` Daniel Borkmann
2018-12-18 23:35     ` Stanislav Fomichev
2018-12-17 18:25 ` [PATCH bpf-next v2 2/6] selftests/bpf: skip sockmap in test_maps if kernel doesn't have support Stanislav Fomichev
2018-12-17 18:25 ` [PATCH bpf-next v2 3/6] selftests/bpf: skip verifier tests for unsupported program types Stanislav Fomichev
2018-12-17 18:25 ` [PATCH bpf-next v2 4/6] selftests/bpf: skip verifier tests for unsupported map types Stanislav Fomichev
2018-12-18 23:25   ` Daniel Borkmann
2018-12-19  0:02     ` Stanislav Fomichev
2018-12-20 20:51       ` Stanislav Fomichev
2018-12-20 22:38         ` Daniel Borkmann
2018-12-20 22:51           ` Stanislav Fomichev
2018-12-17 18:25 ` [PATCH bpf-next v2 5/6] selftests/bpf: mark verifier test that uses bpf_trace_printk as BPF_PROG_TYPE_TRACEPOINT Stanislav Fomichev
2018-12-17 18:25 ` [PATCH bpf-next v2 6/6] bpf: BPF_PROG_TYPE_CGROUP_{SKB,SOCK,SOCK_ADDR} require cgroups enabled Stanislav Fomichev
2018-12-18 21:25 ` [PATCH bpf-next v2 0/6] skip verifier/map tests if kernel support is missing Alexei Starovoitov
2018-12-18 21:30   ` Stanislav Fomichev
2018-12-18 23:18     ` Daniel Borkmann

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.