]> git.baikalelectronics.ru Git - kernel.git/commit
bpftool: Match several programs with same tag
authorPaul Chaignon <paul.chaignon@orange.com>
Fri, 13 Dec 2019 19:10:04 +0000 (20:10 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 15 Dec 2019 17:03:18 +0000 (09:03 -0800)
commit7db33770dc72b659ab455bb11c9b1a7b6e88c83a
tree7354b6b1655f0873b3eb9ee80d47cab4127adce0
parentbbe35bb51e563aa95c5c35a4b56ad7008a7c6f19
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
tools/bpf/bpftool/Documentation/bpftool-prog.rst
tools/bpf/bpftool/prog.c