pespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/15211 )
Change subject: Introduce and use log macros when no mm ctx available ...................................................................... Introduce and use log macros when no mm ctx available Change-Id: Iba22060d8646bc8ec6227684ccb91d98cb4c7be2 --- M include/osmocom/sgsn/gprs_llc.h M include/osmocom/sgsn/gprs_sgsn.h M src/gprs/gprs_gmm.c M src/gprs/gprs_llc.c 4 files changed, 46 insertions(+), 14 deletions(-) Approvals: laforge: Looks good to me, approved osmith: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h index 8a0b9ef..ce0e63c 100644 --- a/include/osmocom/sgsn/gprs_llc.h +++ b/include/osmocom/sgsn/gprs_llc.h @@ -96,6 +96,7 @@ GPRS_LLMS_UNASSIGNED = 1, /* No TLLI yet */ GPRS_LLMS_ASSIGNED = 2, /* TLLI assigned */ }; +extern const struct value_string gprs_llc_llme_state_names[]; /* Section 8.9.9 LLC layer parameter default values */ struct gprs_llc_params { diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h index 10455d6..9753ea2 100644 --- a/include/osmocom/sgsn/gprs_sgsn.h +++ b/include/osmocom/sgsn/gprs_sgsn.h @@ -262,6 +262,28 @@ LOGP(DMM, level, "MM(%s/%08x) " fmt, (mm) ? (mm)->imsi : "---", \ (mm) ? (mm)->p_tmsi : GSM_RESERVED_TMSI, ## args) +#ifdef BUILD_IU +#define LOGIUP(ue, level, fmt, args...) \ + LOGP(DMM, level, "UE(0x%x){%s} " fmt, ue->conn_id, osmo_rai_name(&(ue)->ra_id), ## args) +#else +#define LOGIUP(ue, level, fmt, args...) \ + LOGP(DMM, level, "UE(%p){NOTSUPPORTED} " fmt, ue, ## args) +#endif + +#define LOGGBP(llme, level, fmt, args...) \ + LOGP(DMM, level, "LLME(%08x/%08x){%s} " fmt, (llme)->old_tlli, \ + (llme)->tlli, get_value_string_or_null(gprs_llc_llme_state_names, (llme)->state), ## args); + +#define LOGGBIUP(llme, msg, level, fmt, args...) \ + do { \ + struct ranap_ue_conn_ctx * _ue; \ + if (llme) { \ + LOGGBP(llme, level, fmt, ## args); \ + } else if ((msg) && (_ue = MSG_IU_UE_CTX(msg))) { \ + LOGIUP(_ue, level, fmt, ## args); \ + } else { OSMO_ASSERT(0); } \ + } while (0) + /* look-up a SGSN MM context based on TLLI + RAI */ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli, const struct gprs_ra_id *raid); diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c index 6c87032..2f27182 100644 --- a/src/gprs/gprs_gmm.c +++ b/src/gprs/gprs_gmm.c @@ -186,7 +186,7 @@ #define REQUIRE_MM \ if (!mm) { \ - LOGP(DRANAP, LOGL_NOTICE, "Cannot find mm ctx for IU event %d\n", type); \ + LOGIUP(ctx, LOGL_NOTICE, "Cannot find mm ctx for IU event %d\n", type); \ return rc; \ } @@ -202,8 +202,7 @@ if (mm) LOGMMCTXP(LOGL_INFO, mm, "IU release for imsi %s\n", mm->imsi); else - LOGMMCTXP(LOGL_INFO, mm, "IU release for UE conn 0x%x\n", - ctx->conn_id); + LOGIUP(ctx, LOGL_INFO, "IU release\n"); if (mm && mm->pmm_state == PMM_CONNECTED) mmctx_set_pmm_state(mm, PMM_IDLE); rc = 0; @@ -220,7 +219,10 @@ osmo_fsm_inst_dispatch(mm->gmm_att_req.fsm, E_IU_SECURITY_CMD_COMPLETE, NULL); break; default: - LOGP(DRANAP, LOGL_NOTICE, "Unknown event received: %i\n", type); + if (mm) + LOGMMCTXP(LOGL_NOTICE, mm, "Unknown event received: %i\n", type); + else + LOGIUP(ctx, LOGL_NOTICE, "Unknown event received: %i\n", type); rc = -1; break; } @@ -630,7 +632,7 @@ /* 3GPP TS 24.008 ยง 10.5.5.19: */ rc = osmo_get_rand_id(&rbyte, 1); if (rc < 0) { - LOGP(DMM, LOGL_ERROR, "osmo_get_rand_id() failed for A&C ref: %s\n", strerror(-rc)); + LOGMMCTXP(LOGL_ERROR, mm, "osmo_get_rand_id() failed for A&C ref: %s\n", strerror(-rc)); return rc; } @@ -1659,7 +1661,7 @@ upd_type = *cur++ & 0x07; rate_ctr_inc(&sgsn->rate_ctrs->ctr[CTR_GPRS_ROUTING_AREA_REQUEST]); - LOGP(DMM, LOGL_INFO, "-> GMM RA UPDATE REQUEST type=\"%s\"\n", + LOGMMCTXP(LOGL_INFO, mmctx, "-> GMM RA UPDATE REQUEST type=\"%s\"\n", get_value_string(gprs_upd_t_strs, upd_type)); /* Old routing area identification 10.5.5.15 */ @@ -1669,7 +1671,7 @@ /* MS Radio Access Capability 10.5.5.12a */ ms_ra_acc_cap_len = *cur++; if (ms_ra_acc_cap_len > 52) { - LOGP(DMM, LOGL_ERROR, + LOGMMCTXP(LOGL_ERROR, mmctx, "Rejecting GMM RA Update Request: MS Radio Access Capability too long" " (ms_ra_acc_cap_len = %u > 52)\n", ms_ra_acc_cap_len); reject_cause = GMM_CAUSE_PROTO_ERR_UNSPEC; @@ -1685,7 +1687,7 @@ switch (upd_type) { case GPRS_UPD_T_RA_LA: case GPRS_UPD_T_RA_LA_IMSI_ATT: - LOGP(DMM, LOGL_NOTICE, "Update type %i unsupported in Mode III, is your SI13 corrupt?\n", upd_type); + LOGMMCTXP(LOGL_NOTICE, mmctx, "Update type %i unsupported in Mode III, is your SI13 corrupt?\n", upd_type); reject_cause = GMM_CAUSE_PROTO_ERR_UNSPEC; goto rejected; case GPRS_UPD_T_RA: @@ -1722,7 +1724,8 @@ mmctx = sgsn_mm_ctx_by_ptmsi(tmsi); } #else - LOGP(DMM, LOGL_ERROR, "Rejecting GMM RA Update Request: No Iu support\n"); + LOGIUP(MSG_IU_UE_CTX(msg), LOGL_ERROR, + "Rejecting GMM RA Update Request: No Iu support\n"); goto rejected; #endif } @@ -1758,13 +1761,13 @@ if (llme) { /* send a XID reset to re-set all LLC sequence numbers * in the MS */ - LOGMMCTXP(LOGL_NOTICE, mmctx, "LLC XID RESET\n"); + LOGGBP(llme, LOGL_NOTICE, "LLC XID RESET\n"); gprs_llgmm_reset(llme); } /* The MS has to perform GPRS attach */ /* Device is still IMSI attached for CS but initiate GPRS ATTACH, * see GSM 04.08, 4.7.5.1.4 and G.6 */ - LOGMMCTXP(LOGL_ERROR, mmctx, "Rejecting GMM RA Update Request: MS should GMM Attach first\n"); + LOGGBIUP(llme, msg, LOGL_ERROR, "Rejecting GMM RA Update Request: MS should GMM Attach first\n"); reject_cause = GMM_CAUSE_IMPL_DETACHED; goto rejected; } @@ -1986,7 +1989,7 @@ if (llme && !mmctx && gh->msg_type != GSM48_MT_GMM_ATTACH_REQ && gh->msg_type != GSM48_MT_GMM_RA_UPD_REQ) { - LOGP(DMM, LOGL_NOTICE, "Cannot handle GMM for unknown MM CTX\n"); + LOGGBP(llme, LOGL_NOTICE, "Cannot handle GMM for unknown MM CTX\n"); /* 4.7.10 */ if (gh->msg_type == GSM48_MT_GMM_STATUS) { /* TLLI unassignment */ @@ -2168,7 +2171,7 @@ return rc; null_mmctx: - LOGP(DMM, LOGL_ERROR, + LOGGBIUP(llme, msg, LOGL_ERROR, "Received GSM 04.08 message type 0x%02x," " but no MM context available\n", gh->msg_type); @@ -2842,7 +2845,7 @@ /* MMCTX can be NULL when called */ if (!mmctx) { - LOGP(DMM, LOGL_NOTICE, "Cannot handle SM for unknown MM CTX\n"); + LOGGBIUP(llme, msg, LOGL_NOTICE, "Cannot handle SM for unknown MM CTX\n"); /* 6.1.3.6 */ if (gh->msg_type == GSM48_MT_GSM_STATUS) return 0; diff --git a/src/gprs/gprs_llc.c b/src/gprs/gprs_llc.c index a301a63..2a27da8 100644 --- a/src/gprs/gprs_llc.c +++ b/src/gprs/gprs_llc.c @@ -41,6 +41,12 @@ #include <osmocom/sgsn/gprs_sndcp_comp.h> #include <osmocom/sgsn/gprs_sndcp.h> +const struct value_string gprs_llc_llme_state_names[] = { + { GPRS_LLMS_UNASSIGNED, "UNASSIGNED" }, + { GPRS_LLMS_ASSIGNED, "ASSIGNED" }, + { 0, NULL } +}; + static struct gprs_llc_llme *llme_alloc(uint32_t tlli); static int gprs_llc_tx_xid(struct gprs_llc_lle *lle, struct msgb *msg, int command); -- To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/15211 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: Iba22060d8646bc8ec6227684ccb91d98cb4c7be2 Gerrit-Change-Number: 15211 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <lafo...@gnumonks.org> Gerrit-Reviewer: neels <nhofm...@sysmocom.de> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-MessageType: merged