Skip to contentSkip to conversation

net: filter: split eBPF interpreter out of core networking

PATCH In review Alexei Starovoitov 7 participants 11 messages Jul 23, 2014 – Jul 25, 2014

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover net: filter: split eBPF interpreter out of core networking

Hi David,

I believe my recent set of RFC/patches [1] provided good visibility on where I would like to take eBPF subsystem. These two trivial patches is a first step in that direction:
patch 1 - mechanical split of eBPF interpreter out of filter.c patch 2 - nominate myself as a maintainer for eBPF core pieces
In the foreseeable future eBPF patches will be going through net-next, so put netdev as a primary mailing list

[1] git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf master

Alexei Starovoitov (2):
net: filter: split filter.c into two files
bpf: update MAINTAINERS entry

 MAINTAINERS         |    7 +
 kernel/Makefile     |    1 +
 kernel/bpf/Makefile |    1 +
 kernel/bpf/core.c   |  536 +++++++++++++++++++++++++++++++++++++++++++++++++++
 net/core/filter.c   |  511 ------------------------------------------------
 5 files changed, 545 insertions(+), 511 deletions(-)
 create mode 100644 kernel/bpf/Makefile
 create mode 100644 kernel/bpf/core.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 net: filter: split filter.c into two files

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

This patch only moves functions.

---
 kernel/Makefile     |    1 +
 kernel/bpf/Makefile |    1 +
 kernel/bpf/core.c   |  536 +++++++++++++++++++++++++++++++++++++++++++++++++++
 net/core/filter.c   |  511 ------------------------------------------------
 4 files changed, 538 insertions(+), 511 deletions(-)
 create mode 100644 kernel/bpf/Makefile
 create mode 100644 kernel/bpf/core.c
kernel/Makefile +1 -0
index f2a8b6246ce9..e7360b7c2c0e 100644
@@ -87,6 +87,7 @@ obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_TRACEPOINTS) += trace/
 obj-$(CONFIG_IRQ_WORK) += irq_work.o
 obj-$(CONFIG_CPU_PM) += cpu_pm.o
+obj-$(CONFIG_NET) += bpf/
 
 obj-$(CONFIG_PERF_EVENTS) += events/
 
kernel/bpf/Makefile new file +1 -0
new file mode 100644
index 000000000000..6a71145e2769
@@ -0,0 +1 @@
+obj-y := core.o
kernel/bpf/core.c new file +536 -0

536 lines not on this page · raw message

net/core/filter.c +0 -511

529 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH net-next 1/2] net: filter: split filter.c into two files

Quoted 8 lines · Alexei Starovoitov

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

This patch only moves functions.

If we are moving the code also its good to do cleanup.

Run checkpatch.pl on this...

Signature · 2 lines
Regards,
Varka Bhadram.
#3 lore raw

RE: [PATCH net-next 1/2] net: filter: split filter.c into two files

From: Varka Bhadram

Quoted 11 lines · Alexei Starovoitov
Quoted 8 lines

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

This patch only moves functions.

If we are moving the code also its good to do cleanup.

Except you need to do it as a separate patch.

David

Quoted 11 lines

Run checkpatch.pl on this...

--
Regards,
Varka Bhadram.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH net-next 1/2] net: filter: split filter.c into two files

In reply to Varka Bhadram
Quoted 6 lines · Varka Bhadram
Quoted 5 lines · Alexei Starovoitov

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

Quoted 7 lines
Quoted 3 lines

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

This patch only moves functions.

If we are moving the code also its good to do cleanup.

Run checkpatch.pl on this...

Not sure what you understand as a cleanup, but there's nothing wrong with it and most things reported are either intentional or false positives as you might have seen already. The only thing one could do later on perhaps is to rename related functions to have consistently a 'bpf' prefix instead of 'sk' since they won't be under net/ anymore.

#5 lore raw

Re: [PATCH net-next 1/2] net: filter: split filter.c into two files

Quoted 11 lines · Daniel Borkmann
Quoted 10 lines · Varka Bhadram
Quoted 8 lines · Alexei Starovoitov

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

This patch only moves functions.

Quoted 7 lines
Quoted 3 lines

If we are moving the code also its good to do cleanup.

Run checkpatch.pl on this...

Not sure what you understand as a cleanup, but there's nothing wrong with it and most things reported are either intentional or false positives as you might have seen already. The only thing

+1. interpreter code is quite polished already.
Few lines are longer than 80 char, but wrapping will look ugly. The rest are false positives, since checkpatch is struggling to understand jump-threaded code.

Quoted 3 lines

one could do later on perhaps is to rename related functions to have consistently a 'bpf' prefix instead of 'sk' since they won't be under net/ anymore.

yes. it's on my todo list. The sk_* functions and 'struct sk_filter' look out of place in kernel/bpf/*
The first renaming patch of sock_filter_int->bpf_insn I've sent as rfc:
http://patchwork.ozlabs.org/patch/371332/

'struct sk_filter' I'm thinking to rename as 'struct bpf_prog'

