[PATCH bpf-next v2 2/5] tools: sync bpf.h header
Kumar Kartikeya Dwivedi
memxor at gmail.com
Thu Aug 26 13:39:10 UTC 2021
Update the bpf.h UAPI header with changes made from file local storage
additions.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor at gmail.com>
---
tools/include/uapi/linux/bpf.h | 39 ++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 791f31dd0abe..62aa1ff2dcfb 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -906,6 +906,7 @@ enum bpf_map_type {
BPF_MAP_TYPE_RINGBUF,
BPF_MAP_TYPE_INODE_STORAGE,
BPF_MAP_TYPE_TASK_STORAGE,
+ BPF_MAP_TYPE_FILE_STORAGE,
};
/* Note that tracing related programs such as
@@ -4877,6 +4878,42 @@ union bpf_attr {
* Get the struct pt_regs associated with **task**.
* Return
* A pointer to struct pt_regs.
+ *
+ * void *bpf_file_storage_get(struct bpf_map *map, void *file, void *value, u64 flags)
+ * Description
+ * Get a bpf_local_storage from a *file*.
+ *
+ * Logically, it could be thought of as getting the value from
+ * a *map* with *file* as the **key**. From this
+ * perspective, the usage is not much different from
+ * **bpf_map_lookup_elem**\ (*map*, **&**\ *file*) except this
+ * helper enforces the key must be an file and the map must also
+ * be a **BPF_MAP_TYPE_FILE_STORAGE**.
+ *
+ * Underneath, the value is stored locally at *file* instead of
+ * the *map*. The *map* is used as the bpf-local-storage
+ * "type". The bpf-local-storage "type" (i.e. the *map*) is
+ * searched against all bpf_local_storage residing at *file*.
+ *
+ * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be
+ * used such that a new bpf_local_storage will be
+ * created if one does not exist. *value* can be used
+ * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify
+ * the initial value of a bpf_local_storage. If *value* is
+ * **NULL**, the new bpf_local_storage will be zero initialized.
+ * Return
+ * A bpf_local_storage pointer is returned on success.
+ *
+ * **NULL** if not found or there was an error in adding
+ * a new bpf_local_storage.
+ *
+ * int bpf_file_storage_delete(struct bpf_map *map, void *file)
+ * Description
+ * Delete a bpf_local_storage from a *file*.
+ * Return
+ * 0 on success.
+ *
+ * **-ENOENT** if the bpf_local_storage cannot be found.
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -5055,6 +5092,8 @@ union bpf_attr {
FN(get_func_ip), \
FN(get_attach_cookie), \
FN(task_pt_regs), \
+ FN(file_storage_get), \
+ FN(file_storage_delete), \
/* */
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
--
2.33.0
More information about the Linux-security-module-archive
mailing list