1. 04 Jun, 2018 6 commits
    • Björn Töpel's avatar
      xsk: proper fill queue descriptor validation · 4e64c835
      Björn Töpel authored
      Previously the fill queue descriptor was not copied to kernel space
      prior validating it, making it possible for userland to change the
      descriptor post-kernel-validation.
      Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      4e64c835
    • David Ahern's avatar
      bpf: flowlabel in bpf_fib_lookup should be flowinfo · bd3a08aa
      David Ahern authored
      As Michal noted the flow struct takes both the flow label and priority.
      Update the bpf_fib_lookup API to note that it is flowinfo and not just
      the flow label.
      
      Cc: Michal Kubecek <mkubecek@suse.cz>
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      bd3a08aa
    • Alexei Starovoitov's avatar
      Merge branch 'bpf_get_current_cgroup_id' · 432bdb58
      Alexei Starovoitov authored
      Yonghong Song says:
      
      ====================
      bpf has been used extensively for tracing. For example, bcc
      contains an almost full set of bpf-based tools to trace kernel
      and user functions/events. Most tracing tools are currently
      either filtered based on pid or system-wide.
      
      Containers have been used quite extensively in industry and
      cgroup is often used together to provide resource isolation
      and protection. Several processes may run inside the same
      container. It is often desirable to get container-level tracing
      results as well, e.g. syscall count, function count, I/O
      activity, etc.
      
      This patch implements a new helper, bpf_get_current_cgroup_id(),
      which will return cgroup id based on the cgroup within which
      the current task is running.
      
      Patch #1 implements the new helper in the kernel.
      Patch #2 syncs the uapi bpf.h header and helper between tools
      and kernel.
      Patch #3 shows how to get the same cgroup id in user space,
      so a filter or policy could be configgured in the bpf program
      based on current task cgroup.
      
      Changelog:
        v1 -> v2:
           . rebase to resolve merge conflict with latest bpf-next.
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      432bdb58
    • Yonghong Song's avatar
      tools/bpf: add a selftest for bpf_get_current_cgroup_id() helper · f269099a
      Yonghong Song authored
      Syscall name_to_handle_at() can be used to get cgroup id
      for a particular cgroup path in user space. The selftest
      got cgroup id from both user and kernel, and compare to
      ensure they are equal to each other.
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      f269099a
    • Yonghong Song's avatar
      tools/bpf: sync uapi bpf.h for bpf_get_current_cgroup_id() helper · c7ddbbaf
      Yonghong Song authored
      Sync kernel uapi/linux/bpf.h with tools uapi/linux/bpf.h.
      Also add the necessary helper define in bpf_helpers.h.
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c7ddbbaf
    • Yonghong Song's avatar
      bpf: implement bpf_get_current_cgroup_id() helper · bf6fa2c8
      Yonghong Song authored
      bpf has been used extensively for tracing. For example, bcc
      contains an almost full set of bpf-based tools to trace kernel
      and user functions/events. Most tracing tools are currently
      either filtered based on pid or system-wide.
      
      Containers have been used quite extensively in industry and
      cgroup is often used together to provide resource isolation
      and protection. Several processes may run inside the same
      container. It is often desirable to get container-level tracing
      results as well, e.g. syscall count, function count, I/O
      activity, etc.
      
      This patch implements a new helper, bpf_get_current_cgroup_id(),
      which will return cgroup id based on the cgroup within which
      the current task is running.
      
      The later patch will provide an example to show that
      userspace can get the same cgroup id so it could
      configure a filter or policy in the bpf program based on
      task cgroup id.
      
      The helper is currently implemented for tracing. It can
      be added to other program types as well when needed.
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      bf6fa2c8
  2. 03 Jun, 2018 21 commits
  3. 02 Jun, 2018 9 commits
  4. 30 May, 2018 4 commits
    • David Ahern's avatar
      bpf: Change bpf_fib_lookup to return -EAFNOSUPPORT for unsupported address families · bcece5dc
      David Ahern authored
      Update bpf_fib_lookup to return -EAFNOSUPPORT for unsupported address
      families. Allows userspace to probe for support as more are added
      (e.g., AF_MPLS).
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      bcece5dc
    • Colin Ian King's avatar
      bpf: devmap: remove redundant assignment of dev = dev · 71b2c87d
      Colin Ian King authored
      The assignment dev = dev is redundant and should be removed.
      
      Detected by CoverityScan, CID#1469486 ("Evaluation order violation")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      71b2c87d
    • Andrey Ignatov's avatar
      bpftool: Support sendmsg{4,6} attach types · 13a370b9
      Andrey Ignatov authored
      Add support for recently added BPF_CGROUP_UDP4_SENDMSG and
      BPF_CGROUP_UDP6_SENDMSG attach types to bpftool, update documentation
      and bash completion.
      Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      13a370b9
    • Daniel Borkmann's avatar
      Merge branch 'bpf-ir-decoder' · ee7dbd97
      Daniel Borkmann authored
      Sean Young says:
      
      ====================
      The kernel IR decoders (drivers/media/rc/ir-*-decoder.c) support the most
      widely used IR protocols, but there are many protocols which are not
      supported[1]. For example, the lirc-remotes[2] repo has over 2700 remotes,
      many of which are not supported by rc-core. There is a "long tail" of
      unsupported IR protocols, for which lircd is need to decode the IR .
      
      IR encoding is done in such a way that some simple circuit can decode it;
      therefore, bpf is ideal.
      
      In order to support all these protocols, here we have bpf based IR decoding.
      The idea is that user-space can define a decoder in bpf, attach it to
      the rc device through the lirc chardev.
      
      Separate work is underway to extend ir-keytable to have an extensive library
      of bpf-based decoders, and a much expanded library of rc keymaps.
      
      Another future application would be to compile IRP[3] to a IR BPF program, and
      so support virtually every remote without having to write a decoder for each.
      It might also be possible to support non-button devices such as analog
      directional pads or air conditioning remote controls and decode the target
      temperature in bpf, and pass that to an input device.
      
      [1] http://www.hifi-remote.com/wiki/index.php?title=DecodeIR
      [2] https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/
      [3] http://www.hifi-remote.com/wiki/index.php?title=IRP_Notation
      
      Changes since v4:
       - Renamed rc_dev_bpf_{attach,detach,query} to lirc_bpf_{attach,detach,query}
       - Fixed error path in lirc_bpf_query
       - Rebased on bpf-next
      
      Changes since v3:
       - Implemented review comments from Quentin Monnet and Y Song (thanks!)
       - More helpful and better formatted bpf helper documentation
       - Changed back to bpf_prog_array rather than open-coded implementation
       - scancodes can be 64 bit
       - bpf gets passed values in microseconds, not nanoseconds.
         microseconds is more than than enough (IR receivers support carriers upto
         70kHz, at which point a single period is already 14 microseconds). Also,
         this makes it much more consistent with lirc mode2.
       - Since it looks much more like lirc mode2, rename the program type to
         BPF_PROG_TYPE_LIRC_MODE2.
       - Rebased on bpf-next
      
      Changes since v2:
       - Fixed locking issues
       - Improved self-test to cover more cases
       - Rebased on bpf-next again
      
      Changes since v1:
       - Code review comments from Y Song <ys114321@gmail.com> and
         Randy Dunlap <rdunlap@infradead.org>
       - Re-wrote sample bpf to be selftest
       - Renamed RAWIR_DECODER -> RAWIR_EVENT (Kconfig, context, bpf prog type)
       - Rebase on bpf-next
       - Introduced bpf_rawir_event context structure with simpler access checking
      ====================
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      ee7dbd97