<p>Mykola Shchetinin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13896">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Discard the existing HNB+ContextID to SCCP Connection ID mapping on N-CONNECT.<br><br>After a period of inactivity the phone sends a GMM Service Request again in an<br>InitialUE-Request message which triggers a new connection to be created. The<br>problem is that a new SCCP connection wasn't created but a new ranap_ue_conn_ctx<br>was allocated. As a result, the following message (SecurityModeComplete) uses<br>the old SCCP connection and the wrong ranap_ue_conn_ctx (old) is selected.<br><br>hnbgw_rua.c: rua_to_scu: in case of OSMO_SCU_PRIM_N_CONNECT deactivate the<br>existing hnbgw_context_map to force the context_map_alloc_by_hnb to allocate a<br>new one.<br><br>context_map.c/.h: Create function context_map_find_by_hnb. It replaces part of<br>context_map_alloc_by_hnb's functionality.<br><br>Fixes: OS#3936<br>Change-Id: If85d45dc0c5c6f1a9dbfed6c3752f00ff7b541f2<br>---<br>M include/osmocom/iuh/context_map.h<br>M src/context_map.c<br>M src/hnbgw_rua.c<br>3 files changed, 35 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/96/13896/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/iuh/context_map.h b/include/osmocom/iuh/context_map.h</span><br><span>index 6279b91..29eb64a 100644</span><br><span>--- a/include/osmocom/iuh/context_map.h</span><br><span>+++ b/include/osmocom/iuh/context_map.h</span><br><span>@@ -37,6 +37,10 @@</span><br><span>  enum hnbgw_context_map_state state;</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+struct hnbgw_context_map *</span><br><span style="color: hsl(120, 100%, 40%);">+context_map_find_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,</span><br><span style="color: hsl(120, 100%, 40%);">+                      bool is_ps,</span><br><span style="color: hsl(120, 100%, 40%);">+                   struct hnbgw_cnlink *cn_if_new);</span><br><span> </span><br><span> struct hnbgw_context_map *</span><br><span> context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,</span><br><span>diff --git a/src/context_map.c b/src/context_map.c</span><br><span>index dc555bf..d13eea3 100644</span><br><span>--- a/src/context_map.c</span><br><span>+++ b/src/context_map.c</span><br><span>@@ -63,11 +63,13 @@</span><br><span>  return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* Map from a HNB + ContextID to the SCCP-side Connection ID */</span><br><span style="color: hsl(120, 100%, 40%);">+/* Map from a HNB + ContextID to the SCCP-side Connection ID.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Return NULL if not found.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> struct hnbgw_context_map *</span><br><span style="color: hsl(0, 100%, 40%);">-context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,</span><br><span style="color: hsl(0, 100%, 40%);">-                         bool is_ps,</span><br><span style="color: hsl(0, 100%, 40%);">-                     struct hnbgw_cnlink *cn_if_new)</span><br><span style="color: hsl(120, 100%, 40%);">+context_map_find_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,</span><br><span style="color: hsl(120, 100%, 40%);">+                       bool is_ps,</span><br><span style="color: hsl(120, 100%, 40%);">+                   struct hnbgw_cnlink *cn_if_new)</span><br><span> {</span><br><span>         struct hnbgw_context_map *map;</span><br><span>       uint32_t new_scu_conn_id;</span><br><span>@@ -84,6 +86,25 @@</span><br><span>               }</span><br><span>    }</span><br><span> </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%);">+/* Map from a HNB + ContextID to the SCCP-side Connection ID.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Find an existing one or allocate a new one if not found.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct hnbgw_context_map *</span><br><span style="color: hsl(120, 100%, 40%);">+context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,</span><br><span style="color: hsl(120, 100%, 40%);">+                         bool is_ps,</span><br><span style="color: hsl(120, 100%, 40%);">+                   struct hnbgw_cnlink *cn_if_new)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   struct hnbgw_context_map *map;</span><br><span style="color: hsl(120, 100%, 40%);">+        uint32_t new_scu_conn_id;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   map = context_map_find_by_hnb(hnb, rua_ctx_id, is_ps, cn_if_new);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (map)</span><br><span style="color: hsl(120, 100%, 40%);">+              return map;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        if (alloc_cn_conn_id(cn_if_new, &new_scu_conn_id) < 0) {</span><br><span>              LOGP(DMAIN, LOGL_ERROR, "Unable to allocate CN connection ID\n");</span><br><span>          return NULL;</span><br><span>diff --git a/src/hnbgw_rua.c b/src/hnbgw_rua.c</span><br><span>index 40d1d94..f225f1a 100644</span><br><span>--- a/src/hnbgw_rua.c</span><br><span>+++ b/src/hnbgw_rua.c</span><br><span>@@ -220,6 +220,12 @@</span><br><span>                        osmo_sccp_addr_dump(remote_addr),</span><br><span>                    context_id);</span><br><span>          break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case OSMO_SCU_PRIM_N_CONNECT:</span><br><span style="color: hsl(120, 100%, 40%);">+         map = context_map_find_by_hnb(hnb, context_id, is_ps, cn);</span><br><span style="color: hsl(120, 100%, 40%);">+            if (map) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    /* Forcing context_map_alloc_by_hnb to allocate a new "map" */</span><br><span style="color: hsl(120, 100%, 40%);">+                      context_map_deactivate(map);</span><br><span style="color: hsl(120, 100%, 40%);">+          }</span><br><span>    default:</span><br><span>             map = context_map_alloc_by_hnb(hnb, context_id, is_ps, cn);</span><br><span>          OSMO_ASSERT(map);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13896">change 13896</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/13896"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-iuh </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If85d45dc0c5c6f1a9dbfed6c3752f00ff7b541f2 </div>
<div style="display:none"> Gerrit-Change-Number: 13896 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Mykola Shchetinin <mykola@pentonet.com> </div>