Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bpftool sync 2024-06-27 #150

Merged
merged 10 commits into from
Jun 27, 2024

Commits on Jun 2, 2024

  1. bpftool: Fix typo in MAX_NUM_METRICS macro name

    Correct typo in bpftool profiler and change all instances of 'MATRICS' to
    'METRICS' in the profiler.bpf.c file.
    
    Signed-off-by: Swan Beaujard <beaujardswan@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Quentin Monnet <qmo@kernel.org>
    Link: https://lore.kernel.org/bpf/20240602225812.81171-1-beaujardswan@gmail.com
    Swan Beaujard authored and qmonnet committed Jun 2, 2024
    Configuration menu
    Copy the full SHA
    0079167 View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2024

  1. bpftool: Use BTF field iterator in btfgen

    Switch bpftool's code which is using libbpf-internal
    btf_type_visit_type_ids() helper to new btf_field_iter functionality.
    
    This makes bpftool code simpler, but also unblocks removing libbpf's
    btf_type_visit_type_ids() helper completely.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Tested-by: Alan Maguire <alan.maguire@oracle.com>
    Reviewed-by: Quentin Monnet <qmo@kernel.org>
    Acked-by: Eduard Zingerman <eddyz87@gmail.com>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Link: https://lore.kernel.org/bpf/20240605001629.4061937-5-andrii@kernel.org
    anakryiko authored and qmonnet committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    5e7c22d View commit details
    Browse the repository at this point in the history
  2. libbpf: Auto-attach struct_ops BPF maps in BPF skeleton

    Similarly to `bpf_program`, support `bpf_map` automatic attachment in
    `bpf_object__attach_skeleton`. Currently only struct_ops maps could be
    attached.
    
    On bpftool side, code-generate links in skeleton struct for struct_ops maps.
    Similarly to `bpf_program_skeleton`, set links in `bpf_map_skeleton`.
    
    On libbpf side, extend `bpf_map` with new `autoattach` field to support
    enabling or disabling autoattach functionality, introducing
    getter/setter for this field.
    
    `bpf_object__(attach|detach)_skeleton` is extended with
    attaching/detaching struct_ops maps logic.
    
    Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20240605175135.117127-1-yatsenko@meta.com
    mykyta5 authored and qmonnet committed Jun 5, 2024
    Configuration menu
    Copy the full SHA
    edfd848 View commit details
    Browse the repository at this point in the history

Commits on Jun 6, 2024

  1. bpf: Add CHECKSUM_COMPLETE to bpf test progs

    Add special flag to validate that TC BPF program properly updates
    checksum information in skb.
    
    Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Jakub Kicinski <kuba@kernel.org>
    Acked-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20240606145851.229116-1-vadfed@meta.com
    vvfedorenko authored and qmonnet committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    bd06c36 View commit details
    Browse the repository at this point in the history

Commits on Jun 7, 2024

  1. bpftool: Query only cgroup-related attach types

    When CONFIG_NETKIT=y,
    bpftool-cgroup shows error even if the cgroup's path is correct:
    
    $ bpftool cgroup tree /sys/fs/cgroup
    CgroupPath
    ID       AttachType      AttachFlags     Name
    Error: can't query bpf programs attached to /sys/fs/cgroup: No such device or address
    
    >From strace and kernel tracing, I found netkit returned ENXIO and this command failed.
    I think this AttachType(BPF_NETKIT_PRIMARY) is not relevant to cgroup.
    
    bpftool-cgroup should query just only cgroup-related attach types.
    
    v2->v3:
      - removed an unnecessary check
    
    v1->v2:
      - used an array of cgroup attach types
    
    Signed-off-by: Kenta Tada <tadakentaso@gmail.com>
    Reviewed-by: Quentin Monnet <qmo@kernel.org>
    Link: https://lore.kernel.org/r/20240607111704.6716-1-tadakentaso@gmail.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    KentaTada authored and qmonnet committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    8c593e1 View commit details
    Browse the repository at this point in the history

Commits on Jun 12, 2024

  1. bpftool: Support dumping kfunc prototypes from BTF

    This patch enables dumping kfunc prototypes from bpftool. This is useful
    b/c with this patch, end users will no longer have to manually define
    kfunc prototypes. For the kernel tree, this also means we can optionally
    drop kfunc prototypes from:
    
            tools/testing/selftests/bpf/bpf_kfuncs.h
            tools/testing/selftests/bpf/bpf_experimental.h
    
    Example usage:
    
            $ make PAHOLE=/home/dxu/dev/pahole/build/pahole -j30 vmlinux
    
            $ ./tools/bpf/bpftool/bpftool btf dump file ./vmlinux format c | rg "__ksym;" | head -3
            extern void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) __weak __ksym;
            extern void cgroup_rstat_flush(struct cgroup *cgrp) __weak __ksym;
            extern struct bpf_key *bpf_lookup_user_key(u32 serial, u64 flags) __weak __ksym;
    
    Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
    Link: https://lore.kernel.org/r/bf6c08f9263c4bd9d10a717de95199d766a13f61.1718207789.git.dxu@dxuuu.xyz
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    danobi authored and qmonnet committed Jun 12, 2024
    Configuration menu
    Copy the full SHA
    4b6c669 View commit details
    Browse the repository at this point in the history

