24 Mar, 2020

2 commits

  • The bpf_program__attach of libbpf(using bpf_link) is much more intuitive
    than the previous method using ioctl.

    bpf_program__attach_perf_event manages the enable of perf_event and
    attach of BPF programs to it, so there's no neeed to do this
    directly with ioctl.

    In addition, bpf_link provides consistency in the use of API because it
    allows disable (detach, destroy) for multiple events to be treated as
    one bpf_link__destroy. Also, bpf_link__destroy manages the close() of
    perf_event fd.

    This commit refactors samples that attach the bpf program to perf_event
    by using libbbpf instead of ioctl. Also the bpf_load in the samples were
    removed and migrated to use libbbpf API.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200321100424.1593964-3-danieltimlee@gmail.com

    Daniel T. Lee
     
  • To reduce the reliance of trace samples (trace*_user) on bpf_load,
    move read_trace_pipe to trace_helpers. By moving this bpf_loader helper
    elsewhere, trace functions can be easily migrated to libbbpf.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200321100424.1593964-2-danieltimlee@gmail.com

    Daniel T. Lee
     

10 Feb, 2020

1 commit

  • Pull more Kbuild updates from Masahiro Yamada:

    - fix randconfig to generate a sane .config

    - rename hostprogs-y / always to hostprogs / always-y, which are more
    natual syntax.

    - optimize scripts/kallsyms

    - fix yes2modconfig and mod2yesconfig

    - make multiple directory targets ('make foo/ bar/') work

    * tag 'kbuild-v5.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kbuild: make multiple directory targets work
    kconfig: Invalidate all symbols after changing to y or m.
    kallsyms: fix type of kallsyms_token_table[]
    scripts/kallsyms: change table to store (strcut sym_entry *)
    scripts/kallsyms: rename local variables in read_symbol()
    kbuild: rename hostprogs-y/always to hostprogs/always-y
    kbuild: fix the document to use extra-y for vmlinux.lds
    kconfig: fix broken dependency in randconfig-generated .config

    Linus Torvalds
     

06 Feb, 2020

2 commits

  • ndo_xsk_wakeup() can return -ENETDOWN and there's no particular reason
    to bail the whole application out on that case. Let's check in kick_tx()
    whether errno was set to mentioned value and basically allow application
    to further process frames.

    Fixes: 248c7f9c0e21 ("samples/bpf: convert xdpsock to use libbpf for AF_XDP access")
    Reported-by: Cameron Elliott
    Signed-off-by: Maciej Fijalkowski
    Signed-off-by: Daniel Borkmann
    Acked-by: Björn Töpel
    Link: https://lore.kernel.org/bpf/20200205045834.56795-4-maciej.fijalkowski@intel.com

    Maciej Fijalkowski
     
  • Seems that by accident there is a doubled declaration of global variable
    opt_xdp_bind_flags in xdpsock_user.c. The second one is uninitialized so
    compiler was simply ignoring it.

    To keep things clean, drop the doubled variable.

    Fixes: c543f5469822 ("samples/bpf: add unaligned chunks mode support to xdpsock")
    Signed-off-by: Maciej Fijalkowski
    Signed-off-by: Daniel Borkmann
    Acked-by: Björn Töpel
    Link: https://lore.kernel.org/bpf/20200205045834.56795-3-maciej.fijalkowski@intel.com

    Maciej Fijalkowski
     

04 Feb, 2020

1 commit

  • In old days, the "host-progs" syntax was used for specifying host
    programs. It was renamed to the current "hostprogs-y" in 2004.

    It is typically useful in scripts/Makefile because it allows Kbuild to
    selectively compile host programs based on the kernel configuration.

    This commit renames like follows:

    always -> always-y
    hostprogs-y -> hostprogs

    So, scripts/Makefile will look like this:

    always-$(CONFIG_BUILD_BIN2C) += ...
    always-$(CONFIG_KALLSYMS) += ...
    ...
    hostprogs := $(always-y) $(always-m)

    I think this makes more sense because a host program is always a host
    program, irrespective of the kernel configuration. We want to specify
    which ones to compile by CONFIG options, so always-y will be handier.

    The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
    compatibility for a while.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

21 Jan, 2020

