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

laforge gerrit-no-reply at lists.osmocom.org
Fri Dec 4 18:30:59 UTC 2020


laforge has submitted this change. ( 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 include/osmocom/sgsn/gb_proxy.h
M src/gbproxy/gb_proxy.c
M src/gbproxy/gb_proxy_peer.c
M src/gbproxy/gb_proxy_vty.c
4 files changed, 46 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index fae95c1..b3a9a6c 100644
--- a/include/osmocom/sgsn/gb_proxy.h
+++ b/include/osmocom/sgsn/gb_proxy.h
@@ -15,6 +15,9 @@
 
 #define GBPROXY_INIT_VU_GEN_TX 256
 
+/* BVCI uses 16 bits */
+#define BVC_LOG_CTX_FLAG (1<<17)
+
 struct rate_ctr_group;
 struct gprs_gb_parse_context;
 struct tlv_parsed;
diff --git a/src/gbproxy/gb_proxy.c b/src/gbproxy/gb_proxy.c
index d8b828c..329c1d1 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>
@@ -1568,12 +1569,12 @@
 	}
 }
 
-
 /* called by the ns layer */
 int gprs_ns2_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
 {
 	struct osmo_gprs_ns2_prim *nsp;
 	struct gbproxy_config *cfg = (struct gbproxy_config *) ctx;
+	uintptr_t bvci;
 	int rc = 0;
 
 	if (oph->sap != SAP_NS)
@@ -1589,11 +1590,14 @@
 
 	switch (oph->primitive) {
 	case PRIM_NS_UNIT_DATA:
+
 		/* hand the message into the BSSGP implementation */
 		msgb_bssgph(oph->msg) = oph->msg->l3h;
 		msgb_bvci(oph->msg) = nsp->bvci;
 		msgb_nsei(oph->msg) = nsp->nsei;
+		bvci = nsp->bvci | BVC_LOG_CTX_FLAG;
 
+		log_set_context(LOG_CTX_GB_BVC, (void *)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..2b28dd5 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>
diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c
index caad52e..379b8c2 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,41 @@
 	return CMD_SUCCESS;
 }
 
+static void log_set_bvc_filter(struct log_target *target,
+				const uint16_t *bvci)
+{
+	if (bvci) {
+		uintptr_t bvci_filter = *bvci | BVC_LOG_CTX_FLAG;
+		target->filter_map |= (1 << LOG_FLT_GB_BVC);
+		target->filter_data[LOG_FLT_GB_BVC] = (void *)bvci_filter;
+	} 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 <0-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[0]);
+
+	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 +917,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: 3
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201204/9597c2f7/attachment.htm>


More information about the gerrit-log mailing list