1. 03 6月, 2022 3 次提交
  2. 24 5月, 2022 1 次提交
  3. 20 5月, 2022 3 次提交
  4. 17 5月, 2022 1 次提交
  5. 13 5月, 2022 1 次提交
    • A
      libbpf: Add safer high-level wrappers for map operations · 737d0646
      Andrii Nakryiko 提交于
      Add high-level API wrappers for most common and typical BPF map
      operations that works directly on instances of struct bpf_map * (so
      you don't have to call bpf_map__fd()) and validate key/value size
      expectations.
      
      These helpers require users to specify key (and value, where
      appropriate) sizes when performing lookup/update/delete/etc. This forces
      user to actually think and validate (for themselves) those. This is
      a good thing as user is expected by kernel to implicitly provide correct
      key/value buffer sizes and kernel will just read/write necessary amount
      of data. If it so happens that user doesn't set up buffers correctly
      (which bit people for per-CPU maps especially) kernel either randomly
      overwrites stack data or return -EFAULT, depending on user's luck and
      circumstances. These high-level APIs are meant to prevent such
      unpleasant and hard to debug bugs.
      
      This patch also adds bpf_map_delete_elem_flags() low-level API and
      requires passing flags to bpf_map__delete_elem() API for consistency
      across all similar APIs, even though currently kernel doesn't expect
      any extra flags for BPF_MAP_DELETE_ELEM operation.
      
      List of map operations that get these high-level APIs:
      
        - bpf_map_lookup_elem;
        - bpf_map_update_elem;
        - bpf_map_delete_elem;
        - bpf_map_lookup_and_delete_elem;
        - bpf_map_get_next_key.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20220512220713.2617964-1-andrii@kernel.org
      737d0646
  6. 11 5月, 2022 3 次提交
  7. 09 5月, 2022 5 次提交
  8. 29 4月, 2022 5 次提交
  9. 27 4月, 2022 8 次提交
  10. 26 4月, 2022 1 次提交
  11. 25 4月, 2022 1 次提交
  12. 23 4月, 2022 1 次提交
    • A
      libbpf: Teach bpf_link_create() to fallback to bpf_raw_tracepoint_open() · 8462e0b4
      Andrii Nakryiko 提交于
      Teach bpf_link_create() to fallback to bpf_raw_tracepoint_open() on
      older kernels for programs that are attachable through
      BPF_RAW_TRACEPOINT_OPEN. This makes bpf_link_create() more unified and
      convenient interface for creating bpf_link-based attachments.
      
      With this approach end users can just use bpf_link_create() for
      tp_btf/fentry/fexit/fmod_ret/lsm program attachments without needing to
      care about kernel support, as libbpf will handle this transparently. On
      the other hand, as newer features (like BPF cookie) are added to
      LINK_CREATE interface, they will be readily usable though the same
      bpf_link_create() API without any major refactoring from user's
      standpoint.
      
      bpf_program__attach_btf_id() is now using bpf_link_create() internally
      as well and will take advantaged of this unified interface when BPF
      cookie is added for fentry/fexit.
      
      Doing proactive feature detection of LINK_CREATE support for
      fentry/tp_btf/etc is quite involved. It requires parsing vmlinux BTF,
      determining some stable and guaranteed to be in all kernels versions
      target BTF type (either raw tracepoint or fentry target function),
      actually attaching this program and thus potentially affecting the
      performance of the host kernel briefly, etc. So instead we are taking
      much simpler "lazy" approach of falling back to
      bpf_raw_tracepoint_open() call only if initial LINK_CREATE command
      fails. For modern kernels this will mean zero added overhead, while
      older kernels will incur minimal overhead with a single fast-failing
      LINK_CREATE call.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: NKui-Feng Lee <kuifeng@fb.com>
      Link: https://lore.kernel.org/bpf/20220421033945.3602803-3-andrii@kernel.org
      8462e0b4
  13. 22 4月, 2022 1 次提交
  14. 21 4月, 2022 3 次提交
  15. 20 4月, 2022 3 次提交