<p>daniel <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-sgsn/+/22290">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  lynxis lazus: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gbproxy: Add VTY commands to query the TLLI/IMSI cache<br><br>OsmoGbProxy# show gbproxy tlli-cache<br>TLLI cache timeout 10s<br> TLLI c2200024 -> NSE(02001/BSS) valid 10s<br>TLLI cache contains 1 entries<br><br>OsmoGbProxy# show gbproxy imsi-cache<br>IMSI cache timeout 10s<br> IMSI 262420000001000 -> NSE(00102/SGSN): valid 5s<br> IMSI 262420000000000 -> NSE(00101/SGSN): valid 3s<br>IMSI cache contains 2 entries<br><br>Change-Id: I03f1050573de9b241eb4fa82460c434155c15c6a<br>Related: OS#4951, OS#4472<br>---<br>M src/gbproxy/gb_proxy_vty.c<br>1 file changed, 51 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c</span><br><span>index 7e9e18d..7ae65d2 100644</span><br><span>--- a/src/gbproxy/gb_proxy_vty.c</span><br><span>+++ b/src/gbproxy/gb_proxy_vty.c</span><br><span>@@ -553,6 +553,55 @@</span><br><span>       return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(show_gbproxy_tlli_cache, show_gbproxy_tlli_cache_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "show gbproxy tlli-cache",</span><br><span style="color: hsl(120, 100%, 40%);">+      SHOW_STR GBPROXY_STR "Show TLLI cache entries\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gbproxy_tlli_cache_entry *entry;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct timespec now;</span><br><span style="color: hsl(120, 100%, 40%);">+  time_t expiry;</span><br><span style="color: hsl(120, 100%, 40%);">+        int i, count = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   osmo_clock_gettime(CLOCK_MONOTONIC, &now);</span><br><span style="color: hsl(120, 100%, 40%);">+        expiry = now.tv_sec - g_cfg->tlli_cache.timeout;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "TLLI cache timeout %us%s", g_cfg->tlli_cache.timeout, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+        hash_for_each(g_cfg->tlli_cache.entries, i, entry, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+         time_t valid = entry->tstamp - expiry;</span><br><span style="color: hsl(120, 100%, 40%);">+             struct gbproxy_nse *nse = entry->nse;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            vty_out(vty, " TLLI %08x -> NSE(%05u/%s) valid %lds%s", entry->tlli, nse->nsei,</span><br><span style="color: hsl(120, 100%, 40%);">+                    nse->sgsn_facing ? "SGSN" : "BSS", valid, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+                count++;</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+     vty_out(vty, "TLLI cache contains %u entries%s", count, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+       return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(show_gbproxy_imsi_cache, show_gbproxy_imsi_cache_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "show gbproxy imsi-cache",</span><br><span style="color: hsl(120, 100%, 40%);">+      SHOW_STR GBPROXY_STR "Show IMSI cache entries\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct gbproxy_imsi_cache_entry *entry;</span><br><span style="color: hsl(120, 100%, 40%);">+       struct timespec now;</span><br><span style="color: hsl(120, 100%, 40%);">+  time_t expiry;</span><br><span style="color: hsl(120, 100%, 40%);">+        int i, count = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   osmo_clock_gettime(CLOCK_MONOTONIC, &now);</span><br><span style="color: hsl(120, 100%, 40%);">+        expiry = now.tv_sec - g_cfg->imsi_cache.timeout;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "IMSI cache timeout %us%s", g_cfg->imsi_cache.timeout, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+        hash_for_each(g_cfg->imsi_cache.entries, i, entry, list) {</span><br><span style="color: hsl(120, 100%, 40%);">+         time_t valid = entry->tstamp - expiry;</span><br><span style="color: hsl(120, 100%, 40%);">+             struct gbproxy_nse *nse = entry->nse;</span><br><span style="color: hsl(120, 100%, 40%);">+              vty_out(vty, " IMSI %s -> NSE(%05u/%s): valid %lds%s", entry->imsi, nse->nsei,</span><br><span style="color: hsl(120, 100%, 40%);">+                     nse->sgsn_facing ? "SGSN" : "BSS", valid, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+                count++;</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+     vty_out(vty, "IMSI cache contains %u entries%s", count, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+       return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> DEFUN(delete_gb_bvci, delete_gb_bvci_cmd,</span><br><span>        "delete-gbproxy-peer <0-65534> bvci <2-65534>",</span><br><span>        "Delete a GBProxy bvc by NSEI and optionally BVCI\n"</span><br><span>@@ -684,6 +733,8 @@</span><br><span>         install_element_ve(&show_gbproxy_bvc_cmd);</span><br><span>       install_element_ve(&show_gbproxy_cell_cmd);</span><br><span>      install_element_ve(&show_gbproxy_links_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+      install_element_ve(&show_gbproxy_tlli_cache_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element_ve(&show_gbproxy_imsi_cache_cmd);</span><br><span>        install_element_ve(&show_nri_all_cmd);</span><br><span>   install_element_ve(&show_nri_nsei_cmd);</span><br><span>  install_element_ve(&logging_fltr_bvc_cmd);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-sgsn/+/22290">change 22290</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-sgsn/+/22290"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-sgsn </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I03f1050573de9b241eb4fa82460c434155c15c6a </div>
<div style="display:none"> Gerrit-Change-Number: 22290 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: lynxis lazus <lynxis@fe80.eu> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>