15 Mar, 2020

3 commits


14 Mar, 2020

11 commits

  • Daniel Borkmann says:

    ====================
    pull-request: bpf-next 2020-03-13

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

    We've added 86 non-merge commits during the last 12 day(s) which contain
    a total of 107 files changed, 5771 insertions(+), 1700 deletions(-).

    The main changes are:

    1) Add modify_return attach type which allows to attach to a function via
    BPF trampoline and is run after the fentry and before the fexit programs
    and can pass a return code to the original caller, from KP Singh.

    2) Generalize BPF's kallsyms handling and add BPF trampoline and dispatcher
    objects to be visible in /proc/kallsyms so they can be annotated in
    stack traces, from Jiri Olsa.

    3) Extend BPF sockmap to allow for UDP next to existing TCP support in order
    in order to enable this for BPF based socket dispatch, from Lorenz Bauer.

    4) Introduce a new bpftool 'prog profile' command which attaches to existing
    BPF programs via fentry and fexit hooks and reads out hardware counters
    during that period, from Song Liu. Example usage:

    bpftool prog profile id 337 duration 3 cycles instructions llc_misses

    4228 run_cnt
    3403698 cycles (84.08%)
    3525294 instructions # 1.04 insn per cycle (84.05%)
    13 llc_misses # 3.69 LLC misses per million isns (83.50%)

    5) Batch of improvements to libbpf, bpftool and BPF selftests. Also addition
    of a new bpf_link abstraction to keep in particular BPF tracing programs
    attached even when the applicaion owning them exits, from Andrii Nakryiko.

    6) New bpf_get_current_pid_tgid() helper for tracing to perform PID filtering
    and which returns the PID as seen by the init namespace, from Carlos Neira.

    7) Refactor of RISC-V JIT code to move out common pieces and addition of a
    new RV32G BPF JIT compiler, from Luke Nelson.

    8) Add gso_size context member to __sk_buff in order to be able to know whether
    a given skb is GSO or not, from Willem de Bruijn.

    9) Add a new bpf_xdp_output() helper which reuses XDP's existing perf RB output
    implementation but can be called from tracepoint programs, from Eelco Chaudron.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Add vmlinux.h generation to selftest/bpf's Makefile. Use it from newly added
    test_vmlinux to trace nanosleep syscall using 5 different types of programs:
    - tracepoint;
    - raw tracepoint;
    - raw tracepoint w/ direct memory reads (tp_btf);
    - kprobe;
    - fentry.

    These programs are realistic variants of real-life tracing programs,
    excercising vmlinux.h's usage with tracing applications.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20200313172336.1879637-5-andriin@fb.com

    Andrii Nakryiko
     
  • Syscall raw tracepoints have struct pt_regs pointer as tracepoint's first
    argument. After that, reading any of pt_regs fields requires bpf_probe_read(),
    even for tp_btf programs. Due to that, PT_REGS_PARMx macros are not usable as
    is. This patch adds CO-RE variants of those macros that use BPF_CORE_READ() to
    read necessary fields. This provides relocatable architecture-agnostic pt_regs
    field accesses.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20200313172336.1879637-4-andriin@fb.com

    Andrii Nakryiko
     
  • When finding target type candidates, ignore forward declarations, functions,
    and other named types of incompatible kind. Not doing this can cause false
    errors. See [0] for one such case (due to struct pt_regs forward
    declaration).

    [0] https://github.com/iovisor/bcc/pull/2806#issuecomment-598543645

    Fixes: ddc7c3042614 ("libbpf: implement BPF CO-RE offset relocation algorithm")
    Reported-by: Wenbo Zhang
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20200313172336.1879637-3-andriin@fb.com

    Andrii Nakryiko
     
  • printf() doesn't seem to honor using overwritten stdout/stderr (as part of
    stdio hijacking), so ensure all "standard" invocations of printf() do
    fprintf(stdout, ...) instead.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20200313172336.1879637-2-andriin@fb.com

    Andrii Nakryiko
     
  • Andrii Nakryiko reports that sockmap_listen test suite is frequently
    failing due to accept() calls erroring out with EAGAIN:

    ./test_progs:connect_accept_thread:733: accept: Resource temporarily unavailable
    connect_accept_thread:FAIL:733

    This is because we are using a non-blocking listening TCP socket to
    accept() connections without polling on the socket.

    While at first switching to blocking mode seems like the right thing to do,
    this could lead to test process blocking indefinitely in face of a network
    issue, like loopback interface being down, as Andrii pointed out.

    Hence, stick to non-blocking mode for TCP listening sockets but with
    polling for incoming connection for a limited time before giving up.

    Apply this approach to all socket I/O calls in the test suite that we
    expect to block indefinitely, that is accept() for TCP and recv() for UDP.

    Fixes: 44d28be2b8d4 ("selftests/bpf: Tests for sockmap/sockhash holding listening sockets")
    Reported-by: Andrii Nakryiko
    Signed-off-by: Jakub Sitnicki
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200313161049.677700-1-jakub@cloudflare.com

    Jakub Sitnicki
     
  • Commit fe4eb069edb7 ("bpftool: Use linux/types.h from source tree for
    profiler build") added a build dependency on tools/testing/selftests/bpf
    to tools/bpf/bpftool. This is suboptimal with respect to a possible
    stand-alone build of bpftool.

    Fix this by moving tools/testing/selftests/bpf/include/uapi/linux/types.h
    to tools/include/uapi/linux/types.h.

    This requires an adjustment in the include search path order for the
    tests in tools/testing/selftests/bpf so that tools/include/linux/types.h
    is selected when building host binaries and
    tools/include/uapi/linux/types.h is selected when building bpf binaries.

    Verified by compiling bpftool and the bpf selftests on x86_64 with this
    change.

    Fixes: fe4eb069edb7 ("bpftool: Use linux/types.h from source tree for profiler build")
    Suggested-by: Andrii Nakryiko
    Signed-off-by: Tobias Klauser
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200313113105.6918-1-tklauser@distanz.ch

    Tobias Klauser
     
  • nanosleep syscall expects pointer to struct timespec, not nanoseconds
    directly. Current implementation fulfills its purpose of invoking nanosleep
    syscall, but doesn't really provide sleeping capabilities, which can cause
    flakiness for tests relying on usleep() to wait for something.

    Fixes: ec12a57b822c ("selftests/bpf: Guarantee that useep() calls nanosleep() syscall")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200313061837.3685572-1-andriin@fb.com
    Signed-off-by: Alexei Starovoitov

    Andrii Nakryiko
     
  • Switch to non-blocking accept and wait for server thread to exit before
    proceeding. I noticed that sometimes tcp_rtt server thread failure would
    "spill over" into other tests (that would run after tcp_rtt), probably just
    because server thread exits much later and tcp_rtt doesn't wait for it.

    v1->v2:
    - add usleep() while waiting on initial non-blocking accept() (Stanislav);

    Fixes: 8a03222f508b ("selftests/bpf: test_progs: fix client/server race in tcp_rtt")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Reviewed-by: Stanislav Fomichev
    Link: https://lore.kernel.org/bpf/20200311222749.458015-1-andriin@fb.com
    Signed-off-by: Alexei Starovoitov

    Andrii Nakryiko
     
  • Some implementations of C runtime library won't call nanosleep() syscall from
    usleep(). But a bunch of kprobe/tracepoint selftests rely on nanosleep being
    called to trigger them. To make this more reliable, "override" usleep
    implementation and call nanosleep explicitly.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Cc: Julia Kartseva
    Link: https://lore.kernel.org/bpf/20200311185345.3874602-1-andriin@fb.com
    Signed-off-by: Alexei Starovoitov

    Andrii Nakryiko
     
  • In commit 4a3d6c6a6e4d ("libbpf: Reduce log level for custom section
    names"), log level for messages for libbpf_attach_type_by_name() and
    libbpf_prog_type_by_name() was downgraded from "info" to "debug". The
    latter function, in particular, is used by bpftool when attempting to
    load programs, and this change caused bpftool to exit with no hint or
    error message when it fails to detect the type of the program to load
    (unless "-d" option was provided).

    To help users understand why bpftool fails to load the program, let's do
    a second run of the function with log level in "debug" mode in case of
    failure.

    Before:

    # bpftool prog load sample_ret0.o /sys/fs/bpf/sample_ret0
    # echo $?
    255

    Or really verbose with -d flag:

    # bpftool -d prog load sample_ret0.o /sys/fs/bpf/sample_ret0
    libbpf: loading sample_ret0.o
    libbpf: section(1) .strtab, size 134, link 0, flags 0, type=3
    libbpf: skip section(1) .strtab
    libbpf: section(2) .text, size 16, link 0, flags 6, type=1
    libbpf: found program .text
    libbpf: section(3) .debug_abbrev, size 55, link 0, flags 0, type=1
    libbpf: skip section(3) .debug_abbrev
    libbpf: section(4) .debug_info, size 75, link 0, flags 0, type=1
    libbpf: skip section(4) .debug_info
    libbpf: section(5) .rel.debug_info, size 32, link 14, flags 0, type=9
    libbpf: skip relo .rel.debug_info(5) for section(4)
    libbpf: section(6) .debug_str, size 150, link 0, flags 30, type=1
    libbpf: skip section(6) .debug_str
    libbpf: section(7) .BTF, size 155, link 0, flags 0, type=1
    libbpf: section(8) .BTF.ext, size 80, link 0, flags 0, type=1
    libbpf: section(9) .rel.BTF.ext, size 32, link 14, flags 0, type=9
    libbpf: skip relo .rel.BTF.ext(9) for section(8)
    libbpf: section(10) .debug_frame, size 40, link 0, flags 0, type=1
    libbpf: skip section(10) .debug_frame
    libbpf: section(11) .rel.debug_frame, size 16, link 14, flags 0, type=9
    libbpf: skip relo .rel.debug_frame(11) for section(10)
    libbpf: section(12) .debug_line, size 74, link 0, flags 0, type=1
    libbpf: skip section(12) .debug_line
    libbpf: section(13) .rel.debug_line, size 16, link 14, flags 0, type=9
    libbpf: skip relo .rel.debug_line(13) for section(12)
    libbpf: section(14) .symtab, size 96, link 1, flags 0, type=2
    libbpf: looking for externs among 4 symbols...
    libbpf: collected 0 externs total
    libbpf: failed to guess program type from ELF section '.text'
    libbpf: supported section(type) names are: socket sk_reuseport kprobe/ [...]

    After:

    # bpftool prog load sample_ret0.o /sys/fs/bpf/sample_ret0
    libbpf: failed to guess program type from ELF section '.text'
    libbpf: supported section(type) names are: socket sk_reuseport kprobe/ [...]

    Signed-off-by: Quentin Monnet
    Signed-off-by: Alexei Starovoitov
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200311021205.9755-1-quentin@isovalent.com
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     

13 Mar, 2020

13 commits

  • Minor overlapping changes, nothing serious.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Introduce new helper that reuses existing xdp perf_event output
    implementation, but can be called from raw_tracepoint programs
    that receive 'struct xdp_buff *' as a tracepoint argument.

    Signed-off-by: Eelco Chaudron
    Signed-off-by: Alexei Starovoitov
    Acked-by: John Fastabend
    Acked-by: Toke Høiland-Jørgensen
    Link: https://lore.kernel.org/bpf/158348514556.2239.11050972434793741444.stgit@xdp-tutorial

    Eelco Chaudron
     
  • Self tests added for new helper bpf_get_ns_current_pid_tgid

    Signed-off-by: Carlos Neira
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200304204157.58695-4-cneirabustos@gmail.com

    Carlos Neira
     
  • New bpf helper bpf_get_ns_current_pid_tgid,
    This helper will return pid and tgid from current task
    which namespace matches dev_t and inode number provided,
    this will allows us to instrument a process inside a container.

    Signed-off-by: Carlos Neira
    Signed-off-by: Alexei Starovoitov
    Acked-by: Yonghong Song
    Link: https://lore.kernel.org/bpf/20200304204157.58695-3-cneirabustos@gmail.com

    Carlos Neira
     
  • Minor fixes for bash completion: addition of program name completion for
    two subcommands, and correction for program test-runs and map pinning.

    The completion for the following commands is fixed or improved:

    # bpftool prog run [TAB]
    # bpftool prog pin [TAB]
    # bpftool map pin [TAB]
    # bpftool net attach xdp name [TAB]

    Signed-off-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20200312184608.12050-3-quentin@isovalent.com

    Quentin Monnet
     
  • Documentation and interactive help for bpftool have always explained
    that the regular handles for programs (id|name|tag|pinned) and maps
    (id|name|pinned) can be passed to the utility when attempting to pin
    objects (bpftool prog pin PROG / bpftool map pin MAP).

    THIS IS A LIE!! The tool actually accepts only ids, as the parsing is
    done in do_pin_any() in common.c instead of reusing the parsing
    functions that have long been generic for program and map handles.

    Instead of fixing the doc, fix the code. It is trivial to reuse the
    generic parsing, and to simplify do_pin_any() in the process.

    Do not accept to pin multiple objects at the same time with
    prog_parse_fds() or map_parse_fds() (this would require a more complex
    syntax for passing multiple sysfs paths and validating that they
    correspond to the number of e.g. programs we find for a given name or
    tag).

    Signed-off-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20200312184608.12050-2-quentin@isovalent.com

    Quentin Monnet
     
  • Pull networking fixes from David Miller:
    "It looks like a decent sized set of fixes, but a lot of these are one
    liner off-by-one and similar type changes:

    1) Fix netlink header pointer to calcular bad attribute offset
    reported to user. From Pablo Neira Ayuso.

    2) Don't double clear PHY interrupts when ->did_interrupt is set,
    from Heiner Kallweit.

    3) Add missing validation of various (devlink, nl802154, fib, etc.)
    attributes, from Jakub Kicinski.

    4) Missing *pos increments in various netfilter seq_next ops, from
    Vasily Averin.

    5) Missing break in of_mdiobus_register() loop, from Dajun Jin.

    6) Don't double bump tx_dropped in veth driver, from Jiang Lidong.

    7) Work around FMAN erratum A050385, from Madalin Bucur.

    8) Make sure ARP header is pulled early enough in bonding driver,
    from Eric Dumazet.

    9) Do a cond_resched() during multicast processing of ipvlan and
    macvlan, from Mahesh Bandewar.

    10) Don't attach cgroups to unrelated sockets when in interrupt
    context, from Shakeel Butt.

    11) Fix tpacket ring state management when encountering unknown GSO
    types. From Willem de Bruijn.

    12) Fix MDIO bus PHY resume by checking mdio_bus_phy_may_suspend()
    only in the suspend context. From Heiner Kallweit"

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (112 commits)
    net: systemport: fix index check to avoid an array out of bounds access
    tc-testing: add ETS scheduler to tdc build configuration
    net: phy: fix MDIO bus PM PHY resuming
    net: hns3: clear port base VLAN when unload PF
    net: hns3: fix RMW issue for VLAN filter switch
    net: hns3: fix VF VLAN table entries inconsistent issue
    net: hns3: fix "tc qdisc del" failed issue
    taprio: Fix sending packets without dequeueing them
    net: mvmdio: avoid error message for optional IRQ
    net: dsa: mv88e6xxx: Add missing mask of ATU occupancy register
    net: memcg: fix lockdep splat in inet_csk_accept()
    s390/qeth: implement smarter resizing of the RX buffer pool
    s390/qeth: refactor buffer pool code
    s390/qeth: use page pointers to manage RX buffer pool
    seg6: fix SRv6 L2 tunnels to use IANA-assigned protocol number
    net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed
    net/packet: tpacket_rcv: do not increment ring index on drop
    sxgbe: Fix off by one in samsung driver strncpy size arg
    net: caif: Add lockdep expression to RCU traversal primitive
    MAINTAINERS: remove Sathya Perla as Emulex NIC maintainer
    ...

    Linus Torvalds
     
  • Needs for application BTF being present differs between user-space libbpf needs and kernel
    needs. Currently, BTF is mandatory only in kernel only when BPF application is
    using STRUCT_OPS. While libbpf itself relies more heavily on presense of BTF:
    - for BTF-defined maps;
    - for Kconfig externs;
    - for STRUCT_OPS as well.

    Thus, checks for presence and validness of bpf_object's BPF needs to be
    performed separately, which is patch does.

    Fixes: 5327644614a1 ("libbpf: Relax check whether BTF is mandatory")
    Reported-by: Michal Rostecki
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Cc: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200312185033.736911-1-andriin@fb.com

    Andrii Nakryiko
     
  • These files are generated, so ignore them.

    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200312182332.3953408-4-songliubraving@fb.com

    Song Liu
     
  • Add the dependency to libbpf, to fix build errors like:

    In file included from skeleton/profiler.bpf.c:5:
    .../bpf_helpers.h:5:10: fatal error: 'bpf_helper_defs.h' file not found
    #include "bpf_helper_defs.h"
    ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    make: *** [skeleton/profiler.bpf.o] Error 1
    make: *** Waiting for unfinished jobs....

    Fixes: 47c09d6a9f67 ("bpftool: Introduce "prog profile" command")
    Suggested-by: Quentin Monnet
    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200312182332.3953408-3-songliubraving@fb.com

    Song Liu
     
  • bpftool-prog-profile requires clang to generate BTF for global variables.
    When compared with older clang, skip this command. This is achieved by
    adding a new feature, clang-bpf-global-var, to tools/build/feature.

    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200312182332.3953408-2-songliubraving@fb.com

    Song Liu
     
  • add CONFIG_NET_SCH_ETS to 'config', otherwise test suites using this file
    to perform a full tdc run will encounter the following warning:

    ok 645 e90e - Add ETS qdisc using bands # skipped - "-----> teardown stage" did not complete successfully

    Fixes: 82c664b69c8b ("selftests: qdiscs: Add test coverage for ETS Qdisc")
    Reported-by: Jamal Hadi Salim
    Signed-off-by: Davide Caratti
    Signed-off-by: David S. Miller

    Davide Caratti
     
  • This commit adds a test to check if we can fully utilize 4-tuples for
    connect() when all ephemeral ports are exhausted.

    The test program changes the local port range to use only one port and binds
    two sockets with or without SO_REUSEADDR and SO_REUSEPORT, and with the same
    EUID or with different EUIDs, then do listen().

    We should be able to bind only one socket having both SO_REUSEADDR and
    SO_REUSEPORT per EUID, which restriction is to prevent unintentional
    listen().

    Signed-off-by: Kuniyuki Iwashima
    Signed-off-by: David S. Miller

    Kuniyuki Iwashima
     

