aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/helpers.c
diff options
context:
space:
mode:
authorRoman Gushchin <guro@fb.com>2018-09-28 10:45:36 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-10-01 10:18:32 -0400
commit8bad74f9840f87661f20ced3dc80c84ab4fd55a1 (patch)
tree1ac3ef2547d12f0fd6a232fbc1daac2672537907 /kernel/bpf/helpers.c
parent5bf7a60b8e70969f65c961d7e2c4eb40eb2c664d (diff)
bpf: extend cgroup bpf core to allow multiple cgroup storage types
In order to introduce per-cpu cgroup storage, let's generalize bpf cgroup core to support multiple cgroup storage types. Potentially, per-node cgroup storage can be added later. This commit is mostly a formal change that replaces cgroup_storage pointer with a array of cgroup_storage pointers. It doesn't actually introduce a new storage type, it will be done later. Each bpf program is now able to have one cgroup storage of each type. Signed-off-by: Roman Gushchin <guro@fb.com> Acked-by: Song Liu <songliubraving@fb.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/bpf/helpers.c')
-rw-r--r--kernel/bpf/helpers.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 1991466b8327..9070b2ace6aa 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -194,16 +194,18 @@ const struct bpf_func_proto bpf_get_current_cgroup_id_proto = {
194 .ret_type = RET_INTEGER, 194 .ret_type = RET_INTEGER,
195}; 195};
196 196
197DECLARE_PER_CPU(void*, bpf_cgroup_storage); 197#ifdef CONFIG_CGROUP_BPF
198DECLARE_PER_CPU(void*, bpf_cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE]);
198 199
199BPF_CALL_2(bpf_get_local_storage, struct bpf_map *, map, u64, flags) 200BPF_CALL_2(bpf_get_local_storage, struct bpf_map *, map, u64, flags)
200{ 201{
201 /* map and flags arguments are not used now, 202 /* flags argument is not used now,
202 * but provide an ability to extend the API 203 * but provides an ability to extend the API.
203 * for other types of local storages. 204 * verifier checks that its value is correct.
204 * verifier checks that their values are correct.
205 */ 205 */
206 return (unsigned long) this_cpu_read(bpf_cgroup_storage); 206 enum bpf_cgroup_storage_type stype = cgroup_storage_type(map);
207
208 return (unsigned long) this_cpu_read(bpf_cgroup_storage[stype]);
207} 209}
208 210
209const struct bpf_func_proto bpf_get_local_storage_proto = { 211const struct bpf_func_proto bpf_get_local_storage_proto = {
@@ -214,3 +216,4 @@ const struct bpf_func_proto bpf_get_local_storage_proto = {
214 .arg2_type = ARG_ANYTHING, 216 .arg2_type = ARG_ANYTHING,
215}; 217};
216#endif 218#endif
219#endif