Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Harshitha Ramamurthy <harshitha.ramamurthy@intel.com>,
	bpf@vger.kernel.org,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, David Ahern <dsahern@gmail.com>,
	Alexander Duyck <alexander.h.duyck@intel.com>,
	"TOM.HERBERT@INTEL.COM" <tom.herbert@intel.com>
Subject: Re: [PATCH bpf-next] bpf: add bpf_get_xdp_hash helper function
Date: Wed, 2 Sep 2020 09:56:24 -0600	[thread overview]
Message-ID: <CALx6S36sG_-eT0ziTaAfeHkocBi_K6q646JzphHbQ_W4YxXd0Q@mail.gmail.com> (raw)
In-Reply-To: <0333522d-7b65-e665-f19e-d36d11bd7846@iogearbox.net>

On Mon, Aug 31, 2020 at 2:33 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 8/31/20 9:25 PM, Harshitha Ramamurthy wrote:
> > This patch adds a helper function called bpf_get_xdp_hash to calculate
> > the hash for a packet at the XDP layer. In the helper function, we call
> > the kernel flow dissector in non-skb mode by passing the net pointer
> > to calculate the hash.
>
> So this commit msg says 'what' the patch does, but says nothing about 'why' it is
> needed especially given there's the 1 mio insn limit in place where it should be
> easy to write that up in BPF anyway. The commit msg needs to have a clear rationale
> which describes the motivation behind this helper.. why it cannot be done in BPF
> itself?
>
Daniel,

We already have a fully functional, well tested, and very complete
parser supporting many protocols and packet hash functions in the
kernel in skb_flow_dissect and friends. I suppose we could replicate
all that code in eBPF but I don't think it's fair to say it's easy to
get to the same level in eBPF. eBPF does solve the problem of
extensibility of kernel code, however IMO if someone is looking for an
easy way to get a packet hash then a simple helper function makes
sense and results in a much simpler XDP program.

There's some nice potential follow on work also. If the hardware
provides a quality L4 hash that could be passed into the XDP program
to avoid having to call the helper. If we do invoke the helper it
would make sense to return the hash to the driver so that it can set
in the skbuff to avoid having the stack call skb_flow_dissect again.
We can also have an flow_diessct helper that invokes skb_flow_dissect
and returns the meta data based on input keys. This would be useful
for filtering in XDP etc.

Tom

> > Changes since RFC:
> > - accounted for vlans(David Ahern)
> > - return the correct hash by not using skb_get_hash(David Ahern)
> > - call __skb_flow_dissect in non-skb mode
> >

      parent reply	other threads:[~2020-09-02 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 19:25 Harshitha Ramamurthy
2020-08-31 19:54 ` David Ahern
2020-09-02  0:52   ` Ramamurthy, Harshitha
2020-09-02  2:09     ` David Ahern
2020-08-31 20:33 ` Daniel Borkmann
2020-09-02  0:54   ` Ramamurthy, Harshitha
2020-09-02 15:56   ` Tom Herbert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALx6S36sG_-eT0ziTaAfeHkocBi_K6q646JzphHbQ_W4YxXd0Q@mail.gmail.com \
    --to=tom@herbertland.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=harshitha.ramamurthy@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom.herbert@intel.com \
    --subject='Re: [PATCH bpf-next] bpf: add bpf_get_xdp_hash helper function' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).