2 commits

  • Fix all files in samples/bpf to include libbpf header files with the bpf/
    prefix, to be consistent with external users of the library. Also ensure
    that all includes of exported libbpf header files (those that are exported
    on 'make install' of the library) use bracketed includes instead of quoted.

    To make sure no new files are introduced that doesn't include the bpf/
    prefix in its include, remove tools/lib/bpf from the include path entirely,
    and use tools/lib instead.

    Fixes: 6910d7d3867a ("selftests/bpf: Ensure bpf_helper_defs.h are taken from selftests dir")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Jesper Dangaard Brouer
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/157952560911.1683545.8795966751309534150.stgit@toke.dk

    Toke Høiland-Jørgensen
     
  • The 'clean' rule in the samples/bpf Makefile tries to remove backup
    files (ending in ~). However, if no such files exist, it will instead try
    to remove the user's home directory. While the attempt is mostly harmless,
    it does lead to a somewhat scary warning like this:

    rm: cannot remove '~': Is a directory

    Fix this by using find instead of shell expansion to locate any actual
    backup files that need to be removed.

    Fixes: b62a796c109c ("samples/bpf: allow make to be run from samples/bpf/ directory")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Jesper Dangaard Brouer
    Link: https://lore.kernel.org/bpf/157952560126.1683545.7273054725976032511.stgit@toke.dk

    Toke Høiland-Jørgensen
     

17 Jan, 2020

1 commit

  • Now that we don't have a reference to a devmap when flushing the device
    bulk queue, let's change the the devmap_xmit tracepoint to remote the
    map_id and map_index fields entirely. Rearrange the fields so 'drops' and
    'sent' stay in the same position in the tracepoint struct, to make it
    possible for the xdp_monitor utility to read both the old and the new
    format.

    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/157918768613.1458396.9165902403373826572.stgit@toke.dk

    Jesper Dangaard Brouer
     

28 Dec, 2019

