linux-stable/tools/bpf/bpftool
Paul Chaignon ec2025095c bpftool: Match several programs with same tag
When several BPF programs have the same tag, bpftool matches only the
first (in ID order).  This patch changes that behavior such that dump and
show commands return all matched programs.  Commands that require a single
program (e.g., pin and attach) will error out if given a tag that matches
several.  bpftool prog dump will also error out if file or visual are
given and several programs have the given tag.

In the case of the dump command, a program header is added before each
dump only if the tag matches several programs; this patch doesn't change
the output if a single program matches.  The output when several
programs match thus looks as follows.

$ ./bpftool prog dump xlated tag 6deef7357e7b4530
3: cgroup_skb  tag 6deef7357e7b4530  gpl
   0: (bf) r6 = r1
   [...]
   7: (95) exit

4: cgroup_skb  tag 6deef7357e7b4530  gpl
   0: (bf) r6 = r1
   [...]
   7: (95) exit

Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/fb1fe943202659a69cd21dd5b907c205af1e1e22.1576263640.git.paul.chaignon@gmail.com
2019-12-15 09:03:18 -08:00
..
Documentation bpftool: Match several programs with same tag 2019-12-15 09:03:18 -08:00
bash-completion tools: bpftool: add "bpftool map freeze" subcommand 2019-08-21 21:17:27 +02:00
.gitignore tools: bpf: account for generated feature/ and libbpf/ directories 2019-08-31 00:38:16 +02:00
Makefile tools: bpftool: do not link twice against libbpf.a in Makefile 2019-08-31 00:38:16 +02:00
btf.c tools, bpftool: Fix warning on ignored return value for 'read' 2019-11-24 16:58:44 -08:00
btf_dumper.c tools: bpftool: fix format strings and arguments for jsonw_printf() 2019-08-15 22:06:46 -07:00
cfg.c tools: bpftool: teach cfg code about JMP32 2019-01-26 13:33:01 -08:00
cfg.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00
cgroup.c tools: bpftool: compile with $(EXTRA_WARNINGS) 2019-08-14 22:57:36 +02:00
common.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2019-09-06 16:49:17 +02:00
feature.c tools: bpftool: fix reading from /proc/config.gz 2019-08-12 11:07:16 +02:00
jit_disasm.c tools: bpftool: Fix json dump crash on powerpc 2019-07-05 23:50:38 +02:00
json_writer.c tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
json_writer.h tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
main.c bpftool: Fix bpftool build by switching to bpf_object__open_file() 2019-10-07 18:44:28 -07:00
main.h bpftool: Fix bpftool build by switching to bpf_object__open_file() 2019-10-07 18:44:28 -07:00
map.c tools: bpftool: add "bpftool map freeze" subcommand 2019-08-21 21:17:27 +02:00
map_perf_ring.c tools: bpftool: fix arguments for p_err() in do_event_pipe() 2019-08-15 22:06:46 -07:00
net.c tools: bpftool: fix format string for p_err() in query_flow_dissector() 2019-08-15 22:06:46 -07:00
netlink_dumper.c tools: bpftool: dual license all files 2018-12-13 12:08:44 +01:00
netlink_dumper.h tools: bpftool: dual license all files 2018-12-13 12:08:44 +01:00
perf.c tools: bpftool: compile with $(EXTRA_WARNINGS) 2019-08-14 22:57:36 +02:00
prog.c bpftool: Match several programs with same tag 2019-12-15 09:03:18 -08:00
tracelog.c tools: bpftool: add an option to prevent auto-mount of bpffs, tracefs 2018-12-18 14:47:17 +01:00
xlated_dumper.c bpf: style fix in while(!feof()) loop 2019-05-28 10:54:01 +02:00
xlated_dumper.h tools: bpftool: replace Netronome boilerplate with SPDX license headers 2018-12-13 12:08:44 +01:00