25 Nov, 2019

2 commits

  • 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

    Quentin Monnet
     
  • When building bpftool, a warning was introduced by commit a94364603610
    ("bpftool: Allow to read btf as raw data"), because the return value
    from a call to 'read()' is ignored. Let's address it.

    Signed-off-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jakub Kicinski
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20191119111706.22440-1-quentin.monnet@netronome.com

    Quentin Monnet
     

07 Nov, 2019

1 commit

  • When compiling larger programs with bpf_asm, it's possible to
    accidentally exceed jt/jf range, in which case it won't complain, but
    rather silently emit a truncated offset, leading to a "happy debugging"
    situation.

    Add a warning to help detecting such issues. It could be made an error
    instead, but this might break compilation of existing code (which might
    be working by accident).

    Signed-off-by: Ilya Leoshkevich
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20191107100349.88976-1-iii@linux.ibm.com

    Ilya Leoshkevich
     

27 Oct, 2019

1 commit

  • Daniel Borkmann says:

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

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

    We've added 52 non-merge commits during the last 11 day(s) which contain
    a total of 65 files changed, 2604 insertions(+), 1100 deletions(-).

    The main changes are:

    1) Revolutionize BPF tracing by using in-kernel BTF to type check BPF
    assembly code. The work here teaches BPF verifier to recognize
    kfree_skb()'s first argument as 'struct sk_buff *' in tracepoints
    such that verifier allows direct use of bpf_skb_event_output() helper
    used in tc BPF et al (w/o probing memory access) that dumps skb data
    into perf ring buffer. Also add direct loads to probe memory in order
    to speed up/replace bpf_probe_read() calls, from Alexei Starovoitov.

    2) Big batch of changes to improve libbpf and BPF kselftests. Besides
    others: generalization of libbpf's CO-RE relocation support to now
    also include field existence relocations, revamp the BPF kselftest
    Makefile to add test runner concept allowing to exercise various
    ways to build BPF programs, and teach bpf_object__open() and friends
    to automatically derive BPF program type/expected attach type from
    section names to ease their use, from Andrii Nakryiko.

    3) Fix deadlock in stackmap's build-id lookup on rq_lock(), from Song Liu.

    4) Allow to read BTF as raw data from bpftool. Most notable use case
    is to dump /sys/kernel/btf/vmlinux through this, from Jiri Olsa.

    5) Use bpf_redirect_map() helper in libbpf's AF_XDP helper prog which
    manages to improve "rx_drop" performance by ~4%., from Björn Töpel.

    6) Fix to restore the flow dissector after reattach BPF test and also
    fix error handling in bpf_helper_defs.h generation, from Jakub Sitnicki.

    7) Improve verifier's BTF ctx access for use outside of raw_tp, from
    Martin KaFai Lau.

    8) Improve documentation for AF_XDP with new sections and to reflect
    latest features, from Magnus Karlsson.

    9) Add back 'version' section parsing to libbpf for old kernels, from
    John Fastabend.

    10) Fix strncat bounds error in libbpf's libbpf_prog_type_by_name(),
    from KP Singh.

    11) Turn on -mattr=+alu32 in LLVM by default for BPF kselftests in order
    to improve insn coverage for built BPF progs, from Yonghong Song.

    12) Misc minor cleanups and fixes, from various others.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

26 Oct, 2019

1 commit

  • The bpftool interface stays the same, but now it's possible
    to run it over BTF raw data, like:

    $ bpftool btf dump file /sys/kernel/btf/vmlinux
    [1] INT '(anon)' size=4 bits_offset=0 nr_bits=32 encoding=(none)
    [2] INT 'long unsigned int' size=8 bits_offset=0 nr_bits=64 encoding=(none)
    [3] CONST '(anon)' type_id=2

    Signed-off-by: Jiri Olsa
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Acked-by: Jakub Kicinski
    Link: https://lore.kernel.org/bpf/20191024133025.10691-1-jolsa@kernel.org

    Jiri Olsa
     

23 Oct, 2019

1 commit

  • LIBBPF_OPTS is implemented as a mix of field declaration and memset
    + assignment. This makes it neither variable declaration nor purely
    statements, which is a problem, because you can't mix it with either
    other variable declarations nor other function statements, because C90
    compiler mode emits warning on mixing all that together.

    This patch changes LIBBPF_OPTS into a strictly declaration of variable
    and solves this problem, as can be seen in case of bpftool, which
    previously would emit compiler warning, if done this way (LIBBPF_OPTS as
    part of function variables declaration block).

    This patch also renames LIBBPF_OPTS into DECLARE_LIBBPF_OPTS to follow
    kernel convention for similar macros more closely.

    v1->v2:
    - rename LIBBPF_OPTS into DECLARE_LIBBPF_OPTS (Jakub Sitnicki).

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Toke Høiland-Jørgensen
    Link: https://lore.kernel.org/bpf/20191022172100.3281465-1-andriin@fb.com

    Andrii Nakryiko
     

21 Oct, 2019

1 commit


08 Oct, 2019

1 commit

  • As part of libbpf in 5e61f2707029 ("libbpf: stop enforcing kern_version,
    populate it for users") non-LIBBPF_API __bpf_object__open_xattr() API
    was removed from libbpf.h header. This broke bpftool, which relied on
    that function. This patch fixes the build by switching to newly added
    bpf_object__open_file() which provides the same capabilities, but is
    official and future-proof API.

    v1->v2:
    - fix prog_type shadowing (Stanislav).

    Fixes: 5e61f2707029 ("libbpf: stop enforcing kern_version, populate it for users")
    Reported-by: Stanislav Fomichev
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Reviewed-by: Stanislav Fomichev
    Link: https://lore.kernel.org/bpf/20191007225604.2006146-1-andriin@fb.com

    Andrii Nakryiko
     

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

1 commit

  • 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