<p>daniel <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-gbproxy/+/25577">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  daniel: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gbproxy: Avoid sending STATUS on unexpected BLOCK_ACK<br><br>Handle SGSN BVCs that are gone from the BSS differently.<br><br>The previous patch removed the gbproxy_bvc on the SGSN-side after it was<br>gone on the BSS-side. This caused a STATUS response to BVC_BLOCK_ACK messages<br>that should be valid. Instead of removing the BVC this patch marks it as<br>inactive so we can still handle BVC_BLOCK_ACK correctly, but ignore<br>other messages - especially BVC_RESET from the SGSN.<br><br>Related: SYS#5628. OS#5236<br>Change-Id: Ic9f34a27412d6e15ca1198ee140f66a076b5c6b6<br>---<br>M include/osmocom/gbproxy/gb_proxy.h<br>M src/gb_proxy.c<br>M src/gb_proxy_peer.c<br>3 files changed, 26 insertions(+), 4 deletions(-)<br><br></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 1e73a1d..07373ad 100644</span><br><span>--- a/include/osmocom/gbproxy/gb_proxy.h</span><br><span>+++ b/include/osmocom/gbproxy/gb_proxy.h</span><br><span>@@ -139,6 +139,9 @@</span><br><span>     /* PTP BVCI of this BVC */</span><br><span>   uint16_t bvci;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    /* Whether this BVC is inactive (removed from BSS-side) */</span><br><span style="color: hsl(120, 100%, 40%);">+    bool inactive;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     /* Routing Area that this BVC is part of */</span><br><span>  struct gprs_ra_id raid;</span><br><span> </span><br><span>@@ -279,6 +282,7 @@</span><br><span> #define NSE_F_BSS  0x0002</span><br><span> </span><br><span> struct gbproxy_bvc *gbproxy_bvc_by_bvci(struct gbproxy_nse *nse, uint16_t bvci);</span><br><span style="color: hsl(120, 100%, 40%);">+struct gbproxy_bvc *gbproxy_bvc_by_bvci_inactive(struct gbproxy_nse *nse, uint16_t bvci);</span><br><span> struct gbproxy_bvc *gbproxy_bvc_alloc(struct gbproxy_nse *nse, uint16_t bvci);</span><br><span> void gbproxy_bvc_free(struct gbproxy_bvc *bvc);</span><br><span> int gbproxy_cleanup_bvcs(struct gbproxy_nse *nse, uint16_t bvci);</span><br><span>diff --git a/src/gb_proxy.c b/src/gb_proxy.c</span><br><span>index be075d6..e24f468 100644</span><br><span>--- a/src/gb_proxy.c</span><br><span>+++ b/src/gb_proxy.c</span><br><span>@@ -701,6 +701,8 @@</span><br><span>        * Removing and reallocating is needed becaus the ra_id/cell_id might have changed */</span><br><span>        hash_for_each(cfg->sgsn_nses, i, sgsn_nse, list) {</span><br><span>                struct gbproxy_bvc *sgsn_bvc = gbproxy_bvc_by_bvci(sgsn_nse, bvci);</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!sgsn_bvc)</span><br><span style="color: hsl(120, 100%, 40%);">+                        sgsn_bvc = gbproxy_bvc_by_bvci_inactive(sgsn_nse, bvci);</span><br><span>             if (sgsn_bvc)</span><br><span>                        gbproxy_bvc_free(sgsn_bvc);</span><br><span> </span><br><span>@@ -1374,8 +1376,12 @@</span><br><span>     case BSSGP_PDUT_BVC_BLOCK_ACK:</span><br><span>               bvci = ntohs(tlvp_val16_unal(&tp[0], BSSGP_IE_BVCI));</span><br><span>            sgsn_bvc = gbproxy_bvc_by_bvci(nse, bvci);</span><br><span style="color: hsl(0, 100%, 40%);">-              if (!sgsn_bvc)</span><br><span style="color: hsl(0, 100%, 40%);">-                  goto err_no_bvc;</span><br><span style="color: hsl(120, 100%, 40%);">+              if (!sgsn_bvc) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* Check if BVC was blocked before */</span><br><span style="color: hsl(120, 100%, 40%);">+                 sgsn_bvc = gbproxy_bvc_by_bvci_inactive(nse, bvci);</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (!sgsn_bvc)</span><br><span style="color: hsl(120, 100%, 40%);">+                                goto err_no_bvc;</span><br><span style="color: hsl(120, 100%, 40%);">+              }</span><br><span>            rc = osmo_fsm_inst_dispatch(sgsn_bvc->fi, BSSGP_BVCFSM_E_RX_BLOCK_ACK, msg);</span><br><span>              break;</span><br><span>       case BSSGP_PDUT_BVC_UNBLOCK_ACK:</span><br><span>@@ -1627,7 +1633,7 @@</span><br><span>                                     /* Block BVC, indicate BSS equipment failure */</span><br><span>                                      uint8_t cause = BSSGP_CAUSE_EQUIP_FAIL;</span><br><span>                                      osmo_fsm_inst_dispatch(sgsn_bvc->fi, BSSGP_BVCFSM_E_REQ_BLOCK, &cause);</span><br><span style="color: hsl(0, 100%, 40%);">-                                  gbproxy_bvc_free(sgsn_bvc);</span><br><span style="color: hsl(120, 100%, 40%);">+                                   sgsn_bvc->inactive = true;</span><br><span>                                }</span><br><span>                    }</span><br><span> </span><br><span>diff --git a/src/gb_proxy_peer.c b/src/gb_proxy_peer.c</span><br><span>index abbfa50..f59cf9e 100644</span><br><span>--- a/src/gb_proxy_peer.c</span><br><span>+++ b/src/gb_proxy_peer.c</span><br><span>@@ -62,7 +62,18 @@</span><br><span> {</span><br><span>     struct gbproxy_bvc *bvc;</span><br><span>     hash_for_each_possible(nse->bvcs, bvc, list, bvci) {</span><br><span style="color: hsl(0, 100%, 40%);">-         if (bvc->bvci == bvci)</span><br><span style="color: hsl(120, 100%, 40%);">+             if (bvc->bvci == bvci && bvc->inactive == false)</span><br><span style="color: hsl(120, 100%, 40%);">+                        return bvc;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     return 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%);">+/* Find the gbproxy_bvc by its BVCI. There can only be one match */</span><br><span style="color: hsl(120, 100%, 40%);">+struct gbproxy_bvc *gbproxy_bvc_by_bvci_inactive(struct gbproxy_nse *nse, uint16_t bvci)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct gbproxy_bvc *bvc;</span><br><span style="color: hsl(120, 100%, 40%);">+      hash_for_each_possible(nse->bvcs, bvc, list, bvci) {</span><br><span style="color: hsl(120, 100%, 40%);">+               if (bvc->bvci == bvci && bvc->inactive == true)</span><br><span>                        return bvc;</span><br><span>  }</span><br><span>    return NULL;</span><br><span>@@ -84,6 +95,7 @@</span><br><span>              nse->nsei);</span><br><span>      osmo_identifier_sanitize_buf(idbuf, NULL, '_');</span><br><span>      bvc->bvci = bvci;</span><br><span style="color: hsl(120, 100%, 40%);">+  bvc->inactive = false;</span><br><span>    bvc->ctrg = rate_ctr_group_alloc(bvc, &bvc_ctrg_desc, (nse->nsei << 16) | bvci);</span><br><span>     if (!bvc->ctrg) {</span><br><span>                 talloc_free(bvc);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-gbproxy/+/25577">change 25577</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/+/25577"/><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: Ic9f34a27412d6e15ca1198ee140f66a076b5c6b6 </div>
<div style="display:none"> Gerrit-Change-Number: 25577 </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-Reviewer: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>