diff options
| -rw-r--r-- | tools/include/uapi/linux/bpf.h | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index f7fa7a34a62d..72336bac7573 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
| @@ -133,6 +133,7 @@ enum bpf_map_type { | |||
| 133 | BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, | 133 | BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE, |
| 134 | BPF_MAP_TYPE_QUEUE, | 134 | BPF_MAP_TYPE_QUEUE, |
| 135 | BPF_MAP_TYPE_STACK, | 135 | BPF_MAP_TYPE_STACK, |
| 136 | BPF_MAP_TYPE_SK_STORAGE, | ||
| 136 | }; | 137 | }; |
| 137 | 138 | ||
| 138 | /* Note that tracing related programs such as | 139 | /* Note that tracing related programs such as |
| @@ -2630,6 +2631,42 @@ union bpf_attr { | |||
| 2630 | * was provided. | 2631 | * was provided. |
| 2631 | * | 2632 | * |
| 2632 | * **-ERANGE** if resulting value was out of range. | 2633 | * **-ERANGE** if resulting value was out of range. |
| 2634 | * | ||
| 2635 | * void *bpf_sk_storage_get(struct bpf_map *map, struct bpf_sock *sk, void *value, u64 flags) | ||
| 2636 | * Description | ||
| 2637 | * Get a bpf-local-storage from a sk. | ||
| 2638 | * | ||
| 2639 | * Logically, it could be thought of getting the value from | ||
| 2640 | * a *map* with *sk* as the **key**. From this | ||
| 2641 | * perspective, the usage is not much different from | ||
| 2642 | * **bpf_map_lookup_elem(map, &sk)** except this | ||
| 2643 | * helper enforces the key must be a **bpf_fullsock()** | ||
| 2644 | * and the map must be a BPF_MAP_TYPE_SK_STORAGE also. | ||
| 2645 | * | ||
| 2646 | * Underneath, the value is stored locally at *sk* instead of | ||
| 2647 | * the map. The *map* is used as the bpf-local-storage **type**. | ||
| 2648 | * The bpf-local-storage **type** (i.e. the *map*) is searched | ||
| 2649 | * against all bpf-local-storages residing at sk. | ||
| 2650 | * | ||
| 2651 | * An optional *flags* (BPF_SK_STORAGE_GET_F_CREATE) can be | ||
| 2652 | * used such that a new bpf-local-storage will be | ||
| 2653 | * created if one does not exist. *value* can be used | ||
| 2654 | * together with BPF_SK_STORAGE_GET_F_CREATE to specify | ||
| 2655 | * the initial value of a bpf-local-storage. If *value* is | ||
| 2656 | * NULL, the new bpf-local-storage will be zero initialized. | ||
| 2657 | * Return | ||
| 2658 | * A bpf-local-storage pointer is returned on success. | ||
| 2659 | * | ||
| 2660 | * **NULL** if not found or there was an error in adding | ||
| 2661 | * a new bpf-local-storage. | ||
| 2662 | * | ||
| 2663 | * int bpf_sk_storage_delete(struct bpf_map *map, struct bpf_sock *sk) | ||
| 2664 | * Description | ||
| 2665 | * Delete a bpf-local-storage from a sk. | ||
| 2666 | * Return | ||
| 2667 | * 0 on success. | ||
| 2668 | * | ||
| 2669 | * **-ENOENT** if the bpf-local-storage cannot be found. | ||
| 2633 | */ | 2670 | */ |
| 2634 | #define __BPF_FUNC_MAPPER(FN) \ | 2671 | #define __BPF_FUNC_MAPPER(FN) \ |
| 2635 | FN(unspec), \ | 2672 | FN(unspec), \ |
| @@ -2738,7 +2775,9 @@ union bpf_attr { | |||
| 2738 | FN(sysctl_get_new_value), \ | 2775 | FN(sysctl_get_new_value), \ |
| 2739 | FN(sysctl_set_new_value), \ | 2776 | FN(sysctl_set_new_value), \ |
| 2740 | FN(strtol), \ | 2777 | FN(strtol), \ |
| 2741 | FN(strtoul), | 2778 | FN(strtoul), \ |
| 2779 | FN(sk_storage_get), \ | ||
| 2780 | FN(sk_storage_delete), | ||
| 2742 | 2781 | ||
| 2743 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper | 2782 | /* integer value in 'imm' field of BPF_CALL instruction selects which helper |
| 2744 | * function eBPF program intends to call | 2783 | * function eBPF program intends to call |
| @@ -2814,6 +2853,9 @@ enum bpf_func_id { | |||
| 2814 | /* BPF_FUNC_sysctl_get_name flags. */ | 2853 | /* BPF_FUNC_sysctl_get_name flags. */ |
| 2815 | #define BPF_F_SYSCTL_BASE_NAME (1ULL << 0) | 2854 | #define BPF_F_SYSCTL_BASE_NAME (1ULL << 0) |
| 2816 | 2855 | ||
| 2856 | /* BPF_FUNC_sk_storage_get flags */ | ||
| 2857 | #define BPF_SK_STORAGE_GET_F_CREATE (1ULL << 0) | ||
| 2858 | |||
| 2817 | /* Mode for BPF_FUNC_skb_adjust_room helper. */ | 2859 | /* Mode for BPF_FUNC_skb_adjust_room helper. */ |
| 2818 | enum bpf_adj_room_mode { | 2860 | enum bpf_adj_room_mode { |
| 2819 | BPF_ADJ_ROOM_NET, | 2861 | BPF_ADJ_ROOM_NET, |
