1. 11 Dec, 2019 1 commit
  2. 22 Oct, 2019 1 commit
  3. 08 Oct, 2019 1 commit
  4. 16 Aug, 2019 1 commit
  5. 05 Jul, 2019 1 commit
    • Quentin Monnet's avatar
      tools: bpftool: add "prog run" subcommand to test-run programs · ba95c745
      Quentin Monnet authored
      
      
      Add a new "bpftool prog run" subcommand to run a loaded program on input
      data (and possibly with input context) passed by the user.
      
      Print output data (and output context if relevant) into a file or into
      the console. Print return value and duration for the test run into the
      console.
      
      A "repeat" argument can be passed to run the program several times in a
      row.
      
      The command does not perform any kind of verification based on program
      type (Is this program type allowed to use an input context?) or on data
      consistency (Can I work with empty input data?), this is left to the
      kernel.
      
      Example invocation:
      
          # perl -e 'print "\x0" x 14' | ./bpftool prog run \
                  pinned /sys/fs/bpf/sample_ret0 \
                  data_in - data_out - repeat 5
          0000000 0000 0000 0000 0000 0000 0000 0000      | ........ ......
          Return value: 0, duration (average): 260ns
      
      When one of data_in or ctx_in is "-", bpftool reads from standard input,
      in binary format. Other formats (JSON, hexdump) might be supported (via
      an optional command line keyword like "data_fmt_in") in the future if
      relevant, but this would require doing more parsing in bpftool.
      
      v2:
      - Fix argument names for function check_single_stdin(). (Yonghong)
      
      Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      ba95c745
  6. 27 Jun, 2019 1 commit
  7. 06 Jun, 2019 1 commit
  8. 28 May, 2019 1 commit
    • Quentin Monnet's avatar
      tools: bpftool: make -d option print debug output from verifier · 55d77807
      Quentin Monnet authored
      
      
      The "-d" option is used to require all logs available for bpftool. So
      far it meant telling libbpf to print even debug-level information. But
      there is another source of info that can be made more verbose: when we
      attemt to load programs with bpftool, we can pass a log_level parameter
      to the verifier in order to control the amount of information that is
      printed to the console.
      
      Reuse the "-d" option to print all information the verifier can tell. At
      this time, this means logs related to BPF_LOG_LEVEL1, BPF_LOG_LEVEL2 and
      BPF_LOG_STATS. As mentioned in the discussion on the first version of
      this set, these macros are internal to the kernel
      (include/linux/bpf_verifier.h) and are not meant to be part of the
      stable user API, therefore we simply use the related constants to print
      whatever we can at this time, without trying to tell users what is
      log_level1 or what is statistics.
      
      Verifier logs are only used when loading programs for now (In the
      future: for loading BTF objects with bpftool? Although libbpf does not
      currently offer to print verifier info at debug level if no error
      occurred when loading BTF objects), so bpftool.rst and bpftool-prog.rst
      are the only man pages to get the update.
      
      v3:
      - Add details on log level and BTF loading at the end of commit log.
      
      v2:
      - Remove the possibility to select the log levels to use (v1 offered a
        combination of "log_level1", "log_level2" and "stats").
      - The macros from kernel header bpf_verifier.h are not used (and
        therefore not moved to UAPI header).
      - In v1 this was a distinct option, but is now merged in the only "-d"
        switch to activate libbpf and verifier debug-level logs all at the
        same time.
      
      Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      55d77807
  9. 16 May, 2019 1 commit
    • Yonghong Song's avatar
      tools/bpftool: move set_max_rlimit() before __bpf_object__open_xattr() · ac4e0e05
      Yonghong Song authored
      For a host which has a lower rlimit for max locked memory (e.g., 64KB),
      the following error occurs in one of our production systems:
        # /usr/sbin/bpftool prog load /paragon/pods/52877437/home/mark.o \
          /sys/fs/bpf/paragon_mark_21 type cgroup/skb \
          map idx 0 pinned /sys/fs/bpf/paragon_map_21
        libbpf: Error in bpf_object__probe_name():Operation not permitted(1).
          Couldn't load basic 'r0 = 0' BPF program.
        Error: failed to open object file
      
      The reason is due to low locked memory during bpf_object__probe_name()
      which probes whether program name is supported in kernel or not
      during __bpf_object__open_xattr().
      
      bpftool program load already tries to relax mlock rlimit before
      bpf_object__load(). Let us move set_max_rlimit() before
      __bpf_object__open_xattr(), which fixed the issue here.
      
      Fixes: 47eff617
      
       ("bpf, libbpf: introduce bpf_object__probe_caps to test BPF capabilities")
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      ac4e0e05
  10. 17 Apr, 2019 1 commit
    • Andrey Ignatov's avatar
      bpftool: Support sysctl hook · f25377ee
      Andrey Ignatov authored
      
      
      Add support for recently added BPF_PROG_TYPE_CGROUP_SYSCTL program type
      and BPF_CGROUP_SYSCTL attach type.
      
      Example of bpftool output with sysctl program from selftests:
      
        # bpftool p load ./test_sysctl_prog.o /mnt/bpf/sysctl_prog type cgroup/sysctl
        # bpftool p l
        9: cgroup_sysctl  name sysctl_tcp_mem  tag 0dd05f81a8d0d52e  gpl
                loaded_at 2019-04-16T12:57:27-0700  uid 0
                xlated 1008B  jited 623B  memlock 4096B
        # bpftool c a /mnt/cgroup2/bla sysctl id 9
        # bpftool c t
        CgroupPath
        ID       AttachType      AttachFlags     Name
        /mnt/cgroup2/bla
            9        sysctl                          sysctl_tcp_mem
        # bpftool c d /mnt/cgroup2/bla sysctl id 9
        # bpftool c t
        CgroupPath
        ID       AttachType      AttachFlags     Name
      
      Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f25377ee
  11. 16 Apr, 2019 1 commit
  12. 11 Apr, 2019 1 commit
  13. 19 Mar, 2019 1 commit
    • Song Liu's avatar
      bpftool: use bpf_program__get_prog_info_linear() in prog.c:do_dump() · cae73f23
      Song Liu authored
      
      
      This patches uses bpf_program__get_prog_info_linear() to simplify the
      logic in prog.c do_dump().
      
      Committer testing:
      
      Before:
      
        # bpftool prog dump xlated id 208 > /tmp/dump.xlated.before
        # bpftool prog dump jited id 208 > /tmp/dump.jited.before
        # bpftool map dump id 107 > /tmp/map.dump.before
      
      After:
      
        # ~acme/git/perf/tools/bpf/bpftool/bpftool map dump id 107 > /tmp/map.dump.after
        # ~acme/git/perf/tools/bpf/bpftool/bpftool prog dump xlated id 208 > /tmp/dump.xlated.after
        # ~acme/git/perf/tools/bpf/bpftool/bpftool prog dump jited id 208 > /tmp/dump.jited.after
        # diff -u /tmp/dump.xlated.before /tmp/dump.xlated.after
        # diff -u /tmp/dump.jited.before /tmp/dump.jited.after
        # diff -u /tmp/map.dump.before /tmp/map.dump.after
        # ~acme/git/perf/tools/bpf/bpftool/bpftool prog dump xlated id 208
           0: (bf) r6 = r1
           1: (85) call bpf_get_current_pid_tgid#80800
           2: (63) *(u32 *)(r10 -328) = r0
           3: (bf) r2 = r10
           4: (07) r2 += -328
           5: (18) r1 = map[id:107]
           7: (85) call __htab_map_lookup_elem#85680
           8: (15) if r0 == 0x0 goto pc+1
           9: (07) r0 += 56
          10: (b7) r7 = 0
          11: (55) if r0 != 0x0 goto pc+52
          12: (bf) r1 = r10
          13: (07) r1 += -328
          14: (b7) r2 = 64
          15: (bf) r3 = r6
          16: (85) call bpf_probe_read#-46848
          17: (bf) r2 = r10
          18: (07) r2 += -320
          19: (18) r1 = map[id:106]
          21: (07) r1 += 208
          22: (61) r0 = *(u32 *)(r2 +0)
          23: (35) if r0 >= 0x200 goto pc+3
          24: (67) r0 <<= 3
          25: (0f) r0 += r1
          26: (05) goto pc+1
          27: (b7) r0 = 0
          28: (15) if r0 == 0x0 goto pc+35
          29: (71) r1 = *(u8 *)(r0 +0)
          30: (15) if r1 == 0x0 goto pc+33
          31: (b7) r5 = 64
          32: (79) r1 = *(u64 *)(r10 -320)
          33: (15) if r1 == 0x2 goto pc+2
          34: (15) if r1 == 0x101 goto pc+3
          35: (55) if r1 != 0x15 goto pc+19
          36: (79) r3 = *(u64 *)(r6 +16)
          37: (05) goto pc+1
          38: (79) r3 = *(u64 *)(r6 +24)
          39: (15) if r3 == 0x0 goto pc+15
          40: (b7) r1 = 0
          41: (63) *(u32 *)(r10 -260) = r1
          42: (bf) r1 = r10
          43: (07) r1 += -256
          44: (b7) r2 = 256
          45: (85) call bpf_probe_read_str#-46704
          46: (b7) r5 = 328
          47: (63) *(u32 *)(r10 -264) = r0
          48: (bf) r1 = r0
          49: (67) r1 <<= 32
          50: (77) r1 >>= 32
          51: (25) if r1 > 0xff goto pc+3
          52: (07) r0 += 72
          53: (57) r0 &= 255
          54: (bf) r5 = r0
          55: (bf) r4 = r10
          56: (07) r4 += -328
          57: (bf) r1 = r6
          58: (18) r2 = map[id:105]
          60: (18) r3 = 0xffffffff
          62: (85) call bpf_perf_event_output_tp#-45104
          63: (bf) r7 = r0
          64: (bf) r0 = r7
          65: (95) exit
        #
      
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: kernel-team@fb.com
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Link: http://lkml.kernel.org/r/20190312053051.2690567-4-songliubraving@fb.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cae73f23
  14. 28 Feb, 2019 1 commit
  15. 27 Feb, 2019 1 commit
  16. 19 Feb, 2019 1 commit
  17. 23 Jan, 2019 2 commits
    • Taeung Song's avatar
      libbpf: Show supported ELF section names when failing to guess prog/attach type · c76e4c22
      Taeung Song authored
      
      
      We need to let users check their wrong ELF section name with proper
      ELF section names when they fail to get a prog/attach type from it.
      Because users can't realize libbpf guess prog/attach types from given
      ELF section names. For example, when a 'cgroup' section name of a
      BPF program is used, show available ELF section names(types).
      
      Before:
      
          $ bpftool prog load bpf-prog.o /sys/fs/bpf/prog1
          Error: failed to guess program type based on ELF section name cgroup
      
      After:
      
          libbpf: failed to guess program type based on ELF section name 'cgroup'
          libbpf: supported section(type) names are: socket kprobe/ kretprobe/ classifier action tracepoint/ raw_tracepoint/ xdp perf_event lwt_in lwt_out lwt_xmit lwt_seg6local cgroup_skb/ingress cgroup_skb/egress cgroup/skb cgroup/sock cgroup/post_bind4 cgroup/post_bind6 cgroup/dev sockops sk_skb/stream_parser sk_skb/stream_verdict sk_skb sk_msg lirc_mode2 flow_dissector cgroup/bind4 cgroup/bind6 cgroup/connect4 cgroup/connect6 cgroup/sendmsg4 cgroup/sendmsg6
      
      Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Quentin Monnet <quentin.monnet@netronome.com>
      Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
      Cc: Andrey Ignatov <rdna@fb.com>
      Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      c76e4c22
    • Jiri Olsa's avatar
      bpftool: Fix prog dump by tag · 752bcf80
      Jiri Olsa authored
      Lance reported an issue with bpftool not being able to
      dump program if there are more programs loaded and you
      want to dump any but the first program, like:
      
        # bpftool prog
        28: kprobe  name trace_req_start  tag 1dfc28ba8b3dd597  gpl
        	loaded_at 2019-01-18T17:02:40+1100  uid 0
        	xlated 112B  jited 109B  memlock 4096B  map_ids 13
        29: kprobe  name trace_req_compl  tag 5b6a5ecc6030a683  gpl
        	loaded_at 2019-01-18T17:02:40+1100  uid 0
        	xlated 928B  jited 575B  memlock 4096B  map_ids 13,14
        #  bpftool prog dum jited tag 1dfc28ba8b3dd597
         0:	push   %rbp
         1:	mov    %rsp,%rbp
        ...
      
        #  bpftool prog dum jited tag 5b6a5ecc6030a683
        Error: can't get prog info (29): Bad address
      
      The problem is in the prog_fd_by_tag function not cleaning
      the struct bpf_prog_info before another request, so the
      previous program length is still in there and kernel assumes
      it needs to dump the program, which fails because there's no
      user pointer set.
      
      Moving the struct bpf_prog_info declaration into the loop,
      so it gets cleaned before each query.
      
      Fixes: 71bb428f
      
       ("tools: bpf: add bpftool")
      Reported-by: default avatarLance Digby <ldigby@redhat.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      752bcf80
  18. 15 Dec, 2018 1 commit
  19. 13 Dec, 2018 2 commits
  20. 10 Dec, 2018 2 commits
  21. 09 Dec, 2018 1 commit
    • Martin KaFai Lau's avatar
      bpf: libbpf: bpftool: Print bpf_line_info during prog dump · b053b439
      Martin KaFai Lau authored
      
      
      This patch adds print bpf_line_info function in 'prog dump jitted'
      and 'prog dump xlated':
      
      [root@arch-fb-vm1 bpf]# ~/devshare/fb-kernel/linux/tools/bpf/bpftool/bpftool prog dump jited pinned /sys/fs/bpf/test_btf_haskv
      [...]
      int test_long_fname_2(struct dummy_tracepoint_args * arg):
      bpf_prog_44a040bf25481309_test_long_fname_2:
      ; static int test_long_fname_2(struct dummy_tracepoint_args *arg)
         0:	push   %rbp
         1:	mov    %rsp,%rbp
         4:	sub    $0x30,%rsp
         b:	sub    $0x28,%rbp
         f:	mov    %rbx,0x0(%rbp)
        13:	mov    %r13,0x8(%rbp)
        17:	mov    %r14,0x10(%rbp)
        1b:	mov    %r15,0x18(%rbp)
        1f:	xor    %eax,%eax
        21:	mov    %rax,0x20(%rbp)
        25:	xor    %esi,%esi
      ; int key = 0;
        27:	mov    %esi,-0x4(%rbp)
      ; if (!arg->sock)
        2a:	mov    0x8(%rdi),%rdi
      ; if (!arg->sock)
        2e:	cmp    $0x0,%rdi
        32:	je     0x0000000000000070
        34:	mov    %rbp,%rsi
      ; counts = bpf_map_lookup_elem(&btf_map, &key);
        37:	add    $0xfffffffffffffffc,%rsi
        3b:	movabs $0xffff8881139d7480,%rdi
        45:	add    $0x110,%rdi
        4c:	mov    0x0(%rsi),%eax
        4f:	cmp    $0x4,%rax
        53:	jae    0x000000000000005e
        55:	shl    $0x3,%rax
        59:	add    %rdi,%rax
        5c:	jmp    0x0000000000000060
        5e:	xor    %eax,%eax
      ; if (!counts)
        60:	cmp    $0x0,%rax
        64:	je     0x0000000000000070
      ; counts->v6++;
        66:	mov    0x4(%rax),%edi
        69:	add    $0x1,%rdi
        6d:	mov    %edi,0x4(%rax)
        70:	mov    0x0(%rbp),%rbx
        74:	mov    0x8(%rbp),%r13
        78:	mov    0x10(%rbp),%r14
        7c:	mov    0x18(%rbp),%r15
        80:	add    $0x28,%rbp
        84:	leaveq
        85:	retq
      [...]
      
      With linum:
      [root@arch-fb-vm1 bpf]# ~/devshare/fb-kernel/linux/tools/bpf/bpftool/bpftool prog dump jited pinned /sys/fs/bpf/test_btf_haskv linum
      int _dummy_tracepoint(struct dummy_tracepoint_args * arg):
      bpf_prog_b07ccb89267cf242__dummy_tracepoint:
      ; return test_long_fname_1(arg); [file:/data/users/kafai/fb-kernel/linux/tools/testing/selftests/bpf/test_btf_haskv.c line_num:54 line_col:9]
         0:	push   %rbp
         1:	mov    %rsp,%rbp
         4:	sub    $0x28,%rsp
         b:	sub    $0x28,%rbp
         f:	mov    %rbx,0x0(%rbp)
        13:	mov    %r13,0x8(%rbp)
        17:	mov    %r14,0x10(%rbp)
        1b:	mov    %r15,0x18(%rbp)
        1f:	xor    %eax,%eax
        21:	mov    %rax,0x20(%rbp)
        25:	callq  0x000000000000851e
      ; return test_long_fname_1(arg); [file:/data/users/kafai/fb-kernel/linux/tools/testing/selftests/bpf/test_btf_haskv.c line_num:54 line_col:2]
        2a:	xor    %eax,%eax
        2c:	mov    0x0(%rbp),%rbx
        30:	mov    0x8(%rbp),%r13
        34:	mov    0x10(%rbp),%r14
        38:	mov    0x18(%rbp),%r15
        3c:	add    $0x28,%rbp
        40:	leaveq
        41:	retq
      [...]
      
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b053b439
  22. 06 Dec, 2018 1 commit
  23. 05 Dec, 2018 1 commit
  24. 30 Nov, 2018 1 commit
    • Quentin Monnet's avatar
      tools: bpftool: add owner_prog_type and owner_jited to bpftool output · 99a44bef
      Quentin Monnet authored
      
      
      For prog array maps, the type of the owner program, and the JIT-ed state
      of that program, are available from the file descriptor information
      under /proc. Add them to "bpftool map show" output. Example output:
      
          # bpftool map show
          158225: prog_array  name jmp_table  flags 0x0
              key 4B  value 4B  max_entries 8  memlock 4096B
              owner_prog_type flow_dissector  owner jited
          # bpftool --json --pretty map show
          [{
                  "id": 1337,
                  "type": "prog_array",
                  "name": "jmp_table",
                  "flags": 0,
                  "bytes_key": 4,
                  "bytes_value": 4,
                  "max_entries": 8,
                  "bytes_memlock": 4096,
                  "owner_prog_type": "flow_dissector",
                  "owner_jited": true
              }
          ]
      
      As we move the table used for associating names to program types,
      complete it with the missing types (lwt_seg6local and sk_reuseport).
      Also add missing types to the help message for "bpftool prog"
      (sk_reuseport and flow_dissector).
      
      Suggested-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      99a44bef
  25. 27 Nov, 2018 1 commit
  26. 21 Nov, 2018 1 commit
  27. 20 Nov, 2018 1 commit
    • Yonghong Song's avatar
      tools/bpf: bpftool: add support for func types · 254471e5
      Yonghong Song authored
      
      
      This patch added support to print function signature
      if btf func_info is available. Note that ksym
      now uses function name instead of prog_name as
      prog_name has a limit of 16 bytes including
      ending '\0'.
      
      The following is a sample output for selftests
      test_btf with file test_btf_haskv.o for translated insns
      and jited insns respectively.
      
        $ bpftool prog dump xlated id 1
        int _dummy_tracepoint(struct dummy_tracepoint_args * arg):
           0: (85) call pc+2#bpf_prog_2dcecc18072623fc_test_long_fname_1
           1: (b7) r0 = 0
           2: (95) exit
        int test_long_fname_1(struct dummy_tracepoint_args * arg):
           3: (85) call pc+1#bpf_prog_89d64e4abf0f0126_test_long_fname_2
           4: (95) exit
        int test_long_fname_2(struct dummy_tracepoint_args * arg):
           5: (b7) r2 = 0
           6: (63) *(u32 *)(r10 -4) = r2
           7: (79) r1 = *(u64 *)(r1 +8)
           ...
           22: (07) r1 += 1
           23: (63) *(u32 *)(r0 +4) = r1
           24: (95) exit
      
        $ bpftool prog dump jited id 1
        int _dummy_tracepoint(struct dummy_tracepoint_args * arg):
        bpf_prog_b07ccb89267cf242__dummy_tracepoint:
           0:   push   %rbp
           1:   mov    %rsp,%rbp
          ......
          3c:   add    $0x28,%rbp
          40:   leaveq
          41:   retq
      
        int test_long_fname_1(struct dummy_tracepoint_args * arg):
        bpf_prog_2dcecc18072623fc_test_long_fname_1:
           0:   push   %rbp
           1:   mov    %rsp,%rbp
          ......
          3a:   add    $0x28,%rbp
          3e:   leaveq
          3f:   retq
      
        int test_long_fname_2(struct dummy_tracepoint_args * arg):
        bpf_prog_89d64e4abf0f0126_test_long_fname_2:
           0:   push   %rbp
           1:   mov    %rsp,%rbp
          ......
          80:   add    $0x28,%rbp
          84:   leaveq
          85:   retq
      
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      254471e5
  28. 17 Nov, 2018 1 commit
    • Stanislav Fomichev's avatar
      bpftool: make libbfd optional · 29a9c10e
      Stanislav Fomichev authored
      
      
      Make it possible to build bpftool without libbfd. libbfd and libopcodes are
      typically provided in dev/dbg packages (binutils-dev in debian) which we
      usually don't have installed on the fleet machines and we'd like a way to have
      bpftool version that works without installing any additional packages.
      This excludes support for disassembling jit-ted code and prints an error if
      the user tries to use these features.
      
      Tested by:
      cat > FEATURES_DUMP.bpftool <<EOF
      feature-libbfd=0
      feature-disassembler-four-args=1
      feature-reallocarray=0
      feature-libelf=1
      feature-libelf-mmap=1
      feature-bpf=1
      EOF
      FEATURES_DUMP=$PWD/FEATURES_DUMP.bpftool make
      ldd bpftool | grep libbfd
      
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      29a9c10e
  29. 10 Nov, 2018 3 commits
    • Stanislav Fomichev's avatar
      bpftool: support loading flow dissector · 092f0892
      Stanislav Fomichev authored
      
      
      This commit adds support for loading/attaching/detaching flow
      dissector program.
      
      When `bpftool loadall` is called with a flow_dissector prog (i.e. when the
      'type flow_dissector' argument is passed), we load and pin all programs.
      User is responsible to construct the jump table for the tail calls.
      
      The last argument of `bpftool attach` is made optional for this use
      case.
      
      Example:
      bpftool prog load tools/testing/selftests/bpf/bpf_flow.o \
              /sys/fs/bpf/flow type flow_dissector \
      	pinmaps /sys/fs/bpf/flow
      
      bpftool map update pinned /sys/fs/bpf/flow/jmp_table \
              key 0 0 0 0 \
              value pinned /sys/fs/bpf/flow/IP
      
      bpftool map update pinned /sys/fs/bpf/flow/jmp_table \
              key 1 0 0 0 \
              value pinned /sys/fs/bpf/flow/IPV6
      
      bpftool map update pinned /sys/fs/bpf/flow/jmp_table \
              key 2 0 0 0 \
              value pinned /sys/fs/bpf/flow/IPV6OP
      
      bpftool map update pinned /sys/fs/bpf/flow/jmp_table \
              key 3 0 0 0 \
              value pinned /sys/fs/bpf/flow/IPV6FR
      
      bpftool map update pinned /sys/fs/bpf/flow/jmp_table \
              key 4 0 0 0 \
              value pinned /sys/fs/bpf/flow/MPLS
      
      bpftool map update pinned /sys/fs/bpf/flow/jmp_table \
              key 5 0 0 0 \
              value pinned /sys/fs/bpf/flow/VLAN
      
      bpftool prog attach pinned /sys/fs/bpf/flow/flow_dissector flow_dissector
      
      Tested by using the above lines to load the prog in
      the test_flow_dissector.sh selftest.
      
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      092f0892
    • Stanislav Fomichev's avatar
      bpftool: add pinmaps argument to the load/loadall · 3767a94b
      Stanislav Fomichev authored
      
      
      This new additional argument lets users pin all maps from the object at
      specified path.
      
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      3767a94b
    • Stanislav Fomichev's avatar
      bpftool: add loadall command · 77380998
      Stanislav Fomichev authored
      
      
      This patch adds new *loadall* command which slightly differs from the
      existing *load*. *load* command loads all programs from the obj file,
      but pins only the first programs. *loadall* pins all programs from the
      obj file under specified directory.
      
      The intended usecase is flow_dissector, where we want to load a bunch
      of progs, pin them all and after that construct a jump table.
      
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      77380998
  30. 09 Nov, 2018 1 commit
  31. 07 Nov, 2018 1 commit
    • Quentin Monnet's avatar
      tools: bpftool: adjust rlimit RLIMIT_MEMLOCK when loading programs, maps · 8302b9bd
      Quentin Monnet authored
      
      
      The limit for memory locked in the kernel by a process is usually set to
      64 kbytes by default. This can be an issue when creating large BPF maps
      and/or loading many programs. A workaround is to raise this limit for
      the current process before trying to create a new BPF map. Changing the
      hard limit requires the CAP_SYS_RESOURCE and can usually only be done by
      root user (for non-root users, a call to setrlimit fails (and sets
      errno) and the program simply goes on with its rlimit unchanged).
      
      There is no API to get the current amount of memory locked for a user,
      therefore we cannot raise the limit only when required. One solution,
      used by bcc, is to try to create the map, and on getting a EPERM error,
      raising the limit to infinity before giving another try. Another
      approach, used in iproute2, is to raise the limit in all cases, before
      trying to create the map.
      
      Here we do the same as in iproute2: the rlimit is raised to infinity
      before trying to load programs or to create maps with bpftool.
      
      Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      8302b9bd
  32. 18 Oct, 2018 1 commit
  33. 15 Oct, 2018 2 commits
  34. 14 Sep, 2018 1 commit