1. 28 10月, 2019 2 次提交
  2. 24 10月, 2019 2 次提交
  3. 23 10月, 2019 1 次提交
  4. 18 10月, 2019 5 次提交
    • A
      selftest/bpf: Remove test_libbpf.sh and test_libbpf_open · cb79a4e1
      Andrii Nakryiko 提交于
      test_progs is much more sophisticated superset of tests compared to
      test_libbpf.sh and test_libbpf_open. Remove test_libbpf.sh and
      test_libbpf_open.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191016060051.2024182-8-andriin@fb.com
      cb79a4e1
    • A
      selftests/bpf: Move test_queue_stack_map.h into progs/ where it belongs · 5ac93074
      Andrii Nakryiko 提交于
      test_queue_stack_map.h is used only from BPF programs. Thus it should be
      part of progs/ subdir. An added benefit of moving it there is that new
      TEST_RUNNER_DEFINE_RULES macro-rule will properly capture dependency on
      this header for all BPF objects and trigger re-build, if it changes.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191016060051.2024182-7-andriin@fb.com
      5ac93074
    • A
      selftests/bpf: Replace test_progs and test_maps w/ general rule · 74b5a596
      Andrii Nakryiko 提交于
      Define test runner generation meta-rule that codifies dependencies
      between test runner, its tests, and its dependent BPF programs. Use that
      for defining test_progs and test_maps test-runners. Also additionally define
      2 flavors of test_progs:
      - alu32, which builds BPF programs with 32-bit registers codegen;
      - bpf_gcc, which build BPF programs using GCC, if it supports BPF target.
      
      Overall, this is accomplished through $(eval)'ing a set of generic
      rules, which defines Makefile targets dynamically at runtime. See
      comments explaining the need for 2 $(evals), though.
      
      For each test runner we have (test_maps and test_progs, currently), and,
      optionally, their flavors, the logic of build process is modeled as
      follows (using test_progs as an example):
      - all BPF objects are in progs/:
        - BPF object's .o file is built into output directory from
          corresponding progs/.c file;
        - all BPF objects in progs/*.c depend on all progs/*.h headers;
        - all BPF objects depend on bpf_*.h helpers from libbpf (but not
          libbpf archive). There is an extra rule to trigger bpf_helper_defs.h
          (re-)build, if it's not present/outdated);
        - build recipe for BPF object can be re-defined per test runner/flavor;
      - test files are built from prog_tests/*.c:
        - all such test file objects are built on individual file basis;
        - currently, every single test file depends on all BPF object files;
          this might be improved in follow up patches to do 1-to-1 dependency,
          but allowing to customize this per each individual test;
        - each test runner definition can specify a list of extra .c and .h
          files to be built along test files and test runner binary; all such
          headers are becoming automatic dependency of each test .c file;
        - due to test files sometimes embedding (using .incbin assembly
          directive) contents of some BPF objects at compilation time, which are
          expected to be in CWD of compiler, compilation for test file object does
          cd into test runner's output directory; to support this mode all the
          include paths are turned into absolute paths using $(abspath) make
          function;
      - prog_tests/test.h is automatically (re-)generated with an entry for
        each .c file in prog_tests/;
      - final test runner binary is linked together from test object files and
        extra object files, linking together libbpf's archive as well;
      - it's possible to specify extra "resource" files/targets, which will be
        copied into test runner output directory, if it differes from
        Makefile-wide $(OUTPUT). This is used to ensure btf_dump test cases and
        urandom_read binary is put into a test runner's CWD for tests to find
        them in runtime.
      
      For flavored test runners, their output directory is a subdirectory of
      common Makefile-wide $(OUTPUT) directory with flavor name used as
      subdirectory name.
      
      BPF objects targets might be reused between different test runners, so
      extra checks are employed to not double-define them. Similarly, we have
      redefinition guards for output directories and test headers.
      
      test_verifier follows slightly different patterns and is simple enough
      to not justify generalizing TEST_RUNNER_DEFINE/TEST_RUNNER_DEFINE_RULES
      further to accomodate these differences. Instead, rules for
      test_verifier are minimized and simplified, while preserving correctness
      of dependencies.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191016060051.2024182-6-andriin@fb.com
      74b5a596
    • A
      selftests/bpf: Add simple per-test targets to Makefile · 03dcb784
      Andrii Nakryiko 提交于
      Currently it's impossible to do `make test_progs` and have only
      test_progs be built, because all the binary targets are defined in terms
      of $(OUTPUT)/<binary>, and $(OUTPUT) is absolute path to current
      directory (or whatever gets overridden to by user).
      
      This patch adds simple re-directing targets for all test targets making
      it possible to do simple and nice `make test_progs` (and any other
      target).
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191016060051.2024182-5-andriin@fb.com
      03dcb784
    • A
      selftests/bpf: Switch test_maps to test_progs' test.h format · ee6c52e9
      Andrii Nakryiko 提交于
      Make test_maps use tests.h header format consistent with the one used by
      test_progs, to facilitate unification.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191016060051.2024182-4-andriin@fb.com
      ee6c52e9
  5. 13 10月, 2019 2 次提交
  6. 10 10月, 2019 1 次提交
  7. 09 10月, 2019 1 次提交
  8. 08 10月, 2019 1 次提交
  9. 07 10月, 2019 1 次提交
  10. 06 10月, 2019 1 次提交
  11. 16 9月, 2019 1 次提交
    • I
      selftests/bpf: add bpf-gcc support · 4ce150b6
      Ilya Leoshkevich 提交于
      Now that binutils and gcc support for BPF is upstream, make use of it in
      BPF selftests using alu32-like approach. Share as much as possible of
      CFLAGS calculation with clang.
      
      Fixes only obvious issues, leaving more complex ones for later:
      - Use gcc-provided bpf-helpers.h instead of manually defining the
        helpers, change bpf_helpers.h include guard to avoid conflict.
      - Include <linux/stddef.h> for __always_inline.
      - Add $(OUTPUT)/../usr/include to include path in order to use local
        kernel headers instead of system kernel headers when building with O=.
      
      In order to activate the bpf-gcc support, one needs to configure
      binutils and gcc with --target=bpf and make them available in $PATH. In
      particular, gcc must be installed as `bpf-gcc`, which is the default.
      
      Right now with binutils 25a2915e8dba and gcc r275589 only a handful of
      tests work:
      
      	# ./test_progs_bpf_gcc
      	# Summary: 7/39 PASSED, 1 SKIPPED, 98 FAILED
      
      The reason for those failures are as follows:
      
      - Build errors:
        - `error: too many function arguments for eBPF` for __always_inline
          functions read_str_var and read_map_var - must be inlining issue,
          and for process_l3_headers_v6, which relies on optimizing away
          function arguments.
        - `error: indirect call in function, which are not supported by eBPF`
          where there are no obvious indirect calls in the source calls, e.g.
          in __encap_ipip_none.
        - `error: field 'lock' has incomplete type` for fields of `struct
          bpf_spin_lock` type - bpf_spin_lock is re#defined by bpf-helpers.h,
          so its usage is sensitive to order of #includes.
        - `error: eBPF stack limit exceeded` in sysctl_tcp_mem.
      - Load errors:
        - Missing object files due to above build errors.
        - `libbpf: failed to create map (name: 'test_ver.bss')`.
        - `libbpf: object file doesn't contain bpf program`.
        - `libbpf: Program '.text' contains unrecognized relo data pointing to
          section 0`.
        - `libbpf: BTF is required, but is missing or corrupted` - no BTF
          support in gcc yet.
      Signed-off-by: NIlya Leoshkevich <iii@linux.ibm.com>
      Cc: Jose E. Marchesi <jose.marchesi@oracle.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      4ce150b6
  12. 07 9月, 2019 6 次提交
  13. 31 8月, 2019 1 次提交
    • Q
      tools: bpftool: improve and check builds for different make invocations · 45c5589d
      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=<dir>
        $ make -C tools/bpf/bpftool OUTPUT=<dir>
        $ make -C tools/bpf/bpftool O=<dir>
        $ cd tools/ && make bpf O=<dir>
        $ cd tools/bpf/bpftool && make OUTPUT=<dir>
        $ cd tools/bpf/bpftool && make O=<dir>
      
      After this commit, the build still fails for two variants when passing
      the OUTPUT variable:
      
        $ make tools/bpf OUTPUT=<dir>
        $ cd tools/ && make bpf OUTPUT=<dir>
      
      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: NLorenz Bauer <lmb@cloudflare.com>
      Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      45c5589d
  14. 21 8月, 2019 2 次提交
  15. 18 8月, 2019 1 次提交
  16. 06 8月, 2019 1 次提交
  17. 28 7月, 2019 2 次提交
  18. 17 7月, 2019 2 次提交
  19. 16 7月, 2019 2 次提交
  20. 12 7月, 2019 2 次提交
  21. 03 7月, 2019 1 次提交
  22. 28 6月, 2019 2 次提交