Unverified Commit 9c238bc6 by Christian Brauner Committed by GitHub

Merge pull request #3081 from brauner/2019-07-05/network_unification_fixes

start: call lxc_find_gateway_addresses early
parents 306ca14a 03ca4af8
...@@ -2473,8 +2473,7 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler) ...@@ -2473,8 +2473,7 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler)
continue; continue;
if (netdev->type != LXC_NET_VETH && netdev->type != LXC_NET_MACVLAN) { if (netdev->type != LXC_NET_VETH && netdev->type != LXC_NET_MACVLAN) {
ERROR("Automatic gateway detection is only supported " ERROR("Automatic gateway detection is only supported for veth and macvlan");
"for veth and macvlan");
return -1; return -1;
} }
...@@ -2489,16 +2488,16 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler) ...@@ -2489,16 +2488,16 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler)
if (netdev->ipv4_gateway_auto) { if (netdev->ipv4_gateway_auto) {
if (lxc_ipv4_addr_get(link_index, &netdev->ipv4_gateway)) { if (lxc_ipv4_addr_get(link_index, &netdev->ipv4_gateway)) {
ERROR("Failed to automatically find ipv4 gateway " ERROR("Failed to automatically find ipv4 gateway address from link interface \"%s\"",
"address from link interface \"%s\"", netdev->link); netdev->link);
return -1; return -1;
} }
} }
if (netdev->ipv6_gateway_auto) { if (netdev->ipv6_gateway_auto) {
if (lxc_ipv6_addr_get(link_index, &netdev->ipv6_gateway)) { if (lxc_ipv6_addr_get(link_index, &netdev->ipv6_gateway)) {
ERROR("Failed to automatically find ipv6 gateway " ERROR("Failed to automatically find ipv6 gateway address from link interface \"%s\"",
"address from link interface \"%s\"", netdev->link); netdev->link);
return -1; return -1;
} }
} }
...@@ -4036,18 +4035,6 @@ int lxc_create_network(struct lxc_handler *handler) ...@@ -4036,18 +4035,6 @@ int lxc_create_network(struct lxc_handler *handler)
{ {
int ret; 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) { if (handler->am_root) {
ret = lxc_create_network_priv(handler); ret = lxc_create_network_priv(handler);
if (ret) if (ret)
......
...@@ -1697,6 +1697,14 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1697,6 +1697,14 @@ static int lxc_spawn(struct lxc_handler *handler)
if (ret < 0) if (ret < 0)
goto out_sync_fini; goto out_sync_fini;
if (handler->ns_clone_flags & CLONE_NEWNET) {
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)) { if (!cgroup_ops->payload_create(cgroup_ops, handler)) {
ERROR("Failed creating cgroups"); ERROR("Failed creating cgroups");
goto out_delete_net; goto out_delete_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