• Yonghong Song's avatar
    bpftool: Implement link_query for bpf iterators · e60495ea
    Yonghong Song authored
    The link query for bpf iterators is implemented.
    Besides being shown to the user what bpf iterator
    the link represents, the target_name is also used
    to filter out what additional information should be
    printed out, e.g., whether map_id should be shown or not.
    The following is an example of bpf_iter link dump,
    plain output or pretty output.
    
      $ bpftool link show
      11: iter  prog 59  target_name task
              pids test_progs(1749)
      34: iter  prog 173  target_name bpf_map_elem  map_id 127
              pids test_progs_1(1753)
      $ bpftool -p link show
      [{
              "id": 11,
              "type": "iter",
              "prog_id": 59,
              "target_name": "task",
              "pids": [{
                      "pid": 1749,
                      "comm": "test_progs"
                  }
              ]
          },{
              "id": 34,
              "type": "iter",
              "prog_id": 173,
              "target_name": "bpf_map_elem",
              "map_id": 127,
              "pids": [{
                      "pid": 1753,
                      "comm": "test_progs_1"
                  }
              ]
          }
      ]
    Signed-off-by: default avatarYonghong Song <yhs@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
    Link: https://lore.kernel.org/bpf/20200821184420.574430-1-yhs@fb.com
    e60495ea
link.c 9.07 KB