24 Feb, 2020

1 commit

  • [ Upstream commit 1162f844030ac1ac7321b5e8f6c9badc7a11428f ]

    Currently, when bpftool cgroup show has an error, no error
    message is printed. This is confusing because the user may think the
    result is empty.

    Before the change:

    $ bpftool cgroup show /sys/fs/cgroup
    ID AttachType AttachFlags Name
    $ echo $?
    255

    After the change:
    $ ./bpftool cgroup show /sys/fs/cgroup
    Error: can't query bpf programs attached to /sys/fs/cgroup: Operation
    not permitted

    v2: Rename check_query_cgroup_progs to cgroup_has_attached_progs

    Signed-off-by: Hechao Li
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20191224011742.3714301-1-hechaol@fb.com
    Signed-off-by: Sasha Levin

    Hechao Li
     

15 Feb, 2020

1 commit

  • commit d95f1e8b462c4372ac409886070bb8719d8a4d3a upstream.

    Turns out the xlated program instructions can also be missing if
    kptr_restrict sysctl is set. This means that the previous fix to check the
    jited_prog_insns pointer was insufficient; add another check of the
    xlated_prog_insns pointer as well.

    Fixes: 5b79bcdf0362 ("bpftool: Don't crash on missing jited insns or ksyms")
    Fixes: cae73f233923 ("bpftool: use bpf_program__get_prog_info_linear() in prog.c:do_dump()")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200206102906.112551-1-toke@redhat.com
    Signed-off-by: Greg Kroah-Hartman

    Toke Høiland-Jørgensen
     

23 Jan, 2020

1 commit

  • commit 555089fdfc37ad65e0ee9b42ca40c238ff546f83 upstream.

    For plain text output, it incorrectly prints the pointer value
    "void *data". The "void *data" is actually pointing to memory that
    contains a bpf-map's value. The intention is to print the content of
    the bpf-map's value instead of printing the pointer pointing to the
    bpf-map's value.

    In this case, a member of the bpf-map's value is a pointer type.
    Thus, it should print the "*(void **)data".

    Fixes: 22c349e8db89 ("tools: bpftool: fix format strings and arguments for jsonw_printf()")
    Signed-off-by: Martin KaFai Lau
    Signed-off-by: Alexei Starovoitov
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200110231644.3484151-1-kafai@fb.com
    Signed-off-by: Greg Kroah-Hartman

    Martin KaFai Lau
     

12 Jan, 2020

1 commit

  • [ Upstream commit 5b79bcdf03628a3a9ee04d9cd5fabcf61a8e20be ]

    When the kptr_restrict sysctl is set, the kernel can fail to return
    jited_ksyms or jited_prog_insns, but still have positive values in
    nr_jited_ksyms and jited_prog_len. This causes bpftool to crash when
    trying to dump the program because it only checks the len fields not
    the actual pointers to the instructions and ksyms.

    Fix this by adding the missing checks.

    Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
    Fixes: f84192ee00b7 ("tools: bpftool: resolve calls without using imm field")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Daniel Borkmann
    Acked-by: Martin KaFai Lau
    Link: https://lore.kernel.org/bpf/20191210181412.151226-1-toke@redhat.com
    Signed-off-by: Sasha Levin

    Toke Høiland-Jørgensen
     

31 Dec, 2019

