Skip to content

Commit

Permalink
bpf: Allow to use kfunc XDP hints and frags together
Browse files Browse the repository at this point in the history
There is no fundamental reason, why multi-buffer XDP and XDP kfunc RX hints
cannot coexist in a single program.

Allow those features to be used together by modifying the flags condition
for dev-bound-only programs, segments are still prohibited for fully
offloaded programs, hence additional check.

Suggested-by: Stanislav Fomichev <[email protected]>
Link: https://lore.kernel.org/bpf/CAKH8qBuzgtJj=OKMdsxEkyML36VsAuZpcrsXcyqjdKXSJCBq=Q@mail.gmail.com/
Reviewed-by: Maciej Fijalkowski <[email protected]>
Signed-off-by: Larysa Zaremba <[email protected]>
Acked-by: Stanislav Fomichev <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
  • Loading branch information
walking-machine authored and Martin KaFai Lau committed Sep 15, 2023
1 parent 45ee73a commit 9b2b863
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion kernel/bpf/offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ int bpf_prog_dev_bound_init(struct bpf_prog *prog, union bpf_attr *attr)
attr->prog_type != BPF_PROG_TYPE_XDP)
return -EINVAL;

if (attr->prog_flags & ~BPF_F_XDP_DEV_BOUND_ONLY)
if (attr->prog_flags & ~(BPF_F_XDP_DEV_BOUND_ONLY | BPF_F_XDP_HAS_FRAGS))
return -EINVAL;

/* Frags are allowed only if program is dev-bound-only, but not
* if it is requesting bpf offload.
*/
if (attr->prog_flags & BPF_F_XDP_HAS_FRAGS &&
!(attr->prog_flags & BPF_F_XDP_DEV_BOUND_ONLY))
return -EINVAL;

if (attr->prog_type == BPF_PROG_TYPE_SCHED_CLS &&
Expand Down

0 comments on commit 9b2b863

Please sign in to comment.