[dpdk-dev] [PATCH v1 0/5] add framework to load and execute BPF code

Ananyev, Konstantin konstantin.ananyev at intel.com
Tue Mar 13 18:24:40 CET 2018


Hi Jerin,

> 
> Hi Konstantin,
> 
> >
> > BPF is used quite intensively inside Linux (and BSD) kernels
> > for various different purposes and proved to be extremely useful.
> >
> > BPF inside DPDK might also be used in a lot of places
> > for a lot of similar things.
> >  As an example to:
> > - packet filtering/tracing (aka tcpdump)
> > - packet classification
> > - statistics collection
> > - HW/PMD live-system debugging/prototyping - trace HW descriptors,
> >   internal PMD SW state, etc.
> >  ...
> >
> > All of that in a dynamic, user-defined and extensible manner.
> >
> > So these series introduce new library - librte_bpf.
> > librte_bpf provides API to load and execute BPF bytecode within
> > user-space dpdk app.
> > It supports basic set of features from eBPF spec.
> > Also it introduces basic framework to load/unload BPF-based filters
> > on eth devices (right now via SW RX/TX callbacks).
> 
> It is an interesting feature.
> I am yet to catch up on your implementation details.
> Meanwhile, I have tried to run non JIT version on arm64.
> I had some compilation issue with 4.9 kernel with gcc 5.3 toolchain.
> Following patch fixes that.
> 
> Just wondering what we will do with FreeBSD, May it better to
> kill the dependency of linux/filter.h and different kernel versions
> by making bpf_impl.h self sufficient. Just a thought.

Good point, have pretty much same thought:
we already have some rudimentary bpf-related include:
drivers/net/tap/tap_bpf.h
which is uder dual(bsd and gpl) license.
Might be we can move it to lib/librte_net/bpf (or so)
and extend to contain all necessary bpf related stuff.
Then could be used by  both TAP PMD and librte_bpf
and might be something else in future.
Konstantin

> 
> diff --git a/lib/librte_bpf/bpf_impl.h b/lib/librte_bpf/bpf_impl.h
> index f094170..e500e26 100644
> --- a/lib/librte_bpf/bpf_impl.h
> +++ b/lib/librte_bpf/bpf_impl.h
> @@ -13,6 +13,26 @@
>  extern "C" {
>  #endif
> 
> +#ifndef BPF_JLT
> +#define BPF_JLT        0xa0    /* LT is unsigned, '<' */
> +#endif
> +
> +#ifndef BPF_JLE
> +#define BPF_JLE        0xb0    /* LE is unsigned, '<=' */
> +#endif
> +
> +#ifndef BPF_JSLT
> +#define BPF_JSLT       0xc0    /* SLT is signed, '<' */
> +#endif
> +
> +#ifndef BPF_JSLE
> +#define BPF_JSLE       0xd0    /* SLE is signed, '<=' */
> +#endif
> +
> +#ifndef EM_BPF
> +#define EM_BPF         247     /* Linux BPF - in-kernel virtual machine
> */
> +#endif
> +


More information about the dev mailing list