Change in osmo-sgsn[master]: gbproxy: Add BVC log filters

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

daniel gerrit-no-reply at lists.osmocom.org
Thu Dec 3 17:22:31 UTC 2020


daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/21495 )


Change subject: gbproxy: Add BVC log filters
......................................................................

gbproxy: Add BVC log filters

Since gbproxy doesn't use bssgp_rcvmsg from libosmocore we need to
implement our own filtering.

Change-Id: I4d1b57b89990945d307f27a58a7f630be0253d5b
Related: SYS#5232
---
M src/gbproxy/gb_proxy.c
M src/gbproxy/gb_proxy_peer.c
M src/gbproxy/gb_proxy_vty.c
3 files changed, 41 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/95/21495/1

diff --git a/src/gbproxy/gb_proxy.c b/src/gbproxy/gb_proxy.c
index d8b828c..9090d19 100644
--- a/src/gbproxy/gb_proxy.c
+++ b/src/gbproxy/gb_proxy.c
@@ -31,6 +31,7 @@
 #include <arpa/inet.h>
 #include <time.h>
 
+#include <osmocom/core/logging.h>
 #include <osmocom/core/talloc.h>
 #include <osmocom/core/select.h>
 #include <osmocom/core/rate_ctr.h>
@@ -1594,6 +1595,7 @@
 		msgb_bvci(oph->msg) = nsp->bvci;
 		msgb_nsei(oph->msg) = nsp->nsei;
 
+		log_set_context(LOG_CTX_GB_BVC, (void *)(uintptr_t)nsp->bvci);
 		rc = gbprox_rcvmsg(cfg, oph->msg);
 		msgb_free(oph->msg);
 		break;
diff --git a/src/gbproxy/gb_proxy_peer.c b/src/gbproxy/gb_proxy_peer.c
index 62c4d94..1c3acd9 100644
--- a/src/gbproxy/gb_proxy_peer.c
+++ b/src/gbproxy/gb_proxy_peer.c
@@ -25,6 +25,7 @@
 #include <osmocom/sgsn/debug.h>
 
 #include <osmocom/gprs/protocol/gsm_08_18.h>
+#include <osmocom/core/logging.h>
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/stats.h>
 #include <osmocom/core/talloc.h>
@@ -89,8 +90,9 @@
 	llist_for_each_entry(nse, &cfg->nse_peers, list) {
 		struct gbproxy_peer *peer;
 		llist_for_each_entry(peer, &nse->bts_peers, list) {
-			if (peer->bvci == bvci)
+			if (peer->bvci == bvci) {
 				return peer;
+			}
 		}
 	}
 	return NULL;
diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c
index caad52e..35f2276 100644
--- a/src/gbproxy/gb_proxy_vty.c
+++ b/src/gbproxy/gb_proxy_vty.c
@@ -39,6 +39,7 @@
 #include <osmocom/sgsn/vty.h>
 
 #include <osmocom/vty/command.h>
+#include <osmocom/vty/logging.h>
 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/misc.h>
 
@@ -538,6 +539,40 @@
 	return CMD_SUCCESS;
 }
 
+static void log_set_bvc_filter(struct log_target *target,
+				uintptr_t bvci)
+{
+	if (bvci) {
+		target->filter_map |= (1 << LOG_FLT_GB_BVC);
+		target->filter_data[LOG_FLT_GB_BVC] = (void *)bvci;
+	} else if (target->filter_data[LOG_FLT_GB_BVC]) {
+		target->filter_map = ~(1 << LOG_FLT_GB_BVC);
+		target->filter_data[LOG_FLT_GB_BVC] = NULL;
+	}
+}
+
+DEFUN(logging_fltr_bvc,
+      logging_fltr_bvc_cmd,
+      "logging filter bvc bvci <2-65535>",
+	LOGGING_STR FILTER_STR
+	"Filter based on BSSGP VC\n"
+	"Identify BVC by BVCI\n"
+	"Numeric identifier\n")
+{
+	struct log_target *tgt;
+	uint16_t id = atoi(argv[1]);
+
+	log_tgt_mutex_lock();
+	tgt = osmo_log_vty2tgt(vty);
+	if (!tgt) {
+		log_tgt_mutex_unlock();
+		return CMD_WARNING;
+	}
+
+	log_set_bvc_filter(tgt, id);
+	log_tgt_mutex_unlock();
+	return CMD_SUCCESS;
+}
 
 DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]",
        SHOW_STR "Display information about the Gb proxy\n" "Show statistics\n")
@@ -881,6 +916,7 @@
 {
 	install_element_ve(&show_gbproxy_cmd);
 	install_element_ve(&show_gbproxy_links_cmd);
+	install_element_ve(&logging_fltr_bvc_cmd);
 
 	install_element(ENABLE_NODE, &delete_gb_bvci_cmd);
 	install_element(ENABLE_NODE, &delete_gb_nsei_cmd);

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I4d1b57b89990945d307f27a58a7f630be0253d5b
Gerrit-Change-Number: 21495
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201203/68a35679/attachment.htm>


More information about the gerrit-log mailing list