pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32572 )
Change subject: gmm: Switch state before announcing events to user
......................................................................
gmm: Switch state before announcing events to user
Update the state in the FSM before triggering paths implemented by the
user which may also again interact with the FSM. If the state is not
updated earlier, then the new interactions may encounter the FSM in an
unexpected state with regards to the event received.
Change-Id: I10eb23f6db5ff3b0b90f9066aa4fa44c8cb85170
---
M include/osmocom/gprs/gmm/gmm_ms_fsm.h
M src/gmm/gmm_ms_fsm.c
2 files changed, 49 insertions(+), 24 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/include/osmocom/gprs/gmm/gmm_ms_fsm.h b/include/osmocom/gprs/gmm/gmm_ms_fsm.h
index 16bd022..516801e 100644
--- a/include/osmocom/gprs/gmm/gmm_ms_fsm.h
+++ b/include/osmocom/gprs/gmm/gmm_ms_fsm.h
@@ -42,28 +42,31 @@
GPRS_GMM_MS_EV_LOW_LVL_FAIL,
};
+/* Info about last initiated attach: */
+struct gprs_gmm_ms_fsm_attach_ctx {
+ enum osmo_gprs_gmm_attach_type type;
+ bool with_imsi;
+ bool explicit_att; /* true if by SMREG-ATTACH.req requested it */
+ bool implicit_att; /* true if GMMSM-ESTABLISH.req requested it */
+ /* Session Ids waiting for attach to happen during implicit_att: */
+ uint32_t sess_id[16];
+ uint8_t num_sess_id;
+ /* Retransmission of ATTACH REQUEST (T3310) */
+ uint8_t req_attempts;
+};
+
+/* Info about last initiated detach: */
+struct gprs_gmm_ms_fsm_detach_ctx {
+ enum osmo_gprs_gmm_detach_ms_type type;
+ enum osmo_gprs_gmm_detach_poweroff_type poweroff_type;
+};
+
struct gprs_gmm_ms_fsm_ctx {
struct osmo_fsm_inst *fi;
struct gprs_gmm_entity *gmme;
- /* Info about last initiated attach: */
- struct {
- enum osmo_gprs_gmm_attach_type type;
- bool with_imsi;
- bool explicit_att; /* true if by SMREG-ATTACH.req requested it */
- bool implicit_att; /* true if GMMSM-ESTABLISH.req requested it */
- /* Session Ids waiting for attach to happen during implicit_att: */
- uint32_t sess_id[16];
- uint8_t num_sess_id;
- /* Retransmission of ATTACH REQUEST (T3310) */
- uint8_t req_attempts;
- } attach;
-
- /* Info about last initiated detach: */
- struct {
- enum osmo_gprs_gmm_detach_ms_type type;
- enum osmo_gprs_gmm_detach_poweroff_type poweroff_type;
- } detach;
+ struct gprs_gmm_ms_fsm_attach_ctx attach;
+ struct gprs_gmm_ms_fsm_detach_ctx detach;
};
int gprs_gmm_ms_fsm_init(void);
diff --git a/src/gmm/gmm_ms_fsm.c b/src/gmm/gmm_ms_fsm.c
index 93dd397..85aa6bf 100644
--- a/src/gmm/gmm_ms_fsm.c
+++ b/src/gmm/gmm_ms_fsm.c
@@ -104,6 +104,7 @@
struct gprs_gmm_ms_fsm_ctx *ctx = (struct gprs_gmm_ms_fsm_ctx *)fi->priv;
uint8_t cause;
int rc;
+ struct gprs_gmm_ms_fsm_attach_ctx att;
switch (event) {
case GPRS_GMM_MS_EV_ATTACH_REQUESTED:
@@ -114,28 +115,36 @@
cause = *(uint8_t *)data;
/* fall-through */
case GPRS_GMM_MS_EV_LOW_LVL_FAIL:
+ /* Update state before announcing event to users. Moving to
+ * Deregistered reset attach ctx, hence do a tmp copy here: */
+ memcpy(&att, &ctx->attach, sizeof(att));
+ gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_DEREGISTERED);
+
if (event == GPRS_GMM_MS_EV_LOW_LVL_FAIL)
cause = GMM_CAUSE_MAC_FAIL;
- if (ctx->attach.explicit_att) {
+
+ if (att.explicit_att) {
/* Submit GMMREG-ATTACH-REJ as per TS 24.007 Annex C.1 */
rc = gprs_gmm_submit_gmmreg_attach_cnf(ctx->gmme, false, cause);
if (rc < 0)
return;
}
- if (ctx->attach.implicit_att) {
+
+ if (att.implicit_att) {
/* Submit GMMSM-ESTABLISH-CNF as per TS 24.007 Annex C.3 */
unsigned int i;
- for (i = 0; i < ctx->attach.num_sess_id; i++) {
+ for (i = 0; i < att.num_sess_id; i++) {
rc = gprs_gmm_submit_gmmsm_establish_cnf(ctx->gmme,
- ctx->attach.sess_id[i],
+ att.sess_id[i],
false, cause);
if (rc < 0)
return;
}
}
- gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_DEREGISTERED);
break;
case GPRS_GMM_MS_EV_ATTACH_ACCEPTED:
+ /* Update state before announcing event to users. */
+ gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_REGISTERED);
if (ctx->attach.explicit_att) {
/* Submit GMMREG-ATTACH-CNF as per TS 24.007 Annex C.1 */
rc = gprs_gmm_submit_gmmreg_attach_cnf(ctx->gmme, true, 0);
@@ -151,7 +160,6 @@
return;
}
}
- gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_REGISTERED);
break;
case GPRS_GMM_MS_EV_DETACH_REQUESTED:
gmm_ms_fsm_state_chg(fi, GPRS_GMM_MS_ST_DEREGISTERED);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32572
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I10eb23f6db5ff3b0b90f9066aa4fa44c8cb85170
Gerrit-Change-Number: 32572
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32574 )
Change subject: gmm: Fix typo in param name passed to logging macro
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32574
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Ib8025f29ddd9916907e14becaadad66336306e8a
Gerrit-Change-Number: 32574
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 03 May 2023 08:35:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32572 )
Change subject: gmm: Switch state before announcing events to user
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32572
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I10eb23f6db5ff3b0b90f9066aa4fa44c8cb85170
Gerrit-Change-Number: 32572
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 03 May 2023 08:35:33 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32568 )
Change subject: llc: Log received wrong FCS field
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32568
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I448680ee82fca226df4d33650537167b2e496e24
Gerrit-Change-Number: 32568
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 03 May 2023 08:35:20 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: laforge.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/32550 )
Change subject: gmm: Introduce SIM_AUTH primitive to resolve authentication
......................................................................
Patch Set 3: Code-Review+2
(1 comment)
Patchset:
PS3:
Merging as it is now to have something working for now. We can later improve it since no API is stable here yet.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32550
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I5c97642baac5ed29de63ae93fc7f0ecde5edf735
Gerrit-Change-Number: 32550
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Wed, 03 May 2023 08:35:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment