Skip to content

Commit

Permalink
selftests/bpf: fix veristat's singular file-or-prog filter
Browse files Browse the repository at this point in the history
Fix the bug of filtering out filename too early, before we know the
program name, if using unified file-or-prog filter (i.e., -f
<any-glob>). Because we try to filter BPF object file early without
opening and parsing it, if any_glob (file-or-prog) filter is used we
have to accept any filename just to get program name, which might match
any_glob.

Fixes: 10b1b3f ("selftests/bpf: consolidate and improve file/prog filtering in veristat")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/r/20221111181242.2101192-1-andrii@kernel.org
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
  • Loading branch information
Andrii Nakryiko authored and Martin KaFai Lau committed Nov 11, 2022
1 parent 0f7dc42 commit eb6af4c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/testing/selftests/bpf/veristat.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,13 @@ static bool should_process_file_prog(const char *filename, const char *prog_name
if (f->any_glob) {
if (glob_matches(filename, f->any_glob))
return true;
if (prog_name && glob_matches(prog_name, f->any_glob))
/* If we don't know program name yet, any_glob filter
* has to assume that current BPF object file might be
* relevant; we'll check again later on after opening
* BPF object file, at which point program name will
* be known finally.
*/
if (!prog_name || glob_matches(prog_name, f->any_glob))
return true;
} else {
if (f->file_glob && !glob_matches(filename, f->file_glob))
Expand Down

0 comments on commit eb6af4c

Please sign in to comment.