1 commit

  • Daniel Borkmann says:

    ====================
    pull-request: bpf-next 2019-12-27

    The following pull-request contains BPF updates for your *net-next* tree.

    We've added 127 non-merge commits during the last 17 day(s) which contain
    a total of 110 files changed, 6901 insertions(+), 2721 deletions(-).

    There are three merge conflicts. Conflicts and resolution looks as follows:

    1) Merge conflict in net/bpf/test_run.c:

    There was a tree-wide cleanup c593642c8be0 ("treewide: Use sizeof_field() macro")
    which gets in the way with b590cb5f802d ("bpf: Switch to offsetofend in
    BPF_PROG_TEST_RUN"):

    <<<<<<< HEAD
    if (!range_is_zero(__skb, offsetof(struct __sk_buff, priority) +
    sizeof_field(struct __sk_buff, priority),
    =======
    if (!range_is_zero(__skb, offsetofend(struct __sk_buff, priority),
    >>>>>>> 7c8dce4b166113743adad131b5a24c4acc12f92c

    There are a few occasions that look similar to this. Always take the chunk with
    offsetofend(). Note that there is one where the fields differ in here:

    <<<<<<< HEAD
    if (!range_is_zero(__skb, offsetof(struct __sk_buff, tstamp) +
    sizeof_field(struct __sk_buff, tstamp),
    =======
    if (!range_is_zero(__skb, offsetofend(struct __sk_buff, gso_segs),
    >>>>>>> 7c8dce4b166113743adad131b5a24c4acc12f92c

    Just take the one with offsetofend() /and/ gso_segs. Latter is correct due to
    850a88cc4096 ("bpf: Expose __sk_buff wire_len/gso_segs to BPF_PROG_TEST_RUN").

    2) Merge conflict in arch/riscv/net/bpf_jit_comp.c:

    (I'm keeping Bjorn in Cc here for a double-check in case I got it wrong.)

    <<<<<<< HEAD
    if (is_13b_check(off, insn))
    return -1;
    emit(rv_blt(tcc, RV_REG_ZERO, off >> 1), ctx);
    =======
    emit_branch(BPF_JSLT, RV_REG_T1, RV_REG_ZERO, off, ctx);
    >>>>>>> 7c8dce4b166113743adad131b5a24c4acc12f92c

    Result should look like:

    emit_branch(BPF_JSLT, tcc, RV_REG_ZERO, off, ctx);

    3) Merge conflict in arch/riscv/include/asm/pgtable.h:

    <<<<<<< HEAD
    =======
    #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
    #define VMALLOC_END (PAGE_OFFSET - 1)
    #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)

    #define BPF_JIT_REGION_SIZE (SZ_128M)
    #define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE)
    #define BPF_JIT_REGION_END (VMALLOC_END)

    /*
    * Roughly size the vmemmap space to be large enough to fit enough
    * struct pages to map half the virtual address space. Then
    * position vmemmap directly below the VMALLOC region.
    */
    #define VMEMMAP_SHIFT \
    (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
    #define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
    #define VMEMMAP_END (VMALLOC_START - 1)
    #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)

    #define vmemmap ((struct page *)VMEMMAP_START)

    >>>>>>> 7c8dce4b166113743adad131b5a24c4acc12f92c

    Only take the BPF_* defines from there and move them higher up in the
    same file. Remove the rest from the chunk. The VMALLOC_* etc defines
    got moved via 01f52e16b868 ("riscv: define vmemmap before pfn_to_page
    calls"). Result:

    [...]
    #define __S101 PAGE_READ_EXEC
    #define __S110 PAGE_SHARED_EXEC
    #define __S111 PAGE_SHARED_EXEC

    #define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
    #define VMALLOC_END (PAGE_OFFSET - 1)
    #define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)

    #define BPF_JIT_REGION_SIZE (SZ_128M)
    #define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE)
    #define BPF_JIT_REGION_END (VMALLOC_END)

    /*
    * Roughly size the vmemmap space to be large enough to fit enough
    * struct pages to map half the virtual address space. Then
    * position vmemmap directly below the VMALLOC region.
    */
    #define VMEMMAP_SHIFT \
    (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
    #define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
    #define VMEMMAP_END (VMALLOC_START - 1)
    #define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)

    [...]

    Let me know if there are any other issues.

    Anyway, the main changes are:

    1) Extend bpftool to produce a struct (aka "skeleton") tailored and specific
    to a provided BPF object file. This provides an alternative, simplified API
    compared to standard libbpf interaction. Also, add libbpf extern variable
    resolution for .kconfig section to import Kconfig data, from Andrii Nakryiko.

    2) Add BPF dispatcher for XDP which is a mechanism to avoid indirect calls by
    generating a branch funnel as discussed back in bpfconf'19 at LSF/MM. Also,
    add various BPF riscv JIT improvements, from Björn Töpel.

    3) Extend bpftool to allow matching BPF programs and maps by name,
    from Paul Chaignon.

    4) Support for replacing cgroup BPF programs attached with BPF_F_ALLOW_MULTI
    flag for allowing updates without service interruption, from Andrey Ignatov.

    5) Cleanup and simplification of ring access functions for AF_XDP with a
    bonus of 0-5% performance improvement, from Magnus Karlsson.

    6) Enable BPF JITs for x86-64 and arm64 by default. Also, final version of
    audit support for BPF, from Daniel Borkmann and latter with Jiri Olsa.

    7) Move and extend test_select_reuseport into BPF program tests under
    BPF selftests, from Jakub Sitnicki.

    8) Various BPF sample improvements for xdpsock for customizing parameters
    to set up and benchmark AF_XDP, from Jay Jayatheerthan.

    9) Improve libbpf to provide a ulimit hint on permission denied errors.
    Also change XDP sample programs to attach in driver mode by default,
    from Toke Høiland-Jørgensen.

    10) Extend BPF test infrastructure to allow changing skb mark from tc BPF
    programs, from Nikita V. Shirokov.

    11) Optimize prologue code sequence in BPF arm32 JIT, from Russell King.

    12) Fix xdp_redirect_cpu BPF sample to manually attach to tracepoints after
    libbpf conversion, from Jesper Dangaard Brouer.

    13) Minor misc improvements from various others.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

21 Dec, 2019

