continue;
if (netdev->type != LXC_NET_VETH && netdev->type != LXC_NET_MACVLAN) {
- ERROR("Automatic gateway detection is only supported "
- "for veth and macvlan");
+ ERROR("Automatic gateway detection is only supported for veth and macvlan");
return -1;
}
if (netdev->ipv4_gateway_auto) {
if (lxc_ipv4_addr_get(link_index, &netdev->ipv4_gateway)) {
- ERROR("Failed to automatically find ipv4 gateway "
- "address from link interface \"%s\"", netdev->link);
+ ERROR("Failed to automatically find ipv4 gateway address from link interface \"%s\"",
+ netdev->link);
return -1;
}
}
if (netdev->ipv6_gateway_auto) {
if (lxc_ipv6_addr_get(link_index, &netdev->ipv6_gateway)) {
- ERROR("Failed to automatically find ipv6 gateway "
- "address from link interface \"%s\"", netdev->link);
+ ERROR("Failed to automatically find ipv6 gateway address from link interface \"%s\"",
+ netdev->link);
return -1;
}
}
{
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)
if (ret < 0)
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)) {
ERROR("Failed creating cgroups");
goto out_delete_net;