Skip to content
Permalink
Jakub-Kicinski…
Switch branches/tags

Commits on Dec 15, 2021

  1. bpf: remove the cgroup -> bpf header dependecy

    Remove the dependency from cgroup-defs.h to bpf-cgroup.h and bpf.h.
    This reduces the incremental build size of x86 allmodconfig after
    bpf.h was touched from ~17k objects rebuilt to ~5k objects.
    bpf.h is 2.2kLoC and is modified relatively often.
    
    We need a new header with just the definition of struct cgroup_bpf
    and enum cgroup_bpf_attach_type, this is akin to cgroup-defs.h.
    
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Jakub Kicinski authored and intel-lab-lkp committed Dec 15, 2021
  2. add missing bpf-cgroup.h includes

    We're about to break the cgroup-defs.h -> bpf-cgroup.h dependency,
    make sure those who actually need more than the definition of
    struct cgroup_bpf include bpf-cgroup.h explicitly.
    
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Jakub Kicinski authored and intel-lab-lkp committed Dec 15, 2021
  3. add includes masked by cgroup -> bpf dependency

    cgroup pulls in BPF which pulls in a lot of includes.
    We're about to break that chain so fix those who were
    depending on it.
    
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Jakub Kicinski authored and intel-lab-lkp committed Dec 15, 2021
  4. libbpf: Avoid reading past ELF data section end when copying license

    Fix possible read beyond ELF "license" data section if the license
    string is not properly zero-terminated. Use the fact that libbpf_strlcpy
    never accesses the (N-1)st byte of the source string because it's
    replaced with '\0' anyways.
    
    If this happens, it's a violation of contract between libbpf and a user,
    but not handling this more robustly upsets CIFuzz, so given the fix is
    trivial, let's fix the potential issue.
    
    Fixes: 9fc205b ("libbpf: Add sane strncpy alternative and use it internally")
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211214232054.3458774-1-andrii@kernel.org
    anakryiko authored and Alexei Starovoitov committed Dec 15, 2021

