gbproxy: Add VTY commands to query the TLLI/IMSI cache

OsmoGbProxy# show gbproxy tlli-cache
TLLI cache timeout 10s
 TLLI c2200024 -> NSE(02001/BSS) valid 10s
TLLI cache contains 1 entries

OsmoGbProxy# show gbproxy imsi-cache
IMSI cache timeout 10s
 IMSI 262420000001000 -> NSE(00102/SGSN): valid 5s
 IMSI 262420000000000 -> NSE(00101/SGSN): valid 3s
IMSI cache contains 2 entries

Change-Id: I03f1050573de9b241eb4fa82460c434155c15c6a
Related: OS#4951, OS#4472
This commit is contained in:
Daniel Willmann 2021-01-18 16:57:01 +01:00
parent 2c758f2bc1
commit f2812fbbc6
1 changed files with 51 additions and 0 deletions

View File

@ -553,6 +553,55 @@ DEFUN(show_gbproxy_links, show_gbproxy_links_cmd, "show gbproxy links",
return CMD_SUCCESS;
}
DEFUN(show_gbproxy_tlli_cache, show_gbproxy_tlli_cache_cmd,
"show gbproxy tlli-cache",
SHOW_STR GBPROXY_STR "Show TLLI cache entries\n")
{
struct gbproxy_tlli_cache_entry *entry;
struct timespec now;
time_t expiry;
int i, count = 0;
osmo_clock_gettime(CLOCK_MONOTONIC, &now);
expiry = now.tv_sec - g_cfg->tlli_cache.timeout;
vty_out(vty, "TLLI cache timeout %us%s", g_cfg->tlli_cache.timeout, VTY_NEWLINE);
hash_for_each(g_cfg->tlli_cache.entries, i, entry, list) {
time_t valid = entry->tstamp - expiry;
struct gbproxy_nse *nse = entry->nse;
vty_out(vty, " TLLI %08x -> NSE(%05u/%s) valid %lds%s", entry->tlli, nse->nsei,
nse->sgsn_facing ? "SGSN" : "BSS", valid, VTY_NEWLINE);
count++;
}
vty_out(vty, "TLLI cache contains %u entries%s", count, VTY_NEWLINE);
return CMD_SUCCESS;
}
DEFUN(show_gbproxy_imsi_cache, show_gbproxy_imsi_cache_cmd,
"show gbproxy imsi-cache",
SHOW_STR GBPROXY_STR "Show IMSI cache entries\n")
{
struct gbproxy_imsi_cache_entry *entry;
struct timespec now;
time_t expiry;
int i, count = 0;
osmo_clock_gettime(CLOCK_MONOTONIC, &now);
expiry = now.tv_sec - g_cfg->imsi_cache.timeout;
vty_out(vty, "IMSI cache timeout %us%s", g_cfg->imsi_cache.timeout, VTY_NEWLINE);
hash_for_each(g_cfg->imsi_cache.entries, i, entry, list) {
time_t valid = entry->tstamp - expiry;
struct gbproxy_nse *nse = entry->nse;
vty_out(vty, " IMSI %s -> NSE(%05u/%s): valid %lds%s", entry->imsi, nse->nsei,
nse->sgsn_facing ? "SGSN" : "BSS", valid, VTY_NEWLINE);
count++;
}
vty_out(vty, "IMSI cache contains %u entries%s", count, VTY_NEWLINE);
return CMD_SUCCESS;
}
DEFUN(delete_gb_bvci, delete_gb_bvci_cmd,
"delete-gbproxy-peer <0-65534> bvci <2-65534>",
"Delete a GBProxy bvc by NSEI and optionally BVCI\n"
@ -684,6 +733,8 @@ int gbproxy_vty_init(void)
install_element_ve(&show_gbproxy_bvc_cmd);
install_element_ve(&show_gbproxy_cell_cmd);
install_element_ve(&show_gbproxy_links_cmd);
install_element_ve(&show_gbproxy_tlli_cache_cmd);
install_element_ve(&show_gbproxy_imsi_cache_cmd);
install_element_ve(&show_nri_all_cmd);
install_element_ve(&show_nri_nsei_cmd);
install_element_ve(&logging_fltr_bvc_cmd);