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.orgdaniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/21465 )
Change subject: ns2: Add filtering by NSE/NSEI
......................................................................
ns2: Add filtering by NSE/NSEI
Change-Id: I63c0e85f82f5d08c5a6f535da94b8648498439d2
Related: SYS#5232
---
M include/osmocom/core/logging.h
M src/gb/common_vty.c
M src/gb/gprs_ns2_message.c
M src/gb/gprs_ns2_vty.c
4 files changed, 69 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/21465/1
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 38b465c..418a42e 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -165,6 +165,7 @@
LOG_CTX_BSC_SUBSCR,
LOG_CTX_VLR_SUBSCR,
LOG_CTX_L1_SAPI,
+ LOG_CTX_GB_NSE,
_LOG_CTX_COUNT
};
@@ -178,6 +179,7 @@
LOG_FLT_BSC_SUBSCR,
LOG_FLT_VLR_SUBSCR,
LOG_FLT_L1_SAPI,
+ LOG_FLT_GB_NSE,
_LOG_FLT_COUNT
};
diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c
index eb665d5..42f3404 100644
--- a/src/gb/common_vty.c
+++ b/src/gb/common_vty.c
@@ -40,15 +40,21 @@
int gprs_log_filter_fn(const struct log_context *ctx,
struct log_target *tar)
{
+ const void *nse = ctx->ctx[LOG_CTX_GB_NSE];
const void *nsvc = ctx->ctx[LOG_CTX_GB_NSVC];
const void *bvc = ctx->ctx[LOG_CTX_GB_BVC];
+ /* Filter on the NS Entity */
+ if ((tar->filter_map & (1 << LOG_FLT_GB_NSE)) != 0
+ && nse && (nse == tar->filter_data[LOG_FLT_GB_NSE]))
+ return 1;
+
/* Filter on the NS Virtual Connection */
if ((tar->filter_map & (1 << LOG_FLT_GB_NSVC)) != 0
&& nsvc && (nsvc == tar->filter_data[LOG_FLT_GB_NSVC]))
return 1;
- /* Filter on the NS Virtual Connection */
+ /* Filter on the BSSGP Virtual Connection */
if ((tar->filter_map & (1 << LOG_FLT_GB_BVC)) != 0
&& bvc && (bvc == tar->filter_data[LOG_FLT_GB_BVC]))
return 1;
diff --git a/src/gb/gprs_ns2_message.c b/src/gb/gprs_ns2_message.c
index fac6108..69c833e 100644
--- a/src/gb/gprs_ns2_message.c
+++ b/src/gb/gprs_ns2_message.c
@@ -189,6 +189,7 @@
struct msgb *msg = gprs_ns2_msgb_alloc();
struct gprs_ns_hdr *nsh;
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
if (!msg)
@@ -212,6 +213,7 @@
struct gprs_ns_hdr *nsh;
uint16_t nsvci = osmo_htons(nsvc->nsvci);
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
ERR_IF_NSVC_USES_SNS(nsvc, "transmit NS BLOCK");
@@ -244,6 +246,7 @@
struct gprs_ns_hdr *nsh;
uint16_t nsvci = osmo_htons(nsvc->nsvci);
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
ERR_IF_NSVC_USES_SNS(nsvc, "transmit NS BLOCK ACK");
@@ -275,6 +278,7 @@
uint16_t nsvci = osmo_htons(nsvc->nsvci);
uint16_t nsei = osmo_htons(nsvc->nse->nsei);
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
ERR_IF_NSVC_USES_SNS(nsvc, "transmit NS RESET");
@@ -307,6 +311,7 @@
uint16_t nsvci, nsei;
/* Section 9.2.6 */
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
ERR_IF_NSVC_USES_SNS(nsvc, "transmit NS RESET ACK");
@@ -337,6 +342,7 @@
* \returns 0 in case of success */
int ns2_tx_unblock(struct gprs_ns2_vc *nsvc)
{
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
ERR_IF_NSVC_USES_SNS(nsvc, "transmit NS UNBLOCK");
@@ -353,6 +359,7 @@
* \returns 0 in case of success */
int ns2_tx_unblock_ack(struct gprs_ns2_vc *nsvc)
{
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
ERR_IF_NSVC_USES_SNS(nsvc, "transmit NS UNBLOCK ACK");
@@ -368,6 +375,7 @@
* \returns 0 in case of success */
int ns2_tx_alive(struct gprs_ns2_vc *nsvc)
{
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
LOGP(DLNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE (NSVCI=%u)\n",
nsvc->nse->nsei, nsvc->nsvci);
@@ -380,6 +388,7 @@
* \returns 0 in case of success */
int ns2_tx_alive_ack(struct gprs_ns2_vc *nsvc)
{
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
LOGP(DLNS, LOGL_DEBUG, "NSEI=%u Tx NS ALIVE_ACK (NSVCI=%u)\n",
nsvc->nse->nsei, nsvc->nsvci);
@@ -399,6 +408,7 @@
{
struct gprs_ns_hdr *nsh;
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
msg->l2h = msgb_push(msg, sizeof(*nsh) + 3);
@@ -430,6 +440,7 @@
struct gprs_ns_hdr *nsh;
uint16_t nsvci = osmo_htons(nsvc->nsvci);
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
bvci = osmo_htons(bvci);
@@ -495,6 +506,7 @@
msg = gprs_ns2_msgb_alloc();
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
if (!msg)
return -ENOMEM;
@@ -553,6 +565,7 @@
msg = gprs_ns2_msgb_alloc();
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
if (!msg)
return -ENOMEM;
@@ -601,6 +614,7 @@
return -1;
msg = gprs_ns2_msgb_alloc();
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
if (!msg)
return -ENOMEM;
@@ -646,6 +660,7 @@
msg = gprs_ns2_msgb_alloc();
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
if (!msg)
return -ENOMEM;
@@ -685,6 +700,7 @@
struct gprs_ns_hdr *nsh;
uint16_t nsei;
+ log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
log_set_context(LOG_CTX_GB_NSVC, nsvc);
if (!msg)
return -ENOMEM;
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 97becf6..f41620f 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -110,6 +110,18 @@
{ 0, NULL }
};
+static void log_set_nse_filter(struct log_target *target,
+ struct gprs_ns2_nse *nse)
+{
+ if (nse) {
+ target->filter_map |= (1 << LOG_FLT_GB_NSE);
+ target->filter_data[LOG_FLT_GB_NSE] = nse;
+ } else if (target->filter_data[LOG_FLT_GB_NSE]) {
+ target->filter_map = ~(1 << LOG_FLT_GB_NSE);
+ target->filter_data[LOG_FLT_GB_NSE] = NULL;
+ }
+}
+
static void log_set_nsvc_filter(struct log_target *target,
struct gprs_ns2_vc *nsvc)
{
@@ -745,7 +757,37 @@
/* TODO: allow vty to reset/block/unblock nsvc/nsei */
-/* TODO: add filter for NSEI as ns1 code does */
+DEFUN(logging_fltr_nse,
+ logging_fltr_nse_cmd,
+ "logging filter nse nsei <0-65535>",
+ LOGGING_STR FILTER_STR
+ "Filter based on NS Entity\n"
+ "Identify NSE by NSEI\n"
+ "Numeric identifier\n")
+{
+ struct log_target *tgt;
+ struct gprs_ns2_nse *nse;
+ uint16_t id = atoi(argv[1]);
+
+ log_tgt_mutex_lock();
+ tgt = osmo_log_vty2tgt(vty);
+ if (!tgt) {
+ log_tgt_mutex_unlock();
+ return CMD_WARNING;
+ }
+
+ nse = gprs_ns2_nse_by_nsei(vty_nsi, id);
+ if (!nse) {
+ vty_out(vty, "No NSE by that identifier%s", VTY_NEWLINE);
+ log_tgt_mutex_unlock();
+ return CMD_WARNING;
+ }
+
+ log_set_nse_filter(tgt, nse);
+ log_tgt_mutex_unlock();
+ return CMD_SUCCESS;
+}
+
/* TODO: add filter for single connection by description */
DEFUN(logging_fltr_nsvc,
logging_fltr_nsvc_cmd,
@@ -806,6 +848,7 @@
install_lib_element_ve(&show_ns_entities_cmd);
install_lib_element_ve(&show_ns_pers_cmd);
install_lib_element_ve(&show_nse_cmd);
+ install_lib_element_ve(&logging_fltr_nse_cmd);
install_lib_element_ve(&logging_fltr_nsvc_cmd);
install_lib_element(ENABLE_NODE, &nsvc_force_unconf_cmd);
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/21465
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I63c0e85f82f5d08c5a6f535da94b8648498439d2
Gerrit-Change-Number: 21465
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/20201202/804ffa38/attachment.htm>