sgsn: Only look at TLLIs in sgsn_mm_ctx_by_tlli
Currently the code also matches the TLLI against LOCAL and FOREIGN
mappings of the P-TMSI, thus eventually finding MM contexts not
consistent with the TLLI (both tlli and tlli_new differ). On
the other hand, tlli_new is not checked at all.
This commit changes the function to only look at mmctx->tlli,
mmctx->tlli_new, and the routing area.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 8f8bdc6..f71066d 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -90,47 +90,18 @@
.class_id = OSMO_STATS_CLASS_SUBSCRIBER,
};
-/* See 03.02 Chapter 2.6 */
-static inline uint32_t tlli_foreign(uint32_t tlli)
-{
- return ((tlli | 0x80000000) & ~0x40000000);
-}
-
/* look-up a SGSN MM context based on TLLI + RAI */
struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli,
const struct gprs_ra_id *raid)
{
struct sgsn_mm_ctx *ctx;
- int tlli_type;
llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) {
- if (tlli == ctx->tlli &&
+ if ((tlli == ctx->tlli || tlli == ctx->tlli_new) &&
gprs_ra_id_equals(raid, &ctx->ra))
return ctx;
}
- tlli_type = gprs_tlli_type(tlli);
- switch (tlli_type) {
- case TLLI_LOCAL:
- llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) {
- if ((ctx->p_tmsi | 0xC0000000) == tlli ||
- (ctx->p_tmsi_old && (ctx->p_tmsi_old | 0xC0000000) == tlli)) {
- ctx->tlli = tlli;
- return ctx;
- }
- }
- break;
- case TLLI_FOREIGN:
- llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) {
- if (tlli == tlli_foreign(ctx->tlli) &&
- gprs_ra_id_equals(raid, &ctx->ra))
- return ctx;
- }
- break;
- default:
- break;
- }
-
return NULL;
}