aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gprs_sgsn.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/gprs/gprs_sgsn.c')
-rw-r--r--openbsc/src/gprs/gprs_sgsn.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 0c15619b5..4e5163200 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -359,15 +359,23 @@ uint32_t sgsn_alloc_ptmsi(void)
{
struct sgsn_mm_ctx *mm;
uint32_t ptmsi;
+ int max_retries = 23;
restart:
ptmsi = rand() | 0xC0000000;
llist_for_each_entry(mm, &sgsn_mm_ctxts, list) {
- if (mm->p_tmsi == ptmsi)
+ if (mm->p_tmsi == ptmsi) {
+ if (!max_retries--)
+ goto failed;
goto restart;
+ }
}
return ptmsi;
+
+failed:
+ LOGP(DGPRS, LOGL_ERROR, "Failed to allocate a P-TMSI\n");
+ return GSM_RESERVED_TMSI;
}
static void drop_one_pdp(struct sgsn_pdp_ctx *pdp)