Change in libosmocore[master]: VTY: implement 'no log gsmtap [HOSTNAME]' command

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/.

fixeria gerrit-no-reply at lists.osmocom.org
Sat Jan 1 15:29:19 UTC 2022


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/26708 )


Change subject: VTY: implement 'no log gsmtap [HOSTNAME]' command
......................................................................

VTY: implement 'no log gsmtap [HOSTNAME]' command

Change-Id: I9a4efa1e35cbc22cea06a64a15a369522c32d3c4
---
M include/osmocom/core/gsmtap_util.h
M src/gsmtap_util.c
M src/logging.c
M src/vty/logging_vty.c
4 files changed, 43 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/08/26708/1

diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h
index 1cc8d75..33ade95 100644
--- a/include/osmocom/core/gsmtap_util.h
+++ b/include/osmocom/core/gsmtap_util.h
@@ -44,6 +44,7 @@
 
 struct gsmtap_inst *gsmtap_source_init(const char *host, uint16_t port,
 					int ofd_wq_mode);
+void gsmtap_source_free(struct gsmtap_inst *gti);
 
 int gsmtap_source_add_sink(struct gsmtap_inst *gti);
 
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 671a6c3..2571b85 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -486,6 +486,22 @@
 	return gti;
 }
 
+void gsmtap_source_free(struct gsmtap_inst *gti)
+{
+	if (gti->ofd_wq_mode) {
+		osmo_fd_unregister(&gti->wq.bfd);
+		osmo_wqueue_clear(&gti->wq);
+
+		if (gti->sink_ofd.fd != -1) {
+			osmo_fd_unregister(&gti->sink_ofd);
+			close(gti->sink_ofd.fd);
+		}
+	}
+
+	close(gti->wq.bfd.fd);
+	talloc_free(gti);
+}
+
 #endif /* HAVE_SYS_SOCKET_H */
 
 const struct value_string gsmtap_gsm_channel_names[] = {
diff --git a/src/logging.c b/src/logging.c
index e5c66f2..e05091b 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -67,6 +67,7 @@
 #include <osmocom/core/thread.h>
 #include <osmocom/core/select.h>
 #include <osmocom/core/write_queue.h>
+#include <osmocom/core/gsmtap_util.h>
 
 #include <osmocom/vty/logging.h>	/* for LOGGING_STR. */
 
@@ -1312,6 +1313,9 @@
 		talloc_free((void *)target->tgt_file.fname);
 		target->tgt_file.fname = NULL;
 		break;
+	case LOG_TGT_TYPE_GSMTAP:
+		gsmtap_source_free(target->tgt_gsmtap.gsmtap_inst);
+		break;
 #ifdef HAVE_SYSLOG_H
 	case LOG_TGT_TYPE_SYSLOG:
 		closelog();
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 4e5725b..c83dafd 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -830,6 +830,27 @@
 	RET_WITH_UNLOCK(CMD_SUCCESS);
 }
 
+DEFUN(cfg_no_log_gsmtap, cfg_no_log_gsmtap_cmd,
+	"no log gsmtap [HOSTNAME]",
+	NO_STR 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";
+	struct log_target *tgt;
+
+	log_tgt_mutex_lock();
+	tgt = log_target_find(LOG_TGT_TYPE_GSMTAP, hostname);
+	if (tgt == NULL) {
+		vty_out(vty, "%% Unable to find GSMTAP log target for %s%s",
+			hostname, VTY_NEWLINE);
+		RET_WITH_UNLOCK(CMD_WARNING);
+	}
+
+	log_target_destroy(tgt);
+
+	RET_WITH_UNLOCK(CMD_SUCCESS);
+}
+
 DEFUN(cfg_log_stderr, cfg_log_stderr_cmd,
 	"log stderr [blocking-io]",
 	LOG_STR "Logging via STDERR of the process\n"
@@ -1245,4 +1266,5 @@
 	install_lib_element(CONFIG_NODE, &cfg_log_systemd_journal_cmd);
 	install_lib_element(CONFIG_NODE, &cfg_no_log_systemd_journal_cmd);
 	install_lib_element(CONFIG_NODE, &cfg_log_gsmtap_cmd);
+	install_lib_element(CONFIG_NODE, &cfg_no_log_gsmtap_cmd);
 }

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/26708
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I9a4efa1e35cbc22cea06a64a15a369522c32d3c4
Gerrit-Change-Number: 26708
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20220101/71b7fdac/attachment.htm>


More information about the gerrit-log mailing list