1. 24 1月, 2019 1 次提交
  2. 19 12月, 2018 1 次提交
  3. 18 12月, 2018 1 次提交
  4. 13 12月, 2018 1 次提交
  5. 12 12月, 2018 1 次提交
  6. 11 12月, 2018 1 次提交
  7. 10 12月, 2018 2 次提交
  8. 06 12月, 2018 1 次提交
  9. 05 12月, 2018 1 次提交
  10. 04 12月, 2018 1 次提交
  11. 01 12月, 2018 4 次提交
    • D
      bpf: Add BPF_F_ANY_ALIGNMENT. · e9ee9efc
      David Miller 提交于
      Often we want to write tests cases that check things like bad context
      offset accesses.  And one way to do this is to use an odd offset on,
      for example, a 32-bit load.
      
      This unfortunately triggers the alignment checks first on platforms
      that do not set CONFIG_EFFICIENT_UNALIGNED_ACCESS.  So the test
      case see the alignment failure rather than what it was testing for.
      
      It is often not completely possible to respect the original intention
      of the test, or even test the same exact thing, while solving the
      alignment issue.
      
      Another option could have been to check the alignment after the
      context and other validations are performed by the verifier, but
      that is a non-trivial change to the verifier.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      e9ee9efc
    • J
      bpf: Improve socket lookup reuseport documentation · d74286d2
      Joe Stringer 提交于
      Improve the wording around socket lookup for reuseport sockets, and
      ensure that both bpf.h headers are in sync.
      Signed-off-by: NJoe Stringer <joe@wand.net.nz>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      d74286d2
    • J
      bpf: Support sk lookup in netns with id 0 · f71c6143
      Joe Stringer 提交于
      David Ahern and Nicolas Dichtel report that the handling of the netns id
      0 is incorrect for the BPF socket lookup helpers: rather than finding
      the netns with id 0, it is resolving to the current netns. This renders
      the netns_id 0 inaccessible.
      
      To fix this, adjust the API for the netns to treat all negative s32
      values as a lookup in the current netns (including u64 values which when
      truncated to s32 become negative), while any values with a positive
      value in the signed 32-bit integer space would result in a lookup for a
      socket in the netns corresponding to that id. As before, if the netns
      with that ID does not exist, no socket will be found. Any netns outside
      of these ranges will fail to find a corresponding socket, as those
      values are reserved for future usage.
      Signed-off-by: NJoe Stringer <joe@wand.net.nz>
      Acked-by: NNicolas Dichtel <nicolas.dichtel@6wind.com>
      Acked-by: NJoey Pabalinas <joeypabalinas@gmail.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      f71c6143
    • D
      bpf: fix pointer offsets in context for 32 bit · b7df9ada
      Daniel Borkmann 提交于
      Currently, pointer offsets in three BPF context structures are
      broken in two scenarios: i) 32 bit compiled applications running
      on 64 bit kernels, and ii) LLVM compiled BPF programs running
      on 32 bit kernels. The latter is due to BPF target machine being
      strictly 64 bit. So in each of the cases the offsets will mismatch
      in verifier when checking / rewriting context access. Fix this by
      providing a helper macro __bpf_md_ptr() that will enforce padding
      up to 64 bit and proper alignment, and for context access a macro
      bpf_ctx_range_ptr() which will cover full 64 bit member range on
      32 bit archs. For flow_keys, we additionally need to force the
      size check to sizeof(__u64) as with other pointer types.
      
      Fixes: d58e468b ("flow_dissector: implements flow dissector BPF hook")
      Fixes: 4f738adb ("bpf: create tcp_bpf_ulp allowing BPF to monitor socket TX/RX data")
      Fixes: 2dbb9b9e ("bpf: Introduce BPF_PROG_TYPE_SK_REUSEPORT")
      Reported-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Tested-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      b7df9ada
  12. 29 11月, 2018 1 次提交
  13. 23 11月, 2018 1 次提交
  14. 21 11月, 2018 1 次提交
  15. 20 11月, 2018 1 次提交
  16. 21 10月, 2018 1 次提交
  17. 20 10月, 2018 1 次提交
  18. 18 10月, 2018 1 次提交
  19. 03 10月, 2018 1 次提交
    • J
      bpf: Add helper to retrieve socket in BPF · 6acc9b43
      Joe Stringer 提交于
      This patch adds new BPF helper functions, bpf_sk_lookup_tcp() and
      bpf_sk_lookup_udp() which allows BPF programs to find out if there is a
      socket listening on this host, and returns a socket pointer which the
      BPF program can then access to determine, for instance, whether to
      forward or drop traffic. bpf_sk_lookup_xxx() may take a reference on the
      socket, so when a BPF program makes use of this function, it must
      subsequently pass the returned pointer into the newly added sk_release()
      to return the reference.
      
      By way of example, the following pseudocode would filter inbound
      connections at XDP if there is no corresponding service listening for
      the traffic:
      
        struct bpf_sock_tuple tuple;
        struct bpf_sock_ops *sk;
      
        populate_tuple(ctx, &tuple); // Extract the 5tuple from the packet
        sk = bpf_sk_lookup_tcp(ctx, &tuple, sizeof tuple, netns, 0);
        if (!sk) {
          // Couldn't find a socket listening for this traffic. Drop.
          return TC_ACT_SHOT;
        }
        bpf_sk_release(sk, 0);
        return TC_ACT_OK;
      Signed-off-by: NJoe Stringer <joe@wand.net.nz>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      6acc9b43
  20. 01 10月, 2018 1 次提交
  21. 15 9月, 2018 1 次提交
  22. 13 8月, 2018 1 次提交
  23. 11 8月, 2018 1 次提交
  24. 03 8月, 2018 1 次提交
  25. 31 7月, 2018 1 次提交
  26. 30 7月, 2018 1 次提交
  27. 15 7月, 2018 1 次提交
  28. 13 7月, 2018 1 次提交
  29. 25 6月, 2018 1 次提交
  30. 04 6月, 2018 1 次提交
  31. 03 6月, 2018 1 次提交
  32. 02 6月, 2018 1 次提交
    • D
      bpf: fix uapi hole for 32 bit compat applications · 36f9814a
      Daniel Borkmann 提交于
      In 64 bit, we have a 4 byte hole between ifindex and netns_dev in the
      case of struct bpf_map_info but also struct bpf_prog_info. In net-next
      commit b85fab0e ("bpf: Add gpl_compatible flag to struct bpf_prog_info")
      added a bitfield into it to expose some flags related to programs. Thus,
      add an unnamed __u32 bitfield for both so that alignment keeps the same
      in both 32 and 64 bit cases, and can be naturally extended from there
      as in b85fab0e.
      
      Before:
      
        # file test.o
        test.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
        # pahole test.o
        struct bpf_map_info {
      	__u32                      type;                 /*     0     4 */
      	__u32                      id;                   /*     4     4 */
      	__u32                      key_size;             /*     8     4 */
      	__u32                      value_size;           /*    12     4 */
      	__u32                      max_entries;          /*    16     4 */
      	__u32                      map_flags;            /*    20     4 */
      	char                       name[16];             /*    24    16 */
      	__u32                      ifindex;              /*    40     4 */
      	__u64                      netns_dev;            /*    44     8 */
      	__u64                      netns_ino;            /*    52     8 */
      
      	/* size: 64, cachelines: 1, members: 10 */
      	/* padding: 4 */
        };
      
      After (same as on 64 bit):
      
        # file test.o
        test.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
        # pahole test.o
        struct bpf_map_info {
      	__u32                      type;                 /*     0     4 */
      	__u32                      id;                   /*     4     4 */
      	__u32                      key_size;             /*     8     4 */
      	__u32                      value_size;           /*    12     4 */
      	__u32                      max_entries;          /*    16     4 */
      	__u32                      map_flags;            /*    20     4 */
      	char                       name[16];             /*    24    16 */
      	__u32                      ifindex;              /*    40     4 */
      
      	/* XXX 4 bytes hole, try to pack */
      
      	__u64                      netns_dev;            /*    48     8 */
      	__u64                      netns_ino;            /*    56     8 */
      	/* --- cacheline 1 boundary (64 bytes) --- */
      
      	/* size: 64, cachelines: 1, members: 10 */
      	/* sum members: 60, holes: 1, sum holes: 4 */
        };
      Reported-by: NDmitry V. Levin <ldv@altlinux.org>
      Reported-by: NEugene Syromiatnikov <esyr@redhat.com>
      Fixes: 52775b33 ("bpf: offload: report device information about offloaded maps")
      Fixes: 675fc275 ("bpf: offload: report device information for offloaded programs")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      36f9814a
  33. 30 5月, 2018 2 次提交
  34. 28 5月, 2018 1 次提交
  35. 25 5月, 2018 1 次提交