1. 01 Apr, 2021 6 commits
  2. 31 Mar, 2021 2 commits
  3. 30 Mar, 2021 25 commits
  4. 29 Mar, 2021 1 commit
  5. 28 Mar, 2021 1 commit
  6. 27 Mar, 2021 5 commits
    • Alexei Starovoitov's avatar
      Merge branch 'bpf: Support calling kernel function' · fddbf4b6
      Alexei Starovoitov authored
      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: default avatarAlexei Starovoitov <ast@kernel.org>
      fddbf4b6
    • Martin KaFai Lau's avatar
      bpf: selftests: Add kfunc_call test · 7bd1590d
      Martin KaFai Lau authored
      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: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015252.1551395-1-kafai@fb.com
      7bd1590d
    • Martin KaFai Lau's avatar
      bpf: selftests: Bpf_cubic and bpf_dctcp calling kernel functions · 78e60bbb
      Martin KaFai Lau authored
      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: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015246.1551062-1-kafai@fb.com
      78e60bbb
    • Martin KaFai Lau's avatar
      bpf: selftests: Rename bictcp to bpf_cubic · 39cd9e0f
      Martin KaFai Lau authored
      As a similar chanage in the kernel, this patch gives the proper
      name to the bpf cubic.
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015240.1550074-1-kafai@fb.com
      39cd9e0f
    • Martin KaFai Lau's avatar
      libbpf: Support extern kernel function · 5bd022ec
      Martin KaFai Lau authored
      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: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20210325015234.1548923-1-kafai@fb.com
      5bd022ec