Change in ...osmo-sgsn[master]: Introduce and use log macros when no mm ctx available

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Aug 14 14:31:32 UTC 2019


pespin has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/11/15211/1

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 9f58aaa..2446028 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -260,6 +260,28 @@
 	LOGP(DMM, level, "MM(%s/%08x) " fmt, (mm) ? (mm)->imsi : "---", \
 	     (mm) ? (mm)->p_tmsi : GSM_RESERVED_TMSI, ## args)
 
+#ifdef BUILD_IU
+#define LOGIUP(level, ue, fmt, args...) \
+	LOGP(DMM, level, "UE(0x%x){%s} " fmt, ue->conn_id, osmo_rai_name(&(ue)->ra_id), ## args)
+#else
+#define LOGIUP(level, ue, fmt, args...) \
+	LOGP(DMM, level, "UE(%p){NOTSUPPORTED} " fmt, ue, ## args)
+#endif
+
+#define LOGGBP(level, llme, 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(level, llme, msg, fmt, args...) \
+	do { \
+	struct ranap_ue_conn_ctx * _ue; \
+	if (llme) { \
+		LOGGBP(level, llme, fmt, ## args); \
+	} else if ((msg) && (_ue = MSG_IU_UE_CTX(msg))) { \
+		LOGIUP(level, _ue, 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 e6e7aad..9ab09c4 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -182,7 +182,7 @@
 
 #define REQUIRE_MM \
 	if (!mm) { \
-		LOGP(DRANAP, LOGL_NOTICE, "Cannot find mm ctx for IU event %d\n", type); \
+		LOGIUP(LOGL_NOTICE, ctx, "Cannot find mm ctx for IU event %d\n", type); \
 		return rc; \
 	}
 
@@ -198,8 +198,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(LOGL_INFO, ctx, "IU release\n");
 		if (mm && mm->ran_type == MM_CTX_T_UTRAN_Iu && mm->pmm_state == PMM_CONNECTED)
 			mmctx_set_pmm_state(mm, PMM_IDLE);
 		rc = 0;
@@ -216,7 +215,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(LOGL_NOTICE, ctx, "Unknown event received: %i\n", type);
 		rc = -1;
 		break;
 	}
@@ -628,7 +630,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;
 	}
 
@@ -1658,7 +1660,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 */
@@ -1668,7 +1670,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;
@@ -1684,7 +1686,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:
@@ -1721,7 +1723,8 @@
 				mmctx = sgsn_mm_ctx_by_ptmsi(tmsi);
 			}
 #else
-			LOGP(DMM, LOGL_ERROR, "Rejecting GMM RA Update Request: No Iu support\n");
+			LOGIUP(LOGL_ERROR, MSG_IU_UE_CTX(msg),
+			       "Rejecting GMM RA Update Request: No Iu support\n");
 			goto rejected;
 #endif
 		}
@@ -1756,13 +1759,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(LOGL_NOTICE, llme, "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(LOGL_ERROR, llme, msg, "Rejecting GMM RA Update Request: MS should GMM Attach first\n");
 		reject_cause = GMM_CAUSE_IMPL_DETACHED;
 		goto rejected;
 	}
@@ -1984,7 +1987,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(LOGL_NOTICE, llme, "Cannot handle GMM for unknown MM CTX\n");
 		/* 4.7.10 */
 		if (gh->msg_type == GSM48_MT_GMM_STATUS) {
 			/* TLLI unassignment */
@@ -2170,7 +2173,7 @@
 	return rc;
 
 null_mmctx:
-	LOGP(DMM, LOGL_ERROR,
+	LOGGBIUP(LOGL_ERROR, llme, msg,
 	     "Received GSM 04.08 message type 0x%02x,"
 	     " but no MM context available\n",
 	     gh->msg_type);
@@ -2844,7 +2847,7 @@
 	/* MMCTX can be NULL when called */
 
 	if (!mmctx) {
-		LOGP(DMM, LOGL_NOTICE, "Cannot handle SM for unknown MM CTX\n");
+		LOGGBIUP(LOGL_NOTICE, llme, msg, "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: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190814/44b3b6ad/attachment.htm>


More information about the gerrit-log mailing list