7 commits

  • When sample xdp_redirect_cpu was converted to use libbpf, the
    tracepoints used by this sample were not getting attached automatically
    like with bpf_load.c. The BPF-maps was still getting loaded, thus
    nobody notice that the tracepoints were not updating these maps.

    This fix doesn't use the new skeleton code, as this bug was introduced
    in v5.1 and stable might want to backport this. E.g. Red Hat QA uses
    this sample as part of their testing.

    Fixes: bbaf6029c49c ("samples/bpf: Convert XDP samples to libbpf usage")
    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/157685877642.26195.2798780195186786841.stgit@firesoul

    Jesper Dangaard Brouer
     
  • The UDP payload fill pattern can be specified using '-P' or '--tx-pkt-pattern'
    option. It is an unsigned 32 bit field and defaulted to 0x12345678.

    The IP and UDP checksum is calculated by the code as per the content of
    the packet before transmission.

    Signed-off-by: Jay Jayatheerthan
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191220085530.4980-7-jay.jayatheerthan@intel.com

    Jay Jayatheerthan
     
  • New option '-s' or '--tx-pkt-size' has been added to specify the transmit
    packet size. The packet size ranges from 47 to 4096 bytes. When this
    option is not provided, it defaults to 64 byte packet.

    The code uses struct ethhdr, struct iphdr and struct udphdr to form the
    transmit packet. The MAC address, IP address and UDP ports are set to default
    values.

    The code calculates IP and UDP checksums before sending the packet.
    Checksum calculation code in Linux kernel is used for this purpose.
    The Ethernet FCS is not filled by the code.

    Signed-off-by: Jay Jayatheerthan
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191220085530.4980-6-jay.jayatheerthan@intel.com

    Jay Jayatheerthan
     
  • Use '-C' or '--tx-pkt-count' to specify number of packets to send.
    If it is not specified, the application sends packets forever. If packet
    count is not a multiple of batch size, last batch sent is less than the
    batch size.

    Signed-off-by: Jay Jayatheerthan
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191220085530.4980-5-jay.jayatheerthan@intel.com

    Jay Jayatheerthan
     
  • New option to specify batch size for tx, rx and l2fwd has been added. This
    allows fine tuning to maximize performance. It is specified using '-b' or
    '--batch_size' options. When not specified default is 64.

    Signed-off-by: Jay Jayatheerthan
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191220085530.4980-4-jay.jayatheerthan@intel.com

    Jay Jayatheerthan
     
  • Add code to do cleanup for signals and application completion in a unified
    fashion. The signal handler sets benckmark_done flag terminating the
    threads. The cleanup is called before returning from main() function.

    Signed-off-by: Jay Jayatheerthan
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191220085530.4980-3-jay.jayatheerthan@intel.com

    Jay Jayatheerthan
     
  • The application now supports '-d' or '--duration' option to specify number of
    seconds to run. This is used in tx, rx and l2fwd features. If this option is
    not provided, the application runs forever.

    Signed-off-by: Jay Jayatheerthan
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191220085530.4980-2-jay.jayatheerthan@intel.com

    Jay Jayatheerthan
     

16 Dec, 2019

4 commits

  • When attaching XDP programs, userspace can set flags to request the attach
    mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
    are requested, the kernel will attempt to attach in driver mode, and then
    silently fall back to SKB mode if this fails.

    The silent fallback is a major source of user confusion, as users will try
    to load a program on a device without XDP support, and instead of an error
    they will get the silent fallback behaviour, not notice, and then wonder
    why performance is not what they were expecting.

    In an attempt to combat this, let's switch all the samples to default to
    explicitly requesting driver-mode attach. As part of this, ensure that all
    the userspace utilities have a switch to enable SKB mode. For those that
    have a switch to request driver mode, keep it but turn it into a no-op.

    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Jesper Dangaard Brouer
    Acked-by: David Ahern
    Link: https://lore.kernel.org/bpf/20191216110742.364456-1-toke@redhat.com

    Toke Høiland-Jørgensen
     
  • It seems Clang can in some cases turn on stack protection by default, which
    doesn't work with BPF. This was reported once before[0], but it seems the
    flag to explicitly turn off the stack protector wasn't added to the
    Makefile, so do that now.

    The symptom of this is compile errors like the following:

    error: :0:0: in function bpf_prog1 i32 (%struct.__sk_buff*): A call to built-in function '__stack_chk_fail' is not supported.

    [0] https://www.spinics.net/lists/netdev/msg556400.html

    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191216103819.359535-1-toke@redhat.com

    Toke Høiland-Jørgensen
     
  • Since libbpf now links against zlib, this needs to be included in the
    linker invocation for the userspace programs in samples/bpf that link
    statically against libbpf.

    Fixes: 166750bc1dd2 ("libbpf: Support libbpf-provided extern variables")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Tested-by: Björn Töpel
    Link: https://lore.kernel.org/bpf/20191216102405.353834-1-toke@redhat.com

    Toke Høiland-Jørgensen
     
  • Add xdp_redirect and per_socket_stats_example in build targets.
    They got removed from build targets in Makefile reorganization.

    Fixes: 1d97c6c2511f ("samples/bpf: Base target programs rules on Makefile.target")
    Signed-off-by: Prashant Bhole
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191216071619.25479-1-prashantbhole.linux@gmail.com

    Prashant Bhole
     

