1. 02 4月, 2021 5 次提交
  2. 01 4月, 2021 1 次提交
  3. 31 3月, 2021 21 次提交
  4. 30 3月, 2021 5 次提交
  5. 29 3月, 2021 2 次提交
  6. 27 3月, 2021 6 次提交
    • A
      Merge branch 'bpf: Support calling kernel function' · fddbf4b6
      Alexei Starovoitov 提交于
      Martin KaFai says:
      
      ====================
      
      This series adds support to allow bpf program calling kernel function.
      
      The use case included in this set is to allow bpf-tcp-cc to directly
      call some tcp-cc helper functions (e.g. "tcp_cong_avoid_ai()").  Those
      functions have already been used by some kernel tcp-cc implementations.
      
      This set will also allow the bpf-tcp-cc program to directly call the
      kernel tcp-cc implementation,  For example, a bpf_dctcp may only want to
      implement its own dctcp_cwnd_event() and reuse other dctcp_*() directly
      from the kernel tcp_dctcp.c instead of reimplementing (or
      copy-and-pasting) them.
      
      The tcp-cc kernel functions mentioned above will be white listed
      for the struct_ops bpf-tcp-cc programs to use in a later patch.
      The white listed functions are not bounded to a fixed ABI contract.
      Those functions have already been used by the existing kernel tcp-cc.
      If any of them has changed, both in-tree and out-of-tree kernel tcp-cc
      implementations have to be changed.  The same goes for the struct_ops
      bpf-tcp-cc programs which have to be adjusted accordingly.
      
      Please see individual patch for details.
      
      v2:
      - Patch 2 in v1 is removed.  No need to support extern func in kernel.
        Changed libbpf to adjust the .ksyms datasec for extern func
        in patch 11. (Andrii)
      - Name change: btf_check_func_arg_match() and btf_check_subprog_arg_match()
        in patch 2. (Andrii)
      - Always set unreliable on any error in patch 2 since it does not
        matter. (Andrii)
      - s/kern_func/kfunc/ and s/descriptor/desc/ in this set. (Andrii)
      - Remove some unnecessary changes in disasm.h and disasm.c
        in patch 3.  In particular, no need to change the function
        signature in bpf_insn_revmap_call_t.  Also, removed the changes
        in print_bpf_insn().
      - Fixed an issue in check_kfunc_call() when the calling kernel function
        returns a pointer in patch 3.  Added a selftest.
      - Adjusted the verifier selftests due to the changes in the verifier log
        in patch 3.
      - Fixed a comparison issue in kfunc_desc_cmp_by_imm() in patch 3. (Andrii)
      - Name change: is_ldimm64_insn(),
        new helper: is_call_insn() in patch 10 (Andrii)
      - Move btf_func_linkage() from btf.h to libbpf.c in patch 11. (Andrii)
      - Fixed the linker error when CONFIG_BPF_SYSCALL is not defined.
        Moved the check_kfunc_call from filter.c to test_run.c in patch 14.
        (kernel test robot)
      ====================
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      fddbf4b6
    • M
      bpf: selftests: Add kfunc_call test · 7bd1590d
      Martin KaFai Lau 提交于
      This patch adds a few kernel function bpf_kfunc_call_test*() for the
      selftest's test_run purpose.  They will be allowed for tc_cls prog.
      
      The selftest calling the kernel function bpf_kfunc_call_test*()
      is also added in this patch.
      Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015252.1551395-1-kafai@fb.com
      7bd1590d
    • M
      bpf: selftests: Bpf_cubic and bpf_dctcp calling kernel functions · 78e60bbb
      Martin KaFai Lau 提交于
      This patch removes the bpf implementation of tcp_slow_start()
      and tcp_cong_avoid_ai().  Instead, it directly uses the kernel
      implementation.
      
      It also replaces the bpf_cubic_undo_cwnd implementation by directly
      calling tcp_reno_undo_cwnd().  bpf_dctcp also directly calls
      tcp_reno_cong_avoid() instead.
      Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015246.1551062-1-kafai@fb.com
      78e60bbb
    • M
      bpf: selftests: Rename bictcp to bpf_cubic · 39cd9e0f
      Martin KaFai Lau 提交于
      As a similar chanage in the kernel, this patch gives the proper
      name to the bpf cubic.
      Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015240.1550074-1-kafai@fb.com
      39cd9e0f
    • M
      libbpf: Support extern kernel function · 5bd022ec
      Martin KaFai Lau 提交于
      This patch is to make libbpf able to handle the following extern
      kernel function declaration and do the needed relocations before
      loading the bpf program to the kernel.
      
      extern int foo(struct sock *) __attribute__((section(".ksyms")))
      
      In the collect extern phase, needed changes is made to
      bpf_object__collect_externs() and find_extern_btf_id() to collect
      extern function in ".ksyms" section.  The func in the BTF datasec also
      needs to be replaced by an int var.  The idea is similar to the existing
      handling in extern var.  In case the BTF may not have a var, a dummy ksym
      var is added at the beginning of bpf_object__collect_externs()
      if there is func under ksyms datasec.  It will also change the
      func linkage from extern to global which the kernel can support.
      It also assigns a param name if it does not have one.
      
      In the collect relo phase, it will record the kernel function
      call as RELO_EXTERN_FUNC.
      
      bpf_object__resolve_ksym_func_btf_id() is added to find the func
      btf_id of the running kernel.
      
      During actual relocation, it will patch the BPF_CALL instruction with
      src_reg = BPF_PSEUDO_FUNC_CALL and insn->imm set to the running
      kernel func's btf_id.
      
      The required LLVM patch: https://reviews.llvm.org/D93563Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015234.1548923-1-kafai@fb.com
      5bd022ec
    • M
      libbpf: Record extern sym relocation first · aa0b8d43
      Martin KaFai Lau 提交于
      This patch records the extern sym relocs first before recording
      subprog relocs.  The later patch will have relocs for extern
      kernel function call which is also using BPF_JMP | BPF_CALL.
      It will be easier to handle the extern symbols first in
      the later patch.
      
      is_call_insn() helper is added.  The existing is_ldimm64() helper
      is renamed to is_ldimm64_insn() for consistency.
      Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015227.1548623-1-kafai@fb.com
      aa0b8d43