OSDN Git Service

bpf: Sync bpf.h to tools
authorMartin KaFai Lau <kafai@fb.com>
Fri, 26 Apr 2019 23:39:42 +0000 (16:39 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 27 Apr 2019 16:07:05 +0000 (09:07 -0700)
This patch sync the bpf.h to tools/.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/include/uapi/linux/bpf.h

index f7fa7a3..72336ba 100644 (file)
@@ -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
@@ -2630,6 +2631,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),                     \
@@ -2738,7 +2775,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
@@ -2814,6 +2853,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,