Skip to content

Commit c2f2cdb

Browse files
LorenzoBianconiAlexei Starovoitov
authored andcommitted
bpf: introduce BPF_F_XDP_HAS_FRAGS flag in prog_flags loading the ebpf program
Introduce BPF_F_XDP_HAS_FRAGS and the related field in bpf_prog_aux in order to notify the driver the loaded program support xdp frags. Acked-by: Toke Hoiland-Jorgensen <[email protected]> Acked-by: John Fastabend <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://lore.kernel.org/r/db2e8075b7032a356003f407d1b0deb99adaa0ed.1642758637.git.lorenzo@kernel.org Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent c41ced0 commit c2f2cdb

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

include/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ struct bpf_prog_aux {
933933
bool func_proto_unreliable;
934934
bool sleepable;
935935
bool tail_call_reachable;
936+
bool xdp_has_frags;
936937
struct hlist_node tramp_hlist;
937938
/* BTF_KIND_FUNC_PROTO for valid attach_btf_id */
938939
const struct btf_type *attach_func_proto;

include/uapi/linux/bpf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,11 @@ enum bpf_link_type {
11131113
*/
11141114
#define BPF_F_SLEEPABLE (1U << 4)
11151115

1116+
/* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program
1117+
* fully support xdp frags.
1118+
*/
1119+
#define BPF_F_XDP_HAS_FRAGS (1U << 5)
1120+
11161121
/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
11171122
* the following extensions:
11181123
*

kernel/bpf/syscall.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,8 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr)
22172217
BPF_F_ANY_ALIGNMENT |
22182218
BPF_F_TEST_STATE_FREQ |
22192219
BPF_F_SLEEPABLE |
2220-
BPF_F_TEST_RND_HI32))
2220+
BPF_F_TEST_RND_HI32 |
2221+
BPF_F_XDP_HAS_FRAGS))
22212222
return -EINVAL;
22222223

22232224
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) &&
@@ -2303,6 +2304,7 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr)
23032304
prog->aux->dst_prog = dst_prog;
23042305
prog->aux->offload_requested = !!attr->prog_ifindex;
23052306
prog->aux->sleepable = attr->prog_flags & BPF_F_SLEEPABLE;
2307+
prog->aux->xdp_has_frags = attr->prog_flags & BPF_F_XDP_HAS_FRAGS;
23062308

23072309
err = security_bpf_prog_alloc(prog->aux);
23082310
if (err)

tools/include/uapi/linux/bpf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,11 @@ enum bpf_link_type {
11131113
*/
11141114
#define BPF_F_SLEEPABLE (1U << 4)
11151115

1116+
/* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program
1117+
* fully support xdp frags.
1118+
*/
1119+
#define BPF_F_XDP_HAS_FRAGS (1U << 5)
1120+
11161121
/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
11171122
* the following extensions:
11181123
*

0 commit comments

Comments
 (0)