1. 11 Oct, 2019 3 commits
  2. 10 Oct, 2019 4 commits
  3. 09 Oct, 2019 5 commits
  4. 08 Oct, 2019 14 commits
  5. 07 Oct, 2019 5 commits
  6. 06 Oct, 2019 7 commits
    • Toke Høiland-Jørgensen's avatar
      libbpf: Add cscope and tags targets to Makefile · a9eb048d
      Toke Høiland-Jørgensen authored
      Using cscope and/or TAGS files for navigating the source code is useful.
      Add simple targets to the Makefile to generate the index files for both
      tools.
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Tested-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20191004153444.1711278-1-toke@redhat.com
      a9eb048d
    • Alexei Starovoitov's avatar
      Merge branch 'libbpf-api' · b84fbfe2
      Alexei Starovoitov authored
      Andrii Nakryiko says:
      
      ====================
      Add bpf_object__open_file() and bpf_object__open_mem() APIs that use a new
      approach to providing future-proof non-ABI-breaking API changes. It relies on
      APIs accepting optional self-describing "opts" struct, containing its own
      size, filled out and provided by potentially outdated (as well as
      newer-than-libbpf) user application. A set of internal helper macros
      (OPTS_VALID, OPTS_HAS, and OPTS_GET) streamline and simplify a graceful
      handling forward and backward compatibility for user applications dynamically
      linked against different versions of libbpf shared library.
      
      Users of libbpf are provided with convenience macro LIBBPF_OPTS that takes
      care of populating correct structure size and zero-initializes options struct,
      which helps avoid obscure issues of unitialized padding. Uninitialized padding
      in a struct might turn into garbage-populated new fields understood by future
      versions of libbpf.
      
      Patch #1 removes enforcement of kern_version in libbpf and always populates
      correct one on behalf of users.
      Patch #2 defines necessary infrastructure for options and two new open APIs
      relying on it.
      Patch #3 fixes bug in bpf_object__name().
      Patch #4 switches two of test_progs' tests to use new APIs as a validation
      that they work as expected.
      
      v2->v3:
      - fix LIBBPF_OPTS() to ensure zero-initialization of padded bytes;
      - pass through name override and relaxed maps flag for open_file() (Toke);
      - fix bpf_object__name() to actually return object name;
      - don't bother parsing and verifying version section (John);
      
      v1->v2:
      - use better approach for tracking last field in opts struct;
      - convert few tests to new APIs for validation;
      - fix bug with using offsetof(last_field) instead of offsetofend(last_field).
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b84fbfe2
    • Andrii Nakryiko's avatar
      selftests/bpf: switch tests to new bpf_object__open_{file, mem}() APIs · 928ca75e
      Andrii Nakryiko authored
      Verify new bpf_object__open_mem() and bpf_object__open_file() APIs work
      as expected by switching test_attach_probe test to use embedded BPF
      object and bpf_object__open_mem() and test_reference_tracking to
      bpf_object__open_file().
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      928ca75e
    • Andrii Nakryiko's avatar
      libbpf: fix bpf_object__name() to actually return object name · c9e4c301
      Andrii Nakryiko authored
      bpf_object__name() was returning file path, not name. Fix this.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c9e4c301
    • Andrii Nakryiko's avatar
      libbpf: add bpf_object__open_{file, mem} w/ extensible opts · 2ce8450e
      Andrii Nakryiko authored
      Add new set of bpf_object__open APIs using new approach to optional
      parameters extensibility allowing simpler ABI compatibility approach.
      
      This patch demonstrates an approach to implementing libbpf APIs that
      makes it easy to extend existing APIs with extra optional parameters in
      such a way, that ABI compatibility is preserved without having to do
      symbol versioning and generating lots of boilerplate code to handle it.
      To facilitate succinct code for working with options, add OPTS_VALID,
      OPTS_HAS, and OPTS_GET macros that hide all the NULL, size, and zero
      checks.
      
      Additionally, newly added libbpf APIs are encouraged to follow similar
      pattern of having all mandatory parameters as formal function parameters
      and always have optional (NULL-able) xxx_opts struct, which should
      always have real struct size as a first field and the rest would be
      optional parameters added over time, which tune the behavior of existing
      API, if specified by user.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      2ce8450e
    • Andrii Nakryiko's avatar
      libbpf: stop enforcing kern_version, populate it for users · 5e61f270
      Andrii Nakryiko authored
      Kernel version enforcement for kprobes/kretprobes was removed from
      5.0 kernel in 6c4fc209 ("bpf: remove useless version check for prog load").
      Since then, BPF programs were specifying SEC("version") just to please
      libbpf. We should stop enforcing this in libbpf, if even kernel doesn't
      care. Furthermore, libbpf now will pre-populate current kernel version
      of the host system, in case we are still running on old kernel.
      
      This patch also removes __bpf_object__open_xattr from libbpf.h, as
      nothing in libbpf is relying on having it in that header. That function
      was never exported as LIBBPF_API and even name suggests its internal
      version. So this should be safe to remove, as it doesn't break ABI.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      5e61f270
    • Andrii Nakryiko's avatar
      libbpf: Fix BTF-defined map's __type macro handling of arrays · a53ba15d
      Andrii Nakryiko authored
      Due to a quirky C syntax of declaring pointers to array or function
      prototype, existing __type() macro doesn't work with map key/value types
      that are array or function prototype. One has to create a typedef first
      and use it to specify key/value type for a BPF map.  By using typeof(),
      pointer to type is now handled uniformly for all kinds of types. Convert
      one of self-tests as a demonstration.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191004040211.2434033-1-andriin@fb.com
      a53ba15d
  7. 04 Oct, 2019 2 commits