1. 27 Sep, 2017 34 commits
  2. 26 Sep, 2017 6 commits
    • David S. Miller's avatar
      Merge branch 'bpf-metadata-direct-access' · 390e96ec
      David S. Miller authored
      Daniel Borkmann says:
      
      ====================
      BPF metadata for direct access
      
      This work enables generic transfer of metadata from XDP into skb,
      meaning the packet has a flexible and programmable room for meta
      data, which can later be used by BPF to set various skb members
      when passing up the stack. For details, please see second patch.
      Support has been implemented and tested with two drivers, and
      should be straight forward to add to other drivers as well which
      properly support head adjustment already.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      390e96ec
    • Daniel Borkmann's avatar
      bpf, ixgbe: add meta data support · 366a88fe
      Daniel Borkmann authored
      Implement support for transferring XDP meta data into skb for
      ixgbe driver; before calling into the program, xdp.data_meta points
      to xdp.data, where on program return with pass verdict, we call
      into skb_metadata_set().
      
      We implement this for the default ixgbe_build_skb() variant. For the
      ixgbe_construct_skb() that is used when legacy-rx buffer mananagement
      mode is turned on via ethtool, I found that XDP gets 0 headroom, so
      neither xdp_adjust_head() nor xdp_adjust_meta() can be used with this.
      Just add a comment with explanation for this operating mode.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      366a88fe
    • Daniel Borkmann's avatar
      bpf, nfp: add meta data support · 65d88fd0
      Daniel Borkmann authored
      Implement support for transferring XDP meta data into skb for
      nfp driver; before calling into the program, xdp.data_meta points
      to xdp.data, where on program return with pass verdict, we call
      into skb_metadata_set().
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      65d88fd0
    • Daniel Borkmann's avatar
      bpf: improve selftests and add tests for meta pointer · 22c88526
      Daniel Borkmann authored
      Add various test_verifier selftests, and a simple xdp/tc functional
      test that is being attached to veths. Also let new versions of clang
      use the recently added -mcpu=probe support [1] for the BPF target,
      so that it can probe the underlying kernel for BPF insn set extensions.
      We could also just set this options always, where older versions just
      ignore it and give a note to the user that the -mcpu value is not
      supported, but given emitting the note cannot be turned off from clang
      side lets not confuse users running selftests with it, thus fallback
      to the default generic one when we see that clang doesn't support it.
      Also allow CPU option to be overridden in the Makefile from command
      line.
      
        [1] https://github.com/llvm-mirror/llvm/commit/d7276a40d87b89aed89978dec6457a5b8b3a0db5Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      22c88526
    • Daniel Borkmann's avatar
      bpf: update bpf.h uapi header for tools · ac29991b
      Daniel Borkmann authored
      Looks like a couple of updates missed to get carried into tools/include/uapi/,
      so copy the bpf.h header as usual to pull in latest updates.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ac29991b
    • Daniel Borkmann's avatar
      bpf: add meta pointer for direct access · de8f3a83
      Daniel Borkmann authored
      This work enables generic transfer of metadata from XDP into skb. The
      basic idea is that we can make use of the fact that the resulting skb
      must be linear and already comes with a larger headroom for supporting
      bpf_xdp_adjust_head(), which mangles xdp->data. Here, we base our work
      on a similar principle and introduce a small helper bpf_xdp_adjust_meta()
      for adjusting a new pointer called xdp->data_meta. Thus, the packet has
      a flexible and programmable room for meta data, followed by the actual
      packet data. struct xdp_buff is therefore laid out that we first point
      to data_hard_start, then data_meta directly prepended to data followed
      by data_end marking the end of packet. bpf_xdp_adjust_head() takes into
      account whether we have meta data already prepended and if so, memmove()s
      this along with the given offset provided there's enough room.
      
      xdp->data_meta is optional and programs are not required to use it. The
      rationale is that when we process the packet in XDP (e.g. as DoS filter),
      we can push further meta data along with it for the XDP_PASS case, and
      give the guarantee that a clsact ingress BPF program on the same device
      can pick this up for further post-processing. Since we work with skb
      there, we can also set skb->mark, skb->priority or other skb meta data
      out of BPF, thus having this scratch space generic and programmable
      allows for more flexibility than defining a direct 1:1 transfer of
      potentially new XDP members into skb (it's also more efficient as we
      don't need to initialize/handle each of such new members). The facility
      also works together with GRO aggregation. The scratch space at the head
      of the packet can be multiple of 4 byte up to 32 byte large. Drivers not
      yet supporting xdp->data_meta can simply be set up with xdp->data_meta
      as xdp->data + 1 as bpf_xdp_adjust_meta() will detect this and bail out,
      such that the subsequent match against xdp->data for later access is
      guaranteed to fail.
      
      The verifier treats xdp->data_meta/xdp->data the same way as we treat
      xdp->data/xdp->data_end pointer comparisons. The requirement for doing
      the compare against xdp->data is that it hasn't been modified from it's
      original address we got from ctx access. It may have a range marking
      already from prior successful xdp->data/xdp->data_end pointer comparisons
      though.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      de8f3a83