1. 14 Jul, 2018 2 commits
  2. 13 Jul, 2018 14 commits
  3. 12 Jul, 2018 19 commits
  4. 11 Jul, 2018 5 commits
    • Daniel Borkmann's avatar
      Merge branch 'bpf-bpftool-improved-prog-load' · 671dffa7
      Daniel Borkmann authored
      Jakub Kicinski says:
      
      ====================
      This series starts with two minor clean ups to test_offload.py
      selftest script.
      
      The next 11 patches extend the abilities of bpftool prog load
      beyond the simple cgroup use cases.  Three new parameters are
      added:
      
       - type - allows specifying program type, independent of how
         code sections are named;
       - map  - allows reusing existing maps, instead of creating a new
         map on every program load;
       - dev  - offload/binding to a device.
      
      A number of changes to libbpf is required to accomplish the task.
      The section - program type logic mapping is exposed.  We should
      probably aim to use the libbpf program section naming everywhere.
      For reuse of maps we need to allow users to set FD for bpf map
      object in libbpf.
      
      Examples
      
      Load program my_xdp.o and pin it as /sys/fs/bpf/my_xdp, for xdp
      program type:
      
      $ bpftool prog load my_xdp.o /sys/fs/bpf/my_xdp \
        type xdp
      
      As above but for offload:
      
      $ bpftool prog load my_xdp.o /sys/fs/bpf/my_xdp \
        type xdp \
        dev netdevsim0
      
      Load program my_maps.o, but for the first map reuse map id 17,
      and for the map called "other_map" reuse pinned map /sys/fs/bpf/map0:
      
      $ bpftool prog load my_maps.o /sys/fs/bpf/prog \
        map idx 0 id 17 \
        map name other_map pinned /sys/fs/bpf/map0
      
      v3:
       - fix return codes in patch 5;
       - rename libbpf_prog_type_by_string() -> libbpf_prog_type_by_name();
       - fold file path into xattr in patch 8;
       - add patch 10;
       - use dup3() in patch 12;
       - depend on fd value in patch 12;
       - close old fd in patch 12.
      v2:
       - add compat for reallocarray().
      ====================
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      671dffa7
    • Jakub Kicinski's avatar
      tools: bpftool: allow reuse of maps with bpftool prog load · 3ff5a4dc
      Jakub Kicinski authored
      Add map parameter to prog load which will allow reuse of existing
      maps instead of creating new ones.
      
      We need feature detection and compat code for reallocarray, since
      it's not available in many libc versions.
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      3ff5a4dc
    • Jakub Kicinski's avatar
      tools: libbpf: allow map reuse · 26736eb9
      Jakub Kicinski authored
      More advanced applications may want to only replace programs without
      destroying associated maps.  Allow libbpf users to achieve that.
      Instead of always creating all of the maps at load time, expose to
      users an API to reconstruct the map object from already existing
      map.
      
      The map parameters are read from the kernel and replace the parameters
      of the ELF map.  libbpf does not restrict the map replacement, i.e.
      the reused map does not have to be compatible with the ELF map
      definition.  We relay on the verifier for checking the compatibility
      between maps and programs.  The ELF map definition is completely
      overwritten by the information read from the kernel, to make sure
      libbpf's view of map object corresponds to the actual map.
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Acked-by: default avatarAndrey Ignatov <rdna@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      26736eb9
    • Jakub Kicinski's avatar
      tools: bpf: make use of reallocarray · 531b014e
      Jakub Kicinski authored
      reallocarray() is a safer variant of realloc which checks for
      multiplication overflow in case of array allocation.  Since it's
      not available in Glibc < 2.26 import kernel's overflow.h and
      add a static inline implementation when needed.  Use feature
      detection to probe for existence of reallocarray.
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
      Reviewed-by: default avatarJiong Wang <jiong.wang@netronome.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      531b014e
    • Jakub Kicinski's avatar
      tools: libbpf: move library error code into a separate file · 8d13406c
      Jakub Kicinski authored
      libbpf_strerror() depends on XSI-compliant (POSIX) version of
      strerror_r(), which prevents us from using GNU-extensions in
      libbpf.c, like reallocarray() or dup3().  Move error printing
      code into a separate file to allow it to continue using POSIX
      strerror_r().
      
      No functional changes.
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      8d13406c