Change in osmo-bts[master]: vty: add "logging filter l1-sapi"

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

laforge gerrit-no-reply at lists.osmocom.org
Thu Oct 17 08:04:27 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/15550 )

Change subject: vty: add "logging filter l1-sapi"
......................................................................

vty: add "logging filter l1-sapi"

Add VTY commands to filter by L1 SAPI. Allow to filter by multiple SAPIs
by running the filter command multiple times:

OsmoBTS> logging filter l1-sapi agch
OsmoBTS> logging filter l1-sapi pch

Related: OS#2356
Change-Id: I32d86d3d34757135b4cce59919c2fc2b67f0a889
---
M src/common/logging.c
M src/common/vty.c
2 files changed, 70 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/logging.c b/src/common/logging.c
index 3315a01..8340736 100644
--- a/src/common/logging.c
+++ b/src/common/logging.c
@@ -144,7 +144,21 @@
 	},
 };
 
+static int osmo_bts_filter_fn(const struct log_context *ctx, struct log_target *tgt)
+{
+	uint8_t *sapi = ctx->ctx[LOG_CTX_L1_SAPI];
+	uint16_t *sapi_mask = tgt->filter_data[LOG_FLT_L1_SAPI];
+
+	if ((tgt->filter_map & (1 << LOG_FLT_L1_SAPI)) != 0
+	    && sapi_mask && sapi
+	    && (*sapi_mask & (1 << *sapi)) != 0)
+		return 1;
+
+	return 0;
+}
+
 const struct log_info bts_log_info = {
+	.filter_fn = osmo_bts_filter_fn,
 	.cat = bts_log_info_cat,
 	.num_cat = ARRAY_SIZE(bts_log_info_cat),
 };
diff --git a/src/common/vty.c b/src/common/vty.c
index 801f34c..865c236 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -26,6 +26,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <ctype.h>
+#include <errno.h>
 
 #include <osmocom/core/talloc.h>
 #include <osmocom/gsm/abis_nm.h>
@@ -1600,6 +1601,45 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(logging_fltr_l1_sapi, logging_fltr_l1_sapi_cmd, "HIDDEN", "HIDDEN")
+{
+	uint8_t sapi = get_string_value(l1sap_common_sapi_names, argv[0]);
+	struct log_target *tgt = osmo_log_vty2tgt(vty);
+	uint16_t **sapi_mask;
+
+	OSMO_ASSERT(sapi != -EINVAL);
+	if (!tgt)
+		return CMD_WARNING;
+
+	sapi_mask = (uint16_t **)&tgt->filter_data[LOG_FLT_L1_SAPI];
+
+	if (!*sapi_mask)
+		*sapi_mask = talloc(tgt, uint16_t);
+
+	**sapi_mask |= (1 << sapi);
+	tgt->filter_map |= (1 << LOG_FLT_L1_SAPI);
+
+	return CMD_SUCCESS;
+}
+
+DEFUN(no_logging_fltr_l1_sapi, no_logging_fltr_l1_sapi_cmd, "HIDDEN", "HIDDEN")
+{
+	uint8_t sapi = get_string_value(l1sap_common_sapi_names, argv[0]);
+	struct log_target *tgt = osmo_log_vty2tgt(vty);
+	uint16_t *sapi_mask;
+
+	OSMO_ASSERT(sapi != -EINVAL);
+	if (!tgt)
+		return CMD_WARNING;
+	if (!tgt->filter_data[LOG_FLT_L1_SAPI])
+		return CMD_SUCCESS;
+
+	sapi_mask = (uint16_t *)tgt->filter_data[LOG_FLT_L1_SAPI];
+	*sapi_mask &= ~(1 << sapi);
+
+	return CMD_SUCCESS;
+}
+
 int bts_vty_init(struct gsm_bts *bts)
 {
 	cfg_trx_gsmtap_sapi_cmd.string = vty_cmd_string_from_valstr(bts, gsmtap_sapi_names,
@@ -1616,11 +1656,27 @@
 						NO_STR "GSMTAP SAPI\n",
 						"\n", "", 0);
 
+	logging_fltr_l1_sapi_cmd.string = vty_cmd_string_from_valstr(bts, l1sap_common_sapi_names,
+						"logging filter l1-sapi (",
+						"|", ")", VTY_DO_LOWER);
+	logging_fltr_l1_sapi_cmd.doc = vty_cmd_string_from_valstr(bts, l1sap_common_sapi_names,
+						LOGGING_STR FILTER_STR "L1 SAPI\n",
+						"\n", "", 0);
+
+	no_logging_fltr_l1_sapi_cmd.string = vty_cmd_string_from_valstr(bts, l1sap_common_sapi_names,
+						"no logging filter l1-sapi (",
+						"|", ")", VTY_DO_LOWER);
+	no_logging_fltr_l1_sapi_cmd.doc = vty_cmd_string_from_valstr(bts, l1sap_common_sapi_names,
+						NO_STR LOGGING_STR FILTER_STR "L1 SAPI\n",
+						"\n", "", 0);
+
 	install_element_ve(&show_bts_cmd);
 	install_element_ve(&show_trx_cmd);
 	install_element_ve(&show_ts_cmd);
 	install_element_ve(&show_lchan_cmd);
 	install_element_ve(&show_lchan_summary_cmd);
+	install_element_ve(&logging_fltr_l1_sapi_cmd);
+	install_element_ve(&no_logging_fltr_l1_sapi_cmd);
 
 	logging_vty_add_cmds();
 	osmo_talloc_vty_add_cmds();

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I32d86d3d34757135b4cce59919c2fc2b67f0a889
Gerrit-Change-Number: 15550
Gerrit-PatchSet: 8
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191017/4375e452/attachment.htm>


More information about the gerrit-log mailing list