1 commit

  • [ Upstream commit a89b2cbf71d64b61e79bbe5cb7ff4664797eeaaf ]

    Building selftests with 'make TARGETS=bpf kselftest' was fixed in commit
    55d554f5d140 ("tools: bpf: Use !building_out_of_srctree to determine
    srctree"). However, by updating $(srctree) in tools/bpf/Makefile for
    in-tree builds only, we leave out the case where we pass an output
    directory to build BPF tools, but $(srctree) is not set. This
    typically happens for:

    $ make -s tools/bpf O=/tmp/foo
    Makefile:40: /tools/build/Makefile.feature: No such file or directory

    Fix it by updating $(srctree) in the Makefile not only for out-of-tree
    builds, but also if $(srctree) is empty.

    Detected with test_bpftool_build.sh.

    Fixes: 55d554f5d140 ("tools: bpf: Use !building_out_of_srctree to determine srctree")
    Signed-off-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann
    Acked-by: Jakub Kicinski
    Link: https://lore.kernel.org/bpf/20191119105626.21453-1-quentin.monnet@netronome.com
    Signed-off-by: Sasha Levin

    Quentin Monnet
     

30 Sep, 2019

1 commit

  • make TARGETS=bpf kselftest fails with:

    Makefile:127: tools/build/Makefile.include: No such file or directory

    When the bpf tool make is invoked from tools Makefile, srctree is
    cleared and the current logic check for srctree equals to empty
    string to determine srctree location from CURDIR.

    When the build in invoked from selftests/bpf Makefile, the srctree
    is set to "." and the same logic used for srctree equals to empty is
    needed to determine srctree.

    Check building_out_of_srctree undefined as the condition for both
    cases to fix "make TARGETS=bpf kselftest" build failure.

    Signed-off-by: Shuah Khan
    Signed-off-by: Daniel Borkmann
    Acked-by: Song Liu
    Link: https://lore.kernel.org/bpf/20190927011344.4695-1-skhan@linuxfoundation.org

    Shuah Khan
     

06 Sep, 2019

1 commit

  • Daniel Borkmann says:

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

    The main changes are:

    1) Add the ability to use unaligned chunks in the AF_XDP umem. By
    relaxing where the chunks can be placed, it allows to use an
    arbitrary buffer size and place whenever there is a free
    address in the umem. Helps more seamless DPDK AF_XDP driver
    integration. Support for i40e, ixgbe and mlx5e, from Kevin and
    Maxim.

    2) Addition of a wakeup flag for AF_XDP tx and fill rings so the
    application can wake up the kernel for rx/tx processing which
    avoids busy-spinning of the latter, useful when app and driver
    is located on the same core. Support for i40e, ixgbe and mlx5e,
    from Magnus and Maxim.

    3) bpftool fixes for printf()-like functions so compiler can actually
    enforce checks, bpftool build system improvements for custom output
    directories, and addition of 'bpftool map freeze' command, from Quentin.

    4) Support attaching/detaching XDP programs from 'bpftool net' command,
    from Daniel.

    5) Automatic xskmap cleanup when AF_XDP socket is released, and several
    barrier/{read,write}_once fixes in AF_XDP code, from Björn.

    6) Relicense of bpf_helpers.h/bpf_endian.h for future libbpf
    inclusion as well as libbpf versioning improvements, from Andrii.

    7) Several new BPF kselftests for verifier precision tracking, from Alexei.

    8) Several BPF kselftest fixes wrt endianess to run on s390x, from Ilya.

    9) And more BPF kselftest improvements all over the place, from Stanislav.

    10) Add simple BPF map op cache for nfp driver to batch dumps, from Jakub.

    11) AF_XDP socket umem mapping improvements for 32bit archs, from Ivan.

    12) Add BPF-to-BPF call and BTF line info support for s390x JIT, from Yauheni.

    13) Small optimization in arm64 JIT to spare 1 insns for BPF_MOD, from Jerin.

    14) Fix an error check in bpf_tcp_gen_syncookie() helper, from Petar.

    15) Various minor fixes and cleanups, from Nathan, Masahiro, Masanari,
    Peter, Wei, Yue.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

31 Aug, 2019

