Skip to content

Commit 8a67f2d

Browse files
fomichevAlexei Starovoitov
authored andcommitted
bpf: expose bpf_strtol and bpf_strtoul to all program types
bpf_strncmp is already exposed everywhere. The motivation is to keep those helpers in kernel/bpf/helpers.c. Otherwise it's tempting to move them under kernel/bpf/cgroup.c because they are currently only used by sysctl prog types. Suggested-by: Martin KaFai Lau <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Signed-off-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent bed8918 commit 8a67f2d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

kernel/bpf/cgroup.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,10 +2132,6 @@ sysctl_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
21322132
return func_proto;
21332133

21342134
switch (func_id) {
2135-
case BPF_FUNC_strtol:
2136-
return &bpf_strtol_proto;
2137-
case BPF_FUNC_strtoul:
2138-
return &bpf_strtoul_proto;
21392135
case BPF_FUNC_sysctl_get_name:
21402136
return &bpf_sysctl_get_name_proto;
21412137
case BPF_FUNC_sysctl_get_current_value:

kernel/bpf/helpers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto = {
427427
.ret_type = RET_INTEGER,
428428
.arg1_type = ARG_ANYTHING,
429429
};
430+
#endif /* CONFIG_CGROUPS */
430431

431432
#define BPF_STRTOX_BASE_MASK 0x1F
432433

@@ -555,7 +556,6 @@ const struct bpf_func_proto bpf_strtoul_proto = {
555556
.arg3_type = ARG_ANYTHING,
556557
.arg4_type = ARG_PTR_TO_LONG,
557558
};
558-
#endif
559559

560560
BPF_CALL_3(bpf_strncmp, const char *, s1, u32, s1_sz, const char *, s2)
561561
{
@@ -1619,6 +1619,10 @@ bpf_base_func_proto(enum bpf_func_id func_id)
16191619
return &bpf_loop_proto;
16201620
case BPF_FUNC_strncmp:
16211621
return &bpf_strncmp_proto;
1622+
case BPF_FUNC_strtol:
1623+
return &bpf_strtol_proto;
1624+
case BPF_FUNC_strtoul:
1625+
return &bpf_strtoul_proto;
16221626
case BPF_FUNC_dynptr_from_mem:
16231627
return &bpf_dynptr_from_mem_proto;
16241628
case BPF_FUNC_dynptr_read:

0 commit comments

Comments
 (0)