1. 11 11月, 2018 1 次提交
  2. 21 10月, 2018 1 次提交
    • D
      bpf, libbpf: simplify and cleanup perf ring buffer walk · 3dca2115
      Daniel Borkmann 提交于
      Simplify bpf_perf_event_read_simple() a bit and fix up some minor
      things along the way: the return code in the header is not of type
      int but enum bpf_perf_event_ret instead. Once callback indicated
      to break the loop walking event data, it also needs to be consumed
      in data_tail since it has been processed already.
      
      Moreover, bpf_perf_event_print_t callback should avoid void * as
      we actually get a pointer to struct perf_event_header and thus
      applications can make use of container_of() to have type checks.
      The walk also doesn't have to use modulo op since the ring size is
      required to be power of two.
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      3dca2115
  3. 17 10月, 2018 1 次提交
  4. 16 10月, 2018 1 次提交
    • J
      bpf: bpftool, add flag to allow non-compat map definitions · c034a177
      John Fastabend 提交于
      Multiple map definition structures exist and user may have non-zero
      fields in their definition that are not recognized by bpftool and
      libbpf. The normal behavior is to then fail loading the map. Although
      this is a good default behavior users may still want to load the map
      for debugging or other reasons. This patch adds a --mapcompat flag
      that can be used to override the default behavior and allow loading
      the map even when it has additional non-zero fields.
      
      For now the only user is 'bpftool prog' we can switch over other
      subcommands as needed. The library exposes an API that consumes
      a flags field now but I kept the original API around also in case
      users of the API don't want to expose this. The flags field is an
      int in case we need more control over how the API call handles
      errors/features/etc in the future.
      Signed-off-by: NJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      c034a177
  5. 08 10月, 2018 1 次提交
  6. 04 10月, 2018 4 次提交
  7. 03 10月, 2018 1 次提交
  8. 28 9月, 2018 1 次提交
    • A
      libbpf: Introduce libbpf_attach_type_by_name · 956b620f
      Andrey Ignatov 提交于
      There is a common use-case when ELF object contains multiple BPF
      programs and every program has its own section name. If it's cgroup-bpf
      then programs have to be 1) loaded and 2) attached to a cgroup.
      
      It's convenient to have information necessary to load BPF program
      together with program itself. This is where section name works fine in
      conjunction with libbpf_prog_type_by_name that identifies prog_type and
      expected_attach_type and these can be used with BPF_PROG_LOAD.
      
      But there is currently no way to identify attach_type by section name
      and it leads to messy code in user space that reinvents guessing logic
      every time it has to identify attach type to use with BPF_PROG_ATTACH.
      
      The patch introduces libbpf_attach_type_by_name that guesses attach type
      by section name if a program can be attached.
      
      The difference between expected_attach_type provided by
      libbpf_prog_type_by_name and attach_type provided by
      libbpf_attach_type_by_name is the former is used at BPF_PROG_LOAD time
      and can be zero if a program of prog_type X has only one corresponding
      attach type Y whether the latter provides specific attach type to use
      with BPF_PROG_ATTACH.
      
      No new section names were added to section_names array. Only existing
      ones were reorganized and attach_type was added where appropriate.
      Signed-off-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      956b620f
  9. 07 9月, 2018 1 次提交
    • Y
      tools/bpf: add more netlink functionalities in lib/bpf · 36f1678d
      Yonghong Song 提交于
      This patch added a few netlink attribute parsing functions
      and the netlink API functions to query networking links, tc classes,
      tc qdiscs and tc filters. For example, the following API is
      to get networking links:
        int nl_get_link(int sock, unsigned int nl_pid,
                        dump_nlmsg_t dump_link_nlmsg,
                        void *cookie);
      
      Note that when the API is called, the user also provided a
      callback function with the following signature:
        int (*dump_nlmsg_t)(void *cookie, void *msg, struct nlattr **tb);
      
      The "cookie" is the parameter the user passed to the API and will
      be available for the callback function.
      The "msg" is the information about the result, e.g., ifinfomsg or
      tcmsg. The "tb" is the parsed netlink attributes.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      36f1678d
  10. 27 7月, 2018 1 次提交
  11. 25 7月, 2018 1 次提交
  12. 12 7月, 2018 4 次提交
  13. 01 7月, 2018 1 次提交
  14. 23 5月, 2018 1 次提交
  15. 17 5月, 2018 1 次提交
  16. 11 5月, 2018 2 次提交
  17. 25 4月, 2018 1 次提交
    • J
      bpf: sockmap, add selftests · 16962b24
      John Fastabend 提交于
      This adds a new test program test_sockmap which is the old sample
      sockmap program. By moving the sample program here we can now run it
      as part of the self tests suite. To support this a populate_progs()
      routine is added to load programs and maps which was previously done
      with load_bpf_file(). This is needed because self test libs do not
      provide a similar routine. Also we now use the cgroup_helpers
      routines to manage cgroup use instead of manually creating one and
      supplying it to the CLI.
      
      Notice we keep the CLI around though because it is useful for dbg
      and specialized testing.
      
      To run use ./test_sockmap and the result should be,
      
      Summary 660 PASSED, 0 SKIPPED, 0 FAILED
      Signed-off-by: NJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      16962b24
  18. 20 4月, 2018 1 次提交
  19. 18 4月, 2018 1 次提交
  20. 31 3月, 2018 1 次提交
    • A
      libbpf: Support expected_attach_type at prog load · d7be143b
      Andrey Ignatov 提交于
      Support setting `expected_attach_type` at prog load time in both
      `bpf/bpf.h` and `bpf/libbpf.h`.
      
      Since both headers already have API to load programs, new functions are
      added not to break backward compatibility for existing ones:
      * `bpf_load_program_xattr()` is added to `bpf/bpf.h`;
      * `bpf_prog_load_xattr()` is added to `bpf/libbpf.h`.
      
      Both new functions accept structures, `struct bpf_load_program_attr` and
      `struct bpf_prog_load_attr` correspondingly, where new fields can be
      added in the future w/o changing the API.
      
      Standard `_xattr` suffix is used to name the new API functions.
      
      Since `bpf_load_program_name()` is not used as heavily as
      `bpf_load_program()`, it was removed in favor of more generic
      `bpf_load_program_xattr()`.
      Signed-off-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      d7be143b
  21. 03 2月, 2018 2 次提交
  22. 06 10月, 2017 1 次提交
  23. 17 8月, 2017 1 次提交
  24. 02 4月, 2017 1 次提交
  25. 01 2月, 2017 3 次提交
    • J
      tools lib bpf: Add bpf_object__pin() · d5148d85
      Joe Stringer 提交于
      Add a new API to pin a BPF object to the filesystem. The user can
      specify the path within a BPF filesystem to pin the object.
      Programs will be pinned under a subdirectory named the same as the
      program, with each instance appearing as a numbered file under that
      directory, and maps will be pinned under the path using the name of
      the map as the file basename.
      
      For example, with the directory '/sys/fs/bpf/foo' and a BPF object which
      contains two instances of a program named 'bar', and a map named 'baz':
      
      /sys/fs/bpf/foo/bar/0
      /sys/fs/bpf/foo/bar/1
      /sys/fs/bpf/foo/baz
      Signed-off-by: NJoe Stringer <joe@ovn.org>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20170126212001.14103-4-joe@ovn.org
      [ Check snprintf >= for truncation, as snprintf(bf, size, ...) == size also means truncation ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d5148d85
    • J
      tools lib bpf: Add bpf_map__pin() · b6989f35
      Joe Stringer 提交于
      Add a new API to pin a BPF map to the filesystem. The user can specify
      the path full path within a BPF filesystem to pin the map.
      Signed-off-by: NJoe Stringer <joe@ovn.org>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20170126212001.14103-3-joe@ovn.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b6989f35
    • J
      tools lib bpf: Add BPF program pinning APIs · f367540c
      Joe Stringer 提交于
      Add new APIs to pin a BPF program (or specific instances) to the
      filesystem.  The user can specify the path full path within a BPF
      filesystem to pin the program.
      
      bpf_program__pin_instance(prog, path, n) will pin the nth instance of
      'prog' to the specified path.
      
      bpf_program__pin(prog, path) will create the directory 'path' (if it
      does not exist) and pin each instance within that directory. For
      instance, path/0, path/1, path/2.
      
      Committer notes:
      
      - Add missing headers for mkdir()
      
      - Check strdup() for failure
      
      - Check snprintf >= size, not >, as == also means truncated, see 'man
        snprintf', return value.
      
      - Conditionally define BPF_FS_MAGIC, as it isn't in magic.h in older
        systems and we're not yet having a tools/include/uapi/linux/magic.h
        copy.
      
      - Do not include linux/magic.h, not present in older distros.
      Signed-off-by: NJoe Stringer <joe@ovn.org>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: netdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/20170126212001.14103-2-joe@ovn.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f367540c
  26. 26 1月, 2017 2 次提交
  27. 29 11月, 2016 2 次提交
  28. 14 7月, 2016 1 次提交