[RFC bpf-next 0/3] bpf: Introduce module helper functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patchset is a working prototype that adds support for calling helper
functions in eBPF applications that have been defined in a kernel module.

It would require further work including code refractoring (not included in
the patchset) to rename functions, data structures and variables that are
used for kfunc as well to be appropriately renamed for module helper usage.
If the idea of module helper functions and the approach used in this patchset
is acceptable to the bpf community, I can send a follow up patchset with the
code refractoring included to make it ready for review.

Module helpers are useful as:
- They support more argument and return types when compared to module
kfunc.
- This adds a way to have helper functions that would be too specialized
for a specific usecase to merge upstream, but are functions that can have
a constant API and can be maintained in-kernel modules.
- The number of in-kernel helpers have grown to a large number
(187 at the time of writing this commit). Having module helper functions
could possibly reduce the number of helper functions needing to be
in-kernel in the future and maintained upstream.

When the kernel module registers the helper, the module owner,
BTF id set of the function and function proto is stored as part of a
btf_mod_helper entry in a btf_mod_helper_list which is part of
struct btf. This entry can be removed in the unregister function
while exiting the module, and can be used by the bpf verifier to
check the helper call and get function proto.

This patchset also includes a very simple example selftest showing the
working of module helpers.

Usama Arif (3):
  bpf: btf: Introduce infrastructure for module helpers
  bpf: add support for module helpers in verifier
  selftests/bpf: add test for module helper

 include/linux/btf.h                           | 44 ++++++++++
 kernel/bpf/btf.c                              | 88 +++++++++++++++++++
 kernel/bpf/verifier.c                         | 50 ++++++++---
 tools/testing/selftests/bpf/Makefile          |  3 +-
 .../selftests/bpf/bpf_testmod/bpf_testmod.c   | 21 +++++
 .../selftests/bpf/prog_tests/helper_module.c  | 59 +++++++++++++
 .../selftests/bpf/progs/test_helper_module.c  | 18 ++++
 7 files changed, 271 insertions(+), 12 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/helper_module.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_helper_module.c

-- 
2.25.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux