selftests/bpf: Fix parsing of prog types in UAPI hdr for bpftool sync
authorQuentin Monnet <quentin@isovalent.com>
Mon, 4 Apr 2022 14:09:44 +0000 (15:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:30 +0000 (10:22 +0200)
commit2485af5ca4bb32132137ac6b0fb5080e0be832f7
tree16ad4c02727ca6f03b22be05bd3b152b84b6a067
parent3117e7a0de6f82d154542b82a2df369e801508db
selftests/bpf: Fix parsing of prog types in UAPI hdr for bpftool sync

[ Upstream commit 4eeebce6ac4ad80ee8243bb847c98e0e55848d47 ]

The script for checking that various lists of types in bpftool remain in
sync with the UAPI BPF header uses a regex to parse enum bpf_prog_type.
If this enum contains a set of values different from the list of program
types in bpftool, it complains.

This script should have reported the addition, some time ago, of the new
BPF_PROG_TYPE_SYSCALL, which was not reported to bpftool's program types
list. It failed to do so, because it failed to parse that new type from
the enum. This is because the new value, in the BPF header, has an
explicative comment on the same line, and the regex does not support
that.

Let's update the script to support parsing enum values when they have
comments on the same line.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220404140944.64744-1-quentin@isovalent.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/test_bpftool_synctypes.py