1. 12 Oct, 2019 19 commits
  2. 11 Oct, 2019 7 commits
  3. 10 Oct, 2019 4 commits
  4. 09 Oct, 2019 5 commits
  5. 08 Oct, 2019 5 commits
    • Daniel Borkmann's avatar
      Merge branch 'bpf-libbpf-helpers' · f05c2001
      Daniel Borkmann authored
      Andrii Nakryiko says:
      
      ====================
      This patch set makes bpf_helpers.h and bpf_endian.h a part of libbpf itself
      for consumption by user BPF programs, not just selftests. It also splits off
      tracing helpers into bpf_tracing.h, which also becomes part of libbpf. Some of
      the legacy stuff (BPF_ANNOTATE_KV_PAIR, load_{byte,half,word}, bpf_map_def
      with unsupported fields, etc, is extracted into selftests-only bpf_legacy.h.
      All the selftests and samples are switched to use libbpf's headers and
      selftests' ones are removed.
      
      As part of this patch set we also add BPF_CORE_READ variadic macros, that are
      simplifying BPF CO-RE reads, especially the ones that have to follow few
      pointers. E.g., what in non-BPF world (and when using BCC) would be:
      
      int x = s->a->b.c->d; /* s, a, and b.c are pointers */
      
      Today would have to be written using explicit bpf_probe_read() calls as:
      
        void *t;
        int x;
        bpf_probe_read(&t, sizeof(t), s->a);
        bpf_probe_read(&t, sizeof(t), ((struct b *)t)->b.c);
        bpf_probe_read(&x, sizeof(x), ((struct c *)t)->d);
      
      This is super inconvenient and distracts from program logic a lot. Now, with
      added BPF_CORE_READ() macros, you can write the above as:
      
        int x = BPF_CORE_READ(s, a, b.c, d);
      
      Up to 9 levels of pointer chasing are supported, which should be enough for
      any practical purpose, hopefully, without adding too much boilerplate macro
      definitions (though there is admittedly some, given how variadic and recursive
      C macro have to be implemented).
      
      There is also BPF_CORE_READ_INTO() variant, which relies on caller to allocate
      space for result:
      
        int x;
        BPF_CORE_READ_INTO(&x, s, a, b.c, d);
      
      Result of last bpf_probe_read() call in the chain of calls is the result of
      BPF_CORE_READ_INTO(). If any intermediate bpf_probe_read() aall fails, then
      all the subsequent ones will fail too, so this is sufficient to know whether
      overall "operation" succeeded or not. No short-circuiting of bpf_probe_read()s
      is done, though.
      
      BPF_CORE_READ_STR_INTO() is added as well, which differs from
      BPF_CORE_READ_INTO() only in that last bpf_probe_read() call (to read final
      field after chasing pointers) is replaced with bpf_probe_read_str(). Result of
      bpf_probe_read_str() is returned as a result of BPF_CORE_READ_STR_INTO() macro
      itself, so that applications can track return code and/or length of read
      string.
      
      Patch set outline:
      - patch #1 undoes previously added GCC-specific bpf-helpers.h include;
      - patch #2 splits off legacy stuff we don't want to carry over;
      - patch #3 adjusts CO-RE reloc tests to avoid subsequent naming conflict with
        BPF_CORE_READ;
      - patch #4 splits off bpf_tracing.h;
      - patch #5 moves bpf_{helpers,endian,tracing}.h and bpf_helper_defs.h
        generation into libbpf and adjusts Makefiles to include libbpf for header
        search;
      - patch #6 adds variadic BPF_CORE_READ() macro family, as described above;
      - patch #7 adds tests to verify all possible levels of pointer nestedness for
        BPF_CORE_READ(), as well as correctness test for BPF_CORE_READ_STR_INTO().
      
      v4->v5:
      - move BPF_CORE_READ() stuff into bpf_core_read.h header (Alexei);
      
      v3->v4:
      - rebase on latest bpf-next master;
      - bpf_helper_defs.h generation is moved into libbpf's Makefile;
      
      v2->v3:
      - small formatting fixes and macro () fixes (Song);
      
      v1->v2:
      - fix CO-RE reloc tests before bpf_helpers.h move (Song);
      - split off legacy stuff we don't want to carry over (Daniel, Toke);
      - split off bpf_tracing.h (Daniel);
      - fix samples/bpf build (assuming other fixes are applied);
      - switch remaining maps either to bpf_map_def_legacy or BTF-defined maps;
      ====================
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      f05c2001
    • Andrii Nakryiko's avatar
      selftests/bpf: Add BPF_CORE_READ and BPF_CORE_READ_STR_INTO macro tests · ee2eb063
      Andrii Nakryiko authored
      Validate BPF_CORE_READ correctness and handling of up to 9 levels of
      nestedness using cyclic task->(group_leader->)*->tgid chains.
      
      Also add a test of maximum-dpeth BPF_CORE_READ_STR_INTO() macro.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20191008175942.1769476-8-andriin@fb.com
      ee2eb063
    • Andrii Nakryiko's avatar
      libbpf: Add BPF_CORE_READ/BPF_CORE_READ_INTO helpers · 7db3822a
      Andrii Nakryiko authored
      Add few macros simplifying BCC-like multi-level probe reads, while also
      emitting CO-RE relocations for each read.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20191008175942.1769476-7-andriin@fb.com
      7db3822a
    • Andrii Nakryiko's avatar
      libbpf: Move bpf_{helpers, helper_defs, endian, tracing}.h into libbpf · e01a75c1
      Andrii Nakryiko authored
      Move bpf_helpers.h, bpf_tracing.h, and bpf_endian.h into libbpf. Move
      bpf_helper_defs.h generation into libbpf's Makefile. Ensure all those
      headers are installed along the other libbpf headers. Also, adjust
      selftests and samples include path to include libbpf now.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20191008175942.1769476-6-andriin@fb.com
      e01a75c1
    • Andrii Nakryiko's avatar
      selftests/bpf: Split off tracing-only helpers into bpf_tracing.h · 3ac4dbe3
      Andrii Nakryiko authored
      Split-off PT_REGS-related helpers into bpf_tracing.h header. Adjust
      selftests and samples to include it where necessary.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20191008175942.1769476-5-andriin@fb.com
      3ac4dbe3