Change in osmo-sgsn[master]: gbproxy: Improve VTY state introspection

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
Sat Dec 12 18:21:22 UTC 2020


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

Change subject: gbproxy: Improve VTY state introspection
......................................................................

gbproxy: Improve VTY state introspection

* allow to print not only BSS-side BVCs, but also SGSN-side
* differentiate between SIG and PTP BVC
* print the actual BVC FSM state name instead of just UNBLOCKED/nothing

Change-Id: I8e09a9dc296b15094d191b0451d04457c815d116
---
M src/gbproxy/gb_proxy_vty.c
M tests/vty_test_runner.py
2 files changed, 35 insertions(+), 20 deletions(-)

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



diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c
index 49ec91c..976ac12 100644
--- a/src/gbproxy/gb_proxy_vty.c
+++ b/src/gbproxy/gb_proxy_vty.c
@@ -58,15 +58,29 @@
 
 static void gbprox_vty_print_bvc(struct vty *vty, struct gbproxy_bvc *bvc)
 {
-	struct gprs_ra_id raid;
-	gsm48_parse_ra(&raid, bvc->ra);
 
-	vty_out(vty, "NSEI %5u, PTP-BVCI %5u, "
-		"RAI %s", bvc->nse->nsei, bvc->bvci, osmo_rai_name(&raid));
-	if (bssgp_bvc_fsm_is_unblocked(bvc->fi))
-		vty_out(vty, " [BVC-BLOCKED]");
+	if (bvc->bvci == 0) {
+		vty_out(vty, "NSEI %5u, SIG-BVCI %5u [%s]%s", bvc->nse->nsei, bvc->bvci,
+			osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE);
+	} else {
+		struct gprs_ra_id raid;
+		gsm48_parse_ra(&raid, bvc->ra);
+		vty_out(vty, "NSEI %5u, PTP-BVCI %5u, RAI %s [%s]%s", bvc->nse->nsei, bvc->bvci,
+			osmo_rai_name(&raid), osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE);
+	}
+}
 
-	vty_out(vty, "%s", VTY_NEWLINE);
+static void gbproxy_vty_print_nse(struct vty *vty, struct gbproxy_nse *nse, bool show_stats)
+{
+	struct gbproxy_bvc *bvc;
+	int j;
+
+	hash_for_each(nse->bvcs, j, bvc, list) {
+		gbprox_vty_print_bvc(vty, bvc);
+
+		if (show_stats)
+			vty_out_rate_ctr_group(vty, "  ", bvc->ctrg);
+	}
 }
 
 static int config_write_gbproxy(struct vty *vty)
@@ -184,24 +198,25 @@
 	return CMD_SUCCESS;
 }
 
-DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]",
-       SHOW_STR "Display information about the Gb proxy\n" "Show statistics\n")
+DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy (bss|sgsn) [stats]",
+       SHOW_STR "Display information about the Gb proxy\n"
+       "Display BSS-side BVCs\n"
+       "Display SGSN-side BVCs\n"
+       "Show statistics\n")
 {
 	struct gbproxy_nse *nse;
-	int show_stats = argc >= 1;
-	int i, j;
+	bool show_stats = argc >= 2;
+	int i;
 
 	if (show_stats)
 		vty_out_rate_ctr_group(vty, "", g_cfg->ctrg);
 
-	hash_for_each(g_cfg->bss_nses, i, nse, list) {
-		struct gbproxy_bvc *bvc;
-		hash_for_each(nse->bvcs, j, bvc, list) {
-			gbprox_vty_print_bvc(vty, bvc);
-
-			if (show_stats)
-				vty_out_rate_ctr_group(vty, "  ", bvc->ctrg);
-		}
+	if (!strcmp(argv[0], "bss")) {
+		hash_for_each(g_cfg->bss_nses, i, nse, list)
+			gbproxy_vty_print_nse(vty, nse, show_stats);
+	} else {
+		hash_for_each(g_cfg->sgsn_nses, i, nse, list)
+			gbproxy_vty_print_nse(vty, nse, show_stats);
 	}
 	return CMD_SUCCESS;
 }
diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py
index 4587564..be40abc 100755
--- a/tests/vty_test_runner.py
+++ b/tests/vty_test_runner.py
@@ -97,7 +97,7 @@
         res = self.vty.command("show ns")
         self.assertTrue(res.find('UDP bind') >= 0)
 
-        res = self.vty.command("show gbproxy stats")
+        res = self.vty.command("show gbproxy bss stats")
         self.assertTrue(res.find('GBProxy Global Statistics') >= 0)
 
     def testVtyDeletePeer(self):

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I8e09a9dc296b15094d191b0451d04457c815d116
Gerrit-Change-Number: 21690
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Assignee: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201212/45123a53/attachment.htm>


More information about the gerrit-log mailing list