diff options
author | Harald Welte <laforge@osmocom.org> | 2020-12-12 14:17:51 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2020-12-12 19:12:52 +0100 |
commit | 959f77e34bc4ec2bb4707e5d86957ee47deea763 (patch) | |
tree | 6e03e17621194929a04089fa28017df191dc664d | |
parent | 9e917647aef4679b6fd6eabbe77651bb50b60da8 (diff) |
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
-rw-r--r-- | src/gbproxy/gb_proxy_vty.c | 53 | ||||
-rwxr-xr-x | tests/vty_test_runner.py | 2 |
2 files changed, 35 insertions, 20 deletions
diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c index 49ec91c95..976ac125b 100644 --- a/src/gbproxy/gb_proxy_vty.c +++ b/src/gbproxy/gb_proxy_vty.c @@ -58,15 +58,29 @@ static struct cmd_node gbproxy_node = { 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); + } +} + +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); - vty_out(vty, "%s", VTY_NEWLINE); + if (show_stats) + vty_out_rate_ctr_group(vty, " ", bvc->ctrg); + } } static int config_write_gbproxy(struct vty *vty) @@ -184,24 +198,25 @@ DEFUN(logging_fltr_bvc, 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 4587564bc..be40abc7d 100755 --- a/tests/vty_test_runner.py +++ b/tests/vty_test_runner.py @@ -97,7 +97,7 @@ class TestVTYGbproxy(TestVTYBase): 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): |