From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Tom Herbert <tom@herbertland.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>,
Brenden Blanco <bblanco@plumgrid.com>,
"David S. Miller" <davem@davemloft.net>,
Linux Kernel Network Developers <netdev@vger.kernel.org>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Saeed Mahameed <saeedm@dev.mellanox.co.il>,
Martin KaFai Lau <kafai@fb.com>, Ari Saha <as754m@att.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Or Gerlitz <gerlitz.or@gmail.com>,
john fastabend <john.fastabend@gmail.com>,
Hannes Frederic Sowa <hannes@stressinduktion.org>,
Thomas Graf <tgraf@suug.ch>,
Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH v8 01/11] bpf: add XDP prog type for early driver filter
Date: Tue, 12 Jul 2016 17:08:16 +0100 [thread overview]
Message-ID: <20160712170816.1dd8ba18@jkicinski-Precision-T1700> (raw)
In-Reply-To: <CALx6S36aPgB1PCsTg7Z=SNGQs_8REMm4qJdpp6JJ6ksVp_65VA@mail.gmail.com>
On Tue, 12 Jul 2016 07:52:53 -0700, Tom Herbert wrote:
> On Tue, Jul 12, 2016 at 6:14 AM, Jesper Dangaard Brouer
> <brouer@redhat.com> wrote:
> >
> > On Tue, 12 Jul 2016 00:51:24 -0700 Brenden Blanco <bblanco@plumgrid.com> wrote:
> >
> >> Add a new bpf prog type that is intended to run in early stages of the
> >> packet rx path. Only minimal packet metadata will be available, hence a
> >> new context type, struct xdp_md, is exposed to userspace. So far only
> >> expose the packet start and end pointers, and only in read mode.
> >>
> >> An XDP program must return one of the well known enum values, all other
> >> return codes are reserved for future use. Unfortunately, this
> >> restriction is hard to enforce at verification time, so take the
> >> approach of warning at runtime when such programs are encountered. Out
> >> of bounds return codes should alias to XDP_ABORTED.
> >
> > This is going to be a serious usability problem, when XDP gets extended
> > with newer features.
> >
> > How can users know what XDP capabilities a given driver support?
I'm personally not a big fan of return codes. I'm hoping we can express
most decisions by setting fields in metadata. It provides a better
structure and is easier to detect/translate/optimize.
> We talked about this a the XDP summit and I have some slides on this
> (hope to have slides posted shortly) . Drivers, more generally XDP
> platforms, will provide a list APIs that they support. APIs would be
> contained in a sort common specification files that and would have
> some name like basic_xdp_api, adv_switch_api, etc. An XDP program is
> written using one of the published APIs and the API it uses is
> expressed as part of the program. At runtime (possibly compile time)
> the API used by the program is checked against the list of APIs for
> the target platform-- if the API is not in the set then the program is
> not allowed to be loaded. To whatever extent possible we should also
> try to verify that program adhere's to the API as load and compile
> time. In the event that program violates the API it claims to be
> using, such as return invalid return code for the API, that is an
> error condition.
+1
> > If the user loads a XDP program using capabilities not avail in the
> > driver, then all his traffic will be hard dropped.
> >
> >
> > My proposal is to NOT allow XDP programs to be loaded if they want to use
> > return-codes/features not supported by the driver. Thus, eBPF programs
> > register/annotate their needed capabilities upfront (I guess this could
> > also help HW offload engines).
Not sure we need annotation, use of an API will probably be easily
detectable (call of a function, access to metadata field). Verifier
could collect that info in-kernel with little effort.
> Exactly. We just need to define exactly how this is done ;-)
>
> One open issue is whether XDP needs to be binary compatible across
> platforms or source code compatible (also require recompile in latter
> case for each platform). Personally I prefer source code compatible
> since that might allow platforms to implement the API specifically for
> their needs (like the ordering of fields in a meta data structure.
Since XDP is so close to hardware by design, I think we could consider
introducing per-HW translation stage between the verifier and host JIT.
For extended metadata problem for example - we could define metadata as:
meta {
void *packet_start;
void *packet_end;
struct standard_meta *extended_meta;
}
standard_meta {
vlan;
timestamp;
hash;
...
}
Program coming from the user space would just use standard_meta but
per-driver/per-HW translator would patch it up. extended_meta pointer
would probably become pointer to HW-specific queue descriptor at
runtime. The per-HW translator stage would change the offsets and add
necessary checks and fix-ups. It could even be possible to translate
from extended_meta access to access to metadata prepended to the frame,
translator would need a hint from the verifier on how to get the packet
pointer.
I haven't thought this through in detail, it's just an idea which would
help us to keep binary compatibility. HW-specific optimizations in
user space compiler would be great, but breaking binary compatibility
is a bit of a scary step.
next prev parent reply other threads:[~2016-07-12 16:08 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 7:51 [PATCH v8 00/11] Add driver bpf hook for early packet drop and forwarding Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 01/11] bpf: add XDP prog type for early driver filter Brenden Blanco
2016-07-12 13:14 ` Jesper Dangaard Brouer
2016-07-12 14:52 ` Tom Herbert
2016-07-12 16:08 ` Jakub Kicinski [this message]
2016-07-13 4:14 ` Alexei Starovoitov
2016-07-12 7:51 ` [PATCH v8 02/11] net: add ndo to setup/query xdp prog in adapter rx Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 03/11] rtnl: add option for setting link xdp prog Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 04/11] net/mlx4_en: add support for fast rx drop bpf program Brenden Blanco
2016-07-12 12:02 ` Tariq Toukan
2016-07-13 11:27 ` David Laight
2016-07-13 14:08 ` Brenden Blanco
2016-07-14 7:25 ` Jesper Dangaard Brouer
2016-07-15 3:30 ` Alexei Starovoitov
2016-07-15 8:21 ` Jesper Dangaard Brouer
2016-07-15 16:56 ` Alexei Starovoitov
2016-07-15 16:18 ` Tom Herbert
2016-07-15 16:47 ` Alexei Starovoitov
2016-07-15 17:49 ` Tom Herbert
2016-07-18 9:10 ` Thomas Graf
2016-07-18 11:39 ` Tom Herbert
2016-07-18 12:48 ` Thomas Graf
2016-07-18 13:07 ` Tom Herbert
2016-07-19 2:45 ` Alexei Starovoitov
2016-07-18 19:03 ` Brenden Blanco
2016-07-15 19:09 ` Jesper Dangaard Brouer
2016-07-18 4:01 ` Alexei Starovoitov
2016-07-18 8:35 ` Daniel Borkmann
2016-07-15 18:08 ` Tom Herbert
2016-07-15 18:45 ` Jesper Dangaard Brouer
2016-07-12 7:51 ` [PATCH v8 05/11] Add sample for adding simple drop program to link Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 06/11] net/mlx4_en: add page recycle to prepare rx ring for tx support Brenden Blanco
2016-07-12 12:09 ` Tariq Toukan
2016-07-12 21:18 ` David Miller
2016-07-13 0:54 ` Brenden Blanco
2016-07-13 7:17 ` Tariq Toukan
2016-07-13 15:40 ` Brenden Blanco
2016-07-15 21:52 ` Brenden Blanco
[not found] ` <6d638467-eea6-d3e1-6984-88a1198ef303@gmail.com>
2016-07-19 17:41 ` Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 07/11] bpf: add XDP_TX xdp_action for direct forwarding Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 08/11] net/mlx4_en: break out tx_desc write into separate function Brenden Blanco
2016-07-12 12:16 ` Tariq Toukan
2016-07-12 7:51 ` [PATCH v8 09/11] net/mlx4_en: add xdp forwarding and data write support Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 10/11] bpf: enable direct packet data write for xdp progs Brenden Blanco
2016-07-12 7:51 ` [PATCH v8 11/11] bpf: add sample for xdp forwarding and rewrite Brenden Blanco
2016-07-12 14:38 ` [PATCH v8 00/11] Add driver bpf hook for early packet drop and forwarding Tariq Toukan
2016-07-13 15:00 ` Tariq Toukan
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=20160712170816.1dd8ba18@jkicinski-Precision-T1700 \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=as754m@att.com \
--cc=bblanco@plumgrid.com \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=gerlitz.or@gmail.com \
--cc=hannes@stressinduktion.org \
--cc=jhs@mojatatu.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@dev.mellanox.co.il \
--cc=tgraf@suug.ch \
--cc=tom@herbertland.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox