diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-09 13:57:31 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-01-11 12:58:23 +0100 |
commit | 93bc518b53b3f7e4b3a278835561a220e2dda4f9 (patch) | |
tree | 13b457cffedf7587a27976fc1c49e96136be4229 | |
parent | 58101ea587f725bd79c089b1596a77bffbb152d8 (diff) |
Move global mmctx list into struct sgsn_instance
Change-Id: Idf8458902321da03b9b0831dad3ad383a9c7afa1
-rw-r--r-- | include/osmocom/sgsn/mmctx.h | 2 | ||||
-rw-r--r-- | include/osmocom/sgsn/sgsn.h | 1 | ||||
-rw-r--r-- | src/sgsn/mmctx.c | 16 | ||||
-rw-r--r-- | src/sgsn/sgsn.c | 3 | ||||
-rw-r--r-- | src/sgsn/sgsn_ctrl.c | 2 | ||||
-rw-r--r-- | src/sgsn/sgsn_vty.c | 4 | ||||
-rw-r--r-- | tests/sgsn/sgsn_test.c | 3 |
7 files changed, 16 insertions, 15 deletions
diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h index dd781244c..c19f599c5 100644 --- a/include/osmocom/sgsn/mmctx.h +++ b/include/osmocom/sgsn/mmctx.h @@ -281,8 +281,6 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_nsapi(const struct sgsn_mm_ctx *mm, struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tid(const struct sgsn_mm_ctx *mm, uint8_t tid); -extern struct llist_head sgsn_mm_ctxts; - uint32_t sgsn_alloc_ptmsi(void); /* Called on subscriber data updates */ diff --git a/include/osmocom/sgsn/sgsn.h b/include/osmocom/sgsn/sgsn.h index 0963863c7..441a614c0 100644 --- a/include/osmocom/sgsn/sgsn.h +++ b/include/osmocom/sgsn/sgsn.h @@ -156,6 +156,7 @@ struct sgsn_instance { struct llist_head apn_list; /* list of struct sgsn_apn_ctx */ struct llist_head ggsn_list; /* list of struct sgsn_ggsn_ctx */ struct llist_head mme_list; /* list of struct sgsn_mme_ctx */ + struct llist_head mm_list; /* list of struct sgsn_mm_ctx */ struct llist_head pdp_list; /* list of struct sgsn_pdp_ctx */ struct ctrl_handle *ctrlh; diff --git a/src/sgsn/mmctx.c b/src/sgsn/mmctx.c index c40db219e..0e9309284 100644 --- a/src/sgsn/mmctx.c +++ b/src/sgsn/mmctx.c @@ -60,8 +60,6 @@ #include "../../config.h" -LLIST_HEAD(sgsn_mm_ctxts); - const struct value_string sgsn_ran_type_names[] = { { MM_CTX_T_GERAN_Gb, "GPRS/EDGE via Gb" }, { MM_CTX_T_UTRAN_Iu, "UMTS via Iu" }, @@ -98,7 +96,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_ue_ctx(const void *uectx) { struct sgsn_mm_ctx *ctx; - llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { + llist_for_each_entry(ctx, &sgsn->mm_list, list) { if (ctx->ran_type == MM_CTX_T_UTRAN_Iu && uectx == ctx->iu.ue_ctx) return ctx; @@ -113,7 +111,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli, { struct sgsn_mm_ctx *ctx; - llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { + llist_for_each_entry(ctx, &sgsn->mm_list, list) { if ((tlli == ctx->gb.tlli || tlli == ctx->gb.tlli_new) && gprs_ra_id_equals(raid, &ctx->ra)) return ctx; @@ -137,7 +135,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli, if (tlli_type != TLLI_FOREIGN && tlli_type != TLLI_LOCAL) return NULL; - llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { + llist_for_each_entry(ctx, &sgsn->mm_list, list) { if ((gprs_tmsi2tlli(ctx->p_tmsi, tlli_type) == tlli || gprs_tmsi2tlli(ctx->p_tmsi_old, tlli_type) == tlli) && gprs_ra_id_equals(raid, &ctx->ra)) @@ -151,7 +149,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_ptmsi(uint32_t p_tmsi) { struct sgsn_mm_ctx *ctx; - llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { + llist_for_each_entry(ctx, &sgsn->mm_list, list) { if (p_tmsi == ctx->p_tmsi || (ctx->p_tmsi_old && ctx->p_tmsi_old == p_tmsi)) return ctx; @@ -163,7 +161,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_imsi(const char *imsi) { struct sgsn_mm_ctx *ctx; - llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { + llist_for_each_entry(ctx, &sgsn->mm_list, list) { if (!strcmp(imsi, ctx->imsi)) return ctx; } @@ -205,7 +203,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t rate_ctr_id) INIT_LLIST_HEAD(&ctx->pdp_list); - llist_add(&ctx->list, &sgsn_mm_ctxts); + llist_add(&ctx->list, &sgsn->mm_list); return ctx; @@ -411,7 +409,7 @@ restart: goto restart; } - llist_for_each_entry(mm, &sgsn_mm_ctxts, list) { + llist_for_each_entry(mm, &sgsn->mm_list, list) { if (mm->p_tmsi == ptmsi) { if (!max_retries--) goto failed; diff --git a/src/sgsn/sgsn.c b/src/sgsn/sgsn.c index f394db8b7..6619bf263 100644 --- a/src/sgsn/sgsn.c +++ b/src/sgsn/sgsn.c @@ -99,7 +99,7 @@ static void sgsn_llme_cleanup_free(struct gprs_llc_llme *llme) { struct sgsn_mm_ctx *mmctx = NULL; - llist_for_each_entry(mmctx, &sgsn_mm_ctxts, list) { + llist_for_each_entry(mmctx, &sgsn->mm_list, list) { if (llme == mmctx->gb.llme) { gsm0408_gprs_access_cancelled(mmctx, SGSN_ERROR_CAUSE_NONE); return; @@ -176,6 +176,7 @@ struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx) INIT_LLIST_HEAD(&inst->apn_list); INIT_LLIST_HEAD(&inst->ggsn_list); INIT_LLIST_HEAD(&inst->mme_list); + INIT_LLIST_HEAD(&inst->mm_list); INIT_LLIST_HEAD(&inst->pdp_list); osmo_timer_setup(&inst->llme_timer, sgsn_llme_check_cb, NULL); diff --git a/src/sgsn/sgsn_ctrl.c b/src/sgsn/sgsn_ctrl.c index 15c15ceb7..069304abd 100644 --- a/src/sgsn/sgsn_ctrl.c +++ b/src/sgsn/sgsn_ctrl.c @@ -33,7 +33,7 @@ static int get_subscriber_list(struct ctrl_cmd *cmd, void *d) struct sgsn_mm_ctx *mm; cmd->reply = talloc_strdup(cmd, ""); - llist_for_each_entry(mm, &sgsn_mm_ctxts, list) { + llist_for_each_entry(mm, &sgsn->mm_list, list) { char *addr = NULL; struct sgsn_pdp_ctx *pdp; diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c index 4a1d085e3..79764f190 100644 --- a/src/sgsn/sgsn_vty.c +++ b/src/sgsn/sgsn_vty.c @@ -711,7 +711,7 @@ DEFUN(swow_mmctx_all, show_mmctx_all_cmd, SHOW_STR MMCTX_STR "All MM Contexts\n" INCLUDE_PDP_STR) { struct sgsn_mm_ctx *mm; - llist_for_each_entry(mm, &sgsn_mm_ctxts, list) + llist_for_each_entry(mm, &sgsn->mm_list, list) vty_dump_mmctx(vty, "", mm, (argc > 0) ? 1 : 0); return CMD_SUCCESS; @@ -1006,7 +1006,7 @@ DEFUN_HIDDEN(reset_sgsn_state, struct gprs_subscr *subscr, *tmp_subscr; struct sgsn_mm_ctx *mm, *tmp_mm; - llist_for_each_entry_safe(mm, tmp_mm, &sgsn_mm_ctxts, list) + llist_for_each_entry_safe(mm, tmp_mm, &sgsn->mm_list, list) { gsm0408_gprs_access_cancelled(mm, SGSN_ERROR_CAUSE_NONE); } diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c index bf4d82b83..f8211653a 100644 --- a/tests/sgsn/sgsn_test.c +++ b/tests/sgsn/sgsn_test.c @@ -379,6 +379,7 @@ static void test_auth_triplets(void) uint32_t local_tlli = 0xffeeddcc; printf("Testing authentication triplet handling\n"); + sgsn = sgsn_instance_alloc(tall_sgsn_ctx); /* Check for emptiness */ OSMO_ASSERT(gprs_subscr_get_by_imsi(imsi1) == NULL); @@ -864,6 +865,7 @@ static void test_gmm_detach_accept_unexpected(void) uint32_t local_tlli; printf("Testing GMM detach accept (unexpected)\n"); + sgsn = sgsn_instance_alloc(tall_sgsn_ctx); /* DTAP - Detach Accept (MT) */ /* normal detach */ @@ -900,6 +902,7 @@ static void test_gmm_status_no_mmctx(void) uint32_t local_tlli; printf("Testing GMM Status (no MMCTX)\n"); + sgsn = sgsn_instance_alloc(tall_sgsn_ctx); /* DTAP - GMM Status, protocol error */ static const unsigned char gmm_status[] = { |