<p>daniel has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-gbproxy/+/24956">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gbproxy_peer: Free a cell as soon as no BSS BVC uses it<br><br>This patch adds gbproxy_cell_cleanup_bvc() which removes the bvc pointer<br>to the cell. If the BSS BVC of this cell is removed it frees the whole<br>cell (removing all the SGSN BVC pointers to the cell). The SGSN-side<br>BVCs are blocked at this point and will only be reestablished if this<br>BVC is reset again from the BSS.<br><br>Before this patch cells were never freed and might accumulate over time.<br>They would only be reused if the bvci matched that of a previous cell.<br><br>Related: OS#4960<br>Change-Id: Ib874cbebcea58fa4bf15e1ff40fe11601573e531<br>---<br>M include/osmocom/gbproxy/gb_proxy.h<br>M src/gb_proxy_peer.c<br>2 files changed, 18 insertions(+), 15 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-gbproxy refs/changes/56/24956/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/gbproxy/gb_proxy.h b/include/osmocom/gbproxy/gb_proxy.h</span><br><span>index 76a7d31..1e73a1d 100644</span><br><span>--- a/include/osmocom/gbproxy/gb_proxy.h</span><br><span>+++ b/include/osmocom/gbproxy/gb_proxy.h</span><br><span>@@ -288,6 +288,7 @@</span><br><span> struct gbproxy_cell *gbproxy_cell_by_cellid(struct gbproxy_config *cfg, const struct gprs_ra_id *raid, uint16_t cid);</span><br><span> void gbproxy_cell_free(struct gbproxy_cell *cell);</span><br><span> bool gbproxy_cell_add_sgsn_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc);</span><br><span style="color: hsl(120, 100%, 40%);">+void gbproxy_cell_cleanup_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc);</span><br><span> </span><br><span> /* NSE handling */</span><br><span> struct gbproxy_nse *gbproxy_nse_alloc(struct gbproxy_config *cfg, uint16_t nsei, bool sgsn_facing);</span><br><span>diff --git a/src/gb_proxy_peer.c b/src/gb_proxy_peer.c</span><br><span>index 4eb427b..abbfa50 100644</span><br><span>--- a/src/gb_proxy_peer.c</span><br><span>+++ b/src/gb_proxy_peer.c</span><br><span>@@ -103,8 +103,6 @@</span><br><span> </span><br><span> void gbproxy_bvc_free(struct gbproxy_bvc *bvc)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-        struct gbproxy_cell *cell;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>   if (!bvc)</span><br><span>            return;</span><br><span> </span><br><span>@@ -117,21 +115,10 @@</span><br><span> </span><br><span>      osmo_fsm_inst_free(bvc->fi);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     cell = bvc->cell;</span><br><span style="color: hsl(0, 100%, 40%);">-    if (cell) {</span><br><span style="color: hsl(0, 100%, 40%);">-             int i;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-          if (cell->bss_bvc == bvc)</span><br><span style="color: hsl(0, 100%, 40%);">-                    cell->bss_bvc = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-                /* we could also be a SGSN-side BVC */</span><br><span style="color: hsl(0, 100%, 40%);">-          for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-                        if (cell->sgsn_bvc[i] == bvc)</span><br><span style="color: hsl(0, 100%, 40%);">-                                cell->sgsn_bvc[i] = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-            }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (bvc->cell) {</span><br><span style="color: hsl(120, 100%, 40%);">+           gbproxy_cell_cleanup_bvc(bvc->cell, bvc);</span><br><span>                 bvc->cell = NULL;</span><br><span>         }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>    talloc_free(bvc);</span><br><span> }</span><br><span> </span><br><span>@@ -214,6 +201,21 @@</span><br><span>    return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+void gbproxy_cell_cleanup_bvc(struct gbproxy_cell *cell, struct gbproxy_bvc *bvc)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   int i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      if (cell->bss_bvc == bvc)</span><br><span style="color: hsl(120, 100%, 40%);">+          return gbproxy_cell_free(cell);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     /* we could also be a SGSN-side BVC */</span><br><span style="color: hsl(120, 100%, 40%);">+        for (i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+              if (cell->sgsn_bvc[i] == bvc)</span><br><span style="color: hsl(120, 100%, 40%);">+                      cell->sgsn_bvc[i] = NULL;</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%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void gbproxy_cell_free(struct gbproxy_cell *cell)</span><br><span> {</span><br><span>   unsigned int i;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-gbproxy/+/24956">change 24956</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-gbproxy/+/24956"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-gbproxy </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ib874cbebcea58fa4bf15e1ff40fe11601573e531 </div>
<div style="display:none"> Gerrit-Change-Number: 24956 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: daniel <dwillmann@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>