act_bpf update
Subsystems (6)
Daniel Borkmann
maintainercover act_bpf update
This set adds native eBPF support also to act_bpf and thus covers tc with eBPF in the classifier *and* action part.
A link to iproute2 preview has been provided in patch 2 and the code will be pushed out after Stephen has processed the classifier part and helper bits for tc.
This set depends on ced585c83b27 ("act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome"), so a net into net-next merge would be required first. Hope that's fine by you, Dave. ;)
Thanks a lot!
Daniel Borkmann (2):
ebpf: add sched_act_type and map it to sk_filter's verifier ops
act_bpf: add initial eBPF support for actions
include/net/tc_act/tc_bpf.h | 6 +- include/uapi/linux/bpf.h | 1 + include/uapi/linux/tc_act/tc_bpf.h | 2 + kernel/bpf/verifier.c | 1 + net/core/filter.c | 6 + net/sched/act_bpf.c | 295 ++++++++++++++++++++++++++----------- 6 files changed, 228 insertions(+), 83 deletions(-)
Signature · 1 line
1.9.3
Daniel Borkmann
maintainerPATCH 1/2 ebpf: add sched_act_type and map it to sk_filter's verifier ops
In order to prepare eBPF support for tc action, we need to add sched_act_type, so that the eBPF verifier is aware of what helper function act_bpf may use, that it can load skb data and read out currently available skb fields.
This is bascially analogous to 96be4325f443 ("ebpf: add sched_cls_type and map it to sk_filter's verifier ops").
BPF_PROG_TYPE_SCHED_CLS and BPF_PROG_TYPE_SCHED_ACT need to be separate since both will have a different set of functionality in future (classifier vs action), thus we won't run into ABI troubles when the point in time comes to diverge functionality from the classifier.
The future plan for act_bpf would be that it will be able to write into skb->data and alter selected fields mirrored in struct __sk_buff.
For an initial support, it's sufficient to map it to sk_filter_ops.
--- include/uapi/linux/bpf.h | 1 + kernel/bpf/verifier.c | 1 + net/core/filter.c | 6 ++++++ 3 files changed, 8 insertions(+)
include/uapi/linux/bpf.h +1 -0
@@ -119,6 +119,7 @@ enum bpf_prog_type {BPF_PROG_TYPE_UNSPEC ,BPF_PROG_TYPE_SOCKET_FILTER ,BPF_PROG_TYPE_SCHED_CLS , + BPF_PROG_TYPE_SCHED_ACT, };#define BPF_PSEUDO_MAP_FD 1
kernel/bpf/verifier.c +1 -0
@@ -1180,6 +1180,7 @@ static bool may_access_skb(enum bpf_prog_type type)switch (type) {case BPF_PROG_TYPE_SOCKET_FILTER :case BPF_PROG_TYPE_SCHED_CLS : +case BPF_PROG_TYPE_SCHED_ACT :return true;default :return false;
net/core/filter.c +6 -0
@@ -1264,10 +1264,16 @@ static struct bpf_prog_type_list sched_cls_type __read_mostly = { .type = BPF_PROG_TYPE_SCHED_CLS, }; +static struct bpf_prog_type_list sched_act_type__read_mostly = { + .ops = &sk_filter_ops, + .type =BPF_PROG_TYPE_SCHED_ACT , +}; +static int __init register_sk_filter_ops (void ) {bpf_register_prog_type (&sk_filter_type);bpf_register_prog_type (&sched_cls_type); +bpf_register_prog_type (&sched_act_type);return 0 ; }
Signature · 1 line
1.9.3
Re: [PATCH net-next 1/2] ebpf: add sched_act_type and map it to sk_filter's verifier ops
Quoted 14 lines · Fri, Mar 20, 2015 at 03:11:11PM CET, [email protected] wrote:
In order to prepare eBPF support for tc action, we need to add
sched_act_type, so that the eBPF verifier is aware of what helper functionact_bpfmay use, that it can load skb data and read out currently available skb fields.This is bascially analogous to
96be4325f443("ebpf: addsched_cls_typeand map it to sk_filter's verifier ops").
BPF_PROG_TYPE_SCHED_CLSandBPF_PROG_TYPE_SCHED_ACTneed to be separate since both will have a different set of functionality in future (classifier vs action), thus we won't run into ABI troubles when the point in time comes to diverge functionality from the classifier.
Quoted 7 lines
The future plan for
act_bpfwould be that it will be able to write intoskb->dataand alter selected fields mirrored in struct__sk_buff.For an initial support, it's sufficient to map it to
sk_filter_ops.Signed-off-by Daniel Borkmann <[email protected]>Cc Jiri Pirko <[email protected]>
Re: [PATCH net-next 1/2] ebpf: add sched_act_type and map it to sk_filter's verifier ops
In reply to Daniel BorkmannQuoted 14 lines · Daniel Borkmann
In order to prepare eBPF support for tc action, we need to add
sched_act_type, so that the eBPF verifier is aware of what helper functionact_bpfmay use, that it can load skb data and read out currently available skb fields.This is bascially analogous to
96be4325f443("ebpf: addsched_cls_typeand map it to sk_filter's verifier ops").
BPF_PROG_TYPE_SCHED_CLSandBPF_PROG_TYPE_SCHED_ACTneed to be separate since both will have a different set of functionality in future (classifier vs action), thus we won't run into ABI troubles when the point in time comes to diverge functionality from the classifier.
Quoted 7 lines
The future plan for
act_bpfwould be that it will be able to write intoskb->dataand alter selected fields mirrored in struct__sk_buff.For an initial support, it's sufficient to map it to
sk_filter_ops.Signed-off-by Daniel Borkmann <[email protected]>Cc Jiri Pirko <[email protected]>
Daniel Borkmann
maintainerPATCH 2/2 act_bpf: add initial eBPF support for actions
In reply to Daniel BorkmannThis work extends the "classic" BPF programmable tc action by extending its scope also to native eBPF code!
Together with commit e2e9b6541dd4 ("cls_bpf: add initial eBPF support for programmable classifiers") this adds the facility to implement fully flexible classifier and actions for tc that can be implemented in a C subset in user space, "safely" loaded into the kernel, and being run in native speed when JITed.
Also, since eBPF maps can be shared between eBPF programs, it offers the possibility that cls_bpf and act_bpf can share data 1) between themselves and 2) between user space applications. That means that, f.e. customized runtime statistics can be collected in user space, but also more importantly classifier and action behaviour could be altered based on map input from the user space application.
For the remaining details on the workflow and integration, see the cls_bpf commit e2e9b6541dd4. Preliminary iproute2 part can be found under [1].
[1] http://git.breakpoint.cc/cgit/dborkman/iproute2.git/log/?h=ebpf-act
--- include/net/tc_act/tc_bpf.h | 6 +- include/uapi/linux/tc_act/tc_bpf.h | 2 + net/sched/act_bpf.c | 295 ++++++++++++++++++++++++++----------- 3 files changed, 220 insertions(+), 83 deletions(-)
include/net/tc_act/tc_bpf.h +5 -1
@@ -16,8 +16,12 @@struct tcf_bpf {struct tcf_common common;struct bpf_prog *filter; +union { +u32 bpf_fd; +u16 bpf_num_ops; + };struct sock_filter *bpf_ops; -u16 bpf_num_ops; +const char *bpf_name; };#define to_bpf (a) \ container_of(a->priv, struct tcf_bpf, common)
include/uapi/linux/tc_act/tc_bpf.h +2 -0
@@ -24,6 +24,8 @@ enum {TCA_ACT_BPF_PARMS ,TCA_ACT_BPF_OPS_LEN ,TCA_ACT_BPF_OPS , +TCA_ACT_BPF_FD , +TCA_ACT_BPF_NAME , __TCA_ACT_BPF_MAX, };#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
net/sched/act_bpf.c +213 -82
395 lines not on this page · raw message
Signature · 1 line
1.9.3
Re: [PATCH net-next 2/2] act_bpf: add initial eBPF support for actions
Quoted 16 lines · Fri, Mar 20, 2015 at 03:11:12PM CET, [email protected] wrote:
This work extends the "classic" BPF programmable tc action by extending its scope also to native eBPF code!
Together with commit
e2e9b6541dd4("cls_bpf: add initial eBPF support for programmable classifiers") this adds the facility to implement fully flexible classifier and actions for tc that can be implemented in a C subset in user space, "safely" loaded into the kernel, and being run in native speed when JITed.Also, since eBPF maps can be shared between eBPF programs, it offers the possibility that
cls_bpfandact_bpfcan share data 1) between themselves and 2) between user space applications. That means that, f.e. customized runtime statistics can be collected in user space, but also more importantly classifier and action behaviour could be altered based on map input from the user space application.
Quoted 8 lines
For the remaining details on the workflow and integration, see the
cls_bpfcommite2e9b6541dd4. Preliminary iproute2 part can be found under [1].[1] http://git.breakpoint.cc/cgit/dborkman/iproute2.git/log/?h=ebpf-act
Signed-off-by Daniel Borkmann <[email protected]>Cc Jamal Hadi Salim <[email protected]>Cc Jiri Pirko <[email protected]>
Would be easier to review without the variable renames.
But still, I like this a lot! Thanks!
Re: [PATCH net-next 2/2] act_bpf: add initial eBPF support for actions
In reply to Daniel BorkmannQuoted 16 lines · Daniel Borkmann
This work extends the "classic" BPF programmable tc action by extending its scope also to native eBPF code!
Together with commit
e2e9b6541dd4("cls_bpf: add initial eBPF support for programmable classifiers") this adds the facility to implement fully flexible classifier and actions for tc that can be implemented in a C subset in user space, "safely" loaded into the kernel, and being run in native speed when JITed.Also, since eBPF maps can be shared between eBPF programs, it offers the possibility that
cls_bpfandact_bpfcan share data 1) between themselves and 2) between user space applications. That means that, f.e. customized runtime statistics can be collected in user space, but also more importantly classifier and action behaviour could be altered based on map input from the user space application.
Quoted 8 lines
For the remaining details on the workflow and integration, see the
cls_bpfcommite2e9b6541dd4. Preliminary iproute2 part can be found under [1].[1] http://git.breakpoint.cc/cgit/dborkman/iproute2.git/log/?h=ebpf-actSigned-off-by Daniel Borkmann <[email protected]>Cc Jamal Hadi Salim <[email protected]>Cc Jiri Pirko <[email protected]>
David Miller
maintainerFrom: Daniel Borkmann <[email protected]>
Date: Fri, 20 Mar 2015 15:11:10 +0100
Quoted 7 lines
This set adds native eBPF support also to
act_bpfand thus covers tc with eBPF in the classifier *and* action part.A link to iproute2 preview has been provided in patch 2 and the code will be pushed out after Stephen has processed the classifier part and helper bits for tc.
Quoted 5 lines
This set depends on
ced585c83b27("act_bpf: allow non-defaultTC_ACTopcodes as BPF exec outcome"), so a net into net-next merge would be required first. Hope that's fine by you, Dave. ;)Thanks a lot!
Even with that commit, which is in net-next now, this series does not apply without rejects.
Please respin.
Daniel Borkmann
maintainerHi Dave,
Quoted 14 lines · David Miller
From: Daniel Borkmann <[email protected]>
Date: Fri, 20 Mar 2015 15:11:10 +0100Quoted 11 lines
This set adds native eBPF support also to
act_bpfand thus covers tc with eBPF in the classifier *and* action part.A link to iproute2 preview has been provided in patch 2 and the code will be pushed out after Stephen has processed the classifier part and helper bits for tc.
This set depends on
ced585c83b27("act_bpf: allow non-defaultTC_ACTopcodes as BPF exec outcome"), so a net into net-next merge would be required first. Hope that's fine by you, Dave. ;)
Quoted 6 lines
Quoted 1 line
Thanks a lot!
Even with that commit, which is in net-next now, this series does not apply without rejects.
Please respin.
So my HEAD is at latest net-next commit b4c11cb437fdb34b ("Merge branch 'amd-xgbe-next'"):
$ git cherry-pick ced585c83b27deca427c606a34dd3eaa6b96d82b [ebpf-act 1b8dfa9] act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome 1 file changed, 28 insertions(+), 8 deletions(-) $ git am 0001-ebpf-add-sched_act_type-and-map-it-to-sk_filter-s-ve.patch Applying: ebpf: add sched_act_type and map it to sk_filter's verifier ops $ git am 0002-act_bpf-add-initial-eBPF-support-for-actions.patch Applying: act_bpf: add initial eBPF support for actions $
The dependency mentioned in the cover letter is on net commit ced585c83b27 ("act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome"). On my side that applies fine, hm.
Thanks,
Daniel
Quoted 27 lines · Daniel Borkmann
Quoted 6 lines
Quoted 6 lines
This set depends on
ced585c83b27("act_bpf: allow non-defaultTC_ACTopcodes as BPF exec outcome"), so a net into net-next merge would be required first. Hope that's fine by you, Dave. ;)Quoted 6 lines
Quoted 1 line
Thanks a lot!
Even with that commit, which is in net-next now, this series does not apply without rejects.
Please respin.
So my HEAD is at latest net-next commit
b4c11cb437fdb34b("Merge branch 'amd-xgbe-next'"):$ git cherry-pick ced585c83b27deca427c606a34dd3eaa6b96d82b [ebpf-act 1b8dfa9] act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome 1 file changed, 28 insertions(+), 8 deletions(-) $ git am 0001-ebpf-add-sched_act_type-and-map-it-to-sk_filter-s-ve.patch Applying: ebpf: add sched_act_type and map it to sk_filter's verifier ops $ git am 0002-act_bpf-add-initial-eBPF-support-for-actions.patch Applying: act_bpf: add initial eBPF support for actions $
Quoted 3 lines
The dependency mentioned in the cover letter is on net commit
ced585c83b27("act_bpf: allow non-defaultTC_ACTopcodes as BPF exec outcome"). On my side that applies fine, hm.
I don't think 'net' has been merged into 'net-next' yet. Or may be merged, but not pushed...
David Miller
maintainerFrom: Daniel Borkmann <[email protected]>
Date: Fri, 20 Mar 2015 22:10:36 +0100
Quoted 16 lines
So my HEAD is at latest net-next commit
b4c11cb437fdb34b("Merge branch
'amd-xgbe-next'"):$ git cherry-pick ced585c83b27deca427c606a34dd3eaa6b96d82b [ebpf-act 1b8dfa9] act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome 1 file changed, 28 insertions(+), 8 deletions(-) $ git am 0001-ebpf-add-sched_act_type-and-map-it-to-sk_filter-s-ve.patch Applying: ebpf: add sched_act_type and map it to sk_filter's verifier ops $ git am 0002-act_bpf-add-initial-eBPF-support-for-actions.patch Applying: act_bpf: add initial eBPF support for actions $
Quoted 5 lines
The dependency mentioned in the cover letter is on net commit
ced585c83b27
("act_bpf: allow non-defaultTC_ACTopcodes as BPF exec outcome"). On my
side that applies fine, hm.
Sorry, my bad, I'll sort this out.
Daniel Borkmann
maintainerQuoted 19 lines · David Miller
From: Daniel Borkmann <[email protected]>
Date: Fri, 20 Mar 2015 22:10:36 +0100Quoted 16 lines
So my HEAD is at latest net-next commit
b4c11cb437fdb34b("Merge branch
'amd-xgbe-next'"):$ git cherry-pick ced585c83b27deca427c606a34dd3eaa6b96d82b [ebpf-act 1b8dfa9] act_bpf: allow non-default TC_ACT opcodes as BPF exec outcome 1 file changed, 28 insertions(+), 8 deletions(-) $ git am 0001-ebpf-add-sched_act_type-and-map-it-to-sk_filter-s-ve.patch Applying: ebpf: add sched_act_type and map it to sk_filter's verifier ops $ git am 0002-act_bpf-add-initial-eBPF-support-for-actions.patch Applying: act_bpf: add initial eBPF support for actions $
Quoted 7 lines
Quoted 5 lines
The dependency mentioned in the cover letter is on net commit
ced585c83b27
("act_bpf: allow non-defaultTC_ACTopcodes as BPF exec outcome"). On my
side that applies fine, hm.Sorry, my bad, I'll sort this out.
Ok, thanks a lot David.