Commits on Dec 14, 2021

  1. Merge branch 'Stop using bpf_object__find_program_by_title API'

    Kui-Feng Lee says:
    
    ====================
    
    bpf_object__find_program_by_title is going to be deprecated since
    v0.7.  Replace all use cases with bpf_object__find_program_by_name if
    possible, or use bpf_object__for_each_program to iterate over
    programs, matching section names.
    
    V3 fixes a broken test case, fexit_bpf2bpf, in selftests/bpf, using
    bpf_obj__for_each_program API instead.
    
    [v2] https://lore.kernel.org/bpf/20211211003608.2764928-1-kuifeng@fb.com/
    [v1] https://lore.kernel.org/bpf/20211210190855.1369060-1-kuifeng@fb.com/T/
    ====================
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    anakryiko committed Dec 14, 2021
  2. libbpf: Mark bpf_object__find_program_by_title API deprecated.

    Deprecate this API since v0.7.  All callers should move to
    bpf_object__find_program_by_name if possible, otherwise use
    bpf_object__for_each_program to find a program out from a given
    section.
    
    [0] Closes: libbpf/libbpf#292
    
    Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211214035931.1148209-5-kuifeng@fb.com
    Kui-Feng Lee authored and anakryiko committed Dec 14, 2021
  3. tools/perf: Stop using bpf_object__find_program_by_title API.

    bpf_obj__find_program_by_title() in libbpf is going to be deprecated.
    Call bpf_object_for_each_program to find a program in the section with
    a given name instead.
    
    Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211214035931.1148209-4-kuifeng@fb.com
    Kui-Feng Lee authored and anakryiko committed Dec 14, 2021
  4. samples/bpf: Stop using bpf_object__find_program_by_title API.

    bpf_object__find_program_by_title is going to be deprecated.
    Replace use cases of bpf_object__find_program_by_title in samples/bpf/
    with bpf_object__for_each_program.
    
    Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211214035931.1148209-3-kuifeng@fb.com
    Kui-Feng Lee authored and anakryiko committed Dec 14, 2021
  5. selftests/bpf: Stop using bpf_object__find_program_by_title API.

    bpf_object__find_program_by_title is going to be deprecated.  Replace
    all use cases in tools/testing/selftests/bpf with
    bpf_object__find_program_by_name or bpf_object__for_each_program.
    
    Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211214035931.1148209-2-kuifeng@fb.com
    Kui-Feng Lee authored and anakryiko committed Dec 14, 2021
  6. selftests/bpf: Remove explicit setrlimit(RLIMIT_MEMLOCK) in main self…

    …tests
    
    As libbpf now is able to automatically take care of RLIMIT_MEMLOCK
    increase (or skip it altogether on recent enough kernels), remove
    explicit setrlimit() invocations in bench, test_maps, test_verifier, and
    test_progs.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20211214195904.1785155-3-andrii@kernel.org
    anakryiko authored and borkmann committed Dec 14, 2021
  7. libbpf: Auto-bump RLIMIT_MEMLOCK if kernel needs it for BPF

    The need to increase RLIMIT_MEMLOCK to do anything useful with BPF is
    one of the first extremely frustrating gotchas that all new BPF users go
    through and in some cases have to learn it a very hard way.
    
    Luckily, starting with upstream Linux kernel version 5.11, BPF subsystem
    dropped the dependency on memlock and uses memcg-based memory accounting
    instead. Unfortunately, detecting memcg-based BPF memory accounting is
    far from trivial (as can be evidenced by this patch), so in practice
    most BPF applications still do unconditional RLIMIT_MEMLOCK increase.
    
    As we move towards libbpf 1.0, it would be good to allow users to forget
    about RLIMIT_MEMLOCK vs memcg and let libbpf do the sensible adjustment
    automatically. This patch paves the way forward in this matter. Libbpf
    will do feature detection of memcg-based accounting, and if detected,
    will do nothing. But if the kernel is too old, just like BCC, libbpf
    will automatically increase RLIMIT_MEMLOCK on behalf of user
    application ([0]).
    
    As this is technically a breaking change, during the transition period
    applications have to opt into libbpf 1.0 mode by setting
    LIBBPF_STRICT_AUTO_RLIMIT_MEMLOCK bit when calling
    libbpf_set_strict_mode().
    
    Libbpf allows to control the exact amount of set RLIMIT_MEMLOCK limit
    with libbpf_set_memlock_rlim_max() API. Passing 0 will make libbpf do
    nothing with RLIMIT_MEMLOCK. libbpf_set_memlock_rlim_max() has to be
    called before the first bpf_prog_load(), bpf_btf_load(), or
    bpf_object__load() call, otherwise it has no effect and will return
    -EBUSY.
    
      [0] Closes: libbpf/libbpf#369
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20211214195904.1785155-2-andrii@kernel.org
    anakryiko authored and borkmann committed Dec 14, 2021
  8. libbpf: Add sane strncpy alternative and use it internally

    strncpy() has a notoriously error-prone semantics which makes GCC
    complain about it a lot (and quite often completely completely falsely
    at that). Instead of pleasing GCC all the time (-Wno-stringop-truncation
    is unfortunately only supported by GCC, so it's a bit too messy to just
    enable it in Makefile), add libbpf-internal libbpf_strlcpy() helper
    which follows what FreeBSD's strlcpy() does and what most people would
    expect from strncpy(): copies up to N-1 first bytes from source string
    into destination string and ensures zero-termination afterwards.
    
    Replace all the relevant uses of strncpy/strncat/memcpy in libbpf with
    libbpf_strlcpy().
    
    This also fixes the issue reported by Emmanuel Deloget in xsk.c where
    memcpy() could access source string beyond its end.
    
    Fixes: 2f6324a (libbpf: Support shared umems between queues and devices)
    Reported-by: Emmanuel Deloget <emmanuel.deloget@eho.link>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20211211004043.2374068-1-andrii@kernel.org
    anakryiko authored and borkmann committed Dec 14, 2021
  9. libbpf: Fix potential uninit memory read

    In case of BPF_CORE_TYPE_ID_LOCAL we fill out target result explicitly.
    But targ_res itself isn't initialized in such a case, and subsequent
    call to bpf_core_patch_insn() might read uninitialized field (like
    fail_memsz_adjust in this case). So ensure that targ_res is
    zero-initialized for BPF_CORE_TYPE_ID_LOCAL case.
    
    This was reported by Coverity static analyzer.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20211214010032.3843804-1-andrii@kernel.org
    anakryiko authored and borkmann committed Dec 14, 2021

