1. 25 11月, 2022 1 次提交
  2. 06 12月, 2021 1 次提交
  3. 15 6月, 2021 1 次提交
  4. 06 11月, 2020 1 次提交
  5. 16 9月, 2020 1 次提交
  6. 04 9月, 2020 1 次提交
  7. 14 8月, 2020 1 次提交
  8. 28 7月, 2020 1 次提交
  9. 18 7月, 2020 1 次提交
  10. 25 6月, 2020 1 次提交
  11. 23 6月, 2020 2 次提交
  12. 02 6月, 2020 1 次提交
  13. 20 5月, 2020 1 次提交
  14. 12 5月, 2020 1 次提交
  15. 14 3月, 2020 1 次提交
    • Q
      tools: bpftool: Restore message on failure to guess program type · 6ae32b29
      Quentin Monnet 提交于
      In commit 4a3d6c6a ("libbpf: Reduce log level for custom section
      names"), log level for messages for libbpf_attach_type_by_name() and
      libbpf_prog_type_by_name() was downgraded from "info" to "debug". The
      latter function, in particular, is used by bpftool when attempting to
      load programs, and this change caused bpftool to exit with no hint or
      error message when it fails to detect the type of the program to load
      (unless "-d" option was provided).
      
      To help users understand why bpftool fails to load the program, let's do
      a second run of the function with log level in "debug" mode in case of
      failure.
      
      Before:
      
          # bpftool prog load sample_ret0.o /sys/fs/bpf/sample_ret0
          # echo $?
          255
      
      Or really verbose with -d flag:
      
          # bpftool -d prog load sample_ret0.o /sys/fs/bpf/sample_ret0
          libbpf: loading sample_ret0.o
          libbpf: section(1) .strtab, size 134, link 0, flags 0, type=3
          libbpf: skip section(1) .strtab
          libbpf: section(2) .text, size 16, link 0, flags 6, type=1
          libbpf: found program .text
          libbpf: section(3) .debug_abbrev, size 55, link 0, flags 0, type=1
          libbpf: skip section(3) .debug_abbrev
          libbpf: section(4) .debug_info, size 75, link 0, flags 0, type=1
          libbpf: skip section(4) .debug_info
          libbpf: section(5) .rel.debug_info, size 32, link 14, flags 0, type=9
          libbpf: skip relo .rel.debug_info(5) for section(4)
          libbpf: section(6) .debug_str, size 150, link 0, flags 30, type=1
          libbpf: skip section(6) .debug_str
          libbpf: section(7) .BTF, size 155, link 0, flags 0, type=1
          libbpf: section(8) .BTF.ext, size 80, link 0, flags 0, type=1
          libbpf: section(9) .rel.BTF.ext, size 32, link 14, flags 0, type=9
          libbpf: skip relo .rel.BTF.ext(9) for section(8)
          libbpf: section(10) .debug_frame, size 40, link 0, flags 0, type=1
          libbpf: skip section(10) .debug_frame
          libbpf: section(11) .rel.debug_frame, size 16, link 14, flags 0, type=9
          libbpf: skip relo .rel.debug_frame(11) for section(10)
          libbpf: section(12) .debug_line, size 74, link 0, flags 0, type=1
          libbpf: skip section(12) .debug_line
          libbpf: section(13) .rel.debug_line, size 16, link 14, flags 0, type=9
          libbpf: skip relo .rel.debug_line(13) for section(12)
          libbpf: section(14) .symtab, size 96, link 1, flags 0, type=2
          libbpf: looking for externs among 4 symbols...
          libbpf: collected 0 externs total
          libbpf: failed to guess program type from ELF section '.text'
          libbpf: supported section(type) names are: socket sk_reuseport kprobe/ [...]
      
      After:
      
          # bpftool prog load sample_ret0.o /sys/fs/bpf/sample_ret0
          libbpf: failed to guess program type from ELF section '.text'
          libbpf: supported section(type) names are: socket sk_reuseport kprobe/ [...]
      Signed-off-by: NQuentin Monnet <quentin@isovalent.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20200311021205.9755-1-quentin@isovalent.comSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
      6ae32b29
  16. 13 3月, 2020 2 次提交
  17. 10 3月, 2020 1 次提交
    • S
      bpftool: Introduce "prog profile" command · 47c09d6a
      Song Liu 提交于
      With fentry/fexit programs, it is possible to profile BPF program with
      hardware counters. Introduce bpftool "prog profile", which measures key
      metrics of a BPF program.
      
      bpftool prog profile command creates per-cpu perf events. Then it attaches
      fentry/fexit programs to the target BPF program. The fentry program saves
      perf event value to a map. The fexit program reads the perf event again,
      and calculates the difference, which is the instructions/cycles used by
      the target program.
      
      Example input and output:
      
        ./bpftool prog profile id 337 duration 3 cycles instructions llc_misses
      
              4228 run_cnt
           3403698 cycles                                              (84.08%)
           3525294 instructions   #  1.04 insn per cycle               (84.05%)
                13 llc_misses     #  3.69 LLC misses per million isns  (83.50%)
      
      This command measures cycles and instructions for BPF program with id
      337 for 3 seconds. The program has triggered 4228 times. The rest of the
      output is similar to perf-stat. In this example, the counters were only
      counting ~84% of the time because of time multiplexing of perf counters.
      
      Note that, this approach measures cycles and instructions in very small
      increments. So the fentry/fexit programs introduce noticeable errors to
      the measurement results.
      
      The fentry/fexit programs are generated with BPF skeletons. Therefore, we
      build bpftool twice. The first time _bpftool is built without skeletons.
      Then, _bpftool is used to generate the skeletons. The second time, bpftool
      is built with skeletons.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: NQuentin Monnet <quentin@isovalent.com>
      Acked-by: NYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200309173218.2739965-2-songliubraving@fb.com
      47c09d6a
  18. 26 2月, 2020 1 次提交
  19. 08 2月, 2020 1 次提交
  20. 21 1月, 2020 1 次提交
  21. 16 12月, 2019 2 次提交
  22. 11 12月, 2019 1 次提交
  23. 23 10月, 2019 1 次提交
  24. 08 10月, 2019 1 次提交
  25. 16 8月, 2019 1 次提交
  26. 06 7月, 2019 1 次提交
    • Q
      tools: bpftool: add "prog run" subcommand to test-run programs · ba95c745
      Quentin Monnet 提交于
      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: NQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      ba95c745
  27. 28 6月, 2019 1 次提交
  28. 07 6月, 2019 1 次提交
  29. 28 5月, 2019 1 次提交
    • Q
      tools: bpftool: make -d option print debug output from verifier · 55d77807
      Quentin Monnet 提交于
      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: NQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      55d77807
  30. 17 5月, 2019 1 次提交
    • Y
      tools/bpftool: move set_max_rlimit() before __bpf_object__open_xattr() · ac4e0e05
      Yonghong Song 提交于
      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: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      ac4e0e05
  31. 17 4月, 2019 1 次提交
    • A
      bpftool: Support sysctl hook · f25377ee
      Andrey Ignatov 提交于
      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: NAndrey Ignatov <rdna@fb.com>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      f25377ee
  32. 16 4月, 2019 1 次提交
  33. 11 4月, 2019 1 次提交
  34. 20 3月, 2019 1 次提交
    • S
      bpftool: use bpf_program__get_prog_info_linear() in prog.c:do_dump() · cae73f23
      Song Liu 提交于
      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: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: NArnaldo 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.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cae73f23
  35. 01 3月, 2019 1 次提交
  36. 28 2月, 2019 1 次提交
  37. 20 2月, 2019 1 次提交