[lxc-devel] [lxc/master] start: Moves lxc_find_gateway_addresses back to before clone
tomponline on Github
lxc-bot at linuxcontainers.org
Thu Jul 4 21:39:57 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 476 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190704/175029d0/attachment.bin>
-------------- next part --------------
From 4c8e17482e9ebf81500dca9f7c27aca9f5b34de4 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 4 Jul 2019 22:38:23 +0100
Subject: [PATCH] start: Moves lxc_find_gateway_addresses back to before clone
This restores the lxc.net.x.ipv4.gateway = auto and lxc.net.x.ipv6.gateway = auto functionality.
Fixes #3078
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
src/lxc/network.c | 12 ------------
src/lxc/start.c | 14 ++++++++++++++
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/lxc/network.c b/src/lxc/network.c
index dcedc01507..3aadcf0bd6 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -4036,18 +4036,6 @@ int lxc_create_network(struct lxc_handler *handler)
{
int ret;
- /*
- * Find gateway addresses from the link device, which is no longer
- * accessible inside the container. Do this before creating network
- * interfaces, since goto out_delete_net does not work before
- * lxc_clone.
- */
- ret = lxc_find_gateway_addresses(handler);
- if (ret) {
- ERROR("Failed to find gateway addresses");
- return -1;
- }
-
if (handler->am_root) {
ret = lxc_create_network_priv(handler);
if (ret)
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 1e559f887a..1b4549c799 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1697,6 +1697,20 @@ static int lxc_spawn(struct lxc_handler *handler)
if (ret < 0)
goto out_sync_fini;
+ if (handler->ns_clone_flags & CLONE_NEWNET) {
+ /*
+ * Find gateway addresses from the link device, which is no longer
+ * accessible inside the container. Do this before creating network
+ * interfaces, since goto out_delete_net does not work before
+ * lxc_clone.
+ */
+ ret = lxc_find_gateway_addresses(handler);
+ if (ret) {
+ ERROR("Failed to find gateway addresses");
+ goto out_sync_fini;
+ }
+ }
+
if (!cgroup_ops->payload_create(cgroup_ops, handler)) {
ERROR("Failed creating cgroups");
goto out_delete_net;
More information about the lxc-devel
mailing list