Skip to content

Commit 94caee8

Browse files
borkmanndavem330
authored andcommitted
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 96be432 ("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 <[email protected]> Cc: Jiri Pirko <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0fa74a4 commit 94caee8

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

include/uapi/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ enum bpf_prog_type {
119119
BPF_PROG_TYPE_UNSPEC,
120120
BPF_PROG_TYPE_SOCKET_FILTER,
121121
BPF_PROG_TYPE_SCHED_CLS,
122+
BPF_PROG_TYPE_SCHED_ACT,
122123
};
123124

124125
#define BPF_PSEUDO_MAP_FD 1

kernel/bpf/verifier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ static bool may_access_skb(enum bpf_prog_type type)
11801180
switch (type) {
11811181
case BPF_PROG_TYPE_SOCKET_FILTER:
11821182
case BPF_PROG_TYPE_SCHED_CLS:
1183+
case BPF_PROG_TYPE_SCHED_ACT:
11831184
return true;
11841185
default:
11851186
return false;

net/core/filter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,10 +1263,16 @@ static struct bpf_prog_type_list sched_cls_type __read_mostly = {
12631263
.type = BPF_PROG_TYPE_SCHED_CLS,
12641264
};
12651265

1266+
static struct bpf_prog_type_list sched_act_type __read_mostly = {
1267+
.ops = &sk_filter_ops,
1268+
.type = BPF_PROG_TYPE_SCHED_ACT,
1269+
};
1270+
12661271
static int __init register_sk_filter_ops(void)
12671272
{
12681273
bpf_register_prog_type(&sk_filter_type);
12691274
bpf_register_prog_type(&sched_cls_type);
1275+
bpf_register_prog_type(&sched_act_type);
12701276

12711277
return 0;
12721278
}

0 commit comments

Comments
 (0)