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
2095 * Return2095 * Return
2096 * A 64-bit integer containing the current cgroup id based2096 * A 64-bit integer containing the current cgroup id based
2097 * on the cgroup within which the current task is running.2097 * 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.
2098 */2116 */
2099#define __BPF_FUNC_MAPPER(FN) \2117#define __BPF_FUNC_MAPPER(FN) \
2100 FN(unspec), \2118 FN(unspec), \
@@ -2177,7 +2195,8 @@ union bpf_attr { · 76 unmodified lines
2177 FN(rc_repeat), \2195 FN(rc_repeat), \
2178 FN(rc_keydown), \2196 FN(rc_keydown), \
2179 FN(skb_cgroup_id), \2197 FN(skb_cgroup_id), \
2180 FN(get_current_cgroup_id),2198 FN(get_current_cgroup_id), \
2199 FN(get_local_storage),
2181 2200
2182/* integer value in 'imm' field of BPF_CALL instruction selects which helper2201/* integer value in 'imm' field of BPF_CALL instruction selects which helper
2183 * function eBPF program intends to call2202 * 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