Speaking of kernel/bpf/* comment style...
I would prefer to keep networking comments to save lines.

#6 lore raw

Re: [PATCH net-next 1/2] net: filter: split filter.c into two files

In reply to Alexei Starovoitov
Quoted 7 lines · Alexei Starovoitov

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

Quoted 7 lines

This patch only moves functions.

---
 kernel/Makefile     |    1 +
 kernel/bpf/Makefile |    1 +
 kernel/bpf/core.c   |  536 +++++++++++++++++++++++++++++++++++++++++++++++++

++

Quoted 10 lines
 net/core/filter.c   |  511 ------------------------------------------------
 4 files changed, 538 insertions(+), 511 deletions(-)
 create mode 100644 kernel/bpf/Makefile
 create mode 100644 kernel/bpf/core.c
kernel/Makefile +0 -0
index f2a8b6246ce9..e7360b7c2c0e 100644

kernel/Makefile obj-$(CONFIG_RING_BUFFER) += trace/ · line 90

Quoted 4 lines
kernel/Makefile +1 -0
@@ -87,6 +87,7 @@ obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_TRACEPOINTS) += trace/
 obj-$(CONFIG_IRQ_WORK) += irq_work.o
 obj-$(CONFIG_CPU_PM) += cpu_pm.o
+obj-$(CONFIG_NET) += bpf/

I was expecting to see CONFIG_NETFILTER here. Is CONFIG_NET intentional?

#7 lore raw

Re: [PATCH net-next 1/2] net: filter: split filter.c into two files

Quoted 21 lines · On Thu, Jul 24, 2014 at 4:45 PM, <[email protected]> wrote:
Quoted 7 lines · Alexei Starovoitov

BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest

kernel/bpf/core.c: eBPF interpreter

net/core/filter.c: classic->eBPF converter, classic verifiers, socket filters

Quoted 7 lines

This patch only moves functions.

---
 kernel/Makefile     |    1 +
 kernel/bpf/Makefile |    1 +
 kernel/bpf/core.c   |  536 +++++++++++++++++++++++++++++++++++++++++++++++++

++

Quoted 5 lines
 net/core/filter.c   |  511 ------------------------------------------------
 4 files changed, 538 insertions(+), 511 deletions(-)
 create mode 100644 kernel/bpf/Makefile
 create mode 100644 kernel/bpf/core.c
Quoted 11 lines

kernel/Makefile obj-$(CONFIG_RING_BUFFER) += trace/ · line 90

Quoted 9 lines
kernel/Makefile +1 -0
index f2a8b6246ce9..e7360b7c2c0e 100644
@@ -87,6 +87,7 @@ obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_TRACEPOINTS) += trace/
 obj-$(CONFIG_IRQ_WORK) += irq_work.o
 obj-$(CONFIG_CPU_PM) += cpu_pm.o
+obj-$(CONFIG_NET) += bpf/

I was expecting to see CONFIG_NETFILTER here. Is CONFIG_NET intentional?

yes. it is config_net for now, until eBPF is completely separate from net. Then it will gain its own config_bpf, so it can be used in net-less setups or disabled in net-full setups by folks who care about last byte of .text size. Future will tell.

#8 lore raw

Re: [PATCH net-next 1/2] net: filter: split filter.c into two files

Quoted 10 lines · Alexei Starovoitov
Quoted 5 lines · On Thu, Jul 24, 2014 at 4:45 PM, <[email protected]> wrote:
Quoted 1 line · Alexei Starovoitov

+obj-$(CONFIG_NET) += bpf/

I was expecting to see CONFIG_NETFILTER here. Is CONFIG_NET intentional?

yes. it is config_net for now, until eBPF is completely separate from net. Then it will gain its own config_bpf, so it can be used in net-less setups or disabled in net-full setups by folks who care about last byte of .text size.

OH, OK. That works for me. :)

#9 lore raw

PATCH 2/2 bpf: update MAINTAINERS entry

In reply to Alexei Starovoitov
---
 MAINTAINERS |    7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 78215a5dea28..62bf15f6954f 100644
@@ -1912,6 +1912,13 @@ S:	Supported
 F:	drivers/net/bonding/
 F:	include/uapi/linux/if_bonding.h
 
+BPF (Safe dynamic programs and tools)
+M:	Alexei Starovoitov <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Supported
+F:	kernel/bpf/
+
 BROADCOM B44 10/100 ETHERNET DRIVER
 M:	Gary Zambrano <[email protected]>
 L:	[email protected]
Signature · 1 line
1.7.9.5
maintainer
#10 lore raw
In reply to Alexei Starovoitov

From: Alexei Starovoitov <[email protected]>
Date: Tue, 22 Jul 2014 23:01:57 -0700

Quoted 9 lines

I believe my recent set of RFC/patches [1] provided good visibility on where I would like to take eBPF subsystem. These two trivial patches is a first step in that direction:
patch 1 - mechanical split of eBPF interpreter out of filter.c patch 2 - nominate myself as a maintainer for eBPF core pieces
In the foreseeable future eBPF patches will be going through net-next, so put netdev as a primary mailing list

[1] git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf master

Series applied to net-next.