From: Julia Kartseva <hex@fb.com>
To: <rdna@fb.com>, <bpf@vger.kernel.org>, <ast@kernel.org>,
<daniel@iogearbox.net>, <netdev@vger.kernel.org>,
<kernel-team@fb.com>
Cc: Julia Kartseva <hex@fb.com>
Subject: [PATCH bpf-next 00/10] bpf: bpf_(prog|map|attach)_type_(from|to)_str helpers
Date: Wed, 28 Aug 2019 14:03:03 -0700 [thread overview]
Message-ID: <cover.1567024943.git.hex@fb.com> (raw)
Standardize commonly used bpf enum names by introducing helper methods to
libbpf.
When applications require enum to string mapping the related code is
copy-pasted from bpftool. It hardens maintenance, e.g. when new enum
values are added.
Patches 0001-0003 introduce __MAX_BPF_PROG_TYPE and __MAX_BPF_MAP_TYPE enum
type.
Patches 0004-0006 introduce helpers methods
libbpf_str_from_(prog|map|attach)_type and
libbpf_(prog|map|attach)_type_from_str.
Patches 0007-0008 extend and rename test_section_names test.
Patches 0009-0010 introduce the helpers to bpftool.
An alternative for adding __MAX_BPF_(PROG|MAP)_TYPE is using an erroneous
result of bpf_(prog|map|attach)_type_(from|to)_str as an indicator of
loop bound. The disadvantages are: tests won't fail when a string name
is not provided for a new enum value; whoever wants to loop over enum
values should be aware about this side feature of newly introduced helpers.
Julia Kartseva (10):
bpf: introduce __MAX_BPF_PROG_TYPE and __MAX_BPF_MAP_TYPE enum values
tools/bpf: sync bpf.h to tools/
tools/bpf: handle __MAX_BPF_(PROG|MAP)_TYPE in switch statements
tools/bpf: add libbpf_prog_type_(from|to)_str helpers
tools/bpf: add libbpf_map_type_(from|to)_str helpers
tools/bpf: add libbpf_attach_type_(from|to)_str
selftests/bpf: extend test_section_names with type_(from|to)_str
selftests/bpf: rename test_section_names to
test_section_and_type_names
tools/bpftool: use libbpf_(prog|map)_type_to_str helpers
tools/bpftool: use libbpf_attach_type_to_str helper
include/uapi/linux/bpf.h | 6 +
tools/bpf/bpftool/cgroup.c | 60 +--
tools/bpf/bpftool/feature.c | 47 ++-
tools/bpf/bpftool/main.h | 33 --
tools/bpf/bpftool/map.c | 80 +---
tools/bpf/bpftool/prog.c | 31 +-
tools/include/uapi/linux/bpf.h | 6 +
tools/lib/bpf/libbpf.c | 153 +++++++
tools/lib/bpf/libbpf.h | 17 +
tools/lib/bpf/libbpf.map | 6 +
tools/lib/bpf/libbpf_probes.c | 2 +
tools/testing/selftests/bpf/Makefile | 2 +-
.../bpf/test_section_and_type_names.c | 378 ++++++++++++++++++
.../selftests/bpf/test_section_names.c | 233 -----------
14 files changed, 673 insertions(+), 381 deletions(-)
create mode 100644 tools/testing/selftests/bpf/test_section_and_type_names.c
delete mode 100644 tools/testing/selftests/bpf/test_section_names.c
--
2.17.1
next reply other threads:[~2019-08-28 21:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-28 21:03 Julia Kartseva [this message]
2019-08-28 21:03 ` [PATCH bpf-next 01/10] bpf: introduce __MAX_BPF_PROG_TYPE and __MAX_BPF_MAP_TYPE enum values Julia Kartseva
2019-08-28 21:33 ` Alexei Starovoitov
2019-08-28 21:03 ` [PATCH bpf-next 02/10] tools/bpf: sync bpf.h to tools/ Julia Kartseva
2019-08-28 21:03 ` [PATCH bpf-next 03/10] tools/bpf: handle __MAX_BPF_(PROG|MAP)_TYPE in switch statements Julia Kartseva
2019-08-28 21:19 ` Arnaldo Carvalho de Melo
2019-08-28 21:03 ` [PATCH bpf-next 04/10] tools/bpf: add libbpf_prog_type_(from|to)_str helpers Julia Kartseva
2019-08-28 23:34 ` Jakub Kicinski
2019-08-28 23:46 ` auto-split of commit. Was: " Alexei Starovoitov
2019-08-29 6:51 ` Greg Kroah-Hartman
2019-08-29 17:16 ` Alexei Starovoitov
2019-08-29 18:10 ` Arnaldo Carvalho de Melo
2019-08-29 18:50 ` Jakub Kicinski
2019-08-30 6:47 ` Greg Kroah-Hartman
2019-08-30 9:01 ` Toke Høiland-Jørgensen
2019-08-28 21:03 ` [PATCH bpf-next 05/10] tools/bpf: add libbpf_map_type_(from|to)_str helpers Julia Kartseva
2019-08-28 21:03 ` [PATCH bpf-next 06/10] tools/bpf: add libbpf_attach_type_(from|to)_str Julia Kartseva
2019-08-28 21:03 ` [PATCH bpf-next 07/10] selftests/bpf: extend test_section_names with type_(from|to)_str Julia Kartseva
2019-08-28 21:03 ` [PATCH bpf-next 08/10] selftests/bpf: rename test_section_names to test_section_and_type_names Julia Kartseva
2019-08-28 21:03 ` [PATCH bpf-next 09/10] tools/bpftool: use libbpf_(prog|map)_type_to_str helpers Julia Kartseva
2019-08-28 21:03 ` [PATCH bpf-next 10/10] tools/bpftool: use libbpf_attach_type_to_str helper Julia Kartseva
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=cover.1567024943.git.hex@fb.com \
--to=hex@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=rdna@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).