sgsn: Don't allow mmctx == NULL in sgsn_update_subscriber_data
Currently, sgsn_update_subscriber_data can be called with mmctx ==
NULL and will find and associate the right context (if present) based
on the subscriber's IMSI. This will not happen in regular use
any more, since sgsn_update_subscriber_data will only be called when
subscribers are used (auth mode 'remote') and in this case
gprs_subscr_get_or_create_by_mmctx will already be called by
sgsn_auth_request. Therefore, MM context and subscriber are always
associated except for some test cases and experimental VTY usage.
The current implementation of sgsn_update_subscriber_data also causes
additional complexity for the deletion on MM contexts to avoid a
ipossible double-free MM contexts.
This commit removes the MM context <-> subscriber association code
from sgsn_update_subscriber_data. That function must always be called
with mmctx != NULL, now. To avoid problems with VTY and test usage,
the calling subscriber function now only call
sgsn_update_subscriber_data when mmctx != NULL, since the purpose of
that function is to update that state of an existing MM context after
subscriber data has been changed.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 781be3f..14b9254 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -487,28 +487,11 @@
return gsm0408_gprs_force_reattach_oldmsg(oldmsg);
}
-void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx,
- struct gsm_subscriber *subscr)
+void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx)
{
- if (!mmctx && subscr && strlen(subscr->imsi) > 0) {
- mmctx = sgsn_mm_ctx_by_imsi(subscr->imsi);
- OSMO_ASSERT(!mmctx || !mmctx->subscr || mmctx->subscr == subscr);
- }
-
- if (!mmctx) {
- LOGP(DMM, LOGL_INFO,
- "Subscriber data update for unregistered MM context, IMSI %s\n",
- subscr->imsi);
- return;
- }
-
+ OSMO_ASSERT(mmctx != NULL);
LOGMMCTXP(LOGL_INFO, mmctx, "Subscriber data update\n");
- if (!subscr->sgsn_data->mm && !mmctx->subscr) {
- mmctx->subscr = subscr_get(subscr);
- mmctx->subscr->sgsn_data->mm = mmctx;
- }
-
sgsn_auth_update(mmctx);
}