€•g*Œ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/networking/sysfs-tagging”Œ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/networking/sysfs-tagging”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/it_IT/networking/sysfs-tagging”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ja_JP/networking/sysfs-tagging”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ko_KR/networking/sysfs-tagging”Œ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/networking/sysfs-tagging”Œ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”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒF/var/lib/git/docbuild/linux/Documentation/networking/sysfs-tagging.rst”h KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ Sysfs tagging”h]”hŒ Sysfs tagging”…””}”(hh»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hh¶hžhhŸh³h KubhŒ paragraph”“”)”}”(hŒL(Taken almost verbatim from Eric Biederman's netns tagging patch commit msg)”h]”hŒN(Taken almost verbatim from Eric Biederman’s netns tagging patch commit msg)”…””}”(hhËhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hŒ¡The problem. Network devices show up in sysfs and with the network namespace active multiple devices with the same name can show up in the same directory, ouch!”h]”hŒ¡The problem. Network devices show up in sysfs and with the network namespace active multiple devices with the same name can show up in the same directory, ouch!”…””}”(hhÙhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K hh¶hžhubhÊ)”}”(hŒ´To avoid that problem and allow existing applications in network namespaces to see the same interface that is currently presented in sysfs, sysfs now has tagging directory support.”h]”hŒ´To avoid that problem and allow existing applications in network namespaces to see the same interface that is currently presented in sysfs, sysfs now has tagging directory support.”…””}”(hhçhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hŒÕBy using the network namespace pointers as tags to separate out the sysfs directory entries we ensure that we don't have conflicts in the directories and applications only see a limited set of the network devices.”h]”hŒ×By using the network namespace pointers as tags to separate out the sysfs directory entries we ensure that we don’t have conflicts in the directories and applications only see a limited set of the network devices.”…””}”(hhõhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hX Each sysfs directory entry may be tagged with a namespace via the ``void *ns member`` of its ``kernfs_node``. If a directory entry is tagged, then ``kernfs_node->flags`` will have a flag between KOBJ_NS_TYPE_NONE and KOBJ_NS_TYPES, and ns will point to the namespace to which it belongs.”h]”(hŒBEach sysfs directory entry may be tagged with a namespace via the ”…””}”(hjhžhhŸNh NubhŒliteral”“”)”}”(hŒ``void *ns member``”h]”hŒvoid *ns member”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubhŒ of its ”…””}”(hjhžhhŸNh Nubj )”}”(hŒ``kernfs_node``”h]”hŒ kernfs_node”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubhŒ(. If a directory entry is tagged, then ”…””}”(hjhžhhŸNh Nubj )”}”(hŒ``kernfs_node->flags``”h]”hŒkernfs_node->flags”…””}”(hj1hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubhŒv will have a flag between KOBJ_NS_TYPE_NONE and KOBJ_NS_TYPES, and ns will point to the namespace to which it belongs.”…””}”(hjhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hX.Each sysfs superblock's kernfs_super_info contains an array ``void *ns[KOBJ_NS_TYPES]``. When a task in a tagging namespace kobj_nstype first mounts sysfs, a new superblock is created. It will be differentiated from other sysfs mounts by having its ``s_fs_info->ns[kobj_nstype]`` set to the new namespace. Note that through bind mounting and mounts propagation, a task can easily view the contents of other namespaces' sysfs mounts. Therefore, when a namespace exits, it will call kobj_ns_exit() to invalidate any kernfs_node->ns pointers pointing to it.”h]”(hŒ>Each sysfs superblock’s kernfs_super_info contains an array ”…””}”(hjIhžhhŸNh Nubj )”}”(hŒ``void *ns[KOBJ_NS_TYPES]``”h]”hŒvoid *ns[KOBJ_NS_TYPES]”…””}”(hjQhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjIubhŒ¤. When a task in a tagging namespace kobj_nstype first mounts sysfs, a new superblock is created. It will be differentiated from other sysfs mounts by having its ”…””}”(hjIhžhhŸNh Nubj )”}”(hŒ``s_fs_info->ns[kobj_nstype]``”h]”hŒs_fs_info->ns[kobj_nstype]”…””}”(hjchžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjIubhX set to the new namespace. Note that through bind mounting and mounts propagation, a task can easily view the contents of other namespaces’ sysfs mounts. Therefore, when a namespace exits, it will call kobj_ns_exit() to invalidate any kernfs_node->ns pointers pointing to it.”…””}”(hjIhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhÊ)”}”(hŒUsers of this interface:”h]”hŒUsers of this interface:”…””}”(hj{hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K'hh¶hžhubhŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ2define a type in the ``kobj_ns_type`` enumeration.”h]”hÊ)”}”(hj’h]”(hŒdefine a type in the ”…””}”(hj”hžhhŸNh Nubj )”}”(hŒ``kobj_ns_type``”h]”hŒ kobj_ns_type”…””}”(hj›hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj”ubhŒ enumeration.”…””}”(hj”hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K)hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jŽhj‹hžhhŸh³h Nubj)”}”(hŒãcall kobj_ns_type_register() with its ``kobj_ns_type_operations`` which has - current_ns() which returns current's namespace - netlink_ns() which returns a socket's namespace - initial_ns() which returns the initial namespace ”h]”(hÊ)”}”(hŒKcall kobj_ns_type_register() with its ``kobj_ns_type_operations`` which has”h]”(hŒ&call kobj_ns_type_register() with its ”…””}”(hj½hžhhŸNh Nubj )”}”(hŒ``kobj_ns_type_operations``”h]”hŒkobj_ns_type_operations”…””}”(hjÅhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj½ubhŒ which has”…””}”(hj½hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K*hj¹ubjŠ)”}”(hhh]”(j)”}”(hŒ.current_ns() which returns current's namespace”h]”hÊ)”}”(hjâh]”hŒ0current_ns() which returns current’s namespace”…””}”(hjähžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K,hjàubah}”(h]”h ]”h"]”h$]”h&]”uh1jŽhjÝubj)”}”(hŒ/netlink_ns() which returns a socket's namespace”h]”hÊ)”}”(hjùh]”hŒ1netlink_ns() which returns a socket’s namespace”…””}”(hjûhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K-hj÷ubah}”(h]”h ]”h"]”h$]”h&]”uh1jŽhjÝubj)”}”(hŒ1initial_ns() which returns the initial namespace ”h]”hÊ)”}”(hŒ0initial_ns() which returns the initial namespace”h]”hŒ0initial_ns() which returns the initial namespace”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K.hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jŽhjÝubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j‰hŸh³h K,hj¹ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jŽhj‹hžhhŸNh Nubj)”}”(hŒ=call kobj_ns_exit() when an individual tag is no longer valid”h]”hÊ)”}”(hj6h]”hŒ=call kobj_ns_exit() when an individual tag is no longer valid”…””}”(hj8hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K0hj4ubah}”(h]”h ]”h"]”h$]”h&]”uh1jŽhj‹hžhhŸh³h Nubeh}”(h]”h ]”h"]”h$]”h&]”j,j-uh1j‰hŸh³h K)hh¶hžhubeh}”(h]”Œ sysfs-tagging”ah ]”h"]”Œ sysfs tagging”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”}”Œrefids”}”Œnameids”}”jVjSsŒ nametypes”}”jV‰sh}”jSh¶sŒ 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”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.