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.
Unified · Split
| @@ -2132,10 +2132,6 @@ sysctl_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 2131 unmodified lines | |||
| 2132 | return func_proto; | 2132 | return func_proto; |
| 2133 | 2133 | ||
| 2134 | switch (func_id) { | 2134 | switch (func_id) { |
| 2135 | case BPF_FUNC_strtol: | ||
| 2136 | return &bpf_strtol_proto; | ||
| 2137 | case BPF_FUNC_strtoul: | ||
| 2138 | return &bpf_strtoul_proto; | ||
| 2139 | case BPF_FUNC_sysctl_get_name: | 2135 | case BPF_FUNC_sysctl_get_name: |
| 2140 | return &bpf_sysctl_get_name_proto; | 2136 | return &bpf_sysctl_get_name_proto; |
| 2141 | case BPF_FUNC_sysctl_get_current_value: | 2137 | case BPF_FUNC_sysctl_get_current_value: |
| @@ -427,6 +427,7 @@ const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto = { · 426 unmodified lines | |||
| 427 | .ret_type = RET_INTEGER, | 427 | .ret_type = RET_INTEGER, |
| 428 | .arg1_type = ARG_ANYTHING, | 428 | .arg1_type = ARG_ANYTHING, |
| 429 | }; | 429 | }; |
| 430 | #endif /* CONFIG_CGROUPS */ | ||
| 430 | 431 | ||
| 431 | #define BPF_STRTOX_BASE_MASK 0x1F | 432 | #define BPF_STRTOX_BASE_MASK 0x1F |
| 432 | 433 | ||
| @@ -555,7 +556,6 @@ const struct bpf_func_proto bpf_strtoul_proto = { · 122 unmodified lines | |||
| 555 | .arg3_type = ARG_ANYTHING, | 556 | .arg3_type = ARG_ANYTHING, |
| 556 | .arg4_type = ARG_PTR_TO_LONG, | 557 | .arg4_type = ARG_PTR_TO_LONG, |
| 557 | }; | 558 | }; |
| 558 | #endif | ||
| 559 | 559 | ||
| 560 | BPF_CALL_3(bpf_strncmp, const char *, s1, u32, s1_sz, const char *, s2) | 560 | BPF_CALL_3(bpf_strncmp, const char *, s1, u32, s1_sz, const char *, s2) |
| 561 | { | 561 | { |
| @@ -1619,6 +1619,10 @@ bpf_base_func_proto(enum bpf_func_id func_id) · 1057 unmodified lines | |||
| 1619 | return &bpf_loop_proto; | 1619 | return &bpf_loop_proto; |
| 1620 | case BPF_FUNC_strncmp: | 1620 | case BPF_FUNC_strncmp: |
| 1621 | return &bpf_strncmp_proto; | 1621 | return &bpf_strncmp_proto; |
| 1622 | case BPF_FUNC_strtol: | ||
| 1623 | return &bpf_strtol_proto; | ||
| 1624 | case BPF_FUNC_strtoul: | ||
| 1625 | return &bpf_strtoul_proto; | ||
| 1622 | case BPF_FUNC_dynptr_from_mem: | 1626 | case BPF_FUNC_dynptr_from_mem: |
| 1623 | return &bpf_dynptr_from_mem_proto; | 1627 | return &bpf_dynptr_from_mem_proto; |
| 1624 | case BPF_FUNC_dynptr_read: | 1628 | case BPF_FUNC_dynptr_read: |