Change in ...osmo-pcu[master]: VTY: fix command 'show tbf all': properly filter TBFs

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
Wed Oct 9 15:02:10 UTC 2019


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/15727


Change subject: VTY: fix command 'show tbf all': properly filter TBFs
......................................................................

VTY: fix command 'show tbf all': properly filter TBFs

For a long time the VTY command to show all active TBFs was broken.
The TBF filtering (by allocation origin) logic allows one to show
TBFs allocated on CCCH, PACCH, or on both of them. In the latter
case we have been checking whether a TBF was allocated on both
logical channels at the same time.

Let's fix this by passing a flag-mask instead of boolean arguments.
To be able to use GPRS_RLCMAC_FLAG_* definitions from "tbf.h", let's
exclude them from "#ifdef __cplusplus ... #endif" block.

Change-Id: I1c9f401368af880a97d32905c4cce0da481ffc21
---
M src/pcu_vty.c
M src/pcu_vty_functions.cpp
M src/pcu_vty_functions.h
M src/tbf.h
4 files changed, 22 insertions(+), 19 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/27/15727/1

diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 23a42e7..996ce61 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -1165,13 +1165,14 @@
       "TBFs allocated via PACCH\n")
 {
 	struct gprs_rlcmac_bts *bts = bts_main_data();
-	if (!strcmp(argv[0], "all"))
-		return pcu_vty_show_tbf_all(vty, bts, true, true);
+	uint32_t flags = UINT32_MAX;
 
-	if (!strcmp(argv[0], "ccch"))
-		return pcu_vty_show_tbf_all(vty, bts_main_data(), true, false);
+	if (argv[0][0] == 'c')
+		flags = (1 << GPRS_RLCMAC_FLAG_CCCH);
+	else if (argv[0][0] == 'p')
+		flags = (1 << GPRS_RLCMAC_FLAG_PACCH);
 
-	return pcu_vty_show_tbf_all(vty, bts_main_data(), false, true);
+	return pcu_vty_show_tbf_all(vty, bts, flags);
 }
 
 DEFUN(show_ms_all,
diff --git a/src/pcu_vty_functions.cpp b/src/pcu_vty_functions.cpp
index fd8474b..7b6c84f 100644
--- a/src/pcu_vty_functions.cpp
+++ b/src/pcu_vty_functions.cpp
@@ -45,17 +45,11 @@
 	#include "coding_scheme.h"
 }
 
-static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf, bool show_ccch, bool show_pacch)
+static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf)
 {
 	gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf);
 	gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf);
 
-	if (show_ccch && !(tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)))
-		return;
-
-	if (show_pacch && !(tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH)))
-		return;
-
 	vty_out(vty, "TBF: TFI=%d TLLI=0x%08x (%s) TA=%u DIR=%s IMSI=%s%s", tbf->tfi(),
 			tbf->tlli(), tbf->is_tlli_valid() ? "valid" : "invalid",
 			tbf->ta(),
@@ -108,18 +102,22 @@
 	vty_out(vty, "%s%s", VTY_NEWLINE, VTY_NEWLINE);
 }
 
-int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data, bool show_ccch, bool show_pacch)
+int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data, uint32_t flags)
 {
 	BTS *bts = bts_data->bts;
-	LListHead<gprs_rlcmac_tbf> *ms_iter;
+	LListHead<gprs_rlcmac_tbf> *iter;
 
 	vty_out(vty, "UL TBFs%s", VTY_NEWLINE);
-	llist_for_each(ms_iter, &bts->ul_tbfs())
-		tbf_print_vty_info(vty, ms_iter->entry(), show_ccch, show_pacch);
+	llist_for_each(iter, &bts->ul_tbfs()) {
+		if (iter->entry()->state_flags & flags)
+			tbf_print_vty_info(vty, iter->entry());
+	}
 
 	vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE);
-	llist_for_each(ms_iter, &bts->dl_tbfs())
-		tbf_print_vty_info(vty, ms_iter->entry(), show_ccch, show_pacch);
+	llist_for_each(iter, &bts->dl_tbfs()) {
+		if (iter->entry()->state_flags & flags)
+			tbf_print_vty_info(vty, iter->entry());
+	}
 
 	return CMD_SUCCESS;
 }
diff --git a/src/pcu_vty_functions.h b/src/pcu_vty_functions.h
index 3fef208..6fbc366 100644
--- a/src/pcu_vty_functions.h
+++ b/src/pcu_vty_functions.h
@@ -27,7 +27,7 @@
 struct vty;
 struct gprs_rlcmac_bts;
 
-int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data, bool show_ccch, bool show_pacch);
+int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data, uint32_t flags);
 int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data);
 int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
 	uint32_t tlli);
diff --git a/src/tbf.h b/src/tbf.h
index fd65b20..9545385 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -38,6 +38,8 @@
 class GprsMs;
 struct gprs_rlcmac_bts;
 
+#endif
+
 /*
  * TBF instance
  */
@@ -171,6 +173,8 @@
 #define TBF_ASS_TYPE_SET(t, kind) do { t->ass_type_mod(kind, false, __FILE__, __LINE__); } while(0)
 #define TBF_ASS_TYPE_UNSET(t, kind) do { t->ass_type_mod(kind, true, __FILE__, __LINE__); } while(0)
 
+#ifdef __cplusplus
+
 struct gprs_rlcmac_tbf {
 	gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir);
 

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I1c9f401368af880a97d32905c4cce0da481ffc21
Gerrit-Change-Number: 15727
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191009/cd27e464/attachment.htm>


More information about the gerrit-log mailing list