4 commits

  • In bpftool's Makefile, $(LIBS) includes $(LIBBPF), therefore the library
    is used twice in the linking command. No need to have $(LIBBPF) (from
    $^) on that command, let's do with "$(OBJS) $(LIBS)" (but move $(LIBBPF)
    _before_ the -l flags in $(LIBS)).

    Signed-off-by: Ilya Leoshkevich
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Quentin Monnet
     
  • When building "tools/bpf" from the top of the Linux repository, the
    build system passes a value for the $(OUTPUT) Makefile variable to
    tools/bpf/Makefile and tools/bpf/bpftool/Makefile, which results in
    generating "libbpf/" (for bpftool) and "feature/" (bpf and bpftool)
    directories inside the tree.

    This commit adds such directories to the relevant .gitignore files, and
    edits the Makefiles to ensure they are removed on "make clean". The use
    of "rm" is also made consistent throughout those Makefiles (relies on
    the $(RM) variable, use "--" to prevent interpreting
    $(OUTPUT)/$(DESTDIR) as options.

    v2:
    - New patch.

    Signed-off-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann

    Quentin Monnet
     
  • There are a number of alternative "make" invocations that can be used to
    compile bpftool. The following invocations are expected to work:

    - through the kbuild system, from the top of the repository
    (make tools/bpf)
    - by telling make to change to the bpftool directory
    (make -C tools/bpf/bpftool)
    - by building the BPF tools from tools/
    (cd tools && make bpf)
    - by running make from bpftool directory
    (cd tools/bpf/bpftool && make)

    Additionally, setting the O or OUTPUT variables should tell the build
    system to use a custom output path, for each of these alternatives.

    The following patch fixes the following invocations:

    $ make tools/bpf
    $ make tools/bpf O=
    $ make -C tools/bpf/bpftool OUTPUT=
    $ make -C tools/bpf/bpftool O=
    $ cd tools/ && make bpf O=
    $ cd tools/bpf/bpftool && make OUTPUT=
    $ cd tools/bpf/bpftool && make O=

    After this commit, the build still fails for two variants when passing
    the OUTPUT variable:

    $ make tools/bpf OUTPUT=
    $ cd tools/ && make bpf OUTPUT=

    In order to remember and check what make invocations are supposed to
    work, and to document the ones which do not, a new script is added to
    the BPF selftests. Note that some invocations require the kernel to be
    configured, so the script skips them if no .config file is found.

    v2:
    - In make_and_clean(), set $ERROR to 1 when "make" returns non-zero,
    even if the binary was produced.
    - Run "make clean" from the correct directory (bpf/ instead of bpftool/,
    when relevant).

    Reported-by: Lorenz Bauer
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Quentin Monnet
     
  • Bpftool calls the toplevel Makefile to get the kernel version for the
    sources it is built from. But when the utility is built from the top of
    the kernel repository, it may dump the following error message for
    certain architectures (including x86):

    $ make tools/bpf
    [...]
    make[3]: *** [checkbin] Error 1
    [...]

    This does not prevent bpftool compilation, but may feel disconcerting.
    The "checkbin" arch-dependent target is not supposed to be called for
    target "kernelversion", which is a simple "echo" of the version number.

    It turns out this is caused by the make invocation in tools/bpf/bpftool,
    which attempts to find implicit rules to apply. Extract from debug
    output:

    Reading makefiles...
    Reading makefile 'Makefile'...
    Reading makefile 'scripts/Kbuild.include' (search path) (no ~ expansion)...
    Reading makefile 'scripts/subarch.include' (search path) (no ~ expansion)...
    Reading makefile 'arch/x86/Makefile' (search path) (no ~ expansion)...
    Reading makefile 'scripts/Makefile.kcov' (search path) (no ~ expansion)...
    Reading makefile 'scripts/Makefile.gcc-plugins' (search path) (no ~ expansion)...
    Reading makefile 'scripts/Makefile.kasan' (search path) (no ~ expansion)...
    Reading makefile 'scripts/Makefile.extrawarn' (search path) (no ~ expansion)...
    Reading makefile 'scripts/Makefile.ubsan' (search path) (no ~ expansion)...
    Updating makefiles....
    Considering target file 'scripts/Makefile.ubsan'.
    Looking for an implicit rule for 'scripts/Makefile.ubsan'.
    Trying pattern rule with stem 'Makefile.ubsan'.
    [...]
    Trying pattern rule with stem 'Makefile.ubsan'.
    Trying implicit prerequisite 'scripts/Makefile.ubsan.o'.
    Looking for a rule with intermediate file 'scripts/Makefile.ubsan.o'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem 'Makefile.ubsan'.
    Trying rule prerequisite 'prepare'.
    Trying rule prerequisite 'FORCE'.
    Found an implicit rule for 'scripts/Makefile.ubsan'.
    Considering target file 'prepare'.
    File 'prepare' does not exist.
    Considering target file 'prepare0'.
    File 'prepare0' does not exist.
    Considering target file 'archprepare'.
    File 'archprepare' does not exist.
    Considering target file 'archheaders'.
    File 'archheaders' does not exist.
    Finished prerequisites of target file 'archheaders'.
    Must remake target 'archheaders'.
    Putting child 0x55976f4f6980 (archheaders) PID 31743 on the chain.

    To avoid that, pass the -r and -R flags to eliminate the use of make
    built-in rules (and while at it, built-in variables) when running
    command "make kernelversion" from bpftool's Makefile.

    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Quentin Monnet
     

28 Aug, 2019

1 commit


22 Aug, 2019

2 commits


21 Aug, 2019

1 commit

  • Add a "btf list" (alias: "btf show") subcommand to bpftool in order to
    dump all BTF objects loaded on a system.

    When running the command, hash tables are built in bpftool to retrieve
    all the associations between BTF objects and BPF maps and programs. This
    allows for printing all such associations when listing the BTF objects.

    The command is added at the top of the subcommands for "bpftool btf", so
    that typing only "bpftool btf" also comes down to listing the programs.
    We could not have this with the previous command ("dump"), which
    required a BTF object id, so it should not break any previous behaviour.
    This also makes the "btf" command behaviour consistent with "prog" or
    "map".

    Bash completion is updated to use "bpftool btf" instead of "bpftool
    prog" to list the BTF ids, as it looks more consistent.

    Example output (plain):

    # bpftool btf show
    9: size 2989B prog_ids 21 map_ids 15
    17: size 2847B prog_ids 36 map_ids 30,29,28
    26: size 2847B

    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     

20 Aug, 2019

1 commit


16 Aug, 2019

11 commits

  • When showing metadata about a single program by invoking
    "bpftool prog show PROG", the file descriptor referring to the program
    is not closed before returning from the function. Let's close it.

    Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Acked-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • Some functions in bpftool have a "__printf()" format attributes to tell
    the compiler they should expect printf()-like arguments. But because
    these attributes are not used for the function prototypes in the header
    files, the compiler does not run the checks everywhere the functions are
    used, and some mistakes on format string and corresponding arguments
    slipped in over time.

    Let's move the __printf() attributes to the correct places.

    Note: We add guards around the definition of GCC_VERSION in
    tools/include/linux/compiler-gcc.h to prevent a conflict in jit_disasm.c
    on GCC_VERSION from headers pulled via libbfd.

    Fixes: c101189bc968 ("tools: bpftool: fix -Wmissing declaration warnings")
    Reported-by: Jakub Kicinski
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • There is one call to the p_err() function in detect_common_prefix()
    where the message to print is passed directly as the first argument,
    without using a format string. This is harmless, but may trigger
    warnings if the "__printf()" attribute is used correctly for the p_err()
    function. Let's fix it by using a "%s" format string.

    Fixes: ba95c7452439 ("tools: bpftool: add "prog run" subcommand to test-run programs")
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • The format string passed to one call to the p_err() function in
    query_flow_dissector() does not match the value that should be printed,
    resulting in some garbage integer being printed instead of
    strerror(errno) if /proc/self/ns/net cannot be open. Let's fix the
    format string.

    Fixes: 7f0c57fec80f ("bpftool: show flow_dissector attachment status")
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • The last argument passed to one call to the p_err() function is not
    correct, it should be "*argv" instead of "**argv". This may lead to a
    segmentation fault error if BTF id cannot be parsed correctly. Let's fix
    this.

    Fixes: c93cc69004dt ("bpftool: add ability to dump BTF types")
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • There are some mismatches between format strings and arguments passed to
    jsonw_printf() in the BTF dumper for bpftool, which seems harmless but
    may result in warnings if the "__printf()" attribute is used correctly
    for jsonw_printf(). Let's fix relevant format strings and type cast.

    Fixes: b12d6ec09730 ("bpf: btf: add btf print functionality")
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • The last argument passed to some calls to the p_err() functions is not
    correct, it should be "*argv" instead of "**argv". This may lead to a
    segmentation fault error if CPU IDs or indices from the command line
    cannot be parsed correctly. Let's fix this.

    Fixes: f412eed9dfde ("tools: bpftool: add simple perf event output reader")
    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Alexei Starovoitov

    Quentin Monnet
     
  • Since, new sub-command 'net attach/detach' has been added for
    attaching XDP program on interface,
    this commit documents usage and sample output of `net attach/detach`.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov

    Daniel T. Lee
     
  • This commit adds bash-completion for new "net attach/detach"
    subcommand for attaching XDP program on interface.

    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov

    Daniel T. Lee
     
  • By this commit, using `bpftool net detach`, the attached XDP prog can
    be detached. Detaching the BPF prog will be done through libbpf
    'bpf_set_link_xdp_fd' with the progfd set to -1.

    Acked-by: Yonghong Song
    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov

    Daniel T. Lee
     
  • By this commit, using `bpftool net attach`, user can attach XDP prog on
    interface. New type of enum 'net_attach_type' has been made, as stat ted at
    cover-letter, the meaning of 'attach' is, prog will be attached on interface.

    With 'overwrite' option at argument, attached XDP program could be replaced.
    Added new helper 'net_parse_dev' to parse the network device at argument.

    BPF prog will be attached through libbpf 'bpf_set_link_xdp_fd'.

    Acked-by: Yonghong Song
    Signed-off-by: Daniel T. Lee
    Signed-off-by: Alexei Starovoitov

    Daniel T. Lee
     

15 Aug, 2019

1 commit

  • Compile bpftool with $(EXTRA_WARNINGS), as defined in
    scripts/Makefile.include, and fix the new warnings produced.

    Simply leave -Wswitch-enum out of the warning list, as we have several
    switch-case structures where it is not desirable to process all values
    of an enum.

    Remove -Wshadow from the warnings we manually add to CFLAGS, as it is
    handled in $(EXTRA_WARNINGS).

    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Quentin Monnet
     

13 Aug, 2019

1 commit

  • bpftool requires libelf, and zlib for decompressing /proc/config.gz.
    zlib is a transitive dependency via libelf, and became mandatory since
    elfutils 0.165 (Jan 2016). The feature check of libelf is already done
    in the elfdep target of tools/lib/bpf/Makefile, pulled in by bpftool via
    a dependency on libbpf.a. Add a similar feature check for zlib.

    Suggested-by: Jakub Kicinski
    Signed-off-by: Peter Wu
    Acked-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Peter Wu
     

12 Aug, 2019

1 commit

  • /proc/config has never existed as far as I can see, but /proc/config.gz
    is present on Arch Linux. Add support for decompressing config.gz using
    zlib which is a mandatory dependency of libelf anyway. Replace existing
    stdio functions with gzFile operations since the latter transparently
    handles uncompressed and gzip-compressed files.

    Cc: Quentin Monnet
    Signed-off-by: Peter Wu
    Reviewed-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann

    Peter Wu
     

09 Aug, 2019

2 commits


31 Jul, 2019

1 commit

  • Takshak said in the original submission:

    With different bpf attach_flags available to attach bpf programs specially
    with BPF_F_ALLOW_OVERRIDE and BPF_F_ALLOW_MULTI, the list of effective
    bpf-programs available to any sub-cgroups really needs to be available for
    easy debugging.

    Using BPF_F_QUERY_EFFECTIVE flag, one can get the list of not only attached
    bpf-programs to a cgroup but also the inherited ones from parent cgroup.

    So a new option is introduced to use BPF_F_QUERY_EFFECTIVE query flag here
    to list all the effective bpf-programs available for execution at a specified
    cgroup.

    Reused modified test program test_cgroup_attach from tools/testing/selftests/bpf:
    # ./test_cgroup_attach

    With old bpftool:

    # bpftool cgroup show /sys/fs/cgroup/cgroup-test-work-dir/cg1/
    ID AttachType AttachFlags Name
    271 egress multi pkt_cntr_1
    272 egress multi pkt_cntr_2

    Attached new program pkt_cntr_4 in cg2 gives following:

    # bpftool cgroup show /sys/fs/cgroup/cgroup-test-work-dir/cg1/cg2
    ID AttachType AttachFlags Name
    273 egress override pkt_cntr_4

    And with new "effective" option it shows all effective programs for cg2:

    # bpftool cgroup show /sys/fs/cgroup/cgroup-test-work-dir/cg1/cg2 effective
    ID AttachType AttachFlags Name
    273 egress override pkt_cntr_4
    271 egress override pkt_cntr_1
    272 egress override pkt_cntr_2

    Compared to original submission use a local flag instead of global
    option.

    We need to clear query_flags on every command, in case batch mode
    wants to use varying settings.

    v2: (Takshak)
    - forbid duplicated flags;
    - fix cgroup path freeing.

    Signed-off-by: Takshak Chahande
    Signed-off-by: Jakub Kicinski
    Reviewed-by: Quentin Monnet
    Reviewed-by: Takshak Chahande
    Signed-off-by: Alexei Starovoitov

    Jakub Kicinski
     

30 Jul, 2019

1 commit


12 Jul, 2019

1 commit

  • From commit 9df1c28bb752 ("bpf: add writable context for raw tracepoints"),
    a new type of BPF_PROG, RAW_TRACEPOINT_WRITABLE has been added.

    Since this BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE is not listed at
    bpftool's header, it causes a segfault when executing 'bpftool feature'.

    This commit adds BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE entry to
    prog_type_name enum, and will eventually fixes the segfault issue.

    Fixes: 9df1c28bb752 ("bpf: add writable context for raw tracepoints")
    Signed-off-by: Daniel T. Lee
    Signed-off-by: Daniel Borkmann

    Daniel T. Lee
     

09 Jul, 2019

1 commit


08 Jul, 2019

2 commits

  • Bash completion for proposing the "loadall" subcommand is missing. Let's
    add it to the completion script.

    Add a specific case to propose "load" and "loadall" for completing:

    $ bpftool prog load
    ^ cursor is here

    Otherwise, completion considers that $command is in load|loadall and
    starts making related completions (file or directory names, as the
    number of words on the command line is below 6), when the only suggested
    keywords should be "load" and "loadall" until one has been picked and a
    space entered after that to move to the next word.

    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Quentin Monnet
     
  • Switch event_pipe implementation to rely on new libbpf perf buffer API
    (it's raw low-level variant).

    Signed-off-by: Andrii Nakryiko
    Acked-by: Jakub Kicinski
    Acked-by: Yonghong Song
    Signed-off-by: Daniel Borkmann

    Andrii Nakryiko
     

06 Jul, 2019

2 commits

  • Michael reported crash with by bpf program in json mode on powerpc:

    # bpftool prog -p dump jited id 14
    [{
    "name": "0xd00000000a9aa760",
    "insns": [{
    "pc": "0x0",
    "operation": "nop",
    "operands": [null
    ]
    },{
    "pc": "0x4",
    "operation": "nop",
    "operands": [null
    ]
    },{
    "pc": "0x8",
    "operation": "mflr",
    Segmentation fault (core dumped)

    The code is assuming char pointers in format, which is not always
    true at least for powerpc. Fixing this by dumping the whole string
    into buffer based on its format.

    Please note that libopcodes code does not check return values from
    fprintf callback, but as per Jakub suggestion returning -1 on allocation
    failure so we do the best effort to propagate the error.

    Fixes: 107f041212c1 ("tools: bpftool: add JSON output for `bpftool prog dump jited *` command")
    Reported-by: Michael Petlan
    Signed-off-by: Jiri Olsa
    Reviewed-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Daniel Borkmann

    Jiri Olsa
     
  • Add a new "bpftool prog run" subcommand to run a loaded program on input
    data (and possibly with input context) passed by the user.

    Print output data (and output context if relevant) into a file or into
    the console. Print return value and duration for the test run into the
    console.

    A "repeat" argument can be passed to run the program several times in a
    row.

    The command does not perform any kind of verification based on program
    type (Is this program type allowed to use an input context?) or on data
    consistency (Can I work with empty input data?), this is left to the
    kernel.

    Example invocation:

    # perl -e 'print "\x0" x 14' | ./bpftool prog run \
    pinned /sys/fs/bpf/sample_ret0 \
    data_in - data_out - repeat 5
    0000000 0000 0000 0000 0000 0000 0000 0000 | ........ ......
    Return value: 0, duration (average): 260ns

    When one of data_in or ctx_in is "-", bpftool reads from standard input,
    in binary format. Other formats (JSON, hexdump) might be supported (via
    an optional command line keyword like "data_fmt_in") in the future if
    relevant, but this would require doing more parsing in bpftool.

    v2:
    - Fix argument names for function check_single_stdin(). (Yonghong)

    Signed-off-by: Quentin Monnet
    Reviewed-by: Jakub Kicinski
    Acked-by: Yonghong Song
    Signed-off-by: Daniel Borkmann

    Quentin Monnet