]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - kernel/bpf/helpers.c
bpf: introduce the bpf_get_local_storage() helper function
[linux.git] / kernel / bpf / helpers.c
index 73065e2d23c2810757e660bf9ad51266e5480803..1991466b8327cf51b32c89ed3c10de4a23083b11 100644 (file)
@@ -193,4 +193,24 @@ const struct bpf_func_proto bpf_get_current_cgroup_id_proto = {
        .gpl_only       = false,
        .ret_type       = RET_INTEGER,
 };
+
+DECLARE_PER_CPU(void*, bpf_cgroup_storage);
+
+BPF_CALL_2(bpf_get_local_storage, struct bpf_map *, map, u64, flags)
+{
+       /* map and flags arguments are not used now,
+        * but provide an ability to extend the API
+        * for other types of local storages.
+        * verifier checks that their values are correct.
+        */
+       return (unsigned long) this_cpu_read(bpf_cgroup_storage);
+}
+
+const struct bpf_func_proto bpf_get_local_storage_proto = {
+       .func           = bpf_get_local_storage,
+       .gpl_only       = false,
+       .ret_type       = RET_PTR_TO_MAP_VALUE,
+       .arg1_type      = ARG_CONST_MAP_PTR,
+       .arg2_type      = ARG_ANYTHING,
+};
 #endif