Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs/bpf: Reword docs for BPF_MAP_TYPE_SK_STORAGE

Improve the grammar of the function descriptions and highlight
that the key is a socket fd.

Fixes: f3212ad5b7e9 ("docs/bpf: Add documentation for BPF_MAP_TYPE_SK_STORAGE")
Reported-by: Martin KaFai Lau <martin.lau@linux.dev>
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20221212101600.56026-1-donald.hunter@gmail.com

authored by

Donald Hunter and committed by
Daniel Borkmann
d2b497a9 7ae9888d

+30 -26
+30 -26
Documentation/bpf/map_sk_storage.rst
··· 34 34 35 35 void *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags) 36 36 37 - Socket-local storage can be retrieved using the ``bpf_sk_storage_get()`` 38 - helper. The helper gets the storage from ``sk`` that is associated with ``map``. 39 - If the ``BPF_LOCAL_STORAGE_GET_F_CREATE`` flag is used then 40 - ``bpf_sk_storage_get()`` will create the storage for ``sk`` if it does not 41 - already exist. ``value`` can be used together with 42 - ``BPF_LOCAL_STORAGE_GET_F_CREATE`` to initialize the storage value, otherwise it 43 - will be zero initialized. Returns a pointer to the storage on success, or 37 + Socket-local storage for ``map`` can be retrieved from socket ``sk`` using the 38 + ``bpf_sk_storage_get()`` helper. If the ``BPF_LOCAL_STORAGE_GET_F_CREATE`` 39 + flag is used then ``bpf_sk_storage_get()`` will create the storage for ``sk`` 40 + if it does not already exist. ``value`` can be used together with 41 + ``BPF_LOCAL_STORAGE_GET_F_CREATE`` to initialize the storage value, otherwise 42 + it will be zero initialized. Returns a pointer to the storage on success, or 44 43 ``NULL`` in case of failure. 45 44 46 45 .. note:: ··· 53 54 54 55 long bpf_sk_storage_delete(struct bpf_map *map, void *sk) 55 56 56 - Socket-local storage can be deleted using the ``bpf_sk_storage_delete()`` 57 - helper. The helper deletes the storage from ``sk`` that is identified by 58 - ``map``. Returns ``0`` on success, or negative error in case of failure. 57 + Socket-local storage for ``map`` can be deleted from socket ``sk`` using the 58 + ``bpf_sk_storage_delete()`` helper. Returns ``0`` on success, or negative 59 + error in case of failure. 59 60 60 61 User space 61 62 ---------- ··· 67 68 68 69 int bpf_map_update_elem(int map_fd, const void *key, const void *value, __u64 flags) 69 70 70 - Socket-local storage for the socket identified by ``key`` belonging to 71 - ``map_fd`` can be added or updated using the ``bpf_map_update_elem()`` libbpf 72 - function. ``key`` must be a pointer to a valid ``fd`` in the user space 73 - program. The ``flags`` parameter can be used to control the update behaviour: 71 + Socket-local storage for map ``map_fd`` can be added or updated locally to a 72 + socket using the ``bpf_map_update_elem()`` libbpf function. The socket is 73 + identified by a `socket` ``fd`` stored in the pointer ``key``. The pointer 74 + ``value`` has the data to be added or updated to the socket ``fd``. The type 75 + and size of ``value`` should be the same as the value type of the map 76 + definition. 74 77 75 - - ``BPF_ANY`` will create storage for ``fd`` or update existing storage. 76 - - ``BPF_NOEXIST`` will create storage for ``fd`` only if it did not already 77 - exist, otherwise the call will fail with ``-EEXIST``. 78 - - ``BPF_EXIST`` will update existing storage for ``fd`` if it already exists, 79 - otherwise the call will fail with ``-ENOENT``. 78 + The ``flags`` parameter can be used to control the update behaviour: 79 + 80 + - ``BPF_ANY`` will create storage for `socket` ``fd`` or update existing storage. 81 + - ``BPF_NOEXIST`` will create storage for `socket` ``fd`` only if it did not 82 + already exist, otherwise the call will fail with ``-EEXIST``. 83 + - ``BPF_EXIST`` will update existing storage for `socket` ``fd`` if it already 84 + exists, otherwise the call will fail with ``-ENOENT``. 80 85 81 86 Returns ``0`` on success, or negative error in case of failure. 82 87 ··· 91 88 92 89 int bpf_map_lookup_elem(int map_fd, const void *key, void *value) 93 90 94 - Socket-local storage for the socket identified by ``key`` belonging to 95 - ``map_fd`` can be retrieved using the ``bpf_map_lookup_elem()`` libbpf 96 - function. ``key`` must be a pointer to a valid ``fd`` in the user space 97 - program. Returns ``0`` on success, or negative error in case of failure. 91 + Socket-local storage for map ``map_fd`` can be retrieved from a socket using 92 + the ``bpf_map_lookup_elem()`` libbpf function. The storage is retrieved from 93 + the socket identified by a `socket` ``fd`` stored in the pointer 94 + ``key``. Returns ``0`` on success, or negative error in case of failure. 98 95 99 96 bpf_map_delete_elem() 100 97 ~~~~~~~~~~~~~~~~~~~~~ ··· 103 100 104 101 int bpf_map_delete_elem(int map_fd, const void *key) 105 102 106 - Socket-local storage for the socket identified by ``key`` belonging to 107 - ``map_fd`` can be deleted using the ``bpf_map_delete_elem()`` libbpf 108 - function. Returns ``0`` on success, or negative error in case of failure. 103 + Socket-local storage for map ``map_fd`` can be deleted from a socket using the 104 + ``bpf_map_delete_elem()`` libbpf function. The storage is deleted from the 105 + socket identified by a `socket` ``fd`` stored in the pointer ``key``. Returns 106 + ``0`` on success, or negative error in case of failure. 109 107 110 108 Examples 111 109 ========