History

bpf: introduce the bpf_get_local_storage() helper function

The bpf_get_local_storage() helper function is used to get a pointer to the bpf local storage from a bpf program. It takes a pointer to a storage map and flags as arguments. Right now it accepts only cgroup storage maps, and flags argument has to be 0. Further it can be extended to support other types of local storage: e.g. thread local storage etc.

Roman Gushchin committed 8 years ago

Commit cd339431 parent 7b5dd2b7 files · +85 −2Browse files

Showing the changes to include/uapi/linux (1 of 7 files). Show all

Unified · Split

include/uapi/linux/bpf.h+20−1
@@ -2095,6 +2095,24 @@ union bpf_attr { · 2094 unmodified lines
20952095 * Return
20962096 * A 64-bit integer containing the current cgroup id based
20972097 * on the cgroup within which the current task is running.
2098+ *
2099+ * void* get_local_storage(void *map, u64 flags)
2100+ * Description
2101+ * Get the pointer to the local storage area.
2102+ * The type and the size of the local storage is defined
2103+ * by the *map* argument.
2104+ * The *flags* meaning is specific for each map type,
2105+ * and has to be 0 for cgroup local storage.
2106+ *
2107+ * Depending on the bpf program type, a local storage area
2108+ * can be shared between multiple instances of the bpf program,
2109+ * running simultaneously.
2110+ *
2111+ * A user should care about the synchronization by himself.
2112+ * For example, by using the BPF_STX_XADD instruction to alter
2113+ * the shared data.
2114+ * Return
2115+ * Pointer to the local storage area.
20982116 */
20992117 #define __BPF_FUNC_MAPPER(FN) \
21002118 FN(unspec), \
@@ -2177,7 +2195,8 @@ union bpf_attr { · 76 unmodified lines
21772195 FN(rc_repeat), \
21782196 FN(rc_keydown), \
21792197 FN(skb_cgroup_id), \
2180− FN(get_current_cgroup_id),
2198+ FN(get_current_cgroup_id), \
2199+ FN(get_local_storage),
21812200
21822201 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
21832202 * function eBPF program intends to call

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