pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-sgsn/+/30905 )

Change subject: Move global mmctx list into struct sgsn_instance
......................................................................

Move global mmctx list into struct sgsn_instance

Change-Id: Idf8458902321da03b9b0831dad3ad383a9c7afa1
---
M include/osmocom/sgsn/mmctx.h
M include/osmocom/sgsn/sgsn.h
M src/sgsn/mmctx.c
M src/sgsn/sgsn.c
M src/sgsn/sgsn_ctrl.c
M src/sgsn/sgsn_vty.c
M tests/sgsn/sgsn_test.c
7 files changed, 16 insertions(+), 15 deletions(-)

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



diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h
index dd78124..c19f599 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_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 0963863..441a614 100644
--- a/include/osmocom/sgsn/sgsn.h
+++ b/include/osmocom/sgsn/sgsn.h
@@ -156,6 +156,7 @@
        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 c40db21..0e93092 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 *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 *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 @@
        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 *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 *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 @@

        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 @@
                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 f394db8..6619bf2 100644
--- a/src/sgsn/sgsn.c
+++ b/src/sgsn/sgsn.c
@@ -99,7 +99,7 @@
 {
        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 @@
        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 15c15ce..069304a 100644
--- a/src/sgsn/sgsn_ctrl.c
+++ b/src/sgsn/sgsn_ctrl.c
@@ -33,7 +33,7 @@
        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 4a1d085..79764f1 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -711,7 +711,7 @@
        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 @@
        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 bf4d82b..f821165 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -379,6 +379,7 @@
        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 @@
        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 @@
        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[] = {



2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/30905
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Idf8458902321da03b9b0831dad3ad383a9c7afa1
Gerrit-Change-Number: 30905
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: lynxis lazus <lyn...@fe80.eu>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to