gw: Proper error log on non-existing netns

This commit is contained in:
Pau Espin Pedrol 2020-02-10 15:12:49 +01:00 committed by Andre Puschmann
parent be7c5a009d
commit 1d81ef9e24
1 changed files with 6 additions and 0 deletions

View File

@ -347,6 +347,12 @@ int gw::init_if(char* err_str)
std::string netns("/run/netns/"); std::string netns("/run/netns/");
netns += args.netns; netns += args.netns;
netns_fd = open(netns.c_str(), O_RDONLY); netns_fd = open(netns.c_str(), O_RDONLY);
if (netns_fd == -1) {
err_str = strerror(errno);
log.error("Failed to find netns %s (%s): %s\n",
args.netns.c_str(), netns.c_str(), err_str);
return SRSLTE_ERROR_CANT_START;
}
if (setns(netns_fd, CLONE_NEWNET) == -1) { if (setns(netns_fd, CLONE_NEWNET) == -1) {
err_str = strerror(errno); err_str = strerror(errno);
log.error("Failed to change netns: %s\n", err_str); log.error("Failed to change netns: %s\n", err_str);