pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/41879?usp=email )
Change subject: logging: Add APIs to set/get log_{target,context} fields
......................................................................
logging: Add APIs to set/get log_{target,context} fields
Change-Id: Ie48e7e635feb91509b9c034394df4fb16cb931a3
---
M TODO-RELEASE
M include/osmocom/core/logging.h
M src/core/libosmocore.map
M src/core/logging.c
4 files changed, 115 insertions(+), 5 deletions(-)
Approvals:
fixeria: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
pespin: Verified
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 3c98f06..b7d1585 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -10,3 +10,4 @@
core added osmo_sock_set_nonblock(), osmo_sock_get_nonblock()
core added gsmtap_source_set_nonblock(), gsmtap_source_using_wq()
core added osmo_iofd_set_name_f()
+core added log_{get,set}_filter(_data)(), log_get_context()
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 44263fb..286f646 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -225,7 +225,7 @@
/*! Log context information, passed to filter */
struct log_context {
- void *ctx[LOG_MAX_CTX+1];
+ void *ctx[LOG_MAX_CTX+1] OSMO_DEPRECATED_OUTSIDE("Accessing struct log_context members directly is deprecated");
};
/*! Compatibility with older libosmocore versions */
@@ -298,13 +298,15 @@
};
/*! structure representing a logging target */
+#define OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET \
+ OSMO_DEPRECATED_OUTSIDE("Accessing struct log_target members directly is deprecated")
struct log_target {
struct llist_head entry; /*!< linked list */
/*! Internal data for filtering */
- int filter_map;
+ int filter_map OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET;
/*! Internal data for filtering */
- void *filter_data[LOG_MAX_FILTERS+1];
+ void *filter_data[LOG_MAX_FILTERS+1] OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET;
/*! logging categories */
struct log_category *categories;
@@ -406,10 +408,16 @@
/* context management */
void log_reset_context(void);
-int log_set_context(uint8_t ctx, void *value);
+int log_set_context(uint8_t ctx_nr, void *value);
+void *log_get_context(const struct log_context *ctx, uint8_t ctx_nr);
/* filter on the targets */
void log_set_all_filter(struct log_target *target, int);
+bool log_get_filter(const struct log_target *target, int log_filter_index);
+int log_set_filter(struct log_target *target, int log_filter_index, bool enable);
+void *log_get_filter_data(const struct log_target *target, int log_filter_index);
+int log_set_filter_data(struct log_target *target, int log_filter_index, void *data);
+
int log_cache_enable(void);
void log_cache_update(int mapped_subsys, uint8_t enabled, uint8_t level);
void log_set_use_color(struct log_target *target, int);
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map
index 2818f8a..3ec322c 100644
--- a/src/core/libosmocore.map
+++ b/src/core/libosmocore.map
@@ -75,8 +75,13 @@
log_parse_level;
logp_stub;
log_reset_context;
+log_get_context;
+log_get_filter;
+log_get_filter_data;
log_set_all_filter;
log_set_category_filter;
+log_set_filter;
+log_set_filter_data;
log_set_context;
log_set_log_level;
log_set_print_category;
diff --git a/src/core/logging.c b/src/core/logging.c
index 9e5ae9f..ac10d00 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -886,7 +886,42 @@
return 0;
}
-/*! Enable the \ref LOG_FLT_ALL log filter
+/*! Get the logging context
+ * \param[in] ctx logging context
+ * \param[in] ctx_nr logging context number
+ * \returns value set for the context
+ *
+ * A logging context is something like the subscriber identity to which
+ * the currently processed message relates, or the BTS through which it
+ * was received. The main use of this API is during
+ * (struct log_info)->filter_fn(ctx, log_tgt).
+ */
+void *log_get_context(const struct log_context *ctx, uint8_t ctx_nr)
+{
+ if (ctx_nr > LOG_MAX_CTX)
+ return NULL;
+ return ctx->ctx[ctx_nr];
+}
+
+/*! Query whether a log filter is enabled or disabled
+ * \param[in] target Log target to be queried
+ * \param[in] log_filter_index the index of the log filter to query
+ * \returns whether the filtering is enabled (true) or disabled (false)
+ */
+bool log_get_filter(const struct log_target *target, int log_filter_index)
+{
+ /* TODO: in the future we can support app-specified log filters here,
+ * similar to how we do dynamic cateogries defined by apps. */
+ if (log_filter_index < 0)
+ return false;
+
+ if (log_filter_index >= LOG_MAX_FILTERS)
+ return false;
+
+ return target->filter_map & (1 << log_filter_index);
+}
+
+/*! Enable/disable the \ref LOG_FLT_ALL log filter
* \param[in] target Log target to be affected
* \param[in] all enable (1) or disable (0) the ALL filter
*
@@ -902,6 +937,67 @@
target->filter_map &= ~(1 << LOG_FLT_ALL);
}
+/*! Enable/disable a log filter
+ * \param[in] target Log target to be affected
+ * \param[in] log_filter_index the index of the log filter to set
+ * \param[in] enable enable (true) or disable (false) the ALL filter
+ * \returns 0 on success, negative on error.
+ */
+int log_set_filter(struct log_target *target, int log_filter_index, bool enable)
+{
+ /* TODO: in the future we can support app-specified log filters here,
+ * similar to how we do dynamic cateogries defined by apps. */
+ if (log_filter_index < 0)
+ return -EINVAL;
+
+ if (log_filter_index >= LOG_MAX_FILTERS)
+ return -EINVAL;
+
+ if (enable)
+ target->filter_map |= (1 << log_filter_index);
+ else
+ target->filter_map &= ~(1 << log_filter_index);
+ return 0;
+}
+
+/*! Obtain data associated to a log filter
+ * \param[in] target Log target to be queried
+ * \param[in] log_filter_index the index of the log filter to query
+ * \returns data associated to the log filter
+ */
+void *log_get_filter_data(const struct log_target *target, int log_filter_index)
+{
+ /* TODO: in the future we can support app-specified log filters here,
+ * similar to how we do dynamic cateogries defined by apps. */
+ if (log_filter_index < 0)
+ return NULL;
+
+ if (log_filter_index >= LOG_MAX_FILTERS)
+ return NULL;
+
+ return target->filter_data[log_filter_index];
+}
+
+/*! Set data associated to a log filter
+ * \param[in] target Log target to be affected
+ * \param[in] log_filter_index the index of the log filter to set associate data for
+ * \param[in] data The user provided data pointer to associate to the log filter
+ * \returns 0 on success, negative on error.
+ */
+int log_set_filter_data(struct log_target *target, int log_filter_index, void *data)
+{
+ /* TODO: in the future we can support app-specified log filters here,
+ * similar to how we do dynamic cateogries defined by apps. */
+ if (log_filter_index < 0)
+ return -EINVAL;
+
+ if (log_filter_index >= LOG_MAX_FILTERS)
+ return -EINVAL;
+
+ target->filter_data[log_filter_index] = data;
+ return 0;
+}
+
/*! Enable or disable the use of colored output
* \param[in] target Log target to be affected
* \param[in] use_color Use color (1) or don't use color (0)
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41879?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: Ie48e7e635feb91509b9c034394df4fb16cb931a3
Gerrit-Change-Number: 41879
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
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>
Attention is currently required from: daniel, fixeria, laforge.
Hello Jenkins Builder, daniel, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/41911?usp=email
to look at the new patch set (#6).
The following approvals got outdated and were removed:
Code-Review+1 by laforge, Verified+1 by Jenkins Builder
Change subject: osmo_io: Support rx of segments up to ~UINT16_MAX
......................................................................
osmo_io: Support rx of segments up to ~UINT16_MAX
Previously if we recevied a big chunk (near UINT16_MAX), we would hit
the following assert in iofd_msgb_alloc2(), because our msgb
implementation can only handle sizes up to 16 bit length, counting
headroom + data length:
"OSMO_ASSERT(size + headroom <= 0xffff);".
This new improved logic allows handling segments of up to ~UINT16_MAX
which may come in in multiple read calls. It also adds logic to catch
received segments greater than UINT16_MAX (or buggy segment_cb or buggy
peer transmitting to us) and notifies the user of a broken stream
through read_cb() in that case.
test_segmentation_uint16_max() is added to osmo_io_test, which would
abort without this patch applied.
Related: SYS#7842
Change-Id: I8c11a7edbed2335ada40a1f93d081041974c3586
---
M src/core/osmo_io.c
M tests/osmo_io/osmo_io_test.c
M tests/osmo_io/osmo_io_test.err
M tests/osmo_io/osmo_io_test.ok
4 files changed, 602 insertions(+), 34 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/11/41911/6
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41911?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8c11a7edbed2335ada40a1f93d081041974c3586
Gerrit-Change-Number: 41911
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Attention is currently required from: Timur Davydov, laforge.
fixeria 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 9: Code-Review+1
--
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: 9
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: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Fri, 23 Jan 2026 09:24:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: Timur Davydov, laforge, osmith.
fixeria has posted comments on this change by Timur Davydov. ( https://gerrit.osmocom.org/c/libosmocore/+/41923?usp=email )
Change subject: core: fix printf format casts for struct timeval fields
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41923?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: Icac9e392c728948a7976970658e37f5e0da41709
Gerrit-Change-Number: 41923
Gerrit-PatchSet: 1
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>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Fri, 23 Jan 2026 09:20:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/41895?usp=email )
Change subject: core: always build osmo_sock_multiaddr_* helpers
......................................................................
core: always build osmo_sock_multiaddr_* helpers
Always build the public osmo_sock_multiaddr_* helper functions,
independent of HAVE_LIBSCTP.
Move the HAVE_LIBSCTP checks inside the functions and limit them
to the SCTP-specific code paths: when IPPROTO_SCTP is requested
without libsctp support, return -ENOTSUP, while non-SCTP protocols
continue to work as before.
This fixes link failures in libosmo-netif when building with
--disable-libsctp.
Change-Id: I3e70b7cd6cb4d022252e6ddc70a42ca5eea72bb1
---
M src/core/socket.c
1 file changed, 6 insertions(+), 4 deletions(-)
Approvals:
laforge: Looks good to me, approved
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/core/socket.c b/src/core/socket.c
index 2de4bb3..6cd82f0 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1895,7 +1895,6 @@
return 0;
}
-#ifdef HAVE_LIBSCTP
/*! Get multiple IP addresses and/or port number on socket in separate string buffers
* \param[in] fd file descriptor of socket.
* \param[out] ip_proto IPPROTO of the socket, eg: IPPROTO_SCTP.
@@ -1926,10 +1925,12 @@
int osmo_sock_multiaddr_get_ip_and_port(int fd, int ip_proto, char *ip, size_t *ip_cnt, size_t ip_len,
char *port, size_t port_len, bool local)
{
+#ifdef HAVE_LIBSCTP
struct sockaddr *addrs = NULL;
unsigned int n_addrs, i;
void *addr_buf;
int rc;
+#endif /* HAVE_LIBSCTP */
switch (ip_proto) {
case IPPROTO_SCTP:
@@ -1943,6 +1944,7 @@
return osmo_sock_get_ip_and_port(fd, ip, ip_len, port, port_len, local);
}
+#ifdef HAVE_LIBSCTP
rc = local ? sctp_getladdrs(fd, 0, &addrs) : sctp_getpaddrs(fd, 0, &addrs);
if (rc < 0)
return rc;
@@ -1983,8 +1985,10 @@
free_addrs_ret:
local ? sctp_freeladdrs(addrs) : sctp_freepaddrs(addrs);
return rc;
+#else
+ return -ENOTSUP;
+#endif /* HAVE_LIBSCTP */
}
-#endif
/*! Get local IP address on socket
* \param[in] fd file descriptor of socket
@@ -2047,7 +2051,6 @@
return talloc_asprintf(ctx, "(%s)", str);
}
-#ifdef HAVE_LIBSCTP
/*! Format multiple IP addresses and/or port number into a combined string buffer
* \param[out] str Destination string buffer.
* \param[in] str_len sizeof(str), usually OSMO_SOCK_MULTIADDR_PEER_STR_MAXLEN.
@@ -2153,7 +2156,6 @@
return sb.chars_needed;
}
-#endif
/*! Get address/port information on socket in provided string buffer, like "r=1.2.3.4:5<->l=6.7.8.9:10".
* This does not include braces like osmo_sock_get_name().
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41895?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: I3e70b7cd6cb4d022252e6ddc70a42ca5eea72bb1
Gerrit-Change-Number: 41895
Gerrit-PatchSet: 5
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>
Attention is currently required from: Timur Davydov, 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 9: Code-Review+1
(1 comment)
Commit Message:
https://gerrit.osmocom.org/c/libosmocore/+/41878/comment/172bc91a_59f9fd2e?… :
PS9, Line 19: HAVE_MOUNT and HAVE_CLONE_NEWNET, and return -ENOSYS when the required
return -ENOTSUP
--
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: 9
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Fri, 23 Jan 2026 09:18:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: Timur Davydov, laforge, neels.
pespin has posted comments on this change by Timur Davydov. ( https://gerrit.osmocom.org/c/libosmocore/+/41813?usp=email )
Change subject: Add Emscripten build support and JS callback logging backend
......................................................................
Patch Set 20:
(1 comment)
File configure.ac:
https://gerrit.osmocom.org/c/libosmocore/+/41813/comment/2402e477_c5717334?… :
PS16, Line 259: AM_CONDITIONAL(ENABLE_TUN, test "x$embedded" != "xyes" && test "x$emscripten" != "xyes")
> Agreed, this likely needs an additional fix. This should follow the same […]
Waiting for this to be addressed in a separate patch before this patch.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41813?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: Ia8d5f4bb6570b5e055826f3a051e5e5896866e31
Gerrit-Change-Number: 41813
Gerrit-PatchSet: 20
Gerrit-Owner: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Timur Davydov <dtv.comp(a)gmail.com>
Gerrit-Comment-Date: Fri, 23 Jan 2026 09:15:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: Timur Davydov <dtv.comp(a)gmail.com>