Unverified Commit 52ac245b by Christian Brauner Committed by GitHub

Merge pull request #3047 from Rachid-Koucha/patch-11

Fixed file descriptor leak for network namespace
parents 3d43f611 aa0c0e7b
...@@ -1826,7 +1826,8 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1826,7 +1826,8 @@ static int lxc_spawn(struct lxc_handler *handler)
if (!cgroup_ops->chown(cgroup_ops, handler->conf)) if (!cgroup_ops->chown(cgroup_ops, handler->conf))
goto out_delete_net; goto out_delete_net;
/* Now we're ready to preserve the network namespace */ /* If not done yet, we're now ready to preserve the network namespace */
if (handler->nsfd[LXC_NS_NET] < 0) {
ret = lxc_try_preserve_ns(handler->pid, "net"); ret = lxc_try_preserve_ns(handler->pid, "net");
if (ret < 0) { if (ret < 0) {
if (ret != -EOPNOTSUPP) { if (ret != -EOPNOTSUPP) {
...@@ -1836,13 +1837,13 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1836,13 +1837,13 @@ static int lxc_spawn(struct lxc_handler *handler)
} else { } else {
handler->nsfd[LXC_NS_NET] = ret; handler->nsfd[LXC_NS_NET] = ret;
DEBUG("Preserved net namespace via fd %d", ret); DEBUG("Preserved net namespace via fd %d", ret);
}
}
ret = lxc_netns_set_nsid(handler->nsfd[LXC_NS_NET]); ret = lxc_netns_set_nsid(handler->nsfd[LXC_NS_NET]);
if (ret < 0) if (ret < 0)
SYSWARN("Failed to allocate new network namespace id"); SYSWARN("Failed to allocate new network namespace id");
else else
TRACE("Allocated new network namespace id"); TRACE("Allocated new network namespace id");
}
/* Create the network configuration. */ /* Create the network configuration. */
if (handler->ns_clone_flags & CLONE_NEWNET) { if (handler->ns_clone_flags & CLONE_NEWNET) {
......
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