€• oŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ&/translations/zh_CN/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ&/translations/zh_TW/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ&/translations/it_IT/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ&/translations/ja_JP/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ&/translations/ko_KR/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ&/translations/pt_BR/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ&/translations/sp_SP/bpf/map_sk_storage”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)�”}”(hŒ%SPDX-License-Identifier: GPL-2.0-only”h]”hŒ%SPDX-License-Identifier: GPL-2.0-only”…”�”}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³Œ@/var/lib/git/docbuild/linux/Documentation/bpf/map_sk_storage.rst”h´Kubh¶)�”}”(hŒ Copyright (C) 2022 Red Hat, Inc.”h]”hŒ Copyright (C) 2022 Red Hat, Inc.”…”�”}”hhÈsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1hµhhh²hh³hÇh´KubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒBPF_MAP_TYPE_SK_STORAGE”h]”hŒBPF_MAP_TYPE_SK_STORAGE”…”�”}”(hhÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhhØh²hh³hÇh´KubhŒnote”“”)�”}”(hŒB- ``BPF_MAP_TYPE_SK_STORAGE`` was introduced in kernel version 5.2”h]”hŒ bullet_list”“”)�”}”(hhh]”hŒ list_item”“”)�”}”(hŒ@``BPF_MAP_TYPE_SK_STORAGE`` was introduced in kernel version 5.2”h]”hŒ paragraph”“”)�”}”(hhúh]”(hŒliteral”“”)�”}”(hŒ``BPF_MAP_TYPE_SK_STORAGE``”h]”hŒBPF_MAP_TYPE_SK_STORAGE”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhþubhŒ% was introduced in kernel version 5.2”…”�”}”(hhþh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K hhøubah}”(h]”h ]”h"]”h$]”h&]”uh1höhhóubah}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1hñh³hÇh´K hhíubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhhØh²hh³Nh´Nubhý)�”}”(hXö``BPF_MAP_TYPE_SK_STORAGE`` is used to provide socket-local storage for BPF programs. A map of type ``BPF_MAP_TYPE_SK_STORAGE`` declares the type of storage to be provided and acts as the handle for accessing the socket-local storage. The values for maps of type ``BPF_MAP_TYPE_SK_STORAGE`` are stored locally with each socket instead of with the map. The kernel is responsible for allocating storage for a socket when requested and for freeing the storage when either the map or the socket is deleted.”h]”(j)�”}”(hŒ``BPF_MAP_TYPE_SK_STORAGE``”h]”hŒBPF_MAP_TYPE_SK_STORAGE”…”�”}”(hj3h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj/ubhŒI is used to provide socket-local storage for BPF programs. A map of type ”…”�”}”(hj/h²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_SK_STORAGE``”h]”hŒBPF_MAP_TYPE_SK_STORAGE”…”�”}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj/ubhŒˆ declares the type of storage to be provided and acts as the handle for accessing the socket-local storage. The values for maps of type ”…”�”}”(hj/h²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_SK_STORAGE``”h]”hŒBPF_MAP_TYPE_SK_STORAGE”…”�”}”(hjWh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj/ubhŒÔ are stored locally with each socket instead of with the map. The kernel is responsible for allocating storage for a socket when requested and for freeing the storage when either the map or the socket is deleted.”…”�”}”(hj/h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K hhØh²hubhì)�”}”(hŒ¦- The key type must be ``int`` and ``max_entries`` must be set to ``0``. - The ``BPF_F_NO_PREALLOC`` flag must be used when creating a map for socket-local storage.”h]”hò)�”}”(hhh]”(h÷)�”}”(hŒFThe key type must be ``int`` and ``max_entries`` must be set to ``0``.”h]”hý)�”}”(hjxh]”(hŒThe key type must be ”…”�”}”(hjzh²hh³Nh´Nubj)�”}”(hŒ``int``”h]”hŒint”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjzubhŒ and ”…”�”}”(hjzh²hh³Nh´Nubj)�”}”(hŒ``max_entries``”h]”hŒ max_entries”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjzubhŒ must be set to ”…”�”}”(hjzh²hh³Nh´Nubj)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjzubhŒ.”…”�”}”(hjzh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Khjvubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjsubh÷)�”}”(hŒYThe ``BPF_F_NO_PREALLOC`` flag must be used when creating a map for socket-local storage.”h]”hý)�”}”(hŒYThe ``BPF_F_NO_PREALLOC`` flag must be used when creating a map for socket-local storage.”h]”(hŒThe ”…”�”}”(hjÇh²hh³Nh´Nubj)�”}”(hŒ``BPF_F_NO_PREALLOC``”h]”hŒBPF_F_NO_PREALLOC”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÇubhŒ@ flag must be used when creating a map for socket-local storage.”…”�”}”(hjÇh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KhjÃubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjsubeh}”(h]”h ]”h"]”h$]”h&]”j'j(uh1hñh³hÇh´Khjoubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhhØh²hh³Nh´Nubh×)�”}”(hhh]”(hÜ)�”}”(hŒUsage”h]”hŒUsage”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjùh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Kernel BPF”h]”hŒ Kernel BPF”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj h²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒbpf_sk_storage_get()”h]”hŒbpf_sk_storage_get()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´KubhŒ literal_block”“”)�”}”(hŒOvoid *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags)”h]”hŒOvoid *bpf_sk_storage_get(struct bpf_map *map, void *sk, void *value, u64 flags)”…”�”}”hj.sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒforce”‰Œlanguage”Œc”Œhighlight_args”}”uh1j,h³hÇh´K!hjh²hubhý)�”}”(hXáSocket-local storage for ``map`` can be retrieved from socket ``sk`` using the ``bpf_sk_storage_get()`` helper. If the ``BPF_LOCAL_STORAGE_GET_F_CREATE`` flag is used then ``bpf_sk_storage_get()`` will create the storage for ``sk`` if it does not already exist. ``value`` can be used together with ``BPF_LOCAL_STORAGE_GET_F_CREATE`` to initialize the storage value, otherwise it will be zero initialized. Returns a pointer to the storage on success, or ``NULL`` in case of failure.”h]”(hŒSocket-local storage for ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ``map``”h]”hŒmap”…”�”}”(hjIh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ can be retrieved from socket ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ``sk``”h]”hŒsk”…”�”}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ using the ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ``bpf_sk_storage_get()``”h]”hŒbpf_sk_storage_get()”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ helper. If the ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ"``BPF_LOCAL_STORAGE_GET_F_CREATE``”h]”hŒBPF_LOCAL_STORAGE_GET_F_CREATE”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ flag is used then ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ``bpf_sk_storage_get()``”h]”hŒbpf_sk_storage_get()”…”�”}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ will create the storage for ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ``sk``”h]”hŒsk”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ if it does not already exist. ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ ``value``”h]”hŒvalue”…”�”}”(hjµh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ can be used together with ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ"``BPF_LOCAL_STORAGE_GET_F_CREATE``”h]”hŒBPF_LOCAL_STORAGE_GET_F_CREATE”…”�”}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒy to initialize the storage value, otherwise it will be zero initialized. Returns a pointer to the storage on success, or ”…”�”}”(hjAh²hh³Nh´Nubj)�”}”(hŒ``NULL``”h]”hŒNULL”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjAubhŒ in case of failure.”…”�”}”(hjAh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K%hjh²hubhì)�”}”(hŒŒ- ``sk`` is a kernel ``struct sock`` pointer for LSM or tracing programs. - ``sk`` is a ``struct bpf_sock`` pointer for other program types.”h]”hò)�”}”(hhh]”(h÷)�”}”(hŒG``sk`` is a kernel ``struct sock`` pointer for LSM or tracing programs.”h]”hý)�”}”(hjúh]”(j)�”}”(hŒ``sk``”h]”hŒsk”…”�”}”(hjÿh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjüubhŒ is a kernel ”…”�”}”(hjüh²hh³Nh´Nubj)�”}”(hŒ``struct sock``”h]”hŒ struct sock”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjüubhŒ% pointer for LSM or tracing programs.”…”�”}”(hjüh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K.hjøubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjõubh÷)�”}”(hŒ@``sk`` is a ``struct bpf_sock`` pointer for other program types.”h]”hý)�”}”(hj1h]”(j)�”}”(hŒ``sk``”h]”hŒsk”…”�”}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj3ubhŒ is a ”…”�”}”(hj3h²hh³Nh´Nubj)�”}”(hŒ``struct bpf_sock``”h]”hŒstruct bpf_sock”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj3ubhŒ! pointer for other program types.”…”�”}”(hj3h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K/hj/ubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjõubeh}”(h]”h ]”h"]”h$]”h&]”j'j(uh1hñh³hÇh´K.hjñubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhjh²hh³Nh´Nubeh}”(h]”Œbpf-sk-storage-get”ah ]”h"]”Œbpf_sk_storage_get()”ah$]”h&]”uh1hÖhj h²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒbpf_sk_storage_delete()”h]”hŒbpf_sk_storage_delete()”…”�”}”(hj}h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjzh²hh³hÇh´K2ubj-)�”}”(hŒ9long bpf_sk_storage_delete(struct bpf_map *map, void *sk)”h]”hŒ9long bpf_sk_storage_delete(struct bpf_map *map, void *sk)”…”�”}”hj‹sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj<‰j=j>j?}”uh1j,h³hÇh´K4hjzh²hubhý)�”}”(hŒ°Socket-local storage for ``map`` can be deleted from socket ``sk`` using the ``bpf_sk_storage_delete()`` helper. Returns ``0`` on success, or negative error in case of failure.”h]”(hŒSocket-local storage for ”…”�”}”(hjšh²hh³Nh´Nubj)�”}”(hŒ``map``”h]”hŒmap”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjšubhŒ can be deleted from socket ”…”�”}”(hjšh²hh³Nh´Nubj)�”}”(hŒ``sk``”h]”hŒsk”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjšubhŒ using the ”…”�”}”(hjšh²hh³Nh´Nubj)�”}”(hŒ``bpf_sk_storage_delete()``”h]”hŒbpf_sk_storage_delete()”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjšubhŒ helper. Returns ”…”�”}”(hjšh²hh³Nh´Nubj)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjšubhŒ2 on success, or negative error in case of failure.”…”�”}”(hjšh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K8hjzh²hubeh}”(h]”Œbpf-sk-storage-delete”ah ]”h"]”Œbpf_sk_storage_delete()”ah$]”h&]”uh1hÖhj h²hh³hÇh´K2ubeh}”(h]”Œ kernel-bpf”ah ]”h"]”h$]”Œ kernel bpf”ah&]”uh1hÖhjùh²hh³hÇh´KŒ referenced”Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒ User space”h]”hŒ User space”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´K=ubh×)�”}”(hhh]”(hÜ)�”}”(hŒbpf_map_update_elem()”h]”hŒbpf_map_update_elem()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´K@ubj-)�”}”(hŒTint bpf_map_update_elem(int map_fd, const void *key, const void *value, __u64 flags)”h]”hŒTint bpf_map_update_elem(int map_fd, const void *key, const void *value, __u64 flags)”…”�”}”hj#sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj<‰j=j>j?}”uh1j,h³hÇh´KBhjh²hubhý)�”}”(hX€Socket-local storage for map ``map_fd`` can be added or updated locally to a socket using the ``bpf_map_update_elem()`` libbpf function. The socket is identified by a `socket` ``fd`` stored in the pointer ``key``. The pointer ``value`` has the data to be added or updated to the socket ``fd``. The type and size of ``value`` should be the same as the value type of the map definition.”h]”(hŒSocket-local storage for map ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ ``map_fd``”h]”hŒmap_fd”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ7 can be added or updated locally to a socket using the ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ``bpf_map_update_elem()``”h]”hŒbpf_map_update_elem()”…”�”}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ0 libbpf function. The socket is identified by a ”…”�”}”(hj2h²hh³Nh´NubhŒtitle_reference”“”)�”}”(hŒ`socket`”h]”hŒsocket”…”�”}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hj2ubhŒ ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ stored in the pointer ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ``key``”h]”hŒkey”…”�”}”(hj„h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ. The pointer ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ ``value``”h]”hŒvalue”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ3 has the data to be added or updated to the socket ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ. The type and size of ”…”�”}”(hj2h²hh³Nh´Nubj)�”}”(hŒ ``value``”h]”hŒvalue”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj2ubhŒ< should be the same as the value type of the map definition.”…”�”}”(hj2h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KFhjh²hubhý)�”}”(hŒDThe ``flags`` parameter can be used to control the update behaviour:”h]”(hŒThe ”…”�”}”(hjÒh²hh³Nh´Nubj)�”}”(hŒ ``flags``”h]”hŒflags”…”�”}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÒubhŒ7 parameter can be used to control the update behaviour:”…”�”}”(hjÒh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KMhjh²hubhò)�”}”(hhh]”(h÷)�”}”(hŒO``BPF_ANY`` will create storage for `socket` ``fd`` or update existing storage.”h]”hý)�”}”(hj÷h]”(j)�”}”(hŒ ``BPF_ANY``”h]”hŒBPF_ANY”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjùubhŒ will create storage for ”…”�”}”(hjùh²hh³Nh´Nubj_)�”}”(hŒ`socket`”h]”hŒsocket”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hjùubhŒ ”…”�”}”(hjùh²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjùubhŒ or update existing storage.”…”�”}”(hjùh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KOhjõubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjòh²hh³hÇh´Nubh÷)�”}”(hŒˆ``BPF_NOEXIST`` will create storage for `socket` ``fd`` only if it did not already exist, otherwise the call will fail with ``-EEXIST``.”h]”hý)�”}”(hŒˆ``BPF_NOEXIST`` will create storage for `socket` ``fd`` only if it did not already exist, otherwise the call will fail with ``-EEXIST``.”h]”(j)�”}”(hŒ``BPF_NOEXIST``”h]”hŒ BPF_NOEXIST”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjBubhŒ will create storage for ”…”�”}”(hjBh²hh³Nh´Nubj_)�”}”(hŒ`socket`”h]”hŒsocket”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hjBubhŒ ”…”�”}”(hjBh²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjBubhŒE only if it did not already exist, otherwise the call will fail with ”…”�”}”(hjBh²hh³Nh´Nubj)�”}”(hŒ ``-EEXIST``”h]”hŒ-EEXIST”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjBubhŒ.”…”�”}”(hjBh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KPhj>ubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjòh²hh³hÇh´Nubh÷)�”}”(hŒ„``BPF_EXIST`` will update existing storage for `socket` ``fd`` if it already exists, otherwise the call will fail with ``-ENOENT``. ”h]”hý)�”}”(hŒƒ``BPF_EXIST`` will update existing storage for `socket` ``fd`` if it already exists, otherwise the call will fail with ``-ENOENT``.”h]”(j)�”}”(hŒ ``BPF_EXIST``”h]”hŒ BPF_EXIST”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjžubhŒ" will update existing storage for ”…”�”}”(hjžh²hh³Nh´Nubj_)�”}”(hŒ`socket`”h]”hŒsocket”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hjžubhŒ ”…”�”}”(hjžh²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjžubhŒ9 if it already exists, otherwise the call will fail with ”…”�”}”(hjžh²hh³Nh´Nubj)�”}”(hŒ ``-ENOENT``”h]”hŒ-ENOENT”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjžubhŒ.”…”�”}”(hjžh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KRhjšubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjòh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j'j(uh1hñh³hÇh´KOhjh²hubhý)�”}”(hŒ?Returns ``0`` on success, or negative error in case of failure.”h]”(hŒReturns ”…”�”}”(hjüh²hh³Nh´Nubj)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjüubhŒ2 on success, or negative error in case of failure.”…”�”}”(hjüh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KUhjh²hubeh}”(h]”Œbpf-map-update-elem”ah ]”h"]”Œbpf_map_update_elem()”ah$]”h&]”uh1hÖhjh²hh³hÇh´K@ubh×)�”}”(hhh]”(hÜ)�”}”(hŒbpf_map_lookup_elem()”h]”hŒbpf_map_lookup_elem()”…”�”}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj$h²hh³hÇh´KXubj-)�”}”(hŒAint bpf_map_lookup_elem(int map_fd, const void *key, void *value)”h]”hŒAint bpf_map_lookup_elem(int map_fd, const void *key, void *value)”…”�”}”hj5sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj<‰j=j>j?}”uh1j,h³hÇh´KZhj$h²hubhý)�”}”(hX#Socket-local storage for map ``map_fd`` can be retrieved from a socket using the ``bpf_map_lookup_elem()`` libbpf function. The storage is retrieved from the socket identified by a `socket` ``fd`` stored in the pointer ``key``. Returns ``0`` on success, or negative error in case of failure.”h]”(hŒSocket-local storage for map ”…”�”}”(hjDh²hh³Nh´Nubj)�”}”(hŒ ``map_fd``”h]”hŒmap_fd”…”�”}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjDubhŒ* can be retrieved from a socket using the ”…”�”}”(hjDh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_lookup_elem()``”h]”hŒbpf_map_lookup_elem()”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjDubhŒK libbpf function. The storage is retrieved from the socket identified by a ”…”�”}”(hjDh²hh³Nh´Nubj_)�”}”(hŒ`socket`”h]”hŒsocket”…”�”}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hjDubhŒ ”…”�”}”(hjDh²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjDubhŒ stored in the pointer ”…”�”}”(hjDh²hh³Nh´Nubj)�”}”(hŒ``key``”h]”hŒkey”…”�”}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjDubhŒ . Returns ”…”�”}”(hjDh²hh³Nh´Nubj)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjDubhŒ2 on success, or negative error in case of failure.”…”�”}”(hjDh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K^hj$h²hubeh}”(h]”Œbpf-map-lookup-elem”ah ]”h"]”Œbpf_map_lookup_elem()”ah$]”h&]”uh1hÖhjh²hh³hÇh´KXubh×)�”}”(hhh]”(hÜ)�”}”(hŒbpf_map_delete_elem()”h]”hŒbpf_map_delete_elem()”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjÆh²hh³hÇh´Kdubj-)�”}”(hŒ4int bpf_map_delete_elem(int map_fd, const void *key)”h]”hŒ4int bpf_map_delete_elem(int map_fd, const void *key)”…”�”}”hj×sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj<‰j=j>j?}”uh1j,h³hÇh´KfhjÆh²hubhý)�”}”(hXSocket-local storage for map ``map_fd`` can be deleted from a socket using the ``bpf_map_delete_elem()`` libbpf function. The storage is deleted from the socket identified by a `socket` ``fd`` stored in the pointer ``key``. Returns ``0`` on success, or negative error in case of failure.”h]”(hŒSocket-local storage for map ”…”�”}”(hjæh²hh³Nh´Nubj)�”}”(hŒ ``map_fd``”h]”hŒmap_fd”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjæubhŒ( can be deleted from a socket using the ”…”�”}”(hjæh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_delete_elem()``”h]”hŒbpf_map_delete_elem()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjæubhŒI libbpf function. The storage is deleted from the socket identified by a ”…”�”}”(hjæh²hh³Nh´Nubj_)�”}”(hŒ`socket`”h]”hŒsocket”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j^hjæubhŒ ”…”�”}”(hjæh²hh³Nh´Nubj)�”}”(hŒ``fd``”h]”hŒfd”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjæubhŒ stored in the pointer ”…”�”}”(hjæh²hh³Nh´Nubj)�”}”(hŒ``key``”h]”hŒkey”…”�”}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjæubhŒ . Returns ”…”�”}”(hjæh²hh³Nh´Nubj)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjæubhŒ2 on success, or negative error in case of failure.”…”�”}”(hjæh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KjhjÆh²hubeh}”(h]”Œbpf-map-delete-elem”ah ]”h"]”Œbpf_map_delete_elem()”ah$]”h&]”uh1hÖhjh²hh³hÇh´Kdubeh}”(h]”Œ user-space”ah ]”h"]”Œ user space”ah$]”h&]”uh1hÖhjùh²hh³hÇh´K=ubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Kubh×)�”}”(hhh]”(hÜ)�”}”(hŒExamples”h]”hŒExamples”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjxh²hh³hÇh´Kpubh×)�”}”(hhh]”(hÜ)�”}”(hŒ Kernel BPF”h]”hŒ Kernel BPF”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhj‰h²hh³hÇh´Ksubhý)�”}”(hŒHThis snippet shows how to declare socket-local storage in a BPF program:”h]”hŒHThis snippet shows how to declare socket-local storage in a BPF program:”…”�”}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´Kuhj‰h²hubj-)�”}”(hŒÈstruct { __uint(type, BPF_MAP_TYPE_SK_STORAGE); __uint(map_flags, BPF_F_NO_PREALLOC); __type(key, int); __type(value, struct my_storage); } socket_storage SEC(".maps");”h]”hŒÈstruct { __uint(type, BPF_MAP_TYPE_SK_STORAGE); __uint(map_flags, BPF_F_NO_PREALLOC); __type(key, int); __type(value, struct my_storage); } socket_storage SEC(".maps");”…”�”}”hj¨sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj<‰j=j>j?}”uh1j,h³hÇh´Kwhj‰h²hubhý)�”}”(hŒIThis snippet shows how to retrieve socket-local storage in a BPF program:”h]”hŒIThis snippet shows how to retrieve socket-local storage in a BPF program:”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K€hj‰h²hubj-)�”}”(hX¥SEC("sockops") int _sockops(struct bpf_sock_ops *ctx) { struct my_storage *storage; struct bpf_sock *sk; sk = ctx->sk; if (!sk) return 1; storage = bpf_sk_storage_get(&socket_storage, sk, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 1; /* Use 'storage' here */ return 1; }”h]”hX¥SEC("sockops") int _sockops(struct bpf_sock_ops *ctx) { struct my_storage *storage; struct bpf_sock *sk; sk = ctx->sk; if (!sk) return 1; storage = bpf_sk_storage_get(&socket_storage, sk, 0, BPF_LOCAL_STORAGE_GET_F_CREATE); if (!storage) return 1; /* Use 'storage' here */ return 1; }”…”�”}”hjÅsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj<‰j=j>j?}”uh1j,h³hÇh´K‚hj‰h²hubhý)�”}”(hŒQPlease see the ``tools/testing/selftests/bpf`` directory for functional examples.”h]”(hŒPlease see the ”…”�”}”(hjÔh²hh³Nh´Nubj)�”}”(hŒ``tools/testing/selftests/bpf``”h]”hŒtools/testing/selftests/bpf”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÔubhŒ# directory for functional examples.”…”�”}”(hjÔh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K™hj‰h²hubeh}”(h]”Œid1”ah ]”h"]”h$]”jþah&]”uh1hÖhjxh²hh³hÇh´KsjKubeh}”(h]”Œexamples”ah ]”h"]”Œexamples”ah$]”h&]”uh1hÖhhØh²hh³hÇh´Kpubh×)�”}”(hhh]”(hÜ)�”}”(hŒ References”h]”hŒ References”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´K�ubhý)�”}”(hŒ>https://lwn.net/ml/netdev/20190426171103.61892-1-kafai@fb.com/”h]”hŒ reference”“”)�”}”(hjh]”hŒ>https://lwn.net/ml/netdev/20190426171103.61892-1-kafai@fb.com/”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”juh1jhjubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KŸhjh²hubeh}”(h]”Œ references”ah ]”h"]”Œ references”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K�ubeh}”(h]”Œbpf-map-type-sk-storage”ah ]”h"]”Œbpf_map_type_sk_storage”ah$]”h&]”uh1hÖhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÛNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jaŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j;j8jujrŒ kernel bpf”Njwjtjõjòjmjjj!jjÃjÀjejbjjýj3j0uŒ nametypes”}”(j;‰ju‰j¥‰jw‰jõ‰jm‰j!‰jÉje‰j‰j3‰uh}”(j8hØjrjùjúj jtjjòjzjjjjjjÀj$jbjÆjýjxjöj‰j0juŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”joKs…”R”Œparse_messages”]”hŒsystem_message”“”)�”}”(hhh]”hý)�”}”(hŒ-Duplicate implicit target name: "kernel bpf".”h]”hŒ1Duplicate implicit target name: “kernel bpfâ€�.”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hühjÆubah}”(h]”h ]”h"]”h$]”h&]”jöaŒlevel”KŒtype”ŒINFO”Œsource”hÇŒline”Ksuh1jÄhj‰h²hh³hÇh´KsubaŒtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.