Change in ...osmo-sgsn[master]: Merge common allocation steps for Gb and Iu ctx

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
Mon Sep 2 09:42:23 UTC 2019


pespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/15338 )

Change subject: Merge common allocation steps for Gb and Iu ctx
......................................................................

Merge common allocation steps for Gb and Iu ctx

This way it's easier to add new common functionalitites without
forgetting to add it on both sides, and simplifies the code.

Change-Id: Ib6c0427ac7b35295cf1caf2f28cb2a5c155b9d9c
---
M src/gprs/gprs_sgsn.c
1 file changed, 27 insertions(+), 30 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index 2116590..6acc66e 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -214,9 +214,8 @@
 
 }
 
-/* Allocate a new SGSN MM context for GERAN_Gb */
-struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
-					const struct gprs_ra_id *raid)
+/* Allocate a new SGSN MM context, generic part */
+struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t rate_ctr_id)
 {
 	struct sgsn_mm_ctx *ctx;
 
@@ -224,16 +223,9 @@
 	if (!ctx)
 		return NULL;
 
-	memcpy(&ctx->ra, raid, sizeof(ctx->ra));
-	ctx->ran_type = MM_CTX_T_GERAN_Gb;
-	ctx->gb.tlli = tlli;
 	ctx->gmm_state = GMM_DEREGISTERED;
-	ctx->gb.mm_state = MM_IDLE;
 	ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
-	ctx->ciph_algo = sgsn->cfg.cipher;
-	LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
-		  get_value_string(gprs_cipher_names, ctx->ciph_algo));
-	ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, tlli);
+	ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, rate_ctr_id);
 	if (!ctx->ctrg) {
 		LOGMMCTXP(LOGL_ERROR, ctx, "Cannot allocate counter group\n");
 		talloc_free(ctx);
@@ -246,40 +238,45 @@
 
 	return ctx;
 }
+/* Allocate a new SGSN MM context for GERAN_Gb */
+struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
+					 const struct gprs_ra_id *raid)
+{
+	struct sgsn_mm_ctx *ctx;
 
-/* Allocate a new SGSN MM context */
+	ctx = sgsn_mm_ctx_alloc(tlli);
+	if (!ctx)
+		return NULL;
+
+	memcpy(&ctx->ra, raid, sizeof(ctx->ra));
+	ctx->ran_type = MM_CTX_T_GERAN_Gb;
+	ctx->gb.tlli = tlli;
+	ctx->gb.mm_state = MM_IDLE;
+	ctx->ciph_algo = sgsn->cfg.cipher;
+
+	LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
+		  get_value_string(gprs_cipher_names, ctx->ciph_algo));
+	return ctx;
+}
+
+/* Allocate a new SGSN MM context for UTRAN_Iu */
 struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx)
 {
 #if BUILD_IU
 	struct sgsn_mm_ctx *ctx;
 	struct ranap_ue_conn_ctx *ue_ctx = uectx;
 
-	ctx = talloc_zero(tall_sgsn_ctx, struct sgsn_mm_ctx);
+	ctx = sgsn_mm_ctx_alloc(ue_ctx->conn_id);
 	if (!ctx)
 		return NULL;
 
+	/* Need to get RAID from IU conn */
+	ctx->ra = ue_ctx->ra_id;
 	ctx->ran_type = MM_CTX_T_UTRAN_Iu;
 	ctx->iu.ue_ctx = ue_ctx;
 	ctx->iu.ue_ctx->rab_assign_addr_enc = sgsn->cfg.iu.rab_assign_addr_enc;
 	ctx->iu.new_key = 1;
-	ctx->gmm_state = GMM_DEREGISTERED;
 	ctx->iu.mm_state = PMM_DETACHED;
-	ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
-	ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, ue_ctx->conn_id);
-	if (!ctx->ctrg) {
-		LOGMMCTXP(LOGL_ERROR, ctx, "Cannot allocate counter group for %s.%u\n",
-			  mmctx_ctrg_desc.group_name_prefix, ue_ctx->conn_id);
-		talloc_free(ctx);
-		return NULL;
-	}
-	ctx->gmm_att_req.fsm = osmo_fsm_inst_alloc(&gmm_attach_req_fsm, ctx, ctx, LOGL_DEBUG, "gb_gmm_req");
-
-	/* Need to get RAID from IU conn */
-	ctx->ra = ctx->iu.ue_ctx->ra_id;
-
-	INIT_LLIST_HEAD(&ctx->pdp_list);
-
-	llist_add(&ctx->list, &sgsn_mm_ctxts);
 
 	return ctx;
 #else

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/15338
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Ib6c0427ac7b35295cf1caf2f28cb2a5c155b9d9c
Gerrit-Change-Number: 15338
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190902/0a00987b/attachment.htm>


More information about the gerrit-log mailing list