1. 01 12月, 2018 6 次提交
  2. 30 11月, 2018 1 次提交
    • Y
      tools/bpf: make libbpf _GNU_SOURCE friendly · b4269954
      Yonghong Song 提交于
      During porting libbpf to bcc, I got some warnings like below:
        ...
        [  2%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf.c.o
        /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf.c:12:0:
        warning: "_GNU_SOURCE" redefined [enabled by default]
         #define _GNU_SOURCE
        ...
        [  3%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf_errno.c.o
        /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c: In function ‘libbpf_strerror’:
        /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c:45:7:
        warning: assignment makes integer from pointer without a cast [enabled by default]
           ret = strerror_r(err, buf, size);
        ...
      
      bcc is built with _GNU_SOURCE defined and this caused the above warning.
      This patch intends to make libpf _GNU_SOURCE friendly by
        . define _GNU_SOURCE in libbpf.c unless it is not defined
        . undefine _GNU_SOURCE as non-gnu version of strerror_r is expected.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      b4269954
  3. 29 11月, 2018 4 次提交
  4. 27 11月, 2018 5 次提交
    • A
      libbpf: Document API and ABI conventions · 76d1b894
      Andrey Ignatov 提交于
      Document API and ABI for libbpf: naming convention, symbol visibility,
      ABI versioning.
      
      This is just a starting point. Documentation can be significantly
      extended in the future to cover more topics.
      
      ABI versioning section touches only a few basic points with a link to
      more comprehensive documentation from Ulrich Drepper. This section can
      be extended in the future when there is better understanding what works
      well and what not so well in libbpf development process and production
      usage.
      Signed-off-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      76d1b894
    • A
      libbpf: Verify versioned symbols · 306b267c
      Andrey Ignatov 提交于
      Since ABI versioning info is kept separately from the code it's easy to
      forget to update it while adding a new API.
      
      Add simple verification that all global symbols exported with LIBBPF_API
      are versioned in libbpf.map version script.
      
      The idea is to check that number of global symbols in libbpf-in.o, that
      is the input to the linker, matches with number of unique versioned
      symbols in libbpf.so, that is the output of the linker. If these numbers
      don't match, it may mean some symbol was not versioned and make will
      fail.
      
      "Unique" means that if a symbol is present in more than one version of
      ABI due to ABI changes, it'll be counted once.
      
      Another option to calculate number of global symbols in the "input"
      could be to count number of LIBBPF_ABI entries in C headers but it seems
      to be fragile.
      
      Example of output when a symbol is missing in version script:
      
          ...
          LD       libbpf-in.o
          LINK     libbpf.a
          LINK     libbpf.so
        Warning: Num of global symbols in libbpf-in.o (115) does NOT match
        with num of versioned symbols in libbpf.so (114). Please make sure all
        LIBBPF_API symbols are versioned in libbpf.map.
        make: *** [check_abi] Error 1
      Signed-off-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      306b267c
    • A
      libbpf: Add version script for DSO · 16192a77
      Andrey Ignatov 提交于
      More and more projects use libbpf and one day it'll likely be packaged
      and distributed as DSO and that requires ABI versioning so that both
      compatible and incompatible changes to ABI can be introduced in a safe
      way in the future without breaking executables dynamically linked with a
      previous version of the library.
      
      Usual way to do ABI versioning is version script for the linker. Add
      such a script for libbpf. All global symbols currently exported via
      LIBBPF_API macro are added to the version script libbpf.map.
      
      The version name LIBBPF_0.0.1 is constructed from the name of the
      library + version specified by $(LIBBPF_VERSION) in Makefile.
      
      Version script does not duplicate the work done by LIBBPF_API macro, it
      rather complements it. The macro is used at compile time and can be used
      by compiler to do optimization that can't be done at link time, it is
      purely about global symbol visibility. The version script, in turn, is
      used at link time and takes care of ABI versioning. Both techniques are
      described in details in [1].
      
      Whenever ABI is changed in the future, version script should be changed
      appropriately.
      
      [1] https://www.akkadia.org/drepper/dsohowto.pdfSigned-off-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      16192a77
    • M
      libbpf: Name changing for btf_get_from_id · 1d2f44ca
      Martin KaFai Lau 提交于
      s/btf_get_from_id/btf__get_from_id/ to restore the API naming convention.
      Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAndrey Ignatov <rdna@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      1d2f44ca
    • Y
      tools/bpf: change selftest test_btf for both jit and non-jit · 812dd689
      Yonghong Song 提交于
      The selftest test_btf is changed to test both jit and non-jit.
      The test result should be the same regardless of whether jit
      is enabled or not.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      812dd689
  5. 26 11月, 2018 1 次提交
  6. 25 11月, 2018 1 次提交
    • W
      selftests/net: add txring_overwrite · 358be656
      Willem de Bruijn 提交于
      Packet sockets with PACKET_TX_RING send skbs with user data in frags.
      
      Before commit 5cd8d46e ("packet: copy user buffers before orphan
      or clone") ring slots could be released prematurely, possibly allowing
      a process to overwrite data still in flight.
      
      This test opens two packet sockets, one to send and one to read.
      The sender has a tx ring of one slot. It sends two packets with
      different payload, then reads both and verifies their payload.
      
      Before the above commit, both receive calls return the same data as
      the send calls use the same buffer. From the commit, the clone
      needed for looping onto a packet socket triggers an skb_copy_ubufs
      to create a private copy. The separate sends each arrive correctly.
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      358be656
  7. 24 11月, 2018 2 次提交
  8. 23 11月, 2018 2 次提交
  9. 22 11月, 2018 11 次提交
  10. 21 11月, 2018 7 次提交