Commits on Dec 13, 2021

  1. xsk: Wipe out dead zero_copy_allocator declarations

    zero_copy_allocator has been removed back when Bjorn Topel introduced
    xsk_buff_pool. Remove references to it that were dangling in the tree.
    
    Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
    Link: https://lore.kernel.org/bpf/20211210171511.11574-1-maciej.fijalkowski@intel.com
    mfijalko authored and borkmann committed Dec 13, 2021
  2. libbpf: Add doc comments for bpf_program__(un)pin()

    This adds doc comments for the two bpf_program pinning functions,
    bpf_program__pin() and bpf_program__unpin()
    
    Signed-off-by: Grant Seltzer <grantseltzer@gmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211209232222.541733-1-grantseltzer@gmail.com
    grantseltzer authored and anakryiko committed Dec 13, 2021
  3. selftests/bpf: Fix segfault in bpf_tcp_ca

    Since commit ad9a7f9 ("libbpf: Improve logging around BPF program
    loading"), libbpf_debug_print() gets an additional prog_name parameter
    but doesn't pass it to printf(). Since the format string now expects two
    arguments, printf() may read uninitialized data and segfault. Pass
    prog_name through.
    
    Fixes: ad9a7f9 ("libbpf: Improve logging around BPF program loading")
    Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211213183058.346066-1-jean-philippe@linaro.org
    jpbrucker authored and anakryiko committed Dec 13, 2021
  4. bpf: Let bpf_warn_invalid_xdp_action() report more info

    In non trivial scenarios, the action id alone is not sufficient to
    identify the program causing the warning. Before the previous patch,
    the generated stack-trace pointed out at least the involved device
    driver.
    
    Let's additionally include the program name and id, and the relevant
    device name.
    
    If the user needs additional infos, he can fetch them via a kernel
    probe, leveraging the arguments added here.
    
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
    Link: https://lore.kernel.org/bpf/ddb96bb975cbfddb1546cf5da60e77d5100b533c.1638189075.git.pabeni@redhat.com
    Paolo Abeni authored and borkmann committed Dec 13, 2021
  5. bpf: Do not WARN in bpf_warn_invalid_xdp_action()

    The WARN_ONCE() in bpf_warn_invalid_xdp_action() can be triggered by
    any bugged program, and even attaching a correct program to a NIC
    not supporting the given action.
    
    The resulting splat, beyond polluting the logs, fouls automated tools:
    e.g. a syzkaller reproducers using an XDP program returning an
    unsupported action will never pass validation.
    
    Replace the WARN_ONCE with a less intrusive pr_warn_once().
    
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
    Link: https://lore.kernel.org/bpf/016ceec56e4817ebb2a9e35ce794d5c917df572c.1638189075.git.pabeni@redhat.com
    Paolo Abeni authored and borkmann committed Dec 13, 2021
  6. Merge branch 'bpf: Add helpers to access traced function arguments'

    Jiri Olsa says:
    
    ====================
    Add new helpers to access traced function arguments that
    came out of the trampoline batch changes [1].
    
      Get n-th argument of the traced function:
        long bpf_get_func_arg(void *ctx, u32 n, u64 *value)
    
      Get return value of the traced function:
        long bpf_get_func_ret(void *ctx, u64 *value)
    
      Get arguments count of the traced funtion:
        long bpf_get_func_arg_cnt(void *ctx)
    
    v2 changes:
      - added acks
      - updated stack diagram
      - return -EOPNOTSUPP instead of -EINVAL in bpf_get_func_ret
      - removed gpl_only for all helpers
      - added verifier fix to allow proper arguments checks,
        Andrii asked for checking also 'int *b' argument in
        bpf_modify_return_test programs and it turned out that it's currently
        not supported by verifier - we can't read argument that is int pointer,
        so I had to add verifier change to allow that + adding verifier selftest
      - checking all arguments in bpf_modify_return_test test programs
      - moved helpers proto gets in tracing_prog_func_proto with attach type check
    
    thanks,
    jirka
    
    [1] https://lore.kernel.org/bpf/20211118112455.475349-1-jolsa@kernel.org/
    ====================
    
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Alexei Starovoitov committed Dec 13, 2021
  7. selftests/bpf: Add tests for get_func_[arg|ret|arg_cnt] helpers

    Adding tests for get_func_[arg|ret|arg_cnt] helpers.
    Using these helpers in fentry/fexit/fmod_ret programs.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211208193245.172141-6-jolsa@kernel.org
    Jiri Olsa authored and Alexei Starovoitov committed Dec 13, 2021
  8. bpf: Add get_func_[arg|ret|arg_cnt] helpers

    Adding following helpers for tracing programs:
    
    Get n-th argument of the traced function:
      long bpf_get_func_arg(void *ctx, u32 n, u64 *value)
    
    Get return value of the traced function:
      long bpf_get_func_ret(void *ctx, u64 *value)
    
    Get arguments count of the traced function:
      long bpf_get_func_arg_cnt(void *ctx)
    
    The trampoline now stores number of arguments on ctx-8
    address, so it's easy to verify argument index and find
    return value argument's position.
    
    Moving function ip address on the trampoline stack behind
    the number of functions arguments, so it's now stored on
    ctx-16 address if it's needed.
    
    All helpers above are inlined by verifier.
    
    Also bit unrelated small change - using newly added function
    bpf_prog_has_trampoline in check_get_func_ip.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211208193245.172141-5-jolsa@kernel.org
    Jiri Olsa authored and Alexei Starovoitov committed Dec 13, 2021
  9. bpf, x64: Replace some stack_size usage with offset variables

    As suggested by Andrii, adding variables for registers and ip
    address offsets, which makes the code more clear, rather than
    abusing single stack_size variable for everything.
    
    Also describing the stack layout in the comment.
    
    There is no function change.
    
    Suggested-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Acked-by: John Fastabend <john.fastabend@gmail.com>
    Acked-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211208193245.172141-4-jolsa@kernel.org
    Jiri Olsa authored and Alexei Starovoitov committed Dec 13, 2021
  10. selftests/bpf: Add test to access int ptr argument in tracing program

    Adding verifier test for accessing int pointer argument in
    tracing programs.
    
    The test program loads 2nd argument of bpf_modify_return_test
    function which is int pointer and checks that verifier allows
    that.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211208193245.172141-3-jolsa@kernel.org
    Jiri Olsa authored and Alexei Starovoitov committed Dec 13, 2021
  11. bpf: Allow access to int pointer arguments in tracing programs

    Adding support to access arguments with int pointer arguments
    in tracing programs.
    
    Currently we allow tracing programs to access only pointers to
    string (char pointer), void pointers and pointers to structs.
    
    If we try to access argument which is pointer to int, verifier
    will fail to load the program with;
    
      R1 type=ctx expected=fp
      ; int BPF_PROG(fmod_ret_test, int _a, __u64 _b, int _ret)
      0: (bf) r6 = r1
      ; int BPF_PROG(fmod_ret_test, int _a, __u64 _b, int _ret)
      1: (79) r9 = *(u64 *)(r6 +8)
      func 'bpf_modify_return_test' arg1 type INT is not a struct
    
    There is no harm for the program to access int pointer argument.
    We are already doing that for string pointer, which is pointer
    to int with 1 byte size.
    
    Changing the is_string_ptr to generic integer check and renaming
    it to btf_type_is_int.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211208193245.172141-2-jolsa@kernel.org
    Jiri Olsa authored and Alexei Starovoitov committed Dec 13, 2021
  12. libbpf: Don't validate TYPE_ID relo's original imm value

    During linking, type IDs in the resulting linked BPF object file can
    change, and so ldimm64 instructions corresponding to
    BPF_CORE_TYPE_ID_TARGET and BPF_CORE_TYPE_ID_LOCAL CO-RE relos can get
    their imm value out of sync with actual CO-RE relocation information
    that's updated by BPF linker properly during linking process.
    
    We could teach BPF linker to adjust such instructions, but it feels
    a bit too much for linker to re-implement good chunk of
    bpf_core_patch_insns logic just for this. This is a redundant safety
    check for TYPE_ID relocations, as the real validation is in matching
    CO-RE specs, so if that works fine, it's very unlikely that there is
    something wrong with the instruction itself.
    
    So, instead, teach libbpf (and kernel) to ignore insn->imm for
    BPF_CORE_TYPE_ID_TARGET and BPF_CORE_TYPE_ID_LOCAL relos.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211213010706.100231-1-andrii@kernel.org
    anakryiko authored and Alexei Starovoitov committed Dec 13, 2021
  13. selftests/bpf: Remove last bpf_create_map_xattr from test_verifier

    bpf_create_map_xattr() call was reintroduced after merging bpf tree into
    bpf-next tree. Convert the last instance into bpf_map_create() call.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211212191341.2529573-1-andrii@kernel.org
    anakryiko authored and Alexei Starovoitov committed Dec 13, 2021

Commits on Dec 12, 2021

  1. bpf: Silence coverity false positive warning.

    Coverity issued the following warning:
    6685            cands = bpf_core_add_cands(cands, main_btf, 1);
    6686            if (IS_ERR(cands))
    >>>     CID 1510300:    (RETURN_LOCAL)
    >>>     Returning pointer "cands" which points to local variable "local_cand".
    6687                    return cands;
    
    It's a false positive.
    Add ERR_CAST() to silence it.
    
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Alexei Starovoitov committed Dec 12, 2021
  2. bpf: Use kmemdup() to replace kmalloc + memcpy

    Eliminate the follow coccicheck warning:
    
    ./kernel/bpf/btf.c:6537:13-20: WARNING opportunity for kmemdup.
    
    Reported-by: Abaci Robot <abaci@linux.alibaba.com>
    Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/1639030882-92383-1-git-send-email-jiapeng.chong@linux.alibaba.com
    Jiapeng Chong authored and Alexei Starovoitov committed Dec 12, 2021
  3. Merge branch 'introduce bpf_strncmp() helper'

    Hou Tao says:
    
    ====================
    
    Hi,
    
    The motivation for introducing bpf_strncmp() helper comes from
    two aspects:
    
    (1) clang doesn't always replace strncmp() automatically
    In tracing program, sometimes we need to using a home-made
    strncmp() to check whether or not the file name is expected.
    
    (2) the performance of home-made strncmp is not so good
    As shown in the benchmark in patch #4, the performance of
    bpf_strncmp() helper is 18% or 33% better than home-made strncmp()
    under x86-64 or arm64 when the compared string length is 64. When
    the string length grows to 4095, the performance win will be
    179% or 600% under x86-64 or arm64.
    
    Any comments are welcome.
    Regards,
    Tao
    
    Change Log:
    v2:
     * rebased on bpf-next
     * drop patch "selftests/bpf: factor out common helpers for benchmarks"
       (suggested by Andrii)
     * remove unnecessary inline functions and add comments for programs which
       will be rejected by verifier in patch 4 (suggested by Andrii)
     * rename variables used in will-fail programs to clarify the purposes.
    
    v1: https://lore.kernel.org/bpf/20211130142215.1237217-1-houtao1@huawei.com
     * change API to bpf_strncmp(const char *s1, u32 s1_sz, const char *s2)
     * add benchmark refactor and benchmark between bpf_strncmp() and strncmp()
    
    RFC: https://lore.kernel.org/bpf/20211106132822.1396621-1-houtao1@huawei.com/
    ====================
    
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Alexei Starovoitov committed Dec 12, 2021
  4. selftests/bpf: Add test cases for bpf_strncmp()

    Four test cases are added:
    (1) ensure the return value is expected
    (2) ensure no const string size is rejected
    (3) ensure writable target is rejected
    (4) ensure no null-terminated target is rejected
    
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211210141652.877186-5-houtao1@huawei.com
    Hou Tao authored and Alexei Starovoitov committed Dec 12, 2021
  5. selftests/bpf: Add benchmark for bpf_strncmp() helper

    Add benchmark to compare the performance between home-made strncmp()
    in bpf program and bpf_strncmp() helper. In summary, the performance
    win of bpf_strncmp() under x86-64 is greater than 18% when the compared
    string length is greater than 64, and is 179% when the length is 4095.
    Under arm64 the performance win is even bigger: 33% when the length
    is greater than 64 and 600% when the length is 4095.
    
    The following is the details:
    
    no-helper-X: use home-made strncmp() to compare X-sized string
    helper-Y: use bpf_strncmp() to compare Y-sized string
    
    Under x86-64:
    
    no-helper-1          3.504 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-1             3.347 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-8          3.357 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    helper-8             3.307 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-32         3.064 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-32            3.253 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-64         2.563 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    helper-64            3.040 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-128        1.975 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-128           2.641 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-512        0.759 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-512           1.574 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-2048       0.329 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-2048          0.602 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-4095       0.117 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-4095          0.327 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    
    Under arm64:
    
    no-helper-1          2.806 ± 0.004M/s (drops 0.000 ± 0.000M/s)
    helper-1             2.819 ± 0.002M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-8          2.797 ± 0.109M/s (drops 0.000 ± 0.000M/s)
    helper-8             2.786 ± 0.025M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-32         2.399 ± 0.011M/s (drops 0.000 ± 0.000M/s)
    helper-32            2.703 ± 0.002M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-64         2.020 ± 0.015M/s (drops 0.000 ± 0.000M/s)
    helper-64            2.702 ± 0.073M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-128        1.604 ± 0.001M/s (drops 0.000 ± 0.000M/s)
    helper-128           2.516 ± 0.002M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-512        0.699 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-512           2.106 ± 0.003M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-2048       0.215 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-2048          1.223 ± 0.003M/s (drops 0.000 ± 0.000M/s)
    
    no-helper-4095       0.112 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    helper-4095          0.796 ± 0.000M/s (drops 0.000 ± 0.000M/s)
    
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211210141652.877186-4-houtao1@huawei.com
    Hou Tao authored and Alexei Starovoitov committed Dec 12, 2021
  6. selftests/bpf: Fix checkpatch error on empty function parameter

    Fix checkpatch error: "ERROR: Bad function definition - void foo()
    should probably be void foo(void)". Most replacements are done by
    the following command:
    
      sed -i 's#\([a-z]\)()$#\1(void)#g' testing/selftests/bpf/benchs/*.c
    
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211210141652.877186-3-houtao1@huawei.com
    Hou Tao authored and Alexei Starovoitov committed Dec 12, 2021
  7. bpf: Add bpf_strncmp helper

    The helper compares two strings: one string is a null-terminated
    read-only string, and another string has const max storage size
    but doesn't need to be null-terminated. It can be used to compare
    file name in tracing or LSM program.
    
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/20211210141652.877186-2-houtao1@huawei.com
    Hou Tao authored and Alexei Starovoitov committed Dec 12, 2021
  8. libbpf: Fix gen_loader assumption on number of programs.

    libbpf's obj->nr_programs includes static and global functions. That number
    could be higher than the actual number of bpf programs going be loaded by
    gen_loader. Passing larger nr_programs to bpf_gen__init() doesn't hurt. Those
    exra stack slots will stay as zero. bpf_gen__finish() needs to check that
    actual number of progs that gen_loader saw is less than or equal to
    obj->nr_programs.
    
    Fixes: ba05fd3 ("libbpf: Perform map fd cleanup for gen_loader in case of error")
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Alexei Starovoitov committed Dec 12, 2021

Commits on Dec 11, 2021

  1. Merge branch 'add-fdma-support-on-ocelot-switch-driver'

    Clément Léger says:
    
    ====================
    Add FDMA support on ocelot switch driver
    
    This series adds support for the Frame DMA present on the VSC7514
    switch. The FDMA is able to extract and inject packets on the various
    ethernet interfaces present on the switch.
    ====================
    
    Link: https://lore.kernel.org/r/20211209154911.3152830-1-clement.leger@bootlin.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Jakub Kicinski committed Dec 11, 2021
Older