fixeria has uploaded this change for review.

View Change

gprs_gmm: skip Security Mode on a protected connection

Before the libvlr rework (commit 0b2ad7bdb), the Security Mode Command
was only sent if the Iu connection was not integrity protected yet
(!ue_ctx->integrity_active). Since then, every Service Request starts
vlr_proc_acc_req(), which unconditionally performs the Security Mode
procedure.

A UE in PMM-CONNECTED may send a Service Request (e.g. of type 'data',
to re-establish released RABs) on its existing, already integrity
protected, connection. The resulting second Security Mode Command was
observed to be rejected by the RAN stack (osmo-hnbgw + umts-hnb), and
the Service Request failed.

Restore the old behaviour: if the connection is already integrity
protected, accept the Service Request right away. The UE is in
PMM-CONNECTED, so send the Service Accept explicitly (3GPP TS 24.008,
section 4.7.13.3), then let the GMM FSM re-establish the RABs.

Change-Id: I7aebe12532045aed847dd93d460f688025af587a
Fixes: 0b2ad7bdb ("Rework SGSN code to use new libvlr code")
---
M src/sgsn/gprs_gmm.c
1 file changed, 18 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/42/44242/1
diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c
index 8e2440a..f73719d 100644
--- a/src/sgsn/gprs_gmm.c
+++ b/src/sgsn/gprs_gmm.c
@@ -269,7 +269,9 @@
return;
}

- osmo_fsm_inst_dispatch(ctx->iu.mm_state_fsm, E_PMM_PS_CONN_ESTABLISH, NULL);
+ /* PMM-IDLE -> PMM-CONNECTED (a Service Request may also be received in PMM-CONNECTED) */
+ if (ctx->iu.mm_state_fsm->state == ST_PMM_IDLE)
+ osmo_fsm_inst_dispatch(ctx->iu.mm_state_fsm, E_PMM_PS_CONN_ESTABLISH, NULL);

if (ctx->iu.service.type != GPRS_SERVICE_T_SIGNALLING)
sgsn_mm_ctx_iu_activate_rabs(ctx);
@@ -1955,6 +1957,21 @@
goto rejected;
}

+ /* If the Service Request was received on an Iu connection, which is already integrity protected (e.g. to
+ * re-establish RABs in PMM-CONNECTED), there is no need to (and the RNC may refuse to) perform the Security
+ * Mode procedure again. Accept the Service Request right away. The UE is in PMM-CONNECTED mode, so the
+ * Service Accept must be sent explicitly, see 3GPP TS 24.008 ยง 4.7.13.3. */
+ if (ctx->iu.ue_ctx->integrity_active && ctx->gmm_fsm->state == ST_GMM_REGISTERED_NORMAL) {
+ LOGMMCTXP(LOGL_INFO, ctx, "Iu connection is already integrity protected, "
+ "accepting Service Request without Security Mode procedure\n");
+ /* Terminate a pending proc_arq_fsm (if any), it is superseded by this request */
+ if (ctx->vsub->proc_arq_fsm)
+ osmo_fsm_inst_term(ctx->vsub->proc_arq_fsm, OSMO_FSM_TERM_REQUEST, NULL);
+ gsm48_tx_gmm_service_ack(ctx);
+ osmo_fsm_inst_dispatch(ctx->gmm_fsm, E_GMM_SERVICE_ACCEPT, NULL);
+ return 0;
+ }
+
vlr_proc_acc_req(ctx->gmm_fsm,
E_GMM_SERVICE_ACCEPT,
E_GMM_SERVICE_REJECT,

To view, visit change 44242. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I7aebe12532045aed847dd93d460f688025af587a
Gerrit-Change-Number: 44242
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>