pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/38712?usp=email )
Change subject: hnbgw: Fix wrong map object retrieved from hashtable ......................................................................
hnbgw: Fix wrong map object retrieved from hashtable
If several map objects (mapping between RUA and SCCP transports for a given Iu connection) ended up in the same hashtable bucket, then the first one was always returned by map_from_conn_id().
As a result, when such collisions happened (e.g. when a big number of connections were inserted) a user could see a Iu message coming from SCCP connection "A" end up being forwarded to an unrelated RUA connection "B".
Related: SYS#6602 Fixes: f3caea850bc892551cd09bbaf49f798c172590c4 Change-Id: I107f461bf5bcb92262422c893b23d190659f6f72 (cherry picked from commit e6d87ff967fe614e917d8d9434bc5bd5a6f3d3d6) --- M src/osmo-hnbgw/hnbgw_cn.c 1 file changed, 4 insertions(+), 2 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved; Verified
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index 31bf192..f44f852 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -431,8 +431,10 @@ const struct osmo_prim_hdr *oph) { struct hnbgw_context_map *map; - hash_for_each_possible(hsu->hnbgw_context_map_by_conn_id, map, hnbgw_sccp_user_entry, conn_id) - return map; + hash_for_each_possible(hsu->hnbgw_context_map_by_conn_id, map, hnbgw_sccp_user_entry, conn_id) { + if (map->scu_conn_id == conn_id) + return map; + } LOGP(DRANAP, LOGL_ERROR, "Rx for unknown SCCP connection ID: %u: %s\n", conn_id, osmo_scu_prim_hdr_name_c(OTC_SELECT, oph)); return NULL;