aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2024-03-19 20:01:42 +0100
committerHarald Welte <laforge@osmocom.org>2024-03-19 20:40:51 +0100
commit6d641a15b269ffbb643d34af3e48b80958b3f7f2 (patch)
tree51780bda4c0b1c5098f640f1ddc61adcf7def7d4
parentbd71e8eb1545ee4966d013f73344acde5b5f6640 (diff)
WIP: migrate gsmtap logging over to osmo_iolaforge/log_io_gsmtap
This is working in principle; The problem is just that osmo_io itself contains LOGP calls from within osmo_iofd_write_msgb() and downstream code, so we might easily get up in an infinite recursion bug. This needs further study; possibly we need a "safe" logging function which will never use osmo_io. Or something like a per-thread global boolean variable which the code can check to know if it's re-entering? Change-Id: I69d7eca7d50666b4fcfe73a1dc03f8e8491b32fc
-rw-r--r--include/osmocom/core/gsmtap_util.h3
-rw-r--r--src/core/gsmtap_util.c7
-rw-r--r--src/core/libosmocore.map1
-rw-r--r--src/vty/logging_vty.c18
4 files changed, 24 insertions, 5 deletions
diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h
index d24ee95f..e7559311 100644
--- a/include/osmocom/core/gsmtap_util.h
+++ b/include/osmocom/core/gsmtap_util.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdbool.h>
#include <stdint.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/select.h>
@@ -31,6 +32,8 @@ int gsmtap_inst_fd(struct gsmtap_inst *gti)
int gsmtap_inst_fd2(const struct gsmtap_inst *gti);
+bool gsmtap_inst_get_osmo_io_mode(const struct gsmtap_inst *gti);
+
int gsmtap_source_init_fd(const char *host, uint16_t port);
int gsmtap_source_init_fd2(const char *local_host, uint16_t local_port, const char *rem_host, uint16_t rem_port);
diff --git a/src/core/gsmtap_util.c b/src/core/gsmtap_util.c
index b64c7b05..6c36b28f 100644
--- a/src/core/gsmtap_util.c
+++ b/src/core/gsmtap_util.c
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
+#include <stdbool.h>
#include <string.h>
#include <errno.h>
@@ -85,6 +86,12 @@ int gsmtap_inst_fd2(const struct gsmtap_inst *gti)
return gti->wq.bfd.fd;
}
+/*! determine whether the gsmtap_inst is in osmo_io mode or not. */
+bool gsmtap_inst_get_osmo_io_mode(const struct gsmtap_inst *gti)
+{
+ return gti->osmo_io_mode;
+}
+
/*! convert RSL channel number to GSMTAP channel type
* \param[in] rsl_chantype RSL channel type
* \param[in] link_id RSL link identifier
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map
index 072efee3..bdbfe075 100644
--- a/src/core/libosmocore.map
+++ b/src/core/libosmocore.map
@@ -41,6 +41,7 @@ get_value_string_or_null;
gsmtap_gsm_channel_names;
gsmtap_inst_fd;
gsmtap_inst_fd2;
+gsmtap_inst_get_osmo_io_mode;
gsmtap_makemsg;
gsmtap_makemsg_ex;
gsmtap_send;
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 2a074222..bfe73bb1 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -29,6 +29,7 @@
#include <osmocom/core/strrb.h>
#include <osmocom/core/loggingrb.h>
#include <osmocom/core/gsmtap.h>
+#include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/application.h>
#include <osmocom/vty/command.h>
@@ -803,18 +804,24 @@ DEFUN(cfg_no_log_systemd_journal, cfg_no_log_systemd_journal_cmd,
}
DEFUN(cfg_log_gsmtap, cfg_log_gsmtap_cmd,
- "log gsmtap [HOSTNAME]",
+ "log gsmtap [HOSTNAME] [sync-io]",
LOG_STR "Logging via GSMTAP\n"
"Host name to send the GSMTAP logging to (UDP port 4729)\n")
{
- const char *hostname = argc ? argv[0] : "127.0.0.1";
+ const char *hostname = "127.0.0.1";
+ bool async_io = true;
struct log_target *tgt;
+ if (argc >= 1)
+ hostname = argv[0];
+ if (argc >= 2 && !strcmp(argv[1], "sync-io"))
+ async_io = false;
+
log_tgt_mutex_lock();
tgt = log_target_find(LOG_TGT_TYPE_GSMTAP, hostname);
if (!tgt) {
tgt = log_target_create_gsmtap(hostname, GSMTAP_UDP_PORT,
- host.app_info->name, false,
+ host.app_info->name, async_io,
true);
if (!tgt) {
vty_out(vty, "%% Unable to create GSMTAP log for %s%s",
@@ -1032,8 +1039,9 @@ static int config_write_log_single(struct vty *vty, struct log_target *tgt)
log_target_rb_avail_size(tgt), VTY_NEWLINE);
break;
case LOG_TGT_TYPE_GSMTAP:
- vty_out(vty, "log gsmtap %s%s",
- tgt->tgt_gsmtap.hostname, VTY_NEWLINE);
+ vty_out(vty, "log gsmtap %s%s%s", tgt->tgt_gsmtap.hostname,
+ gsmtap_inst_get_osmo_io_mode(tgt->tgt_gsmtap.gsmtap_inst) ? "" : " sync-io",
+ VTY_NEWLINE);
break;
case LOG_TGT_TYPE_SYSTEMD:
vty_out(vty, "log systemd-journal%s%s",