12 Mar, 2020

1 commit

  • When compiling bpftool on a system where the /usr/include/asm symlink
    doesn't exist (e.g. on an Ubuntu system without gcc-multilib installed),
    the build fails with:

    CLANG skeleton/profiler.bpf.o
    In file included from skeleton/profiler.bpf.c:4:
    In file included from /usr/include/linux/bpf.h:11:
    /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
    #include
    ^~~~~~~~~~~~~
    1 error generated.
    make: *** [Makefile:123: skeleton/profiler.bpf.o] Error 1

    This indicates that the build is using linux/types.h from system headers
    instead of source tree headers.

    To fix this, adjust the clang search path to include the necessary
    headers from tools/testing/selftests/bpf/include/uapi and
    tools/include/uapi. Also use __bitwise__ instead of __bitwise in
    skeleton/profiler.h to avoid clashing with the definition in
    tools/testing/selftests/bpf/include/uapi/linux/types.h.

    Signed-off-by: Tobias Klauser
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200312130330.32239-1-tklauser@distanz.ch

    Tobias Klauser
     

11 Mar, 2020

1 commit

  • Libbpf compiles and runs subset of selftests on each PR in its Github mirror
    repository. To allow still building up-to-date selftests against outdated
    kernel images, add back BPF_F_CURRENT_CPU definitions back.

    N.B. BCC's runqslower version ([0]) doesn't need BPF_F_CURRENT_CPU due to use of
    locally checked in vmlinux.h, generated against kernel with 1aae4bdd7879 ("bpf:
    Switch BPF UAPI #define constants used from BPF program side to enums")
    applied.

    [0] https://github.com/iovisor/bcc/pull/2809

    Fixes: 367d82f17eff (" tools/runqslower: Drop copy/pasted BPF_F_CURRENT_CPU definiton")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20200311043010.530620-1-andriin@fb.com

    Andrii Nakryiko
     

10 Mar, 2020

11 commits

  • allows to run the tests with fixed receive buffer by passing
    "-R " to mptcp_connect.sh.

    While at it, add a default 10 second poll timeout so the "-t"
    becomes optional -- this makes mptcp_connect simpler to use
    during manual testing.

    Signed-off-by: Florian Westphal
    Signed-off-by: David S. Miller

    Florian Westphal
     
  • Pull Ktest fixes and clean ups from Steven Rostedt:

    - Make the default option oldconfig instead of randconfig (one too many
    times I lost my config because I left the build type out)

    - Add timeout to ssh sync to sync before reboot (prevents test hangs)

    - A couple of spelling fix patches

    * tag 'ktest-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
    ktest: Fix typos in ktest.pl
    ktest: Add timeout for ssh sync testing
    ktest: Make default build option oldconfig not randconfig
    ktest: Fix some typos in sample.conf

    Linus Torvalds
     
  • _bpftool_get_map_names => _bpftool_get_prog_names for prog-attach|detach.

    Fixes: 99f9863a0c45 ("bpftool: Match maps by name")
    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200309173218.2739965-5-songliubraving@fb.com

    Song Liu
     
  • Add bash completion for "bpftool prog profile" command.

    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200309173218.2739965-4-songliubraving@fb.com

    Song Liu
     
  • Add documentation for the new bpftool prog profile command.

    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200309173218.2739965-3-songliubraving@fb.com

    Song Liu
     
  • With fentry/fexit programs, it is possible to profile BPF program with
    hardware counters. Introduce bpftool "prog profile", which measures key
    metrics of a BPF program.

    bpftool prog profile command creates per-cpu perf events. Then it attaches
    fentry/fexit programs to the target BPF program. The fentry program saves
    perf event value to a map. The fexit program reads the perf event again,
    and calculates the difference, which is the instructions/cycles used by
    the target program.

    Example input and output:

    ./bpftool prog profile id 337 duration 3 cycles instructions llc_misses

    4228 run_cnt
    3403698 cycles (84.08%)
    3525294 instructions # 1.04 insn per cycle (84.05%)
    13 llc_misses # 3.69 LLC misses per million isns (83.50%)

    This command measures cycles and instructions for BPF program with id
    337 for 3 seconds. The program has triggered 4228 times. The rest of the
    output is similar to perf-stat. In this example, the counters were only
    counting ~84% of the time because of time multiplexing of perf counters.

    Note that, this approach measures cycles and instructions in very small
    increments. So the fentry/fexit programs introduce noticeable errors to
    the measurement results.

    The fentry/fexit programs are generated with BPF skeletons. Therefore, we
    build bpftool twice. The first time _bpftool is built without skeletons.
    Then, _bpftool is used to generate the skeletons. The second time, bpftool
    is built with skeletons.

    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Acked-by: Yonghong Song
    Link: https://lore.kernel.org/bpf/20200309173218.2739965-2-songliubraving@fb.com

    Song Liu
     
  • Remove the guard that disables UDP tests now that sockmap
    has support for them.

    Signed-off-by: Lorenz Bauer
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jakub Sitnicki
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200309111243.6982-12-lmb@cloudflare.com

    Lorenz Bauer
     
  • Expand the TCP sockmap test suite to also check UDP sockets.

    Signed-off-by: Jakub Sitnicki
    Signed-off-by: Lorenz Bauer
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200309111243.6982-11-lmb@cloudflare.com

    Lorenz Bauer
     
  • Most tests for TCP sockmap can be adapted to UDP sockmap if the
    listen call is skipped. Rename listen_loopback, etc. to socket_loopback
    and skip listen() for SOCK_DGRAM.

    Signed-off-by: Lorenz Bauer
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jakub Sitnicki
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200309111243.6982-10-lmb@cloudflare.com

    Lorenz Bauer
     
  • This patch fixes multipe spelling typo found in ktest.pl.

    Link: http://lkml.kernel.org/r/20200309115430.57540-1-standby24x7@gmail.com

    Acked-by: Randy Dunlap
    Signed-off-by: Masanari Iida
    Signed-off-by: Steven Rostedt (VMware)

    Masanari Iida
     
  • Before rebooting the box, a "ssh sync" is called to the test machine to see
    if it is alive or not. But if the test machine is in a partial state, that
    ssh may never actually finish, and the ktest test hangs.

    Add a 10 second timeout to the sync test, which will fail after 10 seconds
    and then cause the test to reboot the test machine.

    Cc: stable@vger.kernel.org
    Fixes: 6474ace999edd ("ktest.pl: Powercycle the box on reboot if no connection can be made")
    Signed-off-by: Steven Rostedt (VMware)

    Steven Rostedt (VMware)