12 Dec, 2019

2 commits

  • Currently, open() is called from the user program and it calls the syscall
    'sys_openat', not the 'sys_open'. This leads to an error of the program
    of user side, due to the fact that the counter maps are zero since no
    function such 'sys_open' is called.

    This commit adds the kernel bpf program which are attached to the
    tracepoint 'sys_enter_openat' and 'sys_enter_openat'.

    Fixes: 1da236b6be963 ("bpf: add a test case for syscalls/sys_{enter|exit}_* tracepoints")
    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov

    Daniel T. Lee
     
  • Previously, when this sample is added, commit 1c47910ef8013
    ("samples/bpf: add perf_event+bpf example"), a symbol 'sys_read' and
    'sys_write' has been used without no prefixes. But currently there are
    no exact symbols with these under kallsyms and this leads to failure.

    This commit changes exact compare to substring compare to keep compatible
    with exact symbol or prefixed symbol.

    Fixes: 1c47910ef8013 ("samples/bpf: add perf_event+bpf example")
    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191205080114.19766-2-danieltimlee@gmail.com

    Daniel T. Lee
     

05 Dec, 2019

1 commit

  • In the days of using bpf_load.c the order in which the 'maps' sections
    were defines in BPF side (*_kern.c) file, were used by userspace side
    to identify the map via using the map order as an index. In effect the
    order-index is created based on the order the maps sections are stored
    in the ELF-object file, by the LLVM compiler.

    This have also carried over in libbpf via API bpf_map__next(NULL, obj)
    to extract maps in the order libbpf parsed the ELF-object file.

    When BTF based maps were introduced a new section type ".maps" were
    created. I found that the LLVM compiler doesn't create the ".maps"
    sections in the order they are defined in the C-file. The order in the
    ELF file is based on the order the map pointer is referenced in the code.

    This combination of changes lead to xdp_rxq_info mixing up the map
    file-descriptors in userspace, resulting in very broken behaviour, but
    without warning the user.

    This patch fix issue by instead using bpf_object__find_map_by_name()
    to find maps via their names. (Note, this is the ELF name, which can
    be longer than the name the kernel retains).

    Fixes: be5bca44aa6b ("samples: bpf: convert some XDP samples from bpf_load to libbpf")
    Fixes: 451d1dc886b5 ("samples: bpf: update map definition to new syntax BTF-defined map")
    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Alexei Starovoitov
    Acked-by: Toke Høiland-Jørgensen
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/157529025128.29832.5953245340679936909.stgit@firesoul

    Jesper Dangaard Brouer
     

21 Nov, 2019

