1. 05 Feb, 2019 3 commits
  2. 04 Feb, 2019 13 commits
    • Alexei Starovoitov's avatar
      Merge branch 'libbpf-btf_ext' · 1728b111
      Alexei Starovoitov authored
      Yonghong Song says:
      
      ====================
      This patch set exposed a few functions in libbpf.
      All these newly added API functions are helpful for
      JIT based bpf compilation where .BTF and .BTF.ext
      are available as in-memory data blobs.
      
      Patch #1 exposed several btf_ext__* API functions which
      are used to handle .BTF.ext ELF sections.
      Patch #2 refactored the function bpf_map_find_btf_info()
      and exposed API function btf__get_map_kv_tids() to
      retrieve the map key/value type id's generated by
      bpf program through BPF_ANNOTATE_KV_PAIR macro.
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      1728b111
    • Yonghong Song's avatar
      tools/bpf: implement libbpf btf__get_map_kv_tids() API function · 96408c43
      Yonghong Song authored
      Currently, to get map key/value type id's, the macro
        BPF_ANNOTATE_KV_PAIR(<map_name>, <key_type>, <value_type>)
      needs to be defined in the bpf program for the
      corresponding map.
      
      During program/map loading time,
      the local static function bpf_map_find_btf_info()
      in libbpf.c is implemented to retrieve the key/value
      type ids given the map name.
      
      The patch refactored function bpf_map_find_btf_info()
      to create an API btf__get_map_kv_tids() which includes
      the bulk of implementation for the original function.
      The API btf__get_map_kv_tids() can be used by bcc,
      a JIT based bpf compilation system, which uses the
      same BPF_ANNOTATE_KV_PAIR to record map key/value types.
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      96408c43
    • Yonghong Song's avatar
      tools/bpf: expose functions btf_ext__* as API functions · b8dcf8d1
      Yonghong Song authored
      The following set of functions, which manipulates .BTF.ext
      section, are exposed as API functions:
        . btf_ext__new
        . btf_ext__free
        . btf_ext__reloc_func_info
        . btf_ext__reloc_line_info
        . btf_ext__func_info_rec_size
        . btf_ext__line_info_rec_size
      
      These functions are useful for JIT based bpf codegen, e.g.,
      bcc, to manipulate in-memory .BTF.ext sections.
      
      The signature of function btf_ext__reloc_func_info()
      is also changed to be the same as its definition in btf.c.
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b8dcf8d1
    • Stanislav Fomichev's avatar
      selftests/bpf: use localhost in tcp_{server,client}.py · 7e8a5903
      Stanislav Fomichev authored
      Bind and connect to localhost. There is no reason for this test to
      use non-localhost interface. This lets us run this test in a network
      namespace.
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      7e8a5903
    • Heiko Carstens's avatar
      s390: bpf: fix JMP32 code-gen · ecc15f11
      Heiko Carstens authored
      Commit 626a5f66 ("s390: bpf: implement jitting of JMP32") added
      JMP32 code-gen support for s390. However it triggers the warning below
      due to some unusual gotos in the original s390 bpf jit code.
      
      Add a couple of additional "is_jmp32" initializations to fix this.
      Also fix the wrong opcode for the "llilf" instruction that was
      introduced with the same commit.
      
      arch/s390/net/bpf_jit_comp.c: In function 'bpf_jit_insn':
      arch/s390/net/bpf_jit_comp.c:248:55: warning: 'is_jmp32' may be used uninitialized in this function [-Wmaybe-uninitialized]
        _EMIT6(op1 | reg(b1, b2) << 16 | (rel & 0xffff), op2 | mask); \
                                                             ^
      arch/s390/net/bpf_jit_comp.c:1211:8: note: 'is_jmp32' was declared here
         bool is_jmp32 = BPF_CLASS(insn->code) == BPF_JMP32;
      
      Fixes: 626a5f66 ("s390: bpf: implement jitting of JMP32")
      Cc: Jiong Wang <jiong.wang@netronome.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Acked-by: default avatarJiong Wang <jiong.wang@netronome.com>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      ecc15f11
    • Alexei Starovoitov's avatar
      Merge branch 'change-libbpf-print-api' · 9fa3b473
      Alexei Starovoitov authored
      Yonghong Song says:
      
      ====================
      These are patches responding to my comments for
      Magnus's patch (https://patchwork.ozlabs.org/patch/1032848/).
      The goal is to make pr_* macros available to other C files
      than libbpf.c, and to simplify API function libbpf_set_print().
      
      Specifically, Patch #1 used global functions
      to facilitate pr_* macros in the header files so they
      are available in different C files.
      Patch #2 removes the global function libbpf_print_level_available()
      which is added in Patch 1.
      Patch #3 simplified libbpf_set_print() which takes only one print
      function with a debug level argument among others.
      
      Changelogs:
       v3 -> v4:
         . rename libbpf internal header util.h to libbpf_util.h
         . rename libbpf internal function libbpf_debug_print() to libbpf_print()
       v2 -> v3:
         . bailed out earlier in libbpf_debug_print() if __libbpf_pr is NULL
         . added missing LIBBPF_DEBUG level check in libbpf.c __base_pr().
       v1 -> v2:
         . Renamed global function libbpf_dprint() to libbpf_debug_print()
           to be more expressive.
         . Removed libbpf_dprint_level_available() as it is used only
           once in btf.c and we can remove it by optimizing for common cases.
      ====================
      Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      9fa3b473
    • Yonghong Song's avatar
      tools/bpf: simplify libbpf API function libbpf_set_print() · 6f1ae8b6
      Yonghong Song authored
      Currently, the libbpf API function libbpf_set_print()
      takes three function pointer parameters for warning, info
      and debug printout respectively.
      
      This patch changes the API to have just one function pointer
      parameter and the function pointer has one additional
      parameter "debugging level". So if in the future, if
      the debug level is increased, the function signature
      won't change.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      6f1ae8b6
    • Yonghong Song's avatar
      tools/bpf: print out btf log at LIBBPF_WARN level · 9d100a19
      Yonghong Song authored
      Currently, the btf log is allocated and printed out in case
      of error at LIBBPF_DEBUG level.
      Such logs from kernel are very important for debugging.
      For example, bpf syscall BPF_PROG_LOAD command can get
      verifier logs back to user space. In function load_program()
      of libbpf.c, the log buffer is allocated unconditionally
      and printed out at pr_warning() level.
      
      Let us do the similar thing here for btf. Allocate buffer
      unconditionally and print out error logs at pr_warning() level.
      This can reduce one global function and
      optimize for common situations where pr_warning()
      is activated either by default or by user supplied
      debug output function.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      9d100a19
    • Yonghong Song's avatar
      tools/bpf: move libbpf pr_* debug print functions to headers · 8461ef8b
      Yonghong Song authored
      A global function libbpf_print, which is invisible
      outside the shared library, is defined to print based
      on levels. The pr_warning, pr_info and pr_debug
      macros are moved into the newly created header
      common.h. So any .c file including common.h can
      use these macros directly.
      
      Currently btf__new and btf_ext__new API has an argument getting
      __pr_debug function pointer into btf.c so the debugging information
      can be printed there. This patch removed this parameter
      from btf__new and btf_ext__new and directly using pr_debug in btf.c.
      
      Another global function libbpf_print_level_available, also
      invisible outside the shared library, can test
      whether a particular level debug printing is
      available or not. It is used in btf.c to
      test whether DEBUG level debug printing is availabl or not,
      based on which the log buffer will be allocated when loading
      btf to the kernel.
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      8461ef8b
    • Stephen Rothwell's avatar
      socket: fix for Add SO_TIMESTAMP[NS]_NEW · cc733578
      Stephen Rothwell authored
      Fixes: 887feae3 ("socket: Add SO_TIMESTAMP[NS]_NEW")
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cc733578
    • Joe Perches's avatar
      netdevice.h: Add __cold to netdev_<level> logging functions · ce3fdb69
      Joe Perches authored
      Add __cold to the netdev_<level> logging functions similar to
      the use of __cold in the generic printk function.
      
      Using __cold moves all the netdev_<level> logging functions
      out-of-line possibly improving code locality and runtime
      performance.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ce3fdb69
    • David S. Miller's avatar
      net: Fix fall through warning in y2038 tstamp changes. · ff7653f9
      David S. Miller authored
      net/core/sock.c: In function 'sock_setsockopt':
      net/core/sock.c:914:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
         sock_set_flag(sk, SOCK_TSTAMP_NEW);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      net/core/sock.c:915:2: note: here
        case SO_TIMESTAMPING_OLD:
        ^~~~
      
      Fixes: 9718475e ("socket: Add SO_TIMESTAMPING_NEW")
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ff7653f9
    • Masahiro Yamada's avatar
      bpfilter: remove extra header search paths for bpfilter_umh · 303a339f
      Masahiro Yamada authored
      Currently, the header search paths -Itools/include and
      -Itools/include/uapi are not used. Let's drop the unused code.
      
      We can remove -I. too by fixing up one C file.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      303a339f
  3. 03 Feb, 2019 24 commits