sgsn: Cleanup GMM state transitions

Currently the GMM state is set to GMM-REGISTERED when an Attach
Accept or a RA Update Accept message is sent, even if a new P-TMSI is
included. In this case 04.08 requires (see 4.7.3.1.3 and 4.7.5.1.3),
that the state is set to GMM-COMMON-PROCEDURE-INITIATED when the
Accept is sent. When the Complete is received, the SGSN shall set
the state to GMM-REGISTERED.

This patch modifies the state updates accordingly.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2014-10-28 16:23:46 +01:00 committed by Holger Hans Peter Freyther
parent 93eae8ec78
commit 0074a77424
2 changed files with 11 additions and 11 deletions

View File

@ -629,13 +629,11 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
{
/* Request IMSI and IMEI from the MS if they are unknown */
if (!strlen(ctx->imei)) {
ctx->mm_state = GMM_COMMON_PROC_INIT;
ctx->t3370_id_type = GSM_MI_TYPE_IMEI;
mmctx_timer_start(ctx, 3370, GSM0408_T3370_SECS);
return gsm48_tx_gmm_id_req(ctx, GSM_MI_TYPE_IMEI);
}
if (!strlen(ctx->imsi)) {
ctx->mm_state = GMM_COMMON_PROC_INIT;
ctx->t3370_id_type = GSM_MI_TYPE_IMSI;
mmctx_timer_start(ctx, 3370, GSM0408_T3370_SECS);
return gsm48_tx_gmm_id_req(ctx, GSM_MI_TYPE_IMSI);
@ -655,9 +653,10 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
/* Start T3350 and re-transmit up to 5 times until ATTACH COMPLETE */
mmctx_timer_start(ctx, 3350, GSM0408_T3350_SECS);
ctx->t3350_mode = GMM_T3350_MODE_ATT;
#else
ctx->mm_state = GMM_REGISTERED_NORMAL;
#endif
ctx->mm_state = GMM_REGISTERED_NORMAL;
return gsm48_tx_gmm_att_ack(ctx);
default:
LOGMMCTXP(LOGL_ERROR, ctx,
@ -860,6 +859,7 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
/* Allocate a new P-TMSI (+ P-TMSI signature) and update TLLI */
ctx->p_tmsi_old = ctx->p_tmsi;
ctx->p_tmsi = sgsn_alloc_ptmsi();
ctx->mm_state = GMM_COMMON_PROC_INIT;
#endif
/* Even if there is no P-TMSI allocated, the MS will switch from
* foreign TLLI to local TLLI */
@ -1078,6 +1078,11 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
/* Start T3350 and re-transmit up to 5 times until ATTACH COMPLETE */
mmctx->t3350_mode = GMM_T3350_MODE_RAU;
mmctx_timer_start(mmctx, 3350, GSM0408_T3350_SECS);
mmctx->mm_state = GMM_COMMON_PROC_INIT;
#else
/* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */
mmctx->mm_state = GMM_REGISTERED_NORMAL;
#endif
/* Even if there is no P-TMSI allocated, the MS will switch from
* foreign TLLI to local TLLI */
@ -1094,9 +1099,6 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
process_ms_ctx_status(mmctx, pdp_status);
}
/* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */
mmctx->mm_state = GMM_REGISTERED_NORMAL;
/* Send RA UPDATE ACCEPT */
return gsm48_tx_gmm_ra_upd_ack(mmctx);
}
@ -1189,6 +1191,7 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
mmctx->tlli = mmctx->tlli_new;
gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new,
GPRS_ALGO_GEA0, NULL);
mmctx->mm_state = GMM_REGISTERED_NORMAL;
rc = 0;
break;
case GSM48_MT_GMM_RA_UPD_COMPL:
@ -1202,6 +1205,7 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
mmctx->tlli = mmctx->tlli_new;
gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new,
GPRS_ALGO_GEA0, NULL);
mmctx->mm_state = GMM_REGISTERED_NORMAL;
rc = 0;
break;
case GSM48_MT_GMM_PTMSI_REALL_COMPL:

View File

@ -376,11 +376,7 @@ static void test_gmm_attach(void)
* authorization */
OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
/* FIXME: If we were authorized, the state should be
* GMM_COMMON_PROC_INIT until the Attach Complete is received, since a
* P-TMSI is included, fix state handling in gprs_gmm.c */
/* OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); */
OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT);
/* we expect an attach accept/reject */
OSMO_ASSERT(sgsn_tx_counter == 1);