This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/17803 ) Change subject: lib/netns: OSMO_ASSER() if user doesn't call init_netns() ...................................................................... lib/netns: OSMO_ASSER() if user doesn't call init_netns() It is vital that init_netns() is called first in order to initialize default_nsfd. Change-Id: Ic16646fa7d60c578056b17351c5fe2090a81dff0 --- M lib/netns.c 1 file changed, 13 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/03/17803/1 diff --git a/lib/netns.c b/lib/netns.c index 8d26330..914f5c8 100644 --- a/lib/netns.c +++ b/lib/netns.c @@ -41,12 +41,14 @@ #include <fcntl.h> #include <errno.h> +#include <osmocom/core/utils.h> + #include "netns.h" #define NETNS_PATH "/var/run/netns" /*! default namespace of the GGSN process */ -static int default_nsfd; +static int default_nsfd = -1; /*! switch to a (non-default) namespace, store existing signal mask in oldmask. * \param[in] nsfd file descriptor representing the namespace to whch we shall switch @@ -57,6 +59,8 @@ sigset_t intmask; int rc; + OSMO_ASSERT(default_nsfd >= 0); + if (sigfillset(&intmask) < 0) return -errno; if ((rc = sigprocmask(SIG_BLOCK, &intmask, oldmask)) != 0) @@ -75,6 +79,8 @@ * \returns 0 on successs; negative errno value in case of error */ int restore_ns(sigset_t *oldmask) { + OSMO_ASSERT(default_nsfd >= 0); + int rc; if (setns(default_nsfd, CLONE_NEWNET) < 0) return -errno; @@ -92,6 +98,8 @@ int fd = -1; int rc; + OSMO_ASSERT(default_nsfd >= 0); + /* mask off all signals, store old signal mask */ if (sigfillset(&intmask) < 0) return -errno; @@ -144,6 +152,8 @@ int sk = -1; int rc; + OSMO_ASSERT(default_nsfd >= 0); + /* mask off all signals, store old signal mask */ if (sigfillset(&intmask) < 0) return -errno; @@ -204,6 +214,8 @@ sigset_t intmask, oldmask; char path[MAXPATHLEN] = NETNS_PATH; + OSMO_ASSERT(default_nsfd >= 0); + /* create /var/run/netns, if it doesn't exist already */ rc = mkdir(path, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); if (rc < 0 && errno != EEXIST) -- To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/17803 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ggsn Gerrit-Branch: master Gerrit-Change-Id: Ic16646fa7d60c578056b17351c5fe2090a81dff0 Gerrit-Change-Number: 17803 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200411/0d3a1a4c/attachment.htm>