€•÷rŒ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_xskmap”Œ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_xskmap”Œ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_xskmap”Œ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_xskmap”Œ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_xskmap”Œ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_xskmap”Œ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_xskmap”Œ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³Œ+-------------+-------------+ | | prog | | 2 | xsk C | | | | | +-------------+ | | | | | | | | | | +---------+ | | | +---------------------------------------------------+”h]”hXË+---------------------------------------------------+ | xsk A | xsk B | xsk C |<---+ User space =========================================================|========== | Queue 0 | Queue 1 | Queue 2 | | Kernel +---------------------------------------------------+ | | Netdev eth0 | | +---------------------------------------------------+ | | +=============+ | | | | key | xsk | | | | +---------+ +=============+ | | | | | | 0 | xsk A | | | | | | +-------------+ | | | | | | 1 | xsk B | | | | | BPF |-- redirect -->+-------------+-------------+ | | prog | | 2 | xsk C | | | | | +-------------+ | | | | | | | | | | +---------+ | | | +---------------------------------------------------+”…”�”}”hjŽsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒforce”‰Œlanguage”Œnone”Œhighlight_args”}”uh1jŒh³hÇh´KhhØh²hubhì)�”}”(hX An AF_XDP socket that is bound to a certain will *only* accept XDP frames from that . If an XDP program tries to redirect from a other than what the socket is bound to, the frame will not be received on the socket.”h]”hý)�”}”(hX An AF_XDP socket that is bound to a certain will *only* accept XDP frames from that . If an XDP program tries to redirect from a other than what the socket is bound to, the frame will not be received on the socket.”h]”(hŒCAn AF_XDP socket that is bound to a certain will ”…”�”}”(hj¥h²hh³Nh´NubhŒemphasis”“”)�”}”(hŒ*only*”h]”hŒonly”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j­hj¥ubhŒÂ accept XDP frames from that . If an XDP program tries to redirect from a other than what the socket is bound to, the frame will not be received on the socket.”…”�”}”(hj¥h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K+hj¡ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhhØh²hh³hÇh´Nubhý)�”}”(hXTypically an XSKMAP is created per netdev. This map contains an array of XSK File Descriptors (FDs). The number of array elements is typically set or adjusted using the ``max_entries`` map parameter. For AF_XDP ``max_entries`` is equal to the number of queues supported by the netdev.”h]”(hŒ©Typically an XSKMAP is created per netdev. This map contains an array of XSK File Descriptors (FDs). The number of array elements is typically set or adjusted using the ”…”�”}”(hjÍh²hh³Nh´Nubj)�”}”(hŒ``max_entries``”h]”hŒ max_entries”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÍubhŒ map parameter. For AF_XDP ”…”�”}”(hjÍh²hh³Nh´Nubj)�”}”(hŒ``max_entries``”h]”hŒ max_entries”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÍubhŒ: is equal to the number of queues supported by the netdev.”…”�”}”(hjÍh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K0hhØh²hubhì)�”}”(hŒ4Both the map key and map value size must be 4 bytes.”h]”hý)�”}”(hjh]”hŒ4Both the map key and map value size must be 4 bytes.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K6hjÿubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhhØh²hh³hÇh´Nubh×)�”}”(hhh]”(hÜ)�”}”(hŒUsage”h]”hŒUsage”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjh²hh³hÇh´K9ubh×)�”}”(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´Kubj�)�”}”(hŒ>long bpf_redirect_map(struct bpf_map *map, u32 key, u64 flags)”h]”hŒ>long bpf_redirect_map(struct bpf_map *map, u32 key, u64 flags)”…”�”}”hjIsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjœ‰j�Œc”jŸ}”uh1jŒh³hÇh´K?hj8h²hubhý)�”}”(hŒºRedirect the packet to the endpoint referenced by ``map`` at index ``key``. For ``BPF_MAP_TYPE_XSKMAP`` this map contains references to XSK FDs for sockets attached to a netdev's queues.”h]”(hŒ2Redirect the packet to the endpoint referenced by ”…”�”}”(hjYh²hh³Nh´Nubj)�”}”(hŒ``map``”h]”hŒmap”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjYubhŒ at index ”…”�”}”(hjYh²hh³Nh´Nubj)�”}”(hŒ``key``”h]”hŒkey”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjYubhŒ. For ”…”�”}”(hjYh²hh³Nh´Nubj)�”}”(hŒ``BPF_MAP_TYPE_XSKMAP``”h]”hŒBPF_MAP_TYPE_XSKMAP”…”�”}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjYubhŒU this map contains references to XSK FDs for sockets attached to a netdev’s queues.”…”�”}”(hjYh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KChj8h²hubhì)�”}”(hŒÙIf the map is empty at an index, the packet is dropped. This means that it is necessary to have an XDP program loaded with at least one XSK in the XSKMAP to be able to get any traffic to user space through the socket.”h]”hý)�”}”(hŒÙIf the map is empty at an index, the packet is dropped. This means that it is necessary to have an XDP program loaded with at least one XSK in the XSKMAP to be able to get any traffic to user space through the socket.”h]”hŒÙIf the map is empty at an index, the packet is dropped. This means that it is necessary to have an XDP program loaded with at least one XSK in the XSKMAP to be able to get any traffic to user space through the socket.”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KHhj�ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhj8h²hh³hÇh´Nubeh}”(h]”Œbpf-redirect-map”ah ]”h"]”Œbpf_redirect_map()”ah$]”h&]”uh1hÖhj'h²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´KMubj�)�”}”(hŒ?void *bpf_map_lookup_elem(struct bpf_map *map, const void *key)”h]”hŒ?void *bpf_map_lookup_elem(struct bpf_map *map, const void *key)”…”�”}”hjÎsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjœ‰j�jWjŸ}”uh1jŒh³hÇh´KNhj½h²hubhý)�”}”(hŒoXSK entry references of type ``struct xdp_sock *`` can be retrieved using the ``bpf_map_lookup_elem()`` helper.”h]”(hŒXSK entry references of type ”…”�”}”(hjÝh²hh³Nh´Nubj)�”}”(hŒ``struct xdp_sock *``”h]”hŒstruct xdp_sock *”…”�”}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÝubhŒ can be retrieved using the ”…”�”}”(hjÝh²hh³Nh´Nubj)�”}”(hŒ``bpf_map_lookup_elem()``”h]”hŒbpf_map_lookup_elem()”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjÝubhŒ helper.”…”�”}”(hjÝh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´KRhj½h²hubeh}”(h]”Œbpf-map-lookup-elem”ah ]”h"]”h$]”Œbpf_map_lookup_elem()”ah&]”uh1hÖhj'h²hh³hÇh´KMŒ referenced”Kubeh}”(h]”Œ kernel-bpf”ah ]”h"]”Œ kernel bpf”ah$]”h&]”uh1hÖhjh²hh³hÇh´Krx_queue_index; if (bpf_map_lookup_elem(&xsks_map, &index)) return bpf_redirect_map(&xsks_map, index, 0); return XDP_PASS; }”h]”hX–struct { __uint(type, BPF_MAP_TYPE_XSKMAP); __type(key, __u32); __type(value, __u32); __uint(max_entries, 64); } xsks_map SEC(".maps"); SEC("xdp") int xsk_redir_prog(struct xdp_md *ctx) { __u32 index = ctx->rx_queue_index; if (bpf_map_lookup_elem(&xsks_map, &index)) return bpf_redirect_map(&xsks_map, index, 0); return XDP_PASS; }”…”�”}”hjRsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjœ‰j�jWjŸ}”uh1jŒh³hÇh´K�hjh²hubeh}”(h]”Œkernel”ah ]”h"]”Œkernel”ah$]”h&]”uh1hÖhjþh²hh³hÇh´Kˆubh×)�”}”(hhh]”(hÜ)�”}”(hŒ User space”h]”hŒ User space”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÛhjih²hh³hÇh´K¢ubhý)�”}”(hŒKThe following code snippet shows how to update an XSKMAP with an XSK entry.”h]”hŒKThe following code snippet shows how to update an XSKMAP with an XSK entry.”…”�”}”(hjzh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K¤hjih²hubj�)�”}”(hX-int update_xsks_map(struct bpf_map *xsks_map, int queue_id, int xsk_fd) { int ret; ret = bpf_map_update_elem(bpf_map__fd(xsks_map), &queue_id, &xsk_fd, 0); if (ret < 0) fprintf(stderr, "Failed to update xsks_map: %s\n", strerror(errno)); return ret; }”h]”hX-int update_xsks_map(struct bpf_map *xsks_map, int queue_id, int xsk_fd) { int ret; ret = bpf_map_update_elem(bpf_map__fd(xsks_map), &queue_id, &xsk_fd, 0); if (ret < 0) fprintf(stderr, "Failed to update xsks_map: %s\n", strerror(errno)); return ret; }”…”�”}”hjˆsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆjœ‰j�jWjŸ}”uh1jŒh³hÇh´K¦hjih²hubhý)�”}”(hŒæFor an example on how create AF_XDP sockets, please see the AF_XDP-example and AF_XDP-forwarding programs in the `bpf-examples`_ directory in the `libxdp`_ repository. For a detailed explanation of the AF_XDP interface please see:”h]”(hŒqFor an example on how create AF_XDP sockets, please see the AF_XDP-example and AF_XDP-forwarding programs in the ”…”�”}”(hj—h²hh³Nh´Nubjn)�”}”(hŒ`bpf-examples`_”h]”hŒ bpf-examples”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ bpf-examples”jŒ+https://github.com/xdp-project/bpf-examples”uh1jmhj—j�KubhŒ directory in the ”…”�”}”(hj—h²hh³Nh´Nubjn)�”}”(hŒ `libxdp`_”h]”hŒlibxdp”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œlibxdp”jjÕuh1jmhj—j�KubhŒK repository. For a detailed explanation of the AF_XDP interface please see:”…”�”}”(hj—h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K³hjih²hubhò)�”}”(hhh]”(h÷)�”}”(hŒ`libxdp-readme`_.”h]”hý)�”}”(hjÓh]”(jn)�”}”(hŒ`libxdp-readme`_”h]”hŒ libxdp-readme”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ libxdp-readme”jŒThttps://github.com/xdp-project/xdp-tools/tree/master/lib/libxdp#using-af_xdp-sockets”uh1jmhjÕj�KubhŒ.”…”�”}”(hjÕh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K·hjÑubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjÎh²hh³hÇh´Nubh÷)�”}”(hŒ `AF_XDP`_ kernel documentation. ”h]”hý)�”}”(hŒ`AF_XDP`_ kernel documentation.”h]”(jn)�”}”(hŒ `AF_XDP`_”h]”hŒAF_XDP”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒAF_XDP”jj€uh1jmhjýj�KubhŒ kernel documentation.”…”�”}”(hjýh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K¸hjùubah}”(h]”h ]”h"]”h$]”h&]”uh1höhjÎh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j'j(uh1hñh³hÇh´K·hjih²hubhì)�”}”(hŒJThe most comprehensive resource for using XSKMAPs and AF_XDP is `libxdp`_.”h]”hý)�”}”(hj)h]”(hŒ@The most comprehensive resource for using XSKMAPs and AF_XDP is ”…”�”}”(hj+h²hh³Nh´Nubjn)�”}”(hŒ `libxdp`_”h]”hŒlibxdp”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œlibxdp”jjÕuh1jmhj+j�KubhŒ.”…”�”}”(hj+h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hüh³hÇh´K»hj'ubah}”(h]”h ]”h"]”h$]”h&]”uh1hëhjih²hh³hÇh´NubhŒtarget”“”)�”}”(hŒK.. _libxdp: https://github.com/xdp-project/xdp-tools/tree/master/lib/libxdp”h]”h}”(h]”Œlibxdp”ah ]”h"]”Œlibxdp”ah$]”h&]”jjÕuh1jRh´K½hjih²hh³hÇjKubjS)�”}”(hŒI.. _AF_XDP: https://www.kernel.org/doc/html/latest/networking/af_xdp.html”h]”h}”(h]”Œaf-xdp”ah ]”h"]”Œaf_xdp”ah$]”h&]”jj€uh1jRh´K¾hjih²hh³hÇjKubjS)�”}”(hŒ=.. _bpf-examples: https://github.com/xdp-project/bpf-examples”h]”h}”(h]”Œ bpf-examples”ah ]”h"]”Œ bpf-examples”ah$]”h&]”jj¯uh1jRh´K¿hjih²hh³hÇjKubjS)�”}”(hŒg.. _libxdp-readme: https://github.com/xdp-project/xdp-tools/tree/master/lib/libxdp#using-af_xdp-sockets”h]”h}”(h]”Œ libxdp-readme”ah ]”h"]”Œ libxdp-readme”ah$]”h&]”jjèuh1jRh´KÀhjih²hh³hÇjKubeh}”(h]”Œid2”ah ]”h"]”h$]”jôah&]”uh1hÖhjþh²hh³hÇh´K¢jKubeh}”(h]”Œexamples”ah ]”h"]”Œexamples”ah$]”h&]”uh1hÖhhØh²hh³hÇh´K†ubeh}”(h]”Œbpf-map-type-xskmap”ah ]”h"]”Œbpf_map_type_xskmap”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”j¾Œ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”}”(Œaf_xdp”]”(jojeŒlibxdp”]”(jÅj´j2eŒ bpf-examples”]”jŸaŒ libxdp-readme”]”jØauŒrefids”}”Œnameids”}”(j˜j•jûjøjjjºj·Œbpf_map_lookup_elem()”NŒ user space”Nj/j,jëjèj�j�jfjcj]jZjijfjujrj�j~uŒ nametypes”}”(j˜‰jû‰j‰jº‰j ‰j ‰j/‰jë‰j�‰jf‰j]ˆjiˆjuˆj�ˆuh}”(j•hØjøjjj'j·j8jj½jðj j,jIjtj2jèjyj�jþjcjj†jijZjTjfj`jrjlj~jxuŒ 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”“”}”jÌKs…”R”Œparse_messages”]”(hŒsystem_message”“”)�”}”(hhh]”hý)�”}”(hŒ8Duplicate implicit target name: "bpf_map_lookup_elem()".”h]”hŒ