bpftool, musl compat: Replace nftw with FTW_ACTIONRETVAL
authorDominique Martinet <asmadeus@codewreck.org>
Sun, 24 Apr 2022 05:10:21 +0000 (14:10 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 25 Apr 2022 21:24:16 +0000 (23:24 +0200)
commit93bc2e9e943d20a51473a49009db3243de6e098d
tree915b2331f2e30255bb4862a4949831a21669082d
parent003fed595c0f37d0ad112447f5f942654979426c
bpftool, musl compat: Replace nftw with FTW_ACTIONRETVAL

musl nftw implementation does not support FTW_ACTIONRETVAL. There have been
multiple attempts at pushing the feature in musl upstream, but it has been
refused or ignored all the times:

  https://www.openwall.com/lists/musl/2021/03/26/1
  https://www.openwall.com/lists/musl/2022/01/22/1

In this case we only care about /proc/<pid>/fd/<fd>, so it's not too difficult
to reimplement directly instead, and the new implementation makes 'bpftool perf'
slightly faster because it doesn't needlessly stat/readdir unneeded directories
(54ms -> 13ms on my machine).

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20220424051022.2619648-4-asmadeus@codewreck.org
tools/bpf/bpftool/perf.c