04 Aug, 2022

2 commits


09 Jun, 2022

1 commit

  • [ Upstream commit ec24704492d8791a52a75a39e3ad762b6e017bc6 ]

    samples/bpf build currently always fails if it can't generate
    vmlinux.h from vmlinux, even when vmlinux.h is directly provided by
    VMLINUX_H variable, which makes VMLINUX_H pointless.
    Only fails when neither method works.

    Fixes: 384b6b3bbf0d ("samples: bpf: Add vmlinux.h generation support")
    Reported-by: CKI Project
    Reported-by: Veronika Kabatova
    Signed-off-by: Jerome Marchand
    Signed-off-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20220507161635.2219052-1-jmarchan@redhat.com
    Signed-off-by: Sasha Levin

    Jerome Marchand
     

08 Apr, 2022

1 commit

  • [ Upstream commit 8fa42d78f6354bb96ad3a079dcbef528ca9fa9e0 ]

    When running xdpsock for a fix duration of time before terminating
    using --duration=, there is a race condition that may cause xdpsock
    to terminate immediately.

    When running for a fixed duration of time the check to determine when to
    terminate execution is in is_benchmark_done() and is being executed in
    the context of the poller thread,

    if (opt_duration > 0) {
    unsigned long dt = (get_nsecs() - start_time);

    if (dt >= opt_duration)
    benchmark_done = true;
    }

    However start_time is only set after the poller thread have been
    created. This leaves a small window when the poller thread is starting
    and calls is_benchmark_done() for the first time that start_time is not
    yet set. In that case start_time have its initial value of 0 and the
    duration check fails as it do not correlate correctly for the
    applications start time and immediately sets benchmark_done which in
    turn terminates the xdpsock application.

    Fix this by setting start_time before creating the poller thread.

    Fixes: d3f11b018f6c ("samples/bpf: xdpsock: Add duration option to specify how long to run")
    Signed-off-by: Niklas Söderlund
    Signed-off-by: Simon Horman
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20220315102948.466436-1-niklas.soderlund@corigine.com
    Signed-off-by: Sasha Levin

    Niklas Söderlund
     

27 Jan, 2022

