网络 – Linux命名空间:网络命名空间是否可以存在而不与进程相关联?

前端之家收集整理的这篇文章主要介绍了网络 – Linux命名空间:网络命名空间是否可以存在而不与进程相关联?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

ip netns创建对/ var / run / ns中的(命名)网络命名空间的引用,可以轻松跟踪它.同样,也可以通过/ proc / [pid] / ns / net来确定.然而,一些自定义程序可能创建一个网络ns,并将相应的inode保存在其他非常规位置.这可能使得难以确定是否存在可以列出的净值.

其次,取消共享< cmd>当进程退出时,会损坏网络,这很好.但是,ip netns exec< netns> < CMD>即使在命令/进程退出后也会保持ns.所以我相信,任何自定义程序都可以这样做.

因此,问题是:自定义程序是否可能创建一个未命名的网络ns,并且与任何进程保持不相关?

此外,鉴于我们不知道inode的路径,是否可以从用户空间中列出这样的(隐藏)网络ns? (内核当然有一个net ns的链表)一个代码段将是有帮助的.

最佳答案

Is it possible that a custom program creates an unnamed net ns,and it is left unassociated with any process?

是的,这是可能的.根据Linux命名空间手册页(http://man7.org/linux/man-pages/man7/namespaces.7.html):

Each process has a /proc/[pid]/ns/ subdirectory containing one entry
for each namespace that supports being manipulated by setns(2):

Bind mounting (see mount(2)) one of the files in this directory to
somewhere else in the filesystem keeps the corresponding namespace of
the process specified by pid alive even if all processes currently in
the namespace terminate.

关于另一个问题:

is it possible to list out such (hidden) net ns from user-space,given that we do not know the paths to the inodes?

如果您从第一个问题考虑上述引用,通过检查绑定路径,您应该可以找到这些隐藏的命名空间.

原文链接:https://www.f2er.com/docker/436432.html

猜你在找的Docker相关文章