diff options
| author | Paul Chaignon <paul.chaignon@gmail.com> | 2023-05-06 23:50:25 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2023-08-25 14:18:37 +0000 |
| commit | 7481b108ac4af790dfc163514c6dc3a1ff5f3902 (patch) | |
| tree | bff6967d55afa66480084ed1314bdc17f309f97b /sys/linux | |
| parent | b64118ab2f7c483d4d00a7d022230a96d88c8af6 (diff) | |
sys/linux: cover live packet mode for BPF_PROG_RUN
Commit [1] upstream added a new mode for the BPF command BPF_PROG_RUN
when used with XDP program (type BPF_PROG_TYPE_XDP). This new mode
allows injecting packets to the network stack after they have been
processed by the test BPF program.
This new mode expects specific arguments. Specifically, only the
BPF_F_TEST_XDP_LIVE_FRAMES flag is accepted and data_out & ctx_out must
be NULL.
1 - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b530e9e1063ed
Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'sys/linux')
| -rw-r--r-- | sys/linux/bpf.txt | 20 | ||||
| -rw-r--r-- | sys/linux/test/btf_id | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt index 9455ba652..ea35eecf7 100644 --- a/sys/linux/bpf.txt +++ b/sys/linux/bpf.txt @@ -73,6 +73,7 @@ bpf$PROG_BIND_MAP(cmd const[BPF_PROG_BIND_MAP], arg ptr[in, bpf_prog_bind_map_ar resource fd_bpf_prog_xdp[fd_bpf_prog] bpf$PROG_LOAD_XDP(cmd const[BPF_PROG_LOAD], arg ptr[in, bpf_prog_xdp], size len[arg]) fd_bpf_prog_xdp bpf$BPF_LINK_CREATE_XDP(cmd const[BPF_LINK_CREATE], arg ptr[in, bpf_link_create_xdp], size len[arg]) fd_bpf_link +bpf$BPF_PROG_TEST_RUN_LIVE(cmd const[BPF_PROG_TEST_RUN], arg ptr[in, bpf_test_prog_live_arg], size len[arg]) type bpf_prog_xdp bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], const[BPF_XDP, int32], const[0, int32], const[0, int32]] type bpf_link_create_xdp bpf_link_create_arg_t[fd_bpf_prog_xdp, ifindex, const[BPF_XDP, int32], flags[xdp_flags, int32]] xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST, XDP_FLAGS_SKB_MODE, XDP_FLAGS_DRV_MODE, XDP_FLAGS_HW_MODE, XDP_FLAGS_REPLACE @@ -556,6 +557,25 @@ bpf_test_prog_arg { outctx ptr64[in, array[int8]] flags flags[bpf_prog_test_run_flags, int32] cpu const[0, int32] + batch_size int32 +} + +bpf_test_prog_live_arg { + prog fd_bpf_prog_xdp + retval const[0, int32] + insizedata len[indata, int32] + outsizedata const[0, int32] + indata ptr64[in, array[int8]] + outdata const[0, int64] + repeat int32 + dur const[0, int32] + insizectx len[inctx, int32] + outsizectx const[0, int32] + inctx ptr64[in, array[int8]] + outctx const[0, int64] + flags const[BPF_F_TEST_XDP_LIVE_FRAMES, int32] + cpu const[0, int32] + batch_size int32 } bpf_prog_get_next_id_arg { diff --git a/sys/linux/test/btf_id b/sys/linux/test/btf_id index d20fa7925..801565973 100644 --- a/sys/linux/test/btf_id +++ b/sys/linux/test/btf_id @@ -4,7 +4,7 @@ r0 = syz_btf_id_by_name$bpf_lsm(&AUTO='bpf_lsm_path_mkdir\x00') # Load the bpf program. -r1 = bpf$BPF_PROG_WITH_BTFID_LOAD(0x5, &AUTO=@bpf_lsm={0x1d, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [], {AUTO, AUTO, AUTO, AUTO}}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, r0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0x9c) +r1 = bpf$BPF_PROG_WITH_BTFID_LOAD(0x5, &AUTO=@bpf_lsm={0x1d, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [], {AUTO, AUTO, AUTO, AUTO}}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, r0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0xa0) # Attach the bpf program to the lsm hook. @@ -14,6 +14,6 @@ r2 = bpf$BPF_RAW_TRACEPOINT_OPEN_UNNAMED(0x11, &AUTO={AUTO, r1}, 0x10) r3 = syz_btf_id_by_name$bpf_lsm(&AUTO='bpf_lsm_path_mkdir\x00') -r4 = bpf$BPF_PROG_WITH_BTFID_LOAD(0x5, &AUTO=@bpf_lsm={0x1d, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [], {AUTO, AUTO, AUTO, AUTO}}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, r3, 0x0, 0x0, 0x0, 0x0, 0x0}, 0x9c) +r4 = bpf$BPF_PROG_WITH_BTFID_LOAD(0x5, &AUTO=@bpf_lsm={0x1d, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [], {AUTO, AUTO, AUTO, AUTO}}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, r3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0xa0) r5 = bpf$BPF_RAW_TRACEPOINT_OPEN_UNNAMED(0x11, &AUTO={AUTO, r4}, 0x10) |
