diff options
author | Florian Westphal <fw@strlen.de> | 2023-04-21 19:02:58 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-04-21 20:34:49 +0200 |
commit | d0fe92fb5e3df6991c640fb9205d880b68603259 (patch) | |
tree | a42f0b6d647e7fdd9a27a624167a483015d6a5da /tools/bpf/bpftool/main.h | |
parent | netfilter: disallow bpf hook attachment at same priority (diff) | |
download | linux-d0fe92fb5e3df6991c640fb9205d880b68603259.tar.xz linux-d0fe92fb5e3df6991c640fb9205d880b68603259.zip |
tools: bpftool: print netfilter link info
Dump protocol family, hook and priority value:
$ bpftool link
2: netfilter prog 14
ip input prio -128
pids install(3264)
5: netfilter prog 14
ip6 forward prio 21
pids a.out(3387)
9: netfilter prog 14
ip prerouting prio 123
pids a.out(5700)
10: netfilter prog 14
ip input prio 21
pids test2(5701)
v2: Quentin Monnet suggested to also add 'bpftool net' support:
$ bpftool net
xdp:
tc:
flow_dissector:
netfilter:
ip prerouting prio 21 prog_id 14
ip input prio -128 prog_id 14
ip input prio 21 prog_id 14
ip forward prio 21 prog_id 14
ip output prio 21 prog_id 14
ip postrouting prio 21 prog_id 14
'bpftool net' only dumps netfilter link type, links are sorted by protocol
family, hook and priority.
v5: fix bpf ci failure: libbpf needs small update to prog_type_name[]
and probe_prog_load helper.
v4: don't fail with -EOPNOTSUPP in libbpf probe_prog_load, update
prog_type_name[] with "netfilter" entry (bpf ci)
v3: fix bpf.h copy, 'reserved' member was removed (Alexei)
use p_err, not fprintf (Quentin)
Suggested-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/eeeaac99-9053-90c2-aa33-cc1ecb1ae9ca@isovalent.com/
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Link: https://lore.kernel.org/r/20230421170300.24115-6-fw@strlen.de
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/main.h')
-rw-r--r-- | tools/bpf/bpftool/main.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h index 9a95788e654d..a49534d7eafa 100644 --- a/tools/bpf/bpftool/main.h +++ b/tools/bpf/bpftool/main.h @@ -267,4 +267,7 @@ static inline bool hashmap__empty(struct hashmap *map) int pathname_concat(char *buf, int buf_sz, const char *path, const char *name); +/* print netfilter bpf_link info */ +void netfilter_dump_plain(const struct bpf_link_info *info); +void netfilter_dump_json(const struct bpf_link_info *info, json_writer_t *wtr); #endif |