Review at  https://gerrit.osmocom.org/5576

rua_to_scu(): don't create a context map for UNITDATA

UNITDATA is connection-less, and as can be observed further below, the 'map'
doesn't get used in the N_UNIDATA case.

Related: OS#2776
Change-Id: Ic35562e6d7bfa54b6be859860657f9a235ad5a50
---
M src/hnbgw_rua.c
1 file changed, 16 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/76/5576/1

diff --git a/src/hnbgw_rua.c b/src/hnbgw_rua.c
index 1d0ffbd..58bb23b 100644
--- a/src/hnbgw_rua.c
+++ b/src/hnbgw_rua.c
@@ -213,13 +213,21 @@
        prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
        osmo_prim_init(&prim->oph, SCCP_SAP_USER, type, PRIM_OP_REQUEST, msg);
 
-       map = context_map_alloc_by_hnb(hnb, context_id, is_ps, cn);
-       OSMO_ASSERT(map);
-
-       DEBUGP(DRUA, "rua_to_scu() %s to %s, rua_ctx_id %u scu_conn_id %u\n",
-              cn_domain_indicator_to_str(cN_DomainIndicator),
-              osmo_sccp_addr_dump(remote_addr),
-              map->rua_ctx_id, map->scu_conn_id);
+       switch (type) {
+       case OSMO_SCU_PRIM_N_UNITDATA:
+               DEBUGP(DRUA, "rua_to_scu() %s to %s, rua_ctx_id %u (unitdata, 
no scu_conn_id)\n",
+                      cn_domain_indicator_to_str(cN_DomainIndicator),
+                      osmo_sccp_addr_dump(remote_addr),
+                      map->rua_ctx_id);
+               break;
+       default:
+               map = context_map_alloc_by_hnb(hnb, context_id, is_ps, cn);
+               OSMO_ASSERT(map);
+               DEBUGP(DRUA, "rua_to_scu() %s to %s, rua_ctx_id %u scu_conn_id 
%u\n",
+                      cn_domain_indicator_to_str(cN_DomainIndicator),
+                      osmo_sccp_addr_dump(remote_addr),
+                      map->rua_ctx_id, map->scu_conn_id);
+       }
 
        /* add primitive header */
        switch (type) {
@@ -263,7 +271,7 @@
 
        rc = osmo_sccp_user_sap_down(cn->sccp_user, &prim->oph);
 
-       if (release_context_map)
+       if (map && release_context_map)
                context_map_deactivate(map);
 
        return rc;

-- 
To view, visit https://gerrit.osmocom.org/5576
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic35562e6d7bfa54b6be859860657f9a235ad5a50
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <[email protected]>

Reply via email to