4 commits

  • [ Upstream commit 6f670d06e47c774bc065aaa84a527a4838f34bd8 ]

    Clang doesn't have 'stringop-truncation' group like GCC does, and
    complains about it when building samples which use xdp_sample_user
    infra:

    samples/bpf/xdp_sample_user.h:48:32: warning: unknown warning group '-Wstringop-truncation', ignored [-Wunknown-warning-option]
    #pragma GCC diagnostic ignored "-Wstringop-truncation"
    ^
    [ repeat ]

    Those are harmless, but avoidable when guarding it with ifdef.
    I could guard push/pop as well, but this would require one more
    ifdef cruft around a single line which I don't think is reasonable.

    Fixes: 156f886cf697 ("samples: bpf: Add basic infrastructure for XDP samples")
    Signed-off-by: Alexander Lobakin
    Signed-off-by: Andrii Nakryiko
    Acked-by: Kumar Kartikeya Dwivedi
    Link: https://lore.kernel.org/bpf/20211203195004.5803-3-alexandr.lobakin@intel.com
    Signed-off-by: Sasha Levin

    Alexander Lobakin
     
  • [ Upstream commit e64fbcaa7a666f16329b1c67af15ea501bc84586 ]

    Clang (13) doesn't get the jokes about specifying libraries to link in
    cclags of individual .o objects:

    clang-13: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
    [ ... ]
    LD samples/bpf/xdp_redirect_cpu
    LD samples/bpf/xdp_redirect_map_multi
    LD samples/bpf/xdp_redirect_map
    LD samples/bpf/xdp_redirect
    LD samples/bpf/xdp_monitor
    /usr/bin/ld: samples/bpf/xdp_sample_user.o: in function `sample_summary_print':
    xdp_sample_user.c:(.text+0x84c): undefined reference to `floor'
    /usr/bin/ld: xdp_sample_user.c:(.text+0x870): undefined reference to `ceil'
    /usr/bin/ld: xdp_sample_user.c:(.text+0x8cf): undefined reference to `floor'
    /usr/bin/ld: xdp_sample_user.c:(.text+0x8f3): undefined reference to `ceil'
    [ more ]

    Specify '-lm' as ldflags for all xdp_sample_user.o users in the main
    Makefile and remove it from ccflags of ^ in Makefile.target -- just
    like it's done for all other samples. This works with all compilers.

    Fixes: 6e1051a54e31 ("samples: bpf: Convert xdp_monitor to XDP samples helper")
    Fixes: b926c55d856c ("samples: bpf: Convert xdp_redirect to XDP samples helper")
    Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper")
    Fixes: bbe65865aa05 ("samples: bpf: Convert xdp_redirect_map to XDP samples helper")
    Fixes: 594a116b2aa1 ("samples: bpf: Convert xdp_redirect_map_multi to XDP samples helper")
    Signed-off-by: Alexander Lobakin
    Signed-off-by: Andrii Nakryiko
    Acked-by: Kumar Kartikeya Dwivedi
    Link: https://lore.kernel.org/bpf/20211203195004.5803-2-alexandr.lobakin@intel.com
    Signed-off-by: Sasha Levin

    Alexander Lobakin
     
  • [ Upstream commit 527024f7aeb683ce7ef49b07ef7ce9ecf015288d ]

    Remove xdp_samples_user.o rule redefinition which generates Makefile
    warning and instead override TPROGS_CFLAGS. This seems to work fine when
    building inside selftests/bpf.

    That was one big head-scratcher before I found that generic
    Makefile.target hid this surprising specialization for for xdp_samples_user.o.

    Main change is to use actual locally installed libbpf headers.

    Also drop printk macro re-definition (not even used!).

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20211201232824.3166325-8-andrii@kernel.org
    Signed-off-by: Sasha Levin

    Andrii Nakryiko
     
  • [ Upstream commit 3f7a3318a7c60947e27be372950840a5eab976d0 ]

    API headers from libbpf should not be accessed directly from the source
    directory. Instead, they should be exported with "make install_headers".
    Make sure that samples/bpf/Makefile installs the headers properly when
    building.

    The object compiled from and exported by libbpf are now placed into a
    subdirectory of sample/bpf/ instead of remaining in tools/lib/bpf/. We
    attempt to remove this directory on "make clean". However, the "clean"
    target re-enters the samples/bpf/ directory from the root of the
    repository ("$(MAKE) -C ../../ M=$(CURDIR) clean"), in such a way that
    $(srctree) and $(src) are not defined, making it impossible to use
    $(LIBBPF_OUTPUT) and $(LIBBPF_DESTDIR) in the recipe. So we only attempt
    to clean $(CURDIR)/libbpf, which is the default value.

    Add a dependency on libbpf's headers for the $(TRACE_HELPERS).

    We also change the output directory for bpftool, to place the generated
    objects under samples/bpf/bpftool/ instead of building in bpftool's
    directory directly. Doing so, we make sure bpftool reuses the libbpf
    library previously compiled and installed.

    Signed-off-by: Quentin Monnet
    Signed-off-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20211007194438.34443-10-quentin@isovalent.com
    Signed-off-by: Sasha Levin

    Quentin Monnet
     

25 Nov, 2021

2 commits

  • [ Upstream commit 2453afe3845523d9dfe89dbfb3d71abfa095e260 ]

    Commit b599015f044d ("samples/bpf: Fix application of sizeof to pointer")
    tried to fix a bug where sizeof was incorrectly applied to a pointer instead
    of the array string was being copied to, to find the destination buffer size,
    but ended up using strlen, which is still incorrect. However, on closer look
    ifname_buf has no other use, hence directly use optarg.

    Fixes: b599015f044d ("samples/bpf: Fix application of sizeof to pointer")
    Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper")
    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Alexander Lobakin
    Tested-by: Alexander Lobakin
    Link: https://lore.kernel.org/bpf/20211112020301.528357-1-memxor@gmail.com
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Kumar Kartikeya Dwivedi
     
  • [ Upstream commit dc14ca4644f48b1cfa93631e35c28bdc011ad109 ]

    sample_summary_print() uses accumulated period to calculate and display
    per-sec averages. This period gets incremented by sampling interval each
    time a new sample is formed, and thus equals to the number of samples
    collected multiplied by this interval.

    However, the totals are being calculated differently, they receive current
    sample statistics already divided by the interval gotten as a difference
    between sample timestamps for better precision -- in other words, they are
    being incremented by the per-sec values each sample.

    This leads to the excessive division of summary per-secs when interval != 1
    sec. It is obvious pps couldn't become two times lower just from picking a
    different sampling interval value:

    $ samples/bpf/xdp_redirect_cpu -p xdp_prognum_n1_inverse_qnum -c all
    -s -d 6 -i 1
    < snip >
    Packets received : 2,197,230,321
    Average packets/s : 22,887,816
    Packets redirected : 2,197,230,472
    Average redir/s : 22,887,817
    $ samples/bpf/xdp_redirect_cpu -p xdp_prognum_n1_inverse_qnum -c all
    -s -d 6 -i 2
    < snip >
    Packets received : 159,566,498
    Average packets/s : 11,397,607
    Packets redirected : 159,566,995
    Average redir/s : 11,397,642

    This can be easily fixed by treating the divisor not as a period, but rather
    as a total number of samples, and thus incrementing it by 1 instead of
    interval. As a nice side effect, we can now remove so-named argument from a
    couple of functions. Let us also create an "alias" for sample_output::rx_cnt::pps
    named 'num' using a union since this field is used to store this number (period
    previously) as well, and the resulting counter-intuitive code might've been a
    reason for this bug.

    Fixes: 156f886cf697 ("samples: bpf: Add basic infrastructure for XDP samples")
    Signed-off-by: Alexander Lobakin
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jesse Brandeburg
    Reviewed-by: Kumar Kartikeya Dwivedi
    Link: https://lore.kernel.org/bpf/20211111215703.690-1-alexandr.lobakin@intel.com
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Alexander Lobakin
     

19 Nov, 2021

1 commit

  • [ Upstream commit b599015f044df53e93ad0a2957b615bc1a26bf73 ]

    The coccinelle check report:
    "./samples/bpf/xdp_redirect_cpu_user.c:397:32-38:
    ERROR: application of sizeof to pointer"
    Using the "strlen" to fix it.

    Reported-by: Zeal Robot
    Signed-off-by: David Yang
    Signed-off-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20211012111649.983253-1-davidcomponentone@gmail.com
    Signed-off-by: Sasha Levin

    David Yang
     

29 Sep, 2021

2 commits

  • libbpf and bpftool have been dual-licensed to facilitate inclusion in software
    that is not compatible with GPL2-only (ie: Apache2), but the samples are still
    GPL2-only.

    Given these files are samples, they get naturally copied around. For example,
    it is the case for samples/bpf/bpf_insn.h which was copied into the systemd
    tree: https://github.com/systemd/systemd/blob/main/src/shared/linux/bpf_insn.h

    Some more context on systemd's needs specifically:

    Most of systemd is (L)GPL2-or-later, which means there is no perceived
    incompatibility with Apache2 software and can thus be linked with
    OpenSSL 3.0. But given this GPL2-only header is included this is currently
    not possible. Dual-licensing this header solves this problem for us as we
    are scoping a move to OpenSSL 3.0, see:

    https://lists.freedesktop.org/archives/systemd-devel/2021-September/046882.html

    Dual-license this header as GPL-2.0-only OR BSD-2-Clause to follow the same
    licensing used by libbpf and bpftool:

    1bc38b8ff6cc ("libbpf: relicense libbpf as LGPL-2.1 OR BSD-2-Clause")
    907b22365115 ("tools: bpftool: dual license all files")

    Signed-off-by: Luca Boccassi
    Signed-off-by: Daniel Borkmann
    Acked-by: Simon Horman
    Acked-by: Daniel Mack
    Acked-by: Josef Bacik
    Acked-by: Joe Stringer
    Acked-by: Chenbo Feng
    Acked-by: Björn Töpel
    Acked-by: Magnus Karlsson
    Acked-by: Brendan Jackman
    Acked-by: Daniel Borkmann
    Acked-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210923000540.47344-1-luca.boccassi@gmail.com

    Luca Boccassi
     
  • Generate vmlinux.h only from the in-tree vmlinux, and remove enum
    declarations that would cause a build failure in case of version
    mismatches.

    There are now two options when building the samples:
    1. Compile the kernel to use in-tree vmlinux for vmlinux.h
    2. Override VMLINUX_BTF for samples using something like this:
    make VMLINUX_BTF=/sys/kernel/btf/vmlinux -C samples/bpf

    This change was tested with relative builds, e.g. cases like:
    * make O=build -C samples/bpf
    * make KBUILD_OUTPUT=build -C samples/bpf
    * make -C samples/bpf
    * cd samples/bpf && make

    When a suitable VMLINUX_BTF is not found, the following message is
    printed:
    /home/kkd/src/linux/samples/bpf/Makefile:333: *** Cannot find a vmlinux
    for VMLINUX_BTF at any of " ./vmlinux", build the kernel or set
    VMLINUX_BTF variable. Stop.

    Fixes: 384b6b3bbf0d (samples: bpf: Add vmlinux.h generation support)
    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Andrii Nakryiko
    Acked-by: Toke Høiland-Jørgensen
    Link: https://lore.kernel.org/bpf/20210928054608.1799021-1-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     

27 Aug, 2021

1 commit


25 Aug, 2021

21 commits

  • Use the libbpf skeleton facility and other utilities provided by XDP
    samples helper. Also adapt to change of type of mac address map, so that
    no resizing is required.

    Add a new flag for sample mask that skips priting the
    from_device->to_device heading for each line, as xdp_redirect_map_multi
    may have two devices but the flow of data may be bidirectional, so the
    output would be confusing.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-23-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • One of the notable changes is using a BPF_MAP_TYPE_HASH instead of array
    map to store mac addresses of devices, as the resizing behavior was
    based on max_ifindex, which unecessarily maximized the capacity of map
    beyond what was needed.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-22-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Use the libbpf skeleton facility and other utilities provided by XDP
    samples helper.

    Since get_mac_addr is already provided by XDP samples helper, we drop
    it. Also convert to XDP samples helper similar to prior samples to
    minimize duplication of code.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-21-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Also update it to use consistent SEC("xdp") and SEC("xdp_devmap")
    naming, and use global variable instead of BPF map for copying the mac
    address.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-20-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Use the libbpf skeleton facility and other utilities provided by XDP
    samples helper.

    Similar to xdp_monitor, xdp_redirect_cpu was quite featureful except a
    few minor omissions (e.g. redirect errno reporting). All of these have
    been moved to XDP samples helper, hence drop the unneeded code and
    convert to usage of helpers provided by it.

    One of the important changes here is dropping of mprog-disable option,
    as we make that the default. Also, we support built-in programs for some
    common actions on the packet when it reaches kthread (pass, drop,
    redirect to device). If the user still needs to install a custom
    program, they can still supply a BPF object, however the program should
    be suitably tagged with SEC("xdp_cpumap") annotation so that the
    expected attach type is correct when updating our cpumap map element.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-19-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Similar to xdp_monitor_kern, a lot of these BPF programs have been
    reimplemented properly consolidating missing features from other XDP
    samples. Hence, drop the unneeded code and rename to .bpf.c suffix.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-18-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Use the libbpf skeleton facility and other utilities provided by XDP
    samples helper.

    One important note:
    The XDP samples helper handles ownership of installed XDP programs on
    devices, including responding to SIGINT and SIGTERM, so drop the code
    here and use the helpers we provide going forward for all xdp_redirect*
    conversions.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-17-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • We moved swap_src_dst_mac to xdp_sample.bpf.h to be shared with other
    potential users, so drop it while moving code to the new file.
    Also, consistently use SEC("xdp") naming instead.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-16-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Use the libbpf skeleton facility and other utilities provided by XDP
    samples helper.

    A lot of the code in xdp_monitor and xdp_redirect_cpu has been moved to
    the xdp_sample_user.o helper, so we remove the duplicate functions here
    that are no longer needed.

    Thanks to BPF skeleton, we no longer depend on order of tracepoints to
    uninstall them on startup. Instead, the sample mask is used to install
    the needed tracepoints.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-15-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • We already moved all the functionality it provided in XDP samples helper
    userspace and kernel BPF object, so just delete the unneeded code.

    We also add generation of BPF skeleton and compilation using clang
    -target bpf for files ending with .bpf.c suffix (to denote that they use
    vmlinux.h).

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-14-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • Also, take this opportunity to depend on in-tree bpftool, so that we can
    use static linking support in subsequent commits for XDP samples BPF
    helper object.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-13-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This adds support for retrieval and printing for devmap_xmit total and
    mutli mode tracepoint. For multi mode, we keep a hash map entry for each
    redirection stream, such that we can dynamically add and remove entries
    on output.

    The from_match and to_match will be set by individual samples when
    setting up the XDP program on these devices.

    The multi mode tracepoint is also handy for xdp_redirect_map_multi,
    where up to 32 devices can be specified.

    Also add samples_init_pre_load macro to finally set up the resized maps
    and mmap them in place for low overhead stats retrieval.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-12-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This adds support for the devmap_xmit tracepoint, and its multi device
    variant that can be used to obtain streams for each individual
    net_device to net_device redirection. This is useful for decomposing
    total xmit stats in xdp_monitor.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-11-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This consolidates retrieval and printing into the XDP sample helper. For
    the kthread stats, it expands xdp_stats separately with its own per-CPU
    stats. For cpumap enqueue, we display FROM->TO stats also with its
    per-CPU stats.

    The help out explains in detail the various aspects of the output.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-10-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • These are invoked in two places, when the XDP frame or SKB (for generic
    XDP) enqueued to the ptr_ring (cpumap_enqueue) and when kthread processes
    the frame after invoking the CPUMAP program for it (returning stats for
    the batch).

    We use cpumap_map_id to filter on the map_id as a way to avoid printing
    incorrect stats for parallel sessions of xdp_redirect_cpu.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-9-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This implements the retrieval and printing, as well the help output.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-8-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This would allow us to store stats for each XDP action, including their
    per-CPU counts. Consolidating this here allows all redirect samples to
    detect xdp_exception events.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-7-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This implements per-errno reporting (for the ones we explicitly
    recognize), adds some help output, and implements the stats retrieval
    and printing functions.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-6-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This adds the shared BPF file that will be used going forward for
    sharing tracepoint programs among XDP redirect samples.

    Since vmlinux.h conflicts with tools/include for READ_ONCE/WRITE_ONCE
    and ARRAY_SIZE, they are copied in to xdp_sample.bpf.h along with other
    helpers that will be required.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-5-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • This file implements some common helpers to consolidate differences in
    features and functionality between the various XDP samples and give them
    a consistent look, feel, and reporting capabilities.

    This commit only adds support for receive statistics, which does not
    rely on any tracepoint, but on the XDP program installed on the device
    by each XDP redirect sample.

    Some of the key features are:
    * A concise output format accompanied by helpful text explaining its
    fields.
    * An elaborate output format building upon the concise one, and folding
    out details in case of errors and staying out of view otherwise.
    * Printing driver names for devices redirecting packets.
    * Getting mac address for interface.
    * Printing summarized total statistics for the entire session.
    * Ability to dynamically switch between concise and verbose mode, using
    SIGQUIT (Ctrl + \).

    In later patches, the support will be extended for each tracepoint with
    its own custom output in concise and verbose mode.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-4-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     
  • cookie_uid_helper_example.c: In function ‘main’:
    cookie_uid_helper_example.c:178:69: warning: ‘ -j ACCEPT’ directive
    writing 10 bytes into a region of size between 8 and 58
    [-Wformat-overflow=]
    178 | sprintf(rules, "iptables -A OUTPUT -m bpf --object-pinned %s -j ACCEPT",
    | ^~~~~~~~~~
    /home/kkd/src/linux/samples/bpf/cookie_uid_helper_example.c:178:9: note:
    ‘sprintf’ output between 53 and 103 bytes into a destination of size 100
    178 | sprintf(rules, "iptables -A OUTPUT -m bpf --object-pinned %s -j ACCEPT",
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    179 | file);
    | ~~~~~

    Fix by using snprintf and a sufficiently sized buffer.

    tracex4_user.c:35:15: warning: ‘write’ reading 12 bytes from a region of
    size 11 [-Wstringop-overread]
    35 | key = write(1, "\e[1;1H\e[2J", 12); /* clear screen */
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Use size as 11.

    Signed-off-by: Kumar Kartikeya Dwivedi
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20210821002010.845777-2-memxor@gmail.com

    Kumar Kartikeya Dwivedi
     

15 Aug, 2021

1 commit


10 Aug, 2021

1 commit


07 Aug, 2021

2 commits

  • There is a forward declaration of ip_fast_csum() just before its
    implementation, remove the unneeded forward declaration.

    While at it mark the implementation as static inline.

    Signed-off-by: Niklas Söderlund
    Signed-off-by: Simon Horman
    Signed-off-by: Andrii Nakryiko
    Reviewed-by: Louis Peens
    Link: https://lore.kernel.org/bpf/20210806122855.26115-3-simon.horman@corigine.com

    Niklas Söderlund
     
  • The xdpsock sample application is a useful base for experiment's around
    AF_XDP sockets. Compiling the sample outside of the kernel tree is made
    harder then it has to be as the sample includes two headers and that are
    not installed by 'make install_header' nor are usually part of
    distributions kernel headers.

    The first header asm/barrier.h is not used and can just be dropped.

    The second linux/compiler.h are only needed for the decorator __force
    and are only used in ip_fast_csum(), csum_fold() and
    csum_tcpudp_nofold(). These functions are copied verbatim from
    include/asm-generic/checksum.h and lib/checksum.c. While it's fine to
    copy and use these functions in the sample application the decorator
    brings no value and can be dropped together with the include.

    With this change it's trivial to compile the xdpsock sample outside the
    kernel tree from xdpsock_user.c and xdpsock.h.

    $ gcc -o xdpsock xdpsock_user.c -lbpf -lpthread

    Signed-off-by: Niklas Söderlund
    Signed-off-by: Simon Horman
    Signed-off-by: Andrii Nakryiko
    Reviewed-by: Louis Peens
    Link: https://lore.kernel.org/bpf/20210806122855.26115-2-simon.horman@corigine.com

    Niklas Söderlund
     

05 Aug, 2021

1 commit

  • Commit ce4dade7f12a ("samples/bpf: xdp_redirect_cpu: Load a eBPF program
    on cpumap") added the following option, but missed adding it to optstring:

    - mprog-disable: disable loading XDP program on cpumap entries

    Fix it and add the missing option character.

    Fixes: ce4dade7f12a ("samples/bpf: xdp_redirect_cpu: Load a eBPF program on cpumap")
    Signed-off-by: Matthew Cover
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20210731005632.13228-1-matthew.cover@stackpath.com

    Matthew Cover