namespace: fall back gracefully when kernel doesn't support network namespaces (#7024)

This commit is contained in:
Michal Sekletar
2017-10-10 09:46:13 +02:00
committed by Lennart Poettering
parent 4984902ccb
commit 6e2d7c4f13
4 changed files with 49 additions and 8 deletions
+8 -5
View File
@@ -3070,11 +3070,14 @@ static int exec_child(
}
if (context->private_network && runtime && runtime->netns_storage_socket[0] >= 0) {
r = setup_netns(runtime->netns_storage_socket);
if (r < 0) {
*exit_status = EXIT_NETWORK;
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
}
if (ns_type_supported(NAMESPACE_NET)) {
r = setup_netns(runtime->netns_storage_socket);
if (r < 0) {
*exit_status = EXIT_NETWORK;
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
}
} else
log_unit_warning(unit, "PrivateNetwork=yes is configured, but the kernel does not support network namespaces, ignoring.");
}
needs_mount_namespace = exec_needs_mount_namespace(context, params, runtime);