• Paul Chaignon's avatar
    bpftool: Match several programs with same tag · ec202509
    Paul Chaignon authored
    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: default avatarPaul Chaignon <paul.chaignon@orange.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/fb1fe943202659a69cd21dd5b907c205af1e1e22.1576263640.git.paul.chaignon@gmail.com
    ec202509
prog.c 34.9 KB