1. 03 12月, 2021 1 次提交
  2. 15 11月, 2021 2 次提交
  3. 26 10月, 2021 3 次提交
    • Q
      bpftool: Switch to libbpf's hashmap for PIDs/names references · d6699f8e
      Quentin Monnet 提交于
      In order to show PIDs and names for processes holding references to BPF
      programs, maps, links, or BTF objects, bpftool creates hash maps to
      store all relevant information. This commit is part of a set that
      transitions from the kernel's hash map implementation to the one coming
      with libbpf.
      
      The motivation is to make bpftool less dependent of kernel headers, to
      ease the path to a potential out-of-tree mirror, like libbpf has.
      
      This is the third and final step of the transition, in which we convert
      the hash maps used for storing the information about the processes
      holding references to BPF objects (programs, maps, links, BTF), and at
      last we drop the inclusion of tools/include/linux/hashtable.h.
      
      Note: Checkpatch complains about the use of __weak declarations, and the
      missing empty lines after the bunch of empty function declarations when
      compiling without the BPF skeletons (none of these were introduced in
      this patch). We want to keep things as they are, and the reports should
      be safe to ignore.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20211023205154.6710-6-quentin@isovalent.com
      d6699f8e
    • Q
      bpftool: Switch to libbpf's hashmap for pinned paths of BPF objects · 8f184732
      Quentin Monnet 提交于
      In order to show pinned paths for BPF programs, maps, or links when
      listing them with the "-f" option, bpftool creates hash maps to store
      all relevant paths under the bpffs. So far, it would rely on the
      kernel implementation (from tools/include/linux/hashtable.h).
      
      We can make bpftool rely on libbpf's implementation instead. The
      motivation is to make bpftool less dependent of kernel headers, to ease
      the path to a potential out-of-tree mirror, like libbpf has.
      
      This commit is the first step of the conversion: the hash maps for
      pinned paths for programs, maps, and links are converted to libbpf's
      hashmap.{c,h}. Other hash maps used for the PIDs of process holding
      references to BPF objects are left unchanged for now. On the build side,
      this requires adding a dependency to a second header internal to libbpf,
      and making it a dependency for the bootstrap bpftool version as well.
      The rest of the changes are a rather straightforward conversion.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20211023205154.6710-4-quentin@isovalent.com
      8f184732
    • Q
      bpftool: Do not expose and init hash maps for pinned path in main.c · 46241271
      Quentin Monnet 提交于
      BPF programs, maps, and links, can all be listed with their pinned paths
      by bpftool, when the "-f" option is provided. To do so, bpftool builds
      hash maps containing all pinned paths for each kind of objects.
      
      These three hash maps are always initialised in main.c, and exposed
      through main.h. There appear to be no particular reason to do so: we can
      just as well make them static to the files that need them (prog.c,
      map.c, and link.c respectively), and initialise them only when we want
      to show objects and the "-f" switch is provided.
      
      This may prevent unnecessary memory allocations if the implementation of
      the hash maps was to change in the future.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20211023205154.6710-3-quentin@isovalent.com
      46241271
  4. 31 7月, 2021 1 次提交
    • Q
      tools: bpftool: Update and synchronise option list in doc and help msg · c07ba629
      Quentin Monnet 提交于
      All bpftool commands support the options for JSON output and debug from
      libbpf. In addition, some commands support additional options
      corresponding to specific use cases.
      
      The list of options described in the man pages for the different
      commands are not always accurate. The messages for interactive help are
      mostly limited to HELP_SPEC_OPTIONS, and are even less representative of
      the actual set of options supported for the commands.
      
      Let's update the lists:
      
      - HELP_SPEC_OPTIONS is modified to contain the "default" options (JSON
        and debug), and to be extensible (no ending curly bracket).
      - All commands use HELP_SPEC_OPTIONS in their help message, and then
        complete the list with their specific options.
      - The lists of options in the man pages are updated.
      - The formatting of the list for bpftool.rst is adjusted to match
        formatting for the other man pages. This is for consistency, and also
        because it will be helpful in a future patch to automatically check
        that the files are synchronised.
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210730215435.7095-5-quentin@isovalent.com
      c07ba629
  5. 30 7月, 2021 1 次提交
  6. 17 3月, 2021 1 次提交
  7. 07 11月, 2020 1 次提交
  8. 11 9月, 2020 3 次提交
  9. 26 8月, 2020 1 次提交
  10. 25 6月, 2020 1 次提交
  11. 23 6月, 2020 2 次提交
  12. 17 6月, 2020 1 次提交
  13. 16 6月, 2020 1 次提交
  14. 02 6月, 2020 1 次提交
  15. 12 5月, 2020 1 次提交
  16. 13 3月, 2020 1 次提交
  17. 21 1月, 2020 1 次提交
  18. 16 1月, 2020 4 次提交
  19. 16 12月, 2019 1 次提交
  20. 22 8月, 2019 2 次提交
  21. 30 7月, 2019 1 次提交
  22. 06 6月, 2019 1 次提交
    • K
      tools: bpftool: Fix JSON output when lookup fails · 1884c066
      Krzesimir Nowak 提交于
      In commit 9a5ab8bf ("tools: bpftool: turn err() and info() macros
      into functions") one case of error reporting was special cased, so it
      could report a lookup error for a specific key when dumping the map
      element. What the code forgot to do is to wrap the key and value keys
      into a JSON object, so an example output of pretty JSON dump of a
      sockhash map (which does not support looking up its values) is:
      
      [
          "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00"
          ],
          "value": {
              "error": "Operation not supported"
          },
          "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01"
          ],
          "value": {
              "error": "Operation not supported"
          }
      ]
      
      Note the key-value pairs inside the toplevel array. They should be
      wrapped inside a JSON object, otherwise it is an invalid JSON. This
      commit fixes this, so the output now is:
      
      [{
              "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00"
              ],
              "value": {
                  "error": "Operation not supported"
              }
          },{
              "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01"
              ],
              "value": {
                  "error": "Operation not supported"
              }
          }
      ]
      
      Fixes: 9a5ab8bf ("tools: bpftool: turn err() and info() macros into functions")
      Cc: Quentin Monnet <quentin.monnet@netronome.com>
      Signed-off-by: NKrzesimir Nowak <krzesimir@kinvolk.io>
      Acked-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      1884c066
  23. 28 4月, 2019 1 次提交
  24. 26 4月, 2019 2 次提交
  25. 17 4月, 2019 2 次提交
  26. 16 4月, 2019 2 次提交
  27. 10 4月, 2019 1 次提交
    • D
      bpf: bpftool support for dumping data/bss/rodata sections · 817998af
      Daniel Borkmann 提交于
      Add the ability to bpftool to handle BTF Var and DataSec kinds
      in order to dump them out of btf_dumper_type(). The value has a
      single object with the section name, which itself holds an array
      of variables it dumps. A single variable is an object by itself
      printed along with its name. From there further type information
      is dumped along with corresponding value information.
      
      Example output from .rodata:
      
        # ./bpftool m d i 150
        [{
                "value": {
                    ".rodata": [{
                            "load_static_data.bar": 18446744073709551615
                        },{
                            "num2": 24
                        },{
                            "num5": 43947
                        },{
                            "num6": 171
                        },{
                            "str0": [97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,0,0,0,0,0,0
                            ]
                        },{
                            "struct0": {
                                "a": 42,
                                "b": 4278120431,
                                "c": 1229782938247303441
                            }
                        },{
                            "struct2": {
                                "a": 0,
                                "b": 0,
                                "c": 0
                            }
                        }
                    ]
                }
            }
        ]
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      817998af