lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/37867?usp=email )
(
19 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: Refactor diffing same GMM messages ......................................................................
Refactor diffing same GMM messages
gprs_gmm_attach_req_ies() isn't specific for the attach request. It also did not cover the full message because of a fixed message length when comparing both messages.
A diff of the old and new GMM message is required to figure out if the MS/UE is retransmitting an old message or starting a new procedure.
Change-Id: Ie698d3a6894a5796663c22c8bfd12b47acda57e6 --- M include/osmocom/sgsn/gprs_gmm.h M src/sgsn/gprs_gmm.c M src/sgsn/gprs_gmm_attach.c 3 files changed, 7 insertions(+), 14 deletions(-)
Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve daniel: Looks good to me, approved
diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h index 6fca77e..900ad6a 100644 --- a/include/osmocom/sgsn/gprs_gmm.h +++ b/include/osmocom/sgsn/gprs_gmm.h @@ -45,7 +45,7 @@ uint8_t gmm_cause); int gsm48_tx_gmm_att_ack(struct sgsn_mm_ctx *mm);
-int gprs_gmm_attach_req_ies(struct msgb *a, struct msgb *b); +int gprs_gmm_msg_cmp(struct msgb *a, struct msgb *b);
int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx); /* TODO: move extract_subscr_* when gsm48_gmm_authorize() got removed */ diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index 7f70260..ea9ffe0 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -1429,25 +1429,18 @@ return 0; }
-/* Checks if two attach request contain the IEs and IE values +/* Checks if two GMM are the same (required diffing Attach Requests/RAU Requests * return 0 if equal - * return -1 if error - * return 1 if unequal - * - * Only do a simple memcmp for now. */ -int gprs_gmm_attach_req_ies(struct msgb *a, struct msgb *b) +int gprs_gmm_msg_cmp(struct msgb *a, struct msgb *b) { struct gsm48_hdr *gh_a = (struct gsm48_hdr *) msgb_gmmh(a); struct gsm48_hdr *gh_b = (struct gsm48_hdr *) msgb_gmmh(b);
-#define GMM_ATTACH_REQ_LEN 26 + if (msgb_l3len(a) != msgb_l3len(b)) + return 2;
- /* there is the LLC FCS behind */ - if (msgb_l3len(a) < GMM_ATTACH_REQ_LEN || msgb_l3len(b) < GMM_ATTACH_REQ_LEN) - return -1; - - return !!memcmp(gh_a, gh_b, GMM_ATTACH_REQ_LEN); + return memcmp(gh_a, gh_b, msgb_l3len(a)); }
/* 3GPP TS 24.008 § 4.7.4.1 / 9.4.5.2 MO Detach request */ diff --git a/src/sgsn/gprs_gmm_attach.c b/src/sgsn/gprs_gmm_attach.c index 708ea8f..6331992 100644 --- a/src/sgsn/gprs_gmm_attach.c +++ b/src/sgsn/gprs_gmm_attach.c @@ -385,7 +385,7 @@ /* 04.08 4.7.3.1.6 d) Abnormal Case * Only do action if Req IEs differs. */ if (ctx->gmm_att_req.attach_req && - gprs_gmm_attach_req_ies(new_attach_req, ctx->gmm_att_req.attach_req)) { + gprs_gmm_msg_cmp(new_attach_req, ctx->gmm_att_req.attach_req)) { osmo_fsm_inst_state_chg(fi, ST_INIT, 0, 0); st_init(fi, event, data); }