1. 06 10月, 2021 2 次提交
  2. 28 9月, 2021 1 次提交
    • J
      selftests, bpf: Fix makefile dependencies on libbpf · d888eaac
      Jiri Benc 提交于
      When building bpf selftest with make -j, I'm randomly getting build failures
      such as this one:
      
        In file included from progs/bpf_flow.c:19:
        [...]/tools/testing/selftests/bpf/tools/include/bpf/bpf_helpers.h:11:10: fatal error: 'bpf_helper_defs.h' file not found
        #include "bpf_helper_defs.h"
                 ^~~~~~~~~~~~~~~~~~~
      
      The file that fails the build varies between runs but it's always in the
      progs/ subdir.
      
      The reason is a missing make dependency on libbpf for the .o files in
      progs/. There was a dependency before commit 3ac2e20f but that commit
      removed it to prevent unneeded rebuilds. However, that only works if libbpf
      has been built already; the 'wildcard' prerequisite does not trigger when
      there's no bpf_helper_defs.h generated yet.
      
      Keep the libbpf as an order-only prerequisite to satisfy both goals. It is
      always built before the progs/ objects but it does not trigger unnecessary
      rebuilds by itself.
      
      Fixes: 3ac2e20f ("selftests/bpf: BPF object files should depend only on libbpf headers")
      Signed-off-by: NJiri Benc <jbenc@redhat.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/ee84ab66436fba05a197f952af23c98d90eb6243.1632758415.git.jbenc@redhat.com
      d888eaac
  3. 18 9月, 2021 1 次提交
  4. 10 9月, 2021 1 次提交
    • Q
      libbpf: Add LIBBPF_DEPRECATED_SINCE macro for scheduling API deprecations · 0b46b755
      Quentin Monnet 提交于
      Introduce a macro LIBBPF_DEPRECATED_SINCE(major, minor, message) to prepare
      the deprecation of two API functions. This macro marks functions as deprecated
      when libbpf's version reaches the values passed as an argument.
      
      As part of this change libbpf_version.h header is added with recorded major
      (LIBBPF_MAJOR_VERSION) and minor (LIBBPF_MINOR_VERSION) libbpf version macros.
      They are now part of libbpf public API and can be relied upon by user code.
      libbpf_version.h is installed system-wide along other libbpf public headers.
      
      Due to this new build-time auto-generated header, in-kernel applications
      relying on libbpf (resolve_btfids, bpftool, bpf_preload) are updated to
      include libbpf's output directory as part of a list of include search paths.
      Better fix would be to use libbpf's make_install target to install public API
      headers, but that clean up is left out as a future improvement. The build
      changes were tested by building kernel (with KBUILD_OUTPUT and O= specified
      explicitly), bpftool, libbpf, selftests/bpf, and resolve_btfids builds. No
      problems were detected.
      
      Note that because of the constraints of the C preprocessor we have to write
      a few lines of macro magic for each version used to prepare deprecation (0.6
      for now).
      
      Also, use LIBBPF_DEPRECATED_SINCE() to schedule deprecation of
      btf__get_from_id() and btf__load(), which are replaced by
      btf__load_from_kernel_by_id() and btf__load_into_kernel(), respectively,
      starting from future libbpf v0.6. This is part of libbpf 1.0 effort ([0]).
      
        [0] Closes: https://github.com/libbpf/libbpf/issues/278Co-developed-by: NQuentin Monnet <quentin@isovalent.com>
      Co-developed-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20210908213226.1871016-1-andrii@kernel.org
      0b46b755
  5. 25 8月, 2021 1 次提交
  6. 05 8月, 2021 1 次提交
  7. 26 5月, 2021 1 次提交
    • H
      selftests/bpf: Add xdp_redirect_multi test · d2329247
      Hangbin Liu 提交于
      Add a bpf selftest for new helper xdp_redirect_map_multi(). In this
      test there are 3 forward groups and 1 exclude group. The test will
      redirect each interface's packets to all the interfaces in the forward
      group, and exclude the interface in exclude map.
      
      Two maps (DEVMAP, DEVMAP_HASH) and two xdp modes (generic, drive) will
      be tested. XDP egress program will also be tested by setting pkt src MAC
      to egress interface's MAC address.
      
      For more test details, you can find it in the test script. Here is
      the test result.
      ]# time ./test_xdp_redirect_multi.sh
      Pass: xdpgeneric arp(F_BROADCAST) ns1-1
      Pass: xdpgeneric arp(F_BROADCAST) ns1-2
      Pass: xdpgeneric arp(F_BROADCAST) ns1-3
      Pass: xdpgeneric IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1
      Pass: xdpgeneric IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2
      Pass: xdpgeneric IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3
      Pass: xdpgeneric IPv6 (no flags) ns1-1
      Pass: xdpgeneric IPv6 (no flags) ns1-2
      Pass: xdpdrv arp(F_BROADCAST) ns1-1
      Pass: xdpdrv arp(F_BROADCAST) ns1-2
      Pass: xdpdrv arp(F_BROADCAST) ns1-3
      Pass: xdpdrv IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-1
      Pass: xdpdrv IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-2
      Pass: xdpdrv IPv4 (F_BROADCAST|F_EXCLUDE_INGRESS) ns1-3
      Pass: xdpdrv IPv6 (no flags) ns1-1
      Pass: xdpdrv IPv6 (no flags) ns1-2
      Pass: xdpegress mac ns1-2
      Pass: xdpegress mac ns1-3
      Summary: PASS 18, FAIL 0
      
      real    1m18.321s
      user    0m0.123s
      sys     0m0.350s
      Signed-off-by: NHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/bpf/20210519090747.1655268-5-liuhangbin@gmail.com
      d2329247
  8. 19 5月, 2021 3 次提交
  9. 25 4月, 2021 1 次提交
    • M
      tools: do not include scripts/Kbuild.include · b61442df
      Masahiro Yamada 提交于
      Since commit 57fd251c ("kbuild: split cc-option and friends to
      scripts/Makefile.compiler"), some kselftests fail to build.
      
      The tools/ directory opted out Kbuild, and went in a different
      direction. People copied scripts and Makefiles to the tools/ directory
      to create their own build system.
      
      tools/build/Build.include mimics scripts/Kbuild.include, but some
      tool Makefiles include the Kbuild one to import a feature that is
      missing in tools/build/Build.include:
      
       - Commit ec04aa3a ("tools/thermal: tmon: use "-fstack-protector"
         only if supported") included scripts/Kbuild.include from
         tools/thermal/tmon/Makefile to import the cc-option macro.
      
       - Commit c2390f16 ("selftests: kvm: fix for compilers that do
         not support -no-pie") included scripts/Kbuild.include from
         tools/testing/selftests/kvm/Makefile to import the try-run macro.
      
       - Commit 9cae4ace ("selftests/bpf: do not ignore clang
         failures") included scripts/Kbuild.include from
         tools/testing/selftests/bpf/Makefile to import the .DELETE_ON_ERROR
         target.
      
       - Commit 0695f8bc ("selftests/powerpc: Handle Makefile for
         unrecognized option") included scripts/Kbuild.include from
         tools/testing/selftests/powerpc/pmu/ebb/Makefile to import the
         try-run macro.
      
      Copy what they need into tools/build/Build.include, and make them
      include it instead of scripts/Kbuild.include.
      
      Link: https://lore.kernel.org/lkml/86dadf33-70f7-a5ac-cb8c-64966d2f45a1@linux.ibm.com/
      Fixes: 57fd251c ("kbuild: split cc-option and friends to scripts/Makefile.compiler")
      Reported-by: NJanosch Frank <frankja@linux.ibm.com>
      Reported-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Acked-by: NYonghong Song <yhs@fb.com>
      b61442df
  10. 24 4月, 2021 5 次提交
  11. 21 4月, 2021 1 次提交
  12. 16 4月, 2021 2 次提交
    • Y
      selftests/bpf: Silence clang compilation warnings · ef998589
      Yonghong Song 提交于
      With clang compiler:
        make -j60 LLVM=1 LLVM_IAS=1  <=== compile kernel
        make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1
      Some linker flags are not used/effective for some binaries and
      we have warnings like:
        warning: -lelf: 'linker' input unused [-Wunused-command-line-argument]
      
      We also have warnings like:
        .../selftests/bpf/prog_tests/ns_current_pid_tgid.c:74:57: note: treat the string as an argument to avoid this
              if (CHECK(waitpid(cpid, &wstatus, 0) == -1, "waitpid", strerror(errno)))
                                                                     ^
                                                                     "%s",
        .../selftests/bpf/test_progs.h:129:35: note: expanded from macro 'CHECK'
              _CHECK(condition, tag, duration, format)
                                               ^
        .../selftests/bpf/test_progs.h:108:21: note: expanded from macro '_CHECK'
                      fprintf(stdout, ##format);                              \
                                        ^
      The first warning can be silenced with clang option -Wno-unused-command-line-argument.
      For the second warning, source codes are modified as suggested by the compiler
      to silence the warning. Since gcc does not support the option
      -Wno-unused-command-line-argument and the warning only happens with clang
      compiler, the option -Wno-unused-command-line-argument is enabled only when
      clang compiler is used.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210413153429.3029377-1-yhs@fb.com
      ef998589
    • Y
      selftests/bpf: Fix test_cpp compilation failure with clang · a22c0c81
      Yonghong Song 提交于
      With clang compiler:
        make -j60 LLVM=1 LLVM_IAS=1  <=== compile kernel
        make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1
      the test_cpp build failed due to the failure:
        warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
        clang-13: error: cannot specify -o when generating multiple output files
      
      test_cpp compilation flag looks like:
        clang++ -g -Og -rdynamic -Wall -I<...> ... \
        -Dbpf_prog_load=bpf_prog_test_load -Dbpf_load_program=bpf_test_load_program \
        test_cpp.cpp <...>/test_core_extern.skel.h <...>/libbpf.a <...>/test_stub.o \
        -lcap -lelf -lz -lrt -lpthread -o <...>/test_cpp
      
      The clang++ compiler complains the header file in the command line and
      also failed the compilation due to this.
      Let us remove the header file from the command line which is not intended
      any way, and this fixed the compilation problem.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210413153424.3028986-1-yhs@fb.com
      a22c0c81
  13. 19 3月, 2021 3 次提交
  14. 17 3月, 2021 1 次提交
  15. 09 3月, 2021 1 次提交
  16. 05 3月, 2021 1 次提交
  17. 27 2月, 2021 1 次提交
  18. 12 2月, 2021 1 次提交
  19. 29 1月, 2021 1 次提交
    • S
      tools: Factor Clang, LLC and LLVM utils definitions · 211a741c
      Sedat Dilek 提交于
      When dealing with BPF/BTF/pahole and DWARF v5 I wanted to build bpftool.
      
      While looking into the source code I found duplicate assignments in misc tools
      for the LLVM eco system, e.g. clang and llvm-objcopy.
      
      Move the Clang, LLC and/or LLVM utils definitions to tools/scripts/Makefile.include
      file and add missing includes where needed. Honestly, I was inspired by the commit
      c8a950d0 ("tools: Factor HOSTCC, HOSTLD, HOSTAR definitions").
      
      I tested with bpftool and perf on Debian/testing AMD64 and LLVM/Clang v11.1.0-rc1.
      
      Build instructions:
      
      [ make and make-options ]
      MAKE="make V=1"
      MAKE_OPTS="HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld LLVM=1 LLVM_IAS=1"
      MAKE_OPTS="$MAKE_OPTS PAHOLE=/opt/pahole/bin/pahole"
      
      [ clean-up ]
      $MAKE $MAKE_OPTS -C tools/ clean
      
      [ bpftool ]
      $MAKE $MAKE_OPTS -C tools/bpf/bpftool/
      
      [ perf ]
      PYTHON=python3 $MAKE $MAKE_OPTS -C tools/perf/
      
      I was careful with respecting the user's wish to override custom compiler, linker,
      GNU/binutils and/or LLVM utils settings.
      Signed-off-by: NSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Acked-by: Jiri Olsa <jolsa@redhat.com> # tools/build and tools/perf
      Link: https://lore.kernel.org/bpf/20210128015117.20515-1-sedat.dilek@gmail.com
      211a741c
  20. 21 1月, 2021 1 次提交
  21. 15 1月, 2021 1 次提交
    • B
      bpf: Add tests for new BPF atomic operations · 98d666d0
      Brendan Jackman 提交于
      The prog_test that's added depends on Clang/LLVM features added by
      Yonghong in commit 286daafd6512 (was https://reviews.llvm.org/D72184).
      
      Note the use of a define called ENABLE_ATOMICS_TESTS: this is used
      to:
      
       - Avoid breaking the build for people on old versions of Clang
       - Avoid needing separate lists of test objects for no_alu32, where
         atomics are not supported even if Clang has the feature.
      
      The atomics_test.o BPF object is built unconditionally both for
      test_progs and test_progs-no_alu32. For test_progs, if Clang supports
      atomics, ENABLE_ATOMICS_TESTS is defined, so it includes the proper
      test code. Otherwise, progs and global vars are defined anyway, as
      stubs; this means that the skeleton user code still builds.
      
      The atomics_test.o userspace object is built once and used for both
      test_progs and test_progs-no_alu32. A variable called skip_tests is
      defined in the BPF object's data section, which tells the userspace
      object whether to skip the atomics test.
      Signed-off-by: NBrendan Jackman <jackmanb@google.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20210114181751.768687-11-jackmanb@google.com
      98d666d0
  22. 14 1月, 2021 5 次提交
  23. 17 12月, 2020 1 次提交
  24. 11 12月, 2020 2 次提交
  25. 10 12月, 2020 1 次提交