Commits on Jun 18, 2024

  1. bpftool: Allow compile-time checks of BPF map auto-attach support in …

    …skeleton
    
    New versions of bpftool now emit additional link placeholders for BPF
    maps (struct_ops maps are the only maps right now that support
    attachment), and set up BPF skeleton in such a way that libbpf will
    auto-attach BPF maps automatically, assumming libbpf is recent enough
    (v1.5+). Old libbpf will do nothing with those links and won't attempt
    to auto-attach maps. This allows user code to handle both pre-v1.5 and
    v1.5+ versions of libbpf at runtime, if necessary.
    
    But if users don't have (or don't want to) control bpftool version that
    generates skeleton, then they can't just assume that skeleton will have
    link placeholders. To make this detection possible and easy, let's add
    the following to generated skeleton header file:
    
      #define BPF_SKEL_SUPPORTS_MAP_AUTO_ATTACH 1
    
    This can be used during compilation time to guard code that accesses
    skel->links.<map> slots.
    
    Note, if auto-attachment is undesirable, libbpf allows to disable this
    through bpf_map__set_autoattach(map, false). This is necessary only on
    libbpf v1.5+, older libbpf doesn't support map auto-attach anyways.
    
    Libbpf version can be detected at compilation time using
    LIBBPF_MAJOR_VERSION and LIBBPF_MINOR_VERSION macros, or at runtime with
    libbpf_major_version() and libbpf_minor_version() APIs.
    
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Quentin Monnet <qmo@kernel.org>
    Link: https://lore.kernel.org/bpf/20240618183832.2535876-1-andrii@kernel.org
    anakryiko authored and qmonnet committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    c2c2d09 View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2024

  1. sync: Update libbpf submodule

    Pull latest libbpf from mirror.
    Libbpf version: 1.5.0
    Libbpf commit:  c1a6c770c46c6e78ad6755bf596c23a4e6f6b216
    
    Signed-off-by: Quentin Monnet <qmo@kernel.org>
    qmonnet committed Jun 27, 2024
    Configuration menu
    Copy the full SHA
    a3d24c5 View commit details
    Browse the repository at this point in the history
  2. sync: update .mailmap

    Update .mailmap based on bpftool's list of contributors and on the
    latest .mailmap version in the upstream repository.
    
    Signed-off-by: Quentin Monnet <qmo@kernel.org>
    qmonnet committed Jun 27, 2024
    Configuration menu
    Copy the full SHA
    8f00371 View commit details
    Browse the repository at this point in the history
  3. sync: Pull latest bpftool changes from kernel

    Syncing latest bpftool commits from kernel repository.
    Baseline bpf-next commit:   531876c80004ecff7bfdbd8ba6c6b48835ef5e22
    Checkpoint bpf-next commit: a12978712d9001b060bcc10eaae42ad5102abe2b
    Baseline bpf commit:        62da3acd28955e7299babebdfcb14243b789e773
    Checkpoint bpf commit:      b1c4b4d45263241ec6c2405a8df8265d4b58e707
    
    Andrii Nakryiko (2):
      bpftool: Use BTF field iterator in btfgen
      bpftool: Allow compile-time checks of BPF map auto-attach support in
        skeleton
    
    Daniel Xu (1):
      bpftool: Support dumping kfunc prototypes from BTF
    
    Kenta Tada (1):
      bpftool: Query only cgroup-related attach types
    
    Mykyta Yatsenko (1):
      libbpf: Auto-attach struct_ops BPF maps in BPF skeleton
    
    Swan Beaujard (1):
      bpftool: Fix typo in MAX_NUM_METRICS macro name
    
    Vadim Fedorenko (1):
      bpf: Add CHECKSUM_COMPLETE to bpf test progs
    
     include/uapi/linux/bpf.h    |  2 ++
     src/btf.c                   | 55 +++++++++++++++++++++++++++++++++++++
     src/cgroup.c                | 40 ++++++++++++++++++++++++---
     src/gen.c                   | 54 ++++++++++++++++++++++++++----------
     src/skeleton/profiler.bpf.c | 14 +++++-----
     5 files changed, 140 insertions(+), 25 deletions(-)
    
    Signed-off-by: Quentin Monnet <qmo@kernel.org>
    qmonnet committed Jun 27, 2024
    Configuration menu
    Copy the full SHA
    4ccf8a2 View commit details
    Browse the repository at this point in the history