History

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.

Stanislav Fomichev committed 4 years ago

Commit 8a67f2d1 parent bed89182 files · +5 −5Browse files

Unified · Split

2 files
  1. kernel/bpf/cgroup.c +0 −4
  2. kernel/bpf/helpers.c +5 −1
kernel/bpf/cgroup.c+0−4
@@ -2132,10 +2132,6 @@ sysctl_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 2131 unmodified lines
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+5−1
@@ -427,6 +427,7 @@ const struct bpf_func_proto bpf_get_current_ancestor_cgroup_id_proto = { · 426 unmodified lines
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 = { · 122 unmodified lines
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) · 1057 unmodified lines
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:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t