aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2015-03-20 10:11:11 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-20 19:10:44 -0400
commit94caee8c312d96522bcdae88791aaa9ebcd5f22c (patch)
tree826896381fcc68c6178122c6d098c00729bcbe60
parent0fa74a4be48e0f810d3dc6ddbc9d6ac7e86cbee8 (diff)
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. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Jiri Pirko <jiri@resnulli.us> Reviewed-by: Jiri Pirko <jiri@resnulli.us> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/bpf.h1
-rw-r--r--kernel/bpf/verifier.c1
-rw-r--r--net/core/filter.c6
3 files changed, 8 insertions, 0 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 1623047af463..3dd314a45d0d 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -119,6 +119,7 @@ enum bpf_prog_type {
119 BPF_PROG_TYPE_UNSPEC, 119 BPF_PROG_TYPE_UNSPEC,
120 BPF_PROG_TYPE_SOCKET_FILTER, 120 BPF_PROG_TYPE_SOCKET_FILTER,
121 BPF_PROG_TYPE_SCHED_CLS, 121 BPF_PROG_TYPE_SCHED_CLS,
122 BPF_PROG_TYPE_SCHED_ACT,
122}; 123};
123 124
124#define BPF_PSEUDO_MAP_FD 1 125#define BPF_PSEUDO_MAP_FD 1
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index c22ebd36fa4b..0e714f799ec0 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1180,6 +1180,7 @@ static bool may_access_skb(enum bpf_prog_type type)
1180 switch (type) { 1180 switch (type) {
1181 case BPF_PROG_TYPE_SOCKET_FILTER: 1181 case BPF_PROG_TYPE_SOCKET_FILTER:
1182 case BPF_PROG_TYPE_SCHED_CLS: 1182 case BPF_PROG_TYPE_SCHED_CLS:
1183 case BPF_PROG_TYPE_SCHED_ACT:
1183 return true; 1184 return true;
1184 default: 1185 default:
1185 return false; 1186 return false;
diff --git a/net/core/filter.c b/net/core/filter.c
index bdaac5895def..084eacc4d1d4 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1263,10 +1263,16 @@ static struct bpf_prog_type_list sched_cls_type __read_mostly = {
1263 .type = BPF_PROG_TYPE_SCHED_CLS, 1263 .type = BPF_PROG_TYPE_SCHED_CLS,
1264}; 1264};
1265 1265
1266static struct bpf_prog_type_list sched_act_type __read_mostly = {
1267 .ops = &sk_filter_ops,
1268 .type = BPF_PROG_TYPE_SCHED_ACT,
1269};
1270
1266static int __init register_sk_filter_ops(void) 1271static int __init register_sk_filter_ops(void)
1267{ 1272{
1268 bpf_register_prog_type(&sk_filter_type); 1273 bpf_register_prog_type(&sk_filter_type);
1269 bpf_register_prog_type(&sched_cls_type); 1274 bpf_register_prog_type(&sched_cls_type);
1275 bpf_register_prog_type(&sched_act_type);
1270 1276
1271 return 0; 1277 return 0;
1272} 1278}