Projects
osmocom:master
libosmocore
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 50
View file
libosmocore.spec
Changed
@@ -14,13 +14,13 @@ Name: libosmocore Requires: osmocom-master -Version: 1.7.0.104.4ce8 +Version: 1.7.0.105.8a50 Release: 0 Summary: The Open Source Mobile Communications Core Library License: GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later AND AGPL-3.0-or-later Group: Productivity/Telephony/Utilities Url: https://osmocom.org/projects/libosmocore/wiki/Libosmocore -Source: libosmocore_1.7.0.104.4ce8.tar.xz +Source: libosmocore_1.7.0.105.8a50.tar.xz Source1: rpmlintrc BuildRequires: automake >= 1.6 BuildRequires: libtool >= 2
View file
commit_4ce820ab8d0820c664afb07e9ea62fdc41eb00ad.txt
Deleted
View file
commit_8a5014be084249be515d0b3d088e9cb21d7552bc.txt
Added
View file
libosmocore_1.7.0.104.4ce8.dsc
Deleted
@@ -1,40 +0,0 @@ -Format: 3.0 (native) -Source: libosmocore -Binary: libosmocore, libosmocodec0, libosmocodec-doc, libosmocoding0, libosmocoding-doc, libosmocore19, libosmocore-doc, libosmogb14, libosmogb-doc, libosmogsm18, libosmogsm-doc, libosmoisdn0, libosmoisdn-doc, libosmovty9, libosmovty-doc, libosmoctrl0, libosmoctrl-doc, libosmosim2, libosmousb0, libosmocore-dev, libosmocore-utils, libosmocore-dbg -Architecture: any all -Version: 1.7.0.104.4ce8 -Maintainer: Osmocom team <openbsc@lists.osmocom.org> -Homepage: https://projects.osmocom.org/projects/libosmocore -Standards-Version: 3.9.8 -Vcs-Browser: https://gitea.osmocom.org/osmocom/libosmocore -Vcs-Git: https://gitea.osmocom.org/osmocom/libosmocore -Build-Depends: debhelper (>= 9), autotools-dev, autoconf, automake, libtool, dh-autoreconf, libdpkg-perl, git, libgnutls28-dev, doxygen, libpcsclite-dev, pkg-config, libtalloc-dev (>= 2.1.0), libsctp-dev, libusb-1.0-0-dev, libmnl-dev, libsystemd-dev, python3:native -Package-List: - libosmocodec-doc deb doc optional arch=all - libosmocodec0 deb libs optional arch=any - libosmocoding-doc deb doc optional arch=all - libosmocoding0 deb libs optional arch=any - libosmocore deb libs optional arch=any - libosmocore-dbg deb debug extra arch=any - libosmocore-dev deb libdevel optional arch=any - libosmocore-doc deb doc optional arch=all - libosmocore-utils deb utils optional arch=any - libosmocore19 deb libs optional arch=any - libosmoctrl-doc deb doc optional arch=all - libosmoctrl0 deb libs optional arch=any - libosmogb-doc deb doc optional arch=all - libosmogb14 deb libs optional arch=any - libosmogsm-doc deb doc optional arch=all - libosmogsm18 deb libs optional arch=any - libosmoisdn-doc deb doc optional arch=all - libosmoisdn0 deb libs optional arch=any - libosmosim2 deb libs optional arch=any - libosmousb0 deb libs optional arch=any - libosmovty-doc deb doc optional arch=all - libosmovty9 deb libs optional arch=any -Checksums-Sha1: - cda7f54ea54ff3e57eb9988ad5baa81105930df3 1007272 libosmocore_1.7.0.104.4ce8.tar.xz -Checksums-Sha256: - 3178210b0d7ab420fdaf59a428779f943e98cdc9bcfa4464ad30b80386433440 1007272 libosmocore_1.7.0.104.4ce8.tar.xz -Files: - ef3589628bf8db8793892d26d3473e8b 1007272 libosmocore_1.7.0.104.4ce8.tar.xz
View file
libosmocore_1.7.0.105.8a50.dsc
Added
@@ -0,0 +1,40 @@ +Format: 3.0 (native) +Source: libosmocore +Binary: libosmocore, libosmocodec0, libosmocodec-doc, libosmocoding0, libosmocoding-doc, libosmocore19, libosmocore-doc, libosmogb14, libosmogb-doc, libosmogsm18, libosmogsm-doc, libosmoisdn0, libosmoisdn-doc, libosmovty9, libosmovty-doc, libosmoctrl0, libosmoctrl-doc, libosmosim2, libosmousb0, libosmocore-dev, libosmocore-utils, libosmocore-dbg +Architecture: any all +Version: 1.7.0.105.8a50 +Maintainer: Osmocom team <openbsc@lists.osmocom.org> +Homepage: https://projects.osmocom.org/projects/libosmocore +Standards-Version: 3.9.8 +Vcs-Browser: https://gitea.osmocom.org/osmocom/libosmocore +Vcs-Git: https://gitea.osmocom.org/osmocom/libosmocore +Build-Depends: debhelper (>= 9), autotools-dev, autoconf, automake, libtool, dh-autoreconf, libdpkg-perl, git, libgnutls28-dev, doxygen, libpcsclite-dev, pkg-config, libtalloc-dev (>= 2.1.0), libsctp-dev, libusb-1.0-0-dev, libmnl-dev, libsystemd-dev, python3:native +Package-List: + libosmocodec-doc deb doc optional arch=all + libosmocodec0 deb libs optional arch=any + libosmocoding-doc deb doc optional arch=all + libosmocoding0 deb libs optional arch=any + libosmocore deb libs optional arch=any + libosmocore-dbg deb debug extra arch=any + libosmocore-dev deb libdevel optional arch=any + libosmocore-doc deb doc optional arch=all + libosmocore-utils deb utils optional arch=any + libosmocore19 deb libs optional arch=any + libosmoctrl-doc deb doc optional arch=all + libosmoctrl0 deb libs optional arch=any + libosmogb-doc deb doc optional arch=all + libosmogb14 deb libs optional arch=any + libosmogsm-doc deb doc optional arch=all + libosmogsm18 deb libs optional arch=any + libosmoisdn-doc deb doc optional arch=all + libosmoisdn0 deb libs optional arch=any + libosmosim2 deb libs optional arch=any + libosmousb0 deb libs optional arch=any + libosmovty-doc deb doc optional arch=all + libosmovty9 deb libs optional arch=any +Checksums-Sha1: + 3151f8000466ccf4f8b3a53456f62c1d875818c4 1007908 libosmocore_1.7.0.105.8a50.tar.xz +Checksums-Sha256: + f5b65e4492fa04d0a0d34fc2a62e3514a18a916b67a3f3a669b6d6fc95a29b7e 1007908 libosmocore_1.7.0.105.8a50.tar.xz +Files: + faf22de779f448f5f2b17335a915878b 1007908 libosmocore_1.7.0.105.8a50.tar.xz
View file
libosmocore_1.7.0.104.4ce8.tar.xz/.tarball-version -> libosmocore_1.7.0.105.8a50.tar.xz/.tarball-version
Changed
@@ -1 +1 @@ -1.7.0.104-4ce8 +1.7.0.105-8a50
View file
libosmocore_1.7.0.104.4ce8.tar.xz/TODO-RELEASE -> libosmocore_1.7.0.105.8a50.tar.xz/TODO-RELEASE
Changed
@@ -9,3 +9,4 @@ #library what description / commit summary line libosmocore new API osmo_sockaddr_is_any(), osmo_sockaddr_netmask_to_prefixlen() libosmocore ABI breakage OSMO_NUM_DLIB change affecting internal_cat +libosmocore new API osmo_netns_*()
View file
libosmocore_1.7.0.104.4ce8.tar.xz/debian/changelog -> libosmocore_1.7.0.105.8a50.tar.xz/debian/changelog
Changed
@@ -1,8 +1,8 @@ -libosmocore (1.7.0.104.4ce8) unstable; urgency=medium +libosmocore (1.7.0.105.8a50) unstable; urgency=medium * Automatically generated changelog entry for building the Osmocom master feed - -- Osmocom OBS scripts <info@osmocom.org> Sat, 21 Jan 2023 21:57:41 +0000 + -- Osmocom OBS scripts <info@osmocom.org> Tue, 24 Jan 2023 18:02:36 +0000 libosmocore (1.7.0) unstable; urgency=medium
View file
libosmocore_1.7.0.104.4ce8.tar.xz/include/osmocom/core/Makefile.am -> libosmocore_1.7.0.105.8a50.tar.xz/include/osmocom/core/Makefile.am
Changed
@@ -35,6 +35,7 @@ stats.h \ macaddr.h \ msgb.h \ + netns.h \ panic.h \ prbs.h \ prim.h \
View file
libosmocore_1.7.0.105.8a50.tar.xz/include/osmocom/core/netns.h
Added
@@ -0,0 +1,24 @@ +/*! \file netns.h + * Network namespace convenience functions. */ + +#pragma once +#if (!EMBEDDED) + +#if defined(__linux__) + +#include <signal.h> + +struct osmo_netns_switch_state { + sigset_t prev_sigmask; + int prev_nsfd; +}; + +int osmo_netns_open_fd(const char *name); +int osmo_netns_switch_enter(int nsfd, struct osmo_netns_switch_state *state); +int osmo_netns_switch_exit(struct osmo_netns_switch_state *state); + + +#endif /* defined(__linux__) */ + +#endif /* (!EMBEDDED) */ +/*! @} */
View file
libosmocore_1.7.0.104.4ce8.tar.xz/src/core/Makefile.am -> libosmocore_1.7.0.105.8a50.tar.xz/src/core/Makefile.am
Changed
@@ -48,6 +48,7 @@ loggingrb.c \ macaddr.c \ msgb.c \ + netns.c \ panic.c \ prbs.c \ prim.c \
View file
libosmocore_1.7.0.105.8a50.tar.xz/src/core/netns.c
Added
@@ -0,0 +1,208 @@ + +/* Network namespace convenience functions + * (C) 2023 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de> + * + * All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "config.h" + +/*! \addtogroup netns + * @{ + * Network namespace convenience functions + * + * \file netns.c */ + +#if defined(__linux__) + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sched.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/socket.h> +#include <sys/mount.h> +#include <sys/param.h> +#include <fcntl.h> +#include <errno.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/netns.h> + +#define NETNS_PREFIX_PATH "/var/run/netns" +#define NETNS_CURRENT_PATH "/proc/self/ns/net" + +/*! Open a file descriptor for the current network namespace. + * \returns fd of the current network namespace on success; negative in case of error + */ +static int netns_open_current_fd(void) +{ + int fd; + /* store the default namespace for later reference */ + if ((fd = open(NETNS_CURRENT_PATH, O_RDONLY)) < 0) + return -errno; + return fd; +} + +/*! switch to a (non-default) namespace, store existing signal mask in oldmask. + * \paramin nsfd file descriptor representing the namespace to which we shall switch + * \paramout state caller-provided memory location to which state of previous netns is stored + * \returns 0 on success; negative on error */ +int osmo_netns_switch_enter(int nsfd, struct osmo_netns_switch_state *state) +{ + sigset_t intmask; + int rc; + + state->prev_nsfd = -1; + + if (sigfillset(&intmask) < 0) + return -errno; + if ((rc = sigprocmask(SIG_BLOCK, &intmask, &state->prev_sigmask)) != 0) + return -rc; + state->prev_nsfd = netns_open_current_fd(); + + if (setns(nsfd, CLONE_NEWNET) < 0) { + /* restore old mask if we couldn't switch the netns */ + sigprocmask(SIG_SETMASK, &state->prev_sigmask, NULL); + close(state->prev_nsfd); + state->prev_nsfd = -1; + return -errno; + } + return 0; +} + +/*! switch back to the previous namespace, restoring signal mask. + * \paramin state information about previous netns, filled by osmo_netns_switch_enter() + * \returns 0 on successs; negative on error */ +int osmo_netns_switch_exit(struct osmo_netns_switch_state *state) +{ + if (state->prev_nsfd < 0) + return -EINVAL; + + int rc; + if (setns(state->prev_nsfd, CLONE_NEWNET) < 0) + return -errno; + + close(state->prev_nsfd); + state->prev_nsfd = -1; + + if ((rc = sigprocmask(SIG_SETMASK, &state->prev_sigmask, NULL)) != 0) + return -rc; + return 0; +} + +static int create_netns(const char *name) +{ + char pathMAXPATHLEN; + sigset_t intmask, oldmask; + int fd, prev_nsfd; + int rc, rc2; + + /* create /var/run/netns, if it doesn't exist already */ + rc = mkdir(NETNS_PREFIX_PATH, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); + if (rc < 0 && errno != EEXIST) + return rc; + + /* create /var/run/netns/name, if it doesn't exist already */ + rc = snprintf(path, sizeof(path), "%s/%s", NETNS_PREFIX_PATH, name); + if (rc >= sizeof(path)) + return -ENAMETOOLONG; + fd = open(path, O_RDONLY|O_CREAT|O_EXCL, 0); + if (fd < 0) + return -errno; + if (close(fd) < 0) + return -errno; + + /* mask off all signals, store old signal mask */ + if (sigfillset(&intmask) < 0) + return -errno; + if ((rc = sigprocmask(SIG_BLOCK, &intmask, &oldmask)) != 0) + return -rc; + + prev_nsfd = netns_open_current_fd(); + if (prev_nsfd < 0) + return prev_nsfd; + + /* create a new network namespace */ + if (unshare(CLONE_NEWNET) < 0) { + rc = -errno; + goto restore_sigmask; + } + if (mount(NETNS_CURRENT_PATH, path, "none", MS_BIND, NULL) < 0) { + rc = -errno; + goto restore_sigmask; + } + + /* switch back to previous namespace */ + if (setns(prev_nsfd, CLONE_NEWNET) < 0) { + rc = -errno; + goto restore_sigmask; + } + +restore_sigmask: + close(prev_nsfd); + + /* restore process mask */ + if ((rc2 = sigprocmask(SIG_SETMASK, &oldmask, NULL)) != 0) + return -rc2; + + /* might have been set above in case mount fails */ + if (rc < 0) + return rc; + + /* finally, open the created namespace file descriptor from previous ns */ + if ((fd = open(path, O_RDONLY)) < 0) + return -errno; + + return fd; +} + +/*! Open a file descriptor for the network namespace with provided name. + * Creates /var/run/netns/ directory if it doesn't exist already. + * \paramin name Name of the network namespace (in /var/run/netns/) + * \returns File descriptor of network namespace; negative in case of error + */ +int osmo_netns_open_fd(const char *name) +{ + int rc; + int fd; + char pathMAXPATHLEN; + + /* path = /var/run/netns/name */ + rc = snprintf(path, sizeof(path), "%s/%s", NETNS_PREFIX_PATH, name); + if (rc >= sizeof(path)) + return -ENAMETOOLONG; + + /* If netns already exists, simply open it: */ + fd = open(path, O_RDONLY); + if (fd >= 0) + return fd; + + /* The netns doesn't exist yet, let's create it: */ + fd = create_netns(name); + return fd; +} + +#endif /* defined(__linux__) */ + +/*! @} */
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.