All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/3] introduce dummy BPF STRUCT_OPS
@ 2021-09-15  3:37 Hou Tao
  2021-09-15  3:37 ` [RFC PATCH bpf-next 1/3] bpf: add dummy BPF STRUCT_OPS for test purpose Hou Tao
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Hou Tao @ 2021-09-15  3:37 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau
  Cc: netdev, bpf, houtao1

Hi,

Currently the test of BPF STRUCT_OPS depends on the specific bpf
implementation of tcp_congestion_ops, but it can not cover all
basic functionalities (e.g, return value handling), so introduce
a dummy BPF STRUCT_OPS for test purpose.

The test procedure works in the following way:
(1) write to newly-created /sys/kernel/bpf_test/dummy_ops_ctl
The format is "test_case_N [option_integer_return]".

(2) test_case_N in bpf_testmod.ko will be call dummy_ops method
It will call bpf_get_dummy_ops() first to get the dummy_ops,
call its method, and check the return value of the method. If
the method succeeds and its return value is expected, the write
succeeds, else it fails.

But there is one concerns: the format of dummy_ops_ctl is too
simply. It can only check a integer state update from dummy_ops
method. If multiple states are updated in a dummy struct_ops
method, it can not verify these updates are expected in
bpf_testmod.ko. Are such test is needed here ?

Any comments are welcome.

Hou Tao (3):
  bpf: add dummy BPF STRUCT_OPS for test purpose
  selftests/bpf: call dummy struct_ops in bpf_testmode
  selftests/bpf: add test for BPF STRUCT_OPS

 include/linux/bpf_dummy_ops.h                 |  28 +++
 kernel/bpf/Kconfig                            |   7 +
 kernel/bpf/Makefile                           |   2 +
 kernel/bpf/bpf_dummy_struct_ops.c             | 173 ++++++++++++++++++
 kernel/bpf/bpf_struct_ops_types.h             |   4 +
 .../selftests/bpf/bpf_testmod/bpf_testmod.c   | 152 ++++++++++++++-
 .../selftests/bpf/prog_tests/bpf_dummy_ops.c  |  95 ++++++++++
 .../selftests/bpf/progs/bpf_dummy_ops.c       |  34 ++++
 8 files changed, 493 insertions(+), 2 deletions(-)
 create mode 100644 include/linux/bpf_dummy_ops.h
 create mode 100644 kernel/bpf/bpf_dummy_struct_ops.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_dummy_ops.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_dummy_ops.c

-- 
2.29.2


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

end of thread, other threads:[~2021-09-18  2:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  3:37 [RFC PATCH bpf-next 0/3] introduce dummy BPF STRUCT_OPS Hou Tao
2021-09-15  3:37 ` [RFC PATCH bpf-next 1/3] bpf: add dummy BPF STRUCT_OPS for test purpose Hou Tao
2021-09-15 20:58   ` Martin KaFai Lau
2021-09-18  2:03     ` Hou Tao
2021-09-16  3:25   ` kernel test robot
2021-09-16  7:09   ` kernel test robot
2021-09-16  7:09     ` kernel test robot
2021-09-15  3:37 ` [RFC PATCH bpf-next 2/3] selftests/bpf: call dummy struct_ops in bpf_testmode Hou Tao
2021-09-15  3:37 ` [RFC PATCH bpf-next 3/3] selftests/bpf: add test for BPF STRUCT_OPS Hou Tao

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.