Attention is currently required from: pespin.
Timur Davydov has posted comments on this change by Timur Davydov. ( https://gerrit.osmocom.org/c/libosmocore/+/41922?usp=email )
Change subject: core: guard TCP stats on availability of linux/tcp.h
......................................................................
Patch Set 2:
(2 comments)
File src/core/stats_tcp.c:
https://gerrit.osmocom.org/c/libosmocore/+/41922/comment/81aa7d6b_bed2da43?… :
PS2, Line 25: #if !defined(EMBEDDED)
> You can probably remove this defined(EMBEDDED) block now, since it will be covered by the ifdef HAVE […]
I see the point, but I'm a bit hesitant to drop the EMBEDDED guard purely
because of HAVE_LINUX_TCP_H.
With --enable-embedded this code path used to be disabled regardless of what
headers are present. If we remove the EMBEDDED guard now, an embedded build
could end up compiling it just because linux/tcp.h happens to be available in
the toolchain sysroot, which would be a behaviour change compared to before.
I'd prefer to keep the embedded decision explicit (either keep the EMBEDDED
guard or force HAVE_LINUX_TCP_H / the corresponding feature off when
--enable-embedded is used in configure.ac), and only use HAVE_LINUX_TCP_H to
guard the Linux-specific implementation details. This way embedded builds stay
consistent, and CI should remain happy.
https://gerrit.osmocom.org/c/libosmocore/+/41922/comment/cca1e99a_29dc69e8?… :
PS2, Line 52: static struct osmo_tcp_stats_config s_tcp_stats_config = {
> This should also be inside the HAVE_LIJNUX_TCP_H block below.
I don't think this can be moved entirely under HAVE_LINUX_TCP_H.
The data structure is accessed unconditionally from other code paths:
- stats.c calls osmo_stats_tcp_set_interval(osmo_tcp_stats_config->interval)
- stats_vty.c reads/writes osmo_tcp_stats_config->{interval,batch_size} and
prints them in the VTY config output
If the definition/allocation is moved under HAVE_LINUX_TCP_H, those callers
will end up dereferencing a NULL pointer at runtime, leading to a segfault.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41922?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ibcd00f15131b0291f0b10eca51401c518b77cc39
Gerrit-Change-Number: 41922
Gerrit-PatchSet: 2
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 25 Jan 2026 22:38:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Attention is currently required from: Timur Davydov.
pespin has posted comments on this change by Timur Davydov. ( https://gerrit.osmocom.org/c/libosmocore/+/41922?usp=email )
Change subject: core: guard TCP stats on availability of linux/tcp.h
......................................................................
Patch Set 2:
(3 comments)
File src/core/stats_tcp.c:
https://gerrit.osmocom.org/c/libosmocore/+/41922/comment/6bb76a84_51130b80?… :
PS2, Line 25: #if !defined(EMBEDDED)
You can probably remove this defined(EMBEDDED) block now, since it will be covered by the ifdef HAVE_LINUX_TCP_H. You can verify it by submitting to gerrit and it should pass the CI, which also builds for EMBEDDED target.
https://gerrit.osmocom.org/c/libosmocore/+/41922/comment/427b01fd_2df34eee?… :
PS2, Line 47: #include <errno.h>
Please move this up before the ifdef HAVE_LINUX_TCP_H.
https://gerrit.osmocom.org/c/libosmocore/+/41922/comment/9ff4d921_52130771?… :
PS2, Line 52: static struct osmo_tcp_stats_config s_tcp_stats_config = {
This should also be inside the HAVE_LIJNUX_TCP_H block below.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41922?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ibcd00f15131b0291f0b10eca51401c518b77cc39
Gerrit-Change-Number: 41922
Gerrit-PatchSet: 2
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Sun, 25 Jan 2026 22:09:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/41878?usp=email )
Change subject: build: keep netns API public and gate features with HAVE_*
......................................................................
build: keep netns API public and gate features with HAVE_*
The netns API was previously guarded by platform-specific preprocessor
conditions (e.g. !EMBEDDED and defined(__linux__)), which caused the
netns headers and implementation to be entirely excluded from non-Linux
builds such as Emscripten. This in turn led to build failures in code
depending on the netns API, as the symbols and declarations were not
available at all.
Always build netns.c and keep the public declarations available
for non-embedded builds. Move platform/feature conditionals into the
implementation: guard the netns code paths with HAVE_SETNS/HAVE_UNSHARE/
HAVE_MOUNT and HAVE_CLONE_NEWNET, and return -ENOTSUP when the required
functionality is not available.
Add configure-time checks for the required headers/functions and for the
CLONE_NEWNET declaration, defining the
corresponding HAVE_* macros.
No functional changes intended for platforms where netns is available.
Change-Id: I2322eb2936bea35596f1fd6b6a713ea5f997b1ea
---
M configure.ac
M include/osmocom/core/netns.h
M src/core/netns.c
3 files changed, 35 insertions(+), 11 deletions(-)
Approvals:
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/configure.ac b/configure.ac
index 4a6a474..5d1bdec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,18 @@
AC_CHECK_FUNCS(localtime_r)
+# Check for network namespace related functions and macros
+AC_CHECK_HEADERS([sched.h sys/mount.h sys/param.h])
+AC_CHECK_FUNCS([setns unshare mount])
+
+dnl Check whether CLONE_NEWNET is available
+AC_CHECK_DECL([CLONE_NEWNET],
+ [AC_DEFINE([HAVE_CLONE_NEWNET], [1],
+ [Define if CLONE_NEWNET is available])],
+ [],
+ [[#define _GNU_SOURCE
+ #include <sched.h>]])
+
AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
AC_CACHE_CHECK(
[whether struct tm has tm_gmtoff member],
diff --git a/include/osmocom/core/netns.h b/include/osmocom/core/netns.h
index 5bbf224..5f1b17e 100644
--- a/include/osmocom/core/netns.h
+++ b/include/osmocom/core/netns.h
@@ -2,9 +2,6 @@
* Network namespace convenience functions. */
#pragma once
-#if (!EMBEDDED)
-
-#if defined(__linux__)
#include <signal.h>
@@ -17,8 +14,4 @@
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) */
/*! @} */
diff --git a/src/core/netns.c b/src/core/netns.c
index c1d75b1..1177030 100644
--- a/src/core/netns.c
+++ b/src/core/netns.c
@@ -26,8 +26,6 @@
*
* \file netns.c */
-#if defined(__linux__)
-
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
@@ -36,13 +34,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#ifdef HAVE_SCHED_H
#include <sched.h>
+#endif
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
#include <fcntl.h>
#include <errno.h>
@@ -52,6 +58,8 @@
#define NETNS_PREFIX_PATH "/var/run/netns"
#define NETNS_CURRENT_PATH "/proc/self/ns/net"
+// To prevent unused function errors when neither setns nor CLONE_NEWNET are available
+#if (HAVE_SETNS && HAVE_CLONE_NEWNET)
/*! Open a file descriptor for the current network namespace.
* \returns fd of the current network namespace on success; negative in case of error
*/
@@ -63,6 +71,7 @@
return -errno;
return fd;
}
+#endif /* HAVE_SETNS && HAVE_CLONE_NEWNET */
/*! switch to a (non-default) namespace, store existing signal mask in oldmask.
* \param[in] nsfd file descriptor representing the namespace to which we shall switch
@@ -70,6 +79,7 @@
* \returns 0 on success; negative on error */
int osmo_netns_switch_enter(int nsfd, struct osmo_netns_switch_state *state)
{
+#if (HAVE_SETNS && HAVE_CLONE_NEWNET)
sigset_t intmask;
int rc;
@@ -89,6 +99,9 @@
return -errno;
}
return 0;
+#else
+ return -ENOTSUP;
+#endif /* HAVE_SETNS && HAVE_CLONE_NEWNET */
}
/*! switch back to the previous namespace, restoring signal mask.
@@ -96,6 +109,7 @@
* \returns 0 on successs; negative on error */
int osmo_netns_switch_exit(struct osmo_netns_switch_state *state)
{
+#if (HAVE_SETNS && HAVE_CLONE_NEWNET)
if (state->prev_nsfd < 0)
return -EINVAL;
@@ -109,10 +123,14 @@
if ((rc = sigprocmask(SIG_SETMASK, &state->prev_sigmask, NULL)) != 0)
return -rc;
return 0;
+#else
+ return -ENOTSUP;
+#endif /* HAVE_SETNS && HAVE_CLONE_NEWNET */
}
static int create_netns(const char *name)
{
+#if (HAVE_UNSHARE && HAVE_MOUNT && HAVE_SETNS && HAVE_CLONE_NEWNET)
char path[MAXPATHLEN];
sigset_t intmask, oldmask;
int fd, prev_nsfd;
@@ -175,6 +193,9 @@
return -errno;
return fd;
+#else
+ return -ENOTSUP;
+#endif /* HAVE_UNSHARE && HAVE_MOUNT && HAVE_SETNS && HAVE_CLONE_NEWNET */
}
/*! Open a file descriptor for the network namespace with provided name.
@@ -203,6 +224,4 @@
return fd;
}
-#endif /* defined(__linux__) */
-
/*! @} */
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41878?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2322eb2936bea35596f1fd6b6a713ea5f997b1ea
Gerrit-Change-Number: 41878
Gerrit-PatchSet: 10
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Attention is currently required from: Timur Davydov, laforge.
pespin has posted comments on this change by Timur Davydov. ( https://gerrit.osmocom.org/c/libosmocore/+/41921?usp=email )
Change subject: core: remove SCTP include from osmo_io_internal.h
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
File src/core/osmo_io_internal.h:
https://gerrit.osmocom.org/c/libosmocore/+/41921/comment/2ac6578b_6d75a01e?… :
PS1, Line 10: #include <netinet/sctp.h>
> You're right, the header itself does not use it directly. […]
Done
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41921?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Icd626d908192a954d55d76a46d7cc863ed332631
Gerrit-Change-Number: 41921
Gerrit-PatchSet: 2
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Sun, 25 Jan 2026 22:05:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: Timur Davydov <dtv.comp(a)gmail.com>
Attention is currently required from: Timur Davydov, fixeria, laforge.
pespin has posted comments on this change by Timur Davydov. ( https://gerrit.osmocom.org/c/libosmocore/+/41878?usp=email )
Change subject: build: keep netns API public and gate features with HAVE_*
......................................................................
Patch Set 10: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41878?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2322eb2936bea35596f1fd6b6a713ea5f997b1ea
Gerrit-Change-Number: 41878
Gerrit-PatchSet: 10
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Sun, 25 Jan 2026 22:04:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/41924?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: vty: guard definition of _XOPEN_SOURCE
......................................................................
vty: guard definition of _XOPEN_SOURCE
Define _XOPEN_SOURCE only if it is not already provided by the build
environment.
This avoids redefinition warnings/errors while ensuring required POSIX
interfaces are available.
Change-Id: I4f53aff1afef02abce7cb70d1b29080ba900ff41
---
M src/vty/command.c
1 file changed, 2 insertions(+), 0 deletions(-)
Approvals:
fixeria: Looks good to me, approved
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
diff --git a/src/vty/command.c b/src/vty/command.c
index c1bda8a..38c6648 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -33,7 +33,9 @@
#include <stdbool.h>
#include <syslog.h>
#include <errno.h>
+#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
+#endif
#include <unistd.h>
#include <ctype.h>
#include <time.h>
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41924?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4f53aff1afef02abce7cb70d1b29080ba900ff41
Gerrit-Change-Number: 41924
Gerrit-PatchSet: 2
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>