1 commit

  • Daniel Borkmann says:

    ====================
    pull-request: bpf-next 2019-11-20

    The following pull-request contains BPF updates for your *net-next* tree.

    We've added 81 non-merge commits during the last 17 day(s) which contain
    a total of 120 files changed, 4958 insertions(+), 1081 deletions(-).

    There are 3 trivial conflicts, resolve it by always taking the chunk from
    196e8ca74886c433:

    <<<<<<< HEAD
    =======
    void *bpf_map_area_mmapable_alloc(u64 size, int numa_node);
    >>>>>>> 196e8ca74886c433dcfc64a809707074b936aaf5

    <<<<<<< HEAD
    void *bpf_map_area_alloc(u64 size, int numa_node)
    =======
    static void *__bpf_map_area_alloc(u64 size, int numa_node, bool mmapable)
    >>>>>>> 196e8ca74886c433dcfc64a809707074b936aaf5

    <<<<<<< HEAD
    if (size << PAGE_ALLOC_COSTLY_ORDER)) {
    =======
    /* kmalloc()'ed memory can't be mmap()'ed */
    if (!mmapable && size << PAGE_ALLOC_COSTLY_ORDER)) {
    >>>>>>> 196e8ca74886c433dcfc64a809707074b936aaf5

    The main changes are:

    1) Addition of BPF trampoline which works as a bridge between kernel functions,
    BPF programs and other BPF programs along with two new use cases: i) fentry/fexit
    BPF programs for tracing with practically zero overhead to call into BPF (as
    opposed to k[ret]probes) and ii) attachment of the former to networking related
    programs to see input/output of networking programs (covering xdpdump use case),
    from Alexei Starovoitov.

    2) BPF array map mmap support and use in libbpf for global data maps; also a big
    batch of libbpf improvements, among others, support for reading bitfields in a
    relocatable manner (via libbpf's CO-RE helper API), from Andrii Nakryiko.

    3) Extend s390x JIT with usage of relative long jumps and loads in order to lift
    the current 64/512k size limits on JITed BPF programs there, from Ilya Leoshkevich.

    4) Add BPF audit support and emit messages upon successful prog load and unload in
    order to have a timeline of events, from Daniel Borkmann and Jiri Olsa.

    5) Extension to libbpf and xdpsock sample programs to demo the shared umem mode
    (XDP_SHARED_UMEM) as well as RX-only and TX-only sockets, from Magnus Karlsson.

    6) Several follow-up bug fixes for libbpf's auto-pinning code and a new API
    call named bpf_get_link_xdp_info() for retrieving the full set of prog
    IDs attached to XDP, from Toke Høiland-Jørgensen.

    7) Add BTF support for array of int, array of struct and multidimensional arrays
    and enable it for skb->cb[] access in kfree_skb test, from Martin KaFai Lau.

    8) Fix AF_XDP by using the correct number of channels from ethtool, from Luigi Rizzo.

    9) Two fixes for BPF selftest to get rid of a hang in test_tc_tunnel and to avoid
    xdping to be run as standalone, from Jiri Benc.

    10) Various BPF selftest fixes when run with latest LLVM trunk, from Yonghong Song.

    11) Fix a memory leak in BPF fentry test run data, from Colin Ian King.

    12) Various smaller misc cleanups and improvements mostly all over BPF selftests and
    samples, from Daniel T. Lee, Andre Guedes, Anders Roxell, Mao Wenan, Yue Haibing.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

16 Nov, 2019

2 commits

  • Commit 743e568c1586 (samples/bpf: Add a "force" flag to XDP samples)
    introduced the '-F' option but missed adding it to the usage() and the
    'long_option' array.

    Fixes: 743e568c1586 (samples/bpf: Add a "force" flag to XDP samples)
    Signed-off-by: Andre Guedes
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20191114162847.221770-2-andre.guedes@intel.com

    Andre Guedes
     
  • The '-f' option is shown twice in the usage(). This patch removes the
    outdated version.

    Signed-off-by: Andre Guedes
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20191114162847.221770-1-andre.guedes@intel.com

    Andre Guedes
     

12 Nov, 2019

1 commit

  • Side effect of some kbuild changes resulted in breaking the
    documented way to build samples/bpf/.

    This patch change the samples/bpf/Makefile to work again, when
    invoking make from the subdir samples/bpf/. Also update the
    documentation in README.rst, to reflect the new way to build.

    Signed-off-by: Jesper Dangaard Brouer
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Jesper Dangaard Brouer
     

11 Nov, 2019

2 commits

  • Use Rx-only sockets for the rxdrop sample and Tx-only sockets for the
    txpush sample in the xdpsock application. This so that we exercise and
    show case these socket types too.

    Signed-off-by: Magnus Karlsson
    Signed-off-by: Alexei Starovoitov
    Tested-by: William Tu
    Acked-by: Jonathan Lemon
    Link: https://lore.kernel.org/bpf/1573148860-30254-5-git-send-email-magnus.karlsson@intel.com

    Magnus Karlsson
     
  • Add support for the XDP_SHARED_UMEM mode to the xdpsock sample
    application. As libbpf does not have a built in XDP program for this
    mode, we use an explicitly loaded XDP program. This also serves as an
    example on how to write your own XDP program that can route to an
    AF_XDP socket.

    Signed-off-by: Magnus Karlsson
    Signed-off-by: Alexei Starovoitov
    Tested-by: William Tu
    Acked-by: Jonathan Lemon
    Link: https://lore.kernel.org/bpf/1573148860-30254-3-git-send-email-magnus.karlsson@intel.com

    Magnus Karlsson
     

