This patch sync the bpf.h to tools/.

Signed-off-by: Martin KaFai Lau <ka...@fb.com>
---
 tools/include/uapi/linux/bpf.h | 44 +++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 704bb69514a2..be08ef00b2c8 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -133,6 +133,7 @@ enum bpf_map_type {
        BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
        BPF_MAP_TYPE_QUEUE,
        BPF_MAP_TYPE_STACK,
+       BPF_MAP_TYPE_SK_STORAGE,
 };
 
 /* Note that tracing related programs such as
@@ -2622,6 +2623,42 @@ union bpf_attr {
  *             was provided.
  *
  *             **-ERANGE** if resulting value was out of range.
+ *
+ * void *bpf_sk_storage_get(struct bpf_map *map, struct bpf_sock *sk, void 
*value, u64 flags)
+ *     Description
+ *             Get a bpf-local-storage from a sk.
+ *
+ *             Logically, it could be thought of getting the value from
+ *             a *map* with *sk* as the **key**.  From this
+ *             perspective,  the usage is not much different from
+ *             **bpf_map_lookup_elem(map, &sk)** except this
+ *             helper enforces the key must be a **bpf_fullsock()**
+ *             and the map must be a BPF_MAP_TYPE_SK_STORAGE also.
+ *
+ *             Underneath, the value is stored locally at *sk* 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-storages residing at sk.
+ *
+ *             An optional *flags* (BPF_SK_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_SK_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_sk_storage_delete(struct bpf_map *map, struct bpf_sock *sk)
+ *     Description
+ *             Delete a bpf-local-storage from a sk.
+ *     Return
+ *             0 on success.
+ *
+ *             **-ENOENT** if the bpf-local-storage cannot be found.
  */
 #define __BPF_FUNC_MAPPER(FN)          \
        FN(unspec),                     \
@@ -2730,7 +2767,9 @@ union bpf_attr {
        FN(sysctl_get_new_value),       \
        FN(sysctl_set_new_value),       \
        FN(strtol),                     \
-       FN(strtoul),
+       FN(strtoul),                    \
+       FN(sk_storage_get),             \
+       FN(sk_storage_delete),
 
 /* integer value in 'imm' field of BPF_CALL instruction selects which helper
  * function eBPF program intends to call
@@ -2806,6 +2845,9 @@ enum bpf_func_id {
 /* BPF_FUNC_sysctl_get_name flags. */
 #define BPF_F_SYSCTL_BASE_NAME         (1ULL << 0)
 
+/* BPF_FUNC_sk_storage_get flags */
+#define BPF_SK_STORAGE_GET_F_CREATE    (1ULL << 0)
+
 /* Mode for BPF_FUNC_skb_adjust_room helper. */
 enum bpf_adj_room_mode {
        BPF_ADJ_ROOM_NET,
-- 
2.17.1

Reply via email to