Skip to content

Commit bacac21

Browse files
mykyta5anakryiko
authored andcommitted
bpf/helpers: Refactor bpf_dynptr_read and bpf_dynptr_write
Refactor bpf_dynptr_read and bpf_dynptr_write helpers: extract code into the static functions namely __bpf_dynptr_read and __bpf_dynptr_write, this allows calling these without compiler warnings. Signed-off-by: Mykyta Yatsenko <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent fc3ab17 commit bacac21

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

kernel/bpf/helpers.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,8 +1759,8 @@ static const struct bpf_func_proto bpf_dynptr_from_mem_proto = {
17591759
.arg4_type = ARG_PTR_TO_DYNPTR | DYNPTR_TYPE_LOCAL | MEM_UNINIT | MEM_WRITE,
17601760
};
17611761

1762-
BPF_CALL_5(bpf_dynptr_read, void *, dst, u32, len, const struct bpf_dynptr_kern *, src,
1763-
u32, offset, u64, flags)
1762+
static int __bpf_dynptr_read(void *dst, u32 len, const struct bpf_dynptr_kern *src,
1763+
u32 offset, u64 flags)
17641764
{
17651765
enum bpf_dynptr_type type;
17661766
int err;
@@ -1793,6 +1793,12 @@ BPF_CALL_5(bpf_dynptr_read, void *, dst, u32, len, const struct bpf_dynptr_kern
17931793
}
17941794
}
17951795

1796+
BPF_CALL_5(bpf_dynptr_read, void *, dst, u32, len, const struct bpf_dynptr_kern *, src,
1797+
u32, offset, u64, flags)
1798+
{
1799+
return __bpf_dynptr_read(dst, len, src, offset, flags);
1800+
}
1801+
17961802
static const struct bpf_func_proto bpf_dynptr_read_proto = {
17971803
.func = bpf_dynptr_read,
17981804
.gpl_only = false,
@@ -1804,8 +1810,8 @@ static const struct bpf_func_proto bpf_dynptr_read_proto = {
18041810
.arg5_type = ARG_ANYTHING,
18051811
};
18061812

1807-
BPF_CALL_5(bpf_dynptr_write, const struct bpf_dynptr_kern *, dst, u32, offset, void *, src,
1808-
u32, len, u64, flags)
1813+
static int __bpf_dynptr_write(const struct bpf_dynptr_kern *dst, u32 offset, void *src,
1814+
u32 len, u64 flags)
18091815
{
18101816
enum bpf_dynptr_type type;
18111817
int err;
@@ -1843,6 +1849,12 @@ BPF_CALL_5(bpf_dynptr_write, const struct bpf_dynptr_kern *, dst, u32, offset, v
18431849
}
18441850
}
18451851

1852+
BPF_CALL_5(bpf_dynptr_write, const struct bpf_dynptr_kern *, dst, u32, offset, void *, src,
1853+
u32, len, u64, flags)
1854+
{
1855+
return __bpf_dynptr_write(dst, offset, src, len, flags);
1856+
}
1857+
18461858
static const struct bpf_func_proto bpf_dynptr_write_proto = {
18471859
.func = bpf_dynptr_write,
18481860
.gpl_only = false,

0 commit comments

Comments
 (0)