10 Nov, 2019

1 commit


09 Nov, 2019

2 commits

  • Since, the new syntax of BTF-defined map has been introduced,
    the syntax for using maps under samples directory are mixed up.
    For example, some are already using the new syntax, and some are using
    existing syntax by calling them as 'legacy'.

    As stated at commit abd29c931459 ("libbpf: allow specifying map
    definitions using BTF"), the BTF-defined map has more compatablility
    with extending supported map definition features.

    The commit doesn't replace all of the map to new BTF-defined map,
    because some of the samples still use bpf_load instead of libbpf, which
    can't properly create BTF-defined map.

    This will only updates the samples which uses libbpf API for loading bpf
    program. (ex. bpf_prog_load_xattr)

    Signed-off-by: Daniel T. Lee
    Acked-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov

    Daniel T. Lee
     
  • Currently, under samples, several methods are being used to load bpf
    program.

    Since using libbpf is preferred solution, lots of previously used
    'load_bpf_file' from bpf_load are replaced with 'bpf_prog_load_xattr'
    from libbpf.

    But some of the error messages still show up as 'load_bpf_file' instead
    of 'bpf_prog_load_xattr'.

    This commit fixes outdated errror messages under samples and fixes some
    code style issues.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20191107005153.31541-2-danieltimlee@gmail.com

    Daniel T. Lee
     

03 Nov, 2019

1 commit

  • Use bpf_probe_read_user() helper instead of bpf_probe_read() for samples that
    attach to kprobes probing on user addresses.

    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/5b0144b3f8e031ec5e2438bd7de8d7877e63bf2f.1572649915.git.daniel@iogearbox.net

    Daniel Borkmann
     

01 Nov, 2019

1 commit

  • To remove that test_attr__{enabled/open} are used by perf-sys.h, we
    set HAVE_ATTR_TEST to zero.

    Signed-off-by: Björn Töpel
    Tested-by: KP Singh
    Acked-by: Song Liu
    Cc: Adrian Hunter
    Cc: Alexei Starovoitov
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: bpf@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Daniel Borkmann
    Link: http://lore.kernel.org/bpf/20191001113307.27796-3-bjorn.topel@gmail.com

    Björn Töpel
     

21 Oct, 2019

1 commit


13 Oct, 2019

4 commits

  • Add couple preparation steps: clean and configuration. Also add newly
    added sysroot support info to cross-compile section.

    Signed-off-by: Ivan Khoronzhuk
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191011002808.28206-16-ivan.khoronzhuk@linaro.org

    Ivan Khoronzhuk
     
  • Basically it only enables that was added by previous couple fixes.
    Sysroot contains correct libs installed and its headers. Useful when
    working with NFC or virtual machine.

    Usage example:

    clean (on demand)
    make ARCH=arm -C samples/bpf clean
    make ARCH=arm -C tools clean
    make ARCH=arm clean

    configure and install headers:

    make ARCH=arm defconfig
    make ARCH=arm headers_install

    build samples/bpf:
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- samples/bpf/ \
    SYSROOT="path/to/sysroot"

    Signed-off-by: Ivan Khoronzhuk
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191011002808.28206-15-ivan.khoronzhuk@linaro.org

    Ivan Khoronzhuk
     
  • In order to build lib using C/LD flags of target arch, provide them
    to libbpf make.

    Signed-off-by: Ivan Khoronzhuk
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191011002808.28206-14-ivan.khoronzhuk@linaro.org

    Ivan Khoronzhuk
     
  • No need in hacking HOSTCC to be cross-compiler any more, so drop
    this trick and use target CC for HDR_PROBE.

    Signed-off-by: Ivan Khoronzhuk
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20191011002808.28206-11-ivan.khoronzhuk@linaro.org

    Ivan Khoronzhuk