Commit 4f9acb6a authored by Pavel Emelyanov's avatar Pavel Emelyanov

net: Do walk net namespaces to collect

Right now we don't support multiple net namespaces,
but some day we will. Other than this we have a logic
to distinguish cases with no namespaces vs one namespace,
so this walking already makes sence.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7327ffe6
...@@ -626,9 +626,35 @@ int veth_pair_add(char *in, char *out) ...@@ -626,9 +626,35 @@ int veth_pair_add(char *in, char *out)
return 0; return 0;
} }
static int collect_net_ns(struct ns_id *ns)
{
pr_info("Collecting netns %d/%d\n", ns->id, ns->pid);
return collect_sockets(ns->pid);
}
int collect_net_namespaces(void) int collect_net_namespaces(void)
{ {
return collect_sockets(root_item->pid.real); int ret = 0;
struct ns_id *ns;
for (ns = ns_ids; ns; ns = ns->next) {
if (!(ns->nd->cflag & CLONE_NEWNET))
continue;
if (ns->pid == getpid()) {
if ((root_ns_mask & CLONE_NEWNET))
continue;
ret = collect_net_ns(ns);
break;
}
ret = collect_net_ns(ns);
if (ret)
break;
}
return ret;
} }
struct ns_desc net_ns_desc = NS_DESC_ENTRY(CLONE_NEWNET, "net"); struct ns_desc net_ns_desc = NS_DESC_ENTRY(CLONE_NEWNET, "net");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment