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

Jerin Jacob jerin.jacob at caviumnetworks.com
Tue Mar 13 14:02:41 CET 2018


-----Original Message-----
> Date: Fri, 9 Mar 2018 16:42:00 +0000
> From: Konstantin Ananyev <konstantin.ananyev at intel.com>
> To: dev at dpdk.org
> CC: Konstantin Ananyev <konstantin.ananyev at intel.com>
> Subject: [dpdk-dev] [PATCH v1 0/5] add framework to load and execute BPF
>  code
> X-Mailer: git-send-email 1.7.0.7

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.

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