1. 21 3月, 2022 2 次提交
  2. 18 3月, 2022 6 次提交
  3. 10 3月, 2022 1 次提交
  4. 08 3月, 2022 2 次提交
  5. 06 3月, 2022 2 次提交
    • A
      libbpf: Support custom SEC() handlers · 697f104d
      Andrii Nakryiko 提交于
      Allow registering and unregistering custom handlers for BPF program.
      This allows user applications and libraries to plug into libbpf's
      declarative SEC() definition handling logic. This allows to offload
      complex and intricate custom logic into external libraries, but still
      provide a great user experience.
      
      One such example is USDT handling library, which has a lot of code and
      complexity which doesn't make sense to put into libbpf directly, but it
      would be really great for users to be able to specify BPF programs with
      something like SEC("usdt/<path-to-binary>:<usdt_provider>:<usdt_name>")
      and have correct BPF program type set (BPF_PROGRAM_TYPE_KPROBE, as it is
      uprobe) and even support BPF skeleton's auto-attach logic.
      
      In some cases, it might be even good idea to override libbpf's default
      handling, like for SEC("perf_event") programs. With custom library, it's
      possible to extend logic to support specifying perf event specification
      right there in SEC() definition without burdening libbpf with lots of
      custom logic or extra library dependecies (e.g., libpfm4). With current
      patch it's possible to override libbpf's SEC("perf_event") handling and
      specify a completely custom ones.
      
      Further, it's possible to specify a generic fallback handling for any
      SEC() that doesn't match any other custom or standard libbpf handlers.
      This allows to accommodate whatever legacy use cases there might be, if
      necessary.
      
      See doc comments for libbpf_register_prog_handler() and
      libbpf_unregister_prog_handler() for detailed semantics.
      
      This patch also bumps libbpf development version to v0.8 and adds new
      APIs there.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Reviewed-by: NAlan Maguire <alan.maguire@oracle.com>
      Link: https://lore.kernel.org/bpf/20220305010129.1549719-3-andrii@kernel.org
      697f104d
    • A
      libbpf: Allow BPF program auto-attach handlers to bail out · 4fa5bcfe
      Andrii Nakryiko 提交于
      Allow some BPF program types to support auto-attach only in subste of
      cases. Currently, if some BPF program type specifies attach callback, it
      is assumed that during skeleton attach operation all such programs
      either successfully attach or entire skeleton attachment fails. If some
      program doesn't support auto-attachment from skeleton, such BPF program
      types shouldn't have attach callback specified.
      
      This is limiting for cases when, depending on how full the SEC("")
      definition is, there could either be enough details to support
      auto-attach or there might not be and user has to use some specific API
      to provide more details at runtime.
      
      One specific example of such desired behavior might be SEC("uprobe"). If
      it's specified as just uprobe auto-attach isn't possible. But if it's
      SEC("uprobe/<some_binary>:<some_func>") then there are enough details to
      support auto-attach. Note that there is a somewhat subtle difference
      between auto-attach behavior of BPF skeleton and using "generic"
      bpf_program__attach(prog) (which uses the same attach handlers under the
      cover). Skeleton allow some programs within bpf_object to not have
      auto-attach implemented and doesn't treat that as an error. Instead such
      BPF programs are just skipped during skeleton's (optional) attach step.
      bpf_program__attach(), on the other hand, is called when user *expects*
      auto-attach to work, so if specified program doesn't implement or
      doesn't support auto-attach functionality, that will be treated as an
      error.
      
      Another improvement to the way libbpf is handling SEC()s would be to not
      require providing dummy kernel function name for kprobe. Currently,
      SEC("kprobe/whatever") is necessary even if actual kernel function is
      determined by user at runtime and bpf_program__attach_kprobe() is used
      to specify it. With changes in this patch, it's possible to support both
      SEC("kprobe") and SEC("kprobe/<actual_kernel_function"), while only in
      the latter case auto-attach will be performed. In the former one, such
      kprobe will be skipped during skeleton attach operation.
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Tested-by: NAlan Maguire <alan.maguire@oracle.com>
      Reviewed-by: NAlan Maguire <alan.maguire@oracle.com>
      Link: https://lore.kernel.org/bpf/20220305010129.1549719-2-andrii@kernel.org
      4fa5bcfe
  6. 03 3月, 2022 1 次提交
  7. 01 3月, 2022 2 次提交
  8. 24 2月, 2022 1 次提交
  9. 23 2月, 2022 1 次提交
  10. 17 2月, 2022 3 次提交
  11. 12 2月, 2022 2 次提交
  12. 11 2月, 2022 1 次提交
  13. 09 2月, 2022 10 次提交
  14. 08 2月, 2022 1 次提交
  15. 05 2月, 2022 1 次提交
    • Y
      libbpf: Fix build issue with llvm-readelf · 0908a66a
      Yonghong Song 提交于
      There are cases where clang compiler is packaged in a way
      readelf is a symbolic link to llvm-readelf. In such cases,
      llvm-readelf will be used instead of default binutils readelf,
      and the following error will appear during libbpf build:
      
        Warning: Num of global symbols in
         /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/sharedobjs/libbpf-in.o (367)
         does NOT match with num of versioned symbols in
         /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/libbpf.so libbpf.map (383).
         Please make sure all LIBBPF_API symbols are versioned in libbpf.map.
        --- /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/libbpf_global_syms.tmp ...
        +++ /home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/build/libbpf/libbpf_versioned_syms.tmp ...
        @@ -324,6 +324,22 @@
         btf__str_by_offset
         btf__type_by_id
         btf__type_cnt
        +LIBBPF_0.0.1
        +LIBBPF_0.0.2
        +LIBBPF_0.0.3
        +LIBBPF_0.0.4
        +LIBBPF_0.0.5
        +LIBBPF_0.0.6
        +LIBBPF_0.0.7
        +LIBBPF_0.0.8
        +LIBBPF_0.0.9
        +LIBBPF_0.1.0
        +LIBBPF_0.2.0
        +LIBBPF_0.3.0
        +LIBBPF_0.4.0
        +LIBBPF_0.5.0
        +LIBBPF_0.6.0
        +LIBBPF_0.7.0
         libbpf_attach_type_by_name
         libbpf_find_kernel_btf
         libbpf_find_vmlinux_btf_id
        make[2]: *** [Makefile:184: check_abi] Error 1
        make[1]: *** [Makefile:140: all] Error 2
      
      The above failure is due to different printouts for some ABS
      versioned symbols. For example, with the same libbpf.so,
        $ /bin/readelf --dyn-syms --wide tools/lib/bpf/libbpf.so | grep "LIBBPF" | grep ABS
           134: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.5.0
           202: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LIBBPF_0.6.0
           ...
        $ /opt/llvm/bin/readelf --dyn-syms --wide tools/lib/bpf/libbpf.so | grep "LIBBPF" | grep ABS
           134: 0000000000000000     0 OBJECT  GLOBAL DEFAULT   ABS LIBBPF_0.5.0@@LIBBPF_0.5.0
           202: 0000000000000000     0 OBJECT  GLOBAL DEFAULT   ABS LIBBPF_0.6.0@@LIBBPF_0.6.0
           ...
      The binutils readelf doesn't print out the symbol LIBBPF_* version and llvm-readelf does.
      Such a difference caused libbpf build failure with llvm-readelf.
      
      The proposed fix filters out all ABS symbols as they are not part of the comparison.
      This works for both binutils readelf and llvm-readelf.
      Reported-by: NDelyan Kratunov <delyank@fb.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220204214355.502108-1-yhs@fb.com
      0908a66a
  16. 04 2月, 2022 2 次提交
  17. 03 2月, 2022 2 次提交