Changes of Revision 740

open5gs_2.7.1.39.dc2e1.202406292026.dsc -> open5gs_2.7.1.48.555c2.202406302026.dsc Changed
x
 
1
@@ -2,7 +2,7 @@
2
 Source: open5gs
3
 Binary: open5gs-common, open5gs-mme, open5gs-sgwc, open5gs-smf, open5gs-amf, open5gs-sgwu, open5gs-upf, open5gs-hss, open5gs-pcrf, open5gs-nrf, open5gs-scp, open5gs-sepp, open5gs-ausf, open5gs-udm, open5gs-pcf, open5gs-nssf, open5gs-bsf, open5gs-udr, open5gs, open5gs-dbg
4
 Architecture: any
5
-Version: 2.7.1.39.dc2e1.202406292026
6
+Version: 2.7.1.48.555c2.202406302026
7
 Maintainer: Harald Welte <laforge@gnumonks.org>
8
 Uploaders: Sukchan Lee <acetcom@gmail.com>
9
 Homepage: https://open5gs.org
10
@@ -32,8 +32,8 @@
11
  open5gs-udr deb net optional arch=any
12
  open5gs-upf deb net optional arch=any
13
 Checksums-Sha1:
14
- 1a6471ddca77dd973e09bdc3f087e03ae40c3942 14495900 open5gs_2.7.1.39.dc2e1.202406292026.tar.xz
15
+ 3f4e25914c7b987f8b9d20b7885615c24f4d4808 14496172 open5gs_2.7.1.48.555c2.202406302026.tar.xz
16
 Checksums-Sha256:
17
- d0078850e3027046f2298d07f140810fa05498eac21373f570e21954b313029b 14495900 open5gs_2.7.1.39.dc2e1.202406292026.tar.xz
18
+ 196b81e7669588a696d887dfbc0deff7f33935c7bcb80d93fbd14ead3b56325e 14496172 open5gs_2.7.1.48.555c2.202406302026.tar.xz
19
 Files:
20
- bad65dc8af8fa7e13375b4dec57d8e7c 14495900 open5gs_2.7.1.39.dc2e1.202406292026.tar.xz
21
+ 1cb6f81f50f1ab8ce45aeb3c541c42ed 14496172 open5gs_2.7.1.48.555c2.202406302026.tar.xz
22
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/.tarball-version -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/.tarball-version Changed
4
 
1
@@ -1 +1 @@
2
-2.7.1.39-dc2e1.202406292026
3
+2.7.1.48-555c2.202406302026
4
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/debian/changelog -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/debian/changelog Changed
12
 
1
@@ -1,8 +1,8 @@
2
-open5gs (2.7.1.39.dc2e1.202406292026) unstable; urgency=medium
3
+open5gs (2.7.1.48.555c2.202406302026) unstable; urgency=medium
4
 
5
   * Automatically generated changelog entry for building the Osmocom nightly feed
6
 
7
- -- Osmocom OBS scripts <info@osmocom.org>  Sat, 29 Jun 2024 20:27:34 +0000
8
+ -- Osmocom OBS scripts <info@osmocom.org>  Sun, 30 Jun 2024 20:27:35 +0000
9
 
10
 open5gs (2.7.1) unstable; urgency=medium
11
 
12
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/core/ogs-macros.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/core/ogs-macros.h Changed
11
 
1
@@ -222,6 +222,9 @@
2
     ((__oBJ)->reference_count)--
3
 #define OGS_OBJECT_IS_REF(__oBJ) ((__oBJ)->reference_count > 1)
4
 
5
+#define OGS_POINTER_TO_UINT(u) ((uintptr_t)(u))
6
+#define OGS_UINT_TO_POINTER(u) ((void *)(uintptr_t)(u))
7
+
8
 #ifdef __cplusplus
9
 }
10
 #endif
11
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/core/ogs-pool.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/core/ogs-pool.h Changed
104
 
1
@@ -28,7 +28,11 @@
2
 extern "C" {
3
 #endif
4
 
5
-typedef uint32_t ogs_pool_id_t;
6
+#define OGS_INVALID_POOL_ID 0
7
+#define OGS_MIN_POOL_ID     1
8
+#define OGS_MAX_POOL_ID     0x7fffffff
9
+
10
+typedef int32_t ogs_pool_id_t;
11
 
12
 #define OGS_POOL(pool, type) \
13
     struct { \
14
@@ -36,6 +40,9 @@
15
         int head, tail; \
16
         int size, avail; \
17
         type **free, *array, **index; \
18
+        \
19
+        ogs_hash_t *id_hash; \
20
+        ogs_pool_id_t id; \
21
     } pool
22
 
23
 /*
24
@@ -57,6 +64,9 @@
25
         (pool)->freei = &((pool)->arrayi); \
26
         (pool)->indexi = NULL; \
27
     } \
28
+    \
29
+    (pool)->id_hash = ogs_hash_make(); \
30
+    ogs_assert((pool)->id_hash); \
31
 } while (0)
32
 
33
 /*
34
@@ -70,6 +80,9 @@
35
     free((pool)->free); \
36
     free((pool)->array); \
37
     free((pool)->index); \
38
+    \
39
+    ogs_assert((pool)->id_hash); \
40
+    ogs_hash_destroy((pool)->id_hash); \
41
 } while (0)
42
 
43
 /*
44
@@ -93,6 +106,9 @@
45
         (pool)->freei = &((pool)->arrayi); \
46
         (pool)->indexi = NULL; \
47
     } \
48
+    \
49
+    (pool)->id_hash = ogs_hash_make(); \
50
+    ogs_assert((pool)->id_hash); \
51
 } while (0)
52
 
53
 /*
54
@@ -108,14 +124,11 @@
55
     ogs_free((pool)->free); \
56
     ogs_free((pool)->array); \
57
     ogs_free((pool)->index); \
58
+    \
59
+    ogs_assert((pool)->id_hash); \
60
+    ogs_hash_destroy((pool)->id_hash); \
61
 } while (0)
62
 
63
-#define ogs_pool_index(pool, node) (((node) - (pool)->array)+1)
64
-#define ogs_pool_find(pool, _index) \
65
-    (_index > 0 && _index <= (pool)->size) ? (pool)->index_index-1 : NULL
66
-#define ogs_pool_cycle(pool, node) \
67
-    ogs_pool_find((pool), ogs_pool_index((pool), (node)))
68
-
69
 #define ogs_pool_alloc(pool, node) do { \
70
     *(node) = NULL; \
71
     if ((pool)->avail > 0) { \
72
@@ -136,6 +149,31 @@
73
     } \
74
 } while (0)
75
 
76
+#define ogs_pool_index(pool, node) (((node) - (pool)->array)+1)
77
+#define ogs_pool_find(pool, _index) \
78
+    (_index > 0 && _index <= (pool)->size) ? (pool)->index_index-1 : NULL
79
+
80
+#define ogs_pool_id_calloc(pool, node) do { \
81
+    ogs_pool_alloc(pool, node); \
82
+    if (*node) { \
83
+        memset(*(node), 0, sizeof(**(node))); \
84
+        (*(node))->id = OGS_NEXT_ID((pool)->id, 1, OGS_MAX_POOL_ID); \
85
+        ogs_hash_set((pool)->id_hash, \
86
+                &((*(node))->id), sizeof(ogs_pool_id_t), *(node)); \
87
+    } \
88
+} while (0)
89
+
90
+#define ogs_pool_id_free(pool, node) do { \
91
+    ogs_assert(((node)->id) >= OGS_MIN_POOL_ID && \
92
+            ((node)->id) <= OGS_MAX_POOL_ID); \
93
+    ogs_hash_set((pool)->id_hash, \
94
+            &((node)->id), sizeof(ogs_pool_id_t), NULL); \
95
+    ogs_pool_free(pool, node); \
96
+} while (0)
97
+
98
+#define ogs_pool_find_by_id(pool, id) \
99
+    ogs_hash_get((pool)->id_hash, &id, sizeof(ogs_pool_id_t))
100
+
101
 #define ogs_pool_size(pool) ((pool)->size)
102
 #define ogs_pool_avail(pool) ((pool)->avail)
103
 
104
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/core/ogs-timer.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/core/ogs-timer.c Changed
50
 
1
@@ -73,12 +73,6 @@
2
     ogs_free(manager);
3
 }
4
 
5
-static ogs_timer_t *ogs_timer_cycle(ogs_timer_mgr_t *manager, ogs_timer_t *timer)
6
-{
7
-    ogs_assert(manager);
8
-    return ogs_pool_cycle(&manager->pool, timer);
9
-}
10
-
11
 ogs_timer_t *ogs_timer_add(
12
         ogs_timer_mgr_t *manager, void (*cb)(void *data), void *data)
13
 {
14
@@ -106,11 +100,6 @@
15
     ogs_assert(timer);
16
     manager = timer->manager;
17
     ogs_assert(manager);
18
-    timer = ogs_timer_cycle(manager, timer);
19
-    if (!timer) {
20
-        ogs_fatal("ogs_timer_delete() failed in %s", file_line);
21
-        ogs_assert_if_reached();
22
-    }
23
 
24
     ogs_timer_stop(timer);
25
 
26
@@ -126,11 +115,6 @@
27
 
28
     manager = timer->manager;
29
     ogs_assert(manager);
30
-    timer = ogs_timer_cycle(manager, timer);
31
-    if (!timer) {
32
-        ogs_fatal("ogs_timer_start() failed in %s", file_line);
33
-        ogs_assert_if_reached();
34
-    }
35
 
36
     if (timer->running == true)
37
         ogs_rbtree_delete(&manager->tree, timer);
38
@@ -145,11 +129,6 @@
39
     ogs_assert(timer);
40
     manager = timer->manager;
41
     ogs_assert(manager);
42
-    timer = ogs_timer_cycle(manager, timer);
43
-    if (!timer) {
44
-        ogs_fatal("ogs_timer_stop() failed in %s", file_line);
45
-        ogs_assert_if_reached();
46
-    }
47
 
48
     if (timer->running == false)
49
         return;
50
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/gtp/xact.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/gtp/xact.c Changed
101
 
1
@@ -75,9 +75,8 @@
2
     ogs_assert(gnode);
3
     ogs_assert(hdesc);
4
 
5
-    ogs_pool_alloc(&pool, &xact);
6
+    ogs_pool_id_calloc(&pool, &xact);
7
     ogs_assert(xact);
8
-    memset(xact, 0, sizeof *xact);
9
     xact->index = ogs_pool_index(&pool, xact);
10
 
11
     xact->gtp_version = 1;
12
@@ -131,9 +130,8 @@
13
     ogs_assert(gnode);
14
     ogs_assert(hdesc);
15
 
16
-    ogs_pool_alloc(&pool, &xact);
17
+    ogs_pool_id_calloc(&pool, &xact);
18
     ogs_assert(xact);
19
-    memset(xact, 0, sizeof *xact);
20
     xact->index = ogs_pool_index(&pool, xact);
21
 
22
     xact->gtp_version = 2;
23
@@ -184,9 +182,8 @@
24
 
25
     ogs_assert(gnode);
26
 
27
-    ogs_pool_alloc(&pool, &xact);
28
+    ogs_pool_id_calloc(&pool, &xact);
29
     ogs_assert(xact);
30
-    memset(xact, 0, sizeof *xact);
31
     xact->index = ogs_pool_index(&pool, xact);
32
 
33
     xact->gtp_version = gtp_version;
34
@@ -216,9 +213,9 @@
35
     return xact;
36
 }
37
 
38
-ogs_gtp_xact_t *ogs_gtp_xact_cycle(ogs_gtp_xact_t *xact)
39
+ogs_gtp_xact_t *ogs_gtp_xact_find_by_id(ogs_pool_id_t id)
40
 {
41
-    return ogs_pool_cycle(&pool, xact);
42
+    return ogs_pool_find_by_id(&pool, id);
43
 }
44
 
45
 void ogs_gtp_xact_delete_all(ogs_gtp_node_t *gnode)
46
@@ -1134,11 +1131,11 @@
47
     ogs_assert(xact1);
48
     ogs_assert(xact2);
49
 
50
-    ogs_assert(xact1->assoc_xact == NULL);
51
-    ogs_assert(xact2->assoc_xact == NULL);
52
+    ogs_assert(xact1->assoc_xact_id == OGS_INVALID_POOL_ID);
53
+    ogs_assert(xact2->assoc_xact_id == OGS_INVALID_POOL_ID);
54
 
55
-    xact1->assoc_xact = xact2;
56
-    xact2->assoc_xact = xact1;
57
+    xact1->assoc_xact_id = xact2->id;
58
+    xact2->assoc_xact_id = xact1->id;
59
 }
60
 
61
 void ogs_gtp_xact_deassociate(ogs_gtp_xact_t *xact1, ogs_gtp_xact_t *xact2)
62
@@ -1146,16 +1143,17 @@
63
     ogs_assert(xact1);
64
     ogs_assert(xact2);
65
 
66
-    ogs_assert(xact1->assoc_xact != NULL);
67
-    ogs_assert(xact2->assoc_xact != NULL);
68
+    ogs_assert(xact1->assoc_xact_id != OGS_INVALID_POOL_ID);
69
+    ogs_assert(xact2->assoc_xact_id != OGS_INVALID_POOL_ID);
70
 
71
-    xact1->assoc_xact = NULL;
72
-    xact2->assoc_xact = NULL;
73
+    xact1->assoc_xact_id = OGS_INVALID_POOL_ID;
74
+    xact2->assoc_xact_id = OGS_INVALID_POOL_ID;
75
 }
76
 
77
 static int ogs_gtp_xact_delete(ogs_gtp_xact_t *xact)
78
 {
79
     char bufOGS_ADDRSTRLEN;
80
+    ogs_gtp_xact_t *assoc_xact = NULL;
81
 
82
     ogs_assert(xact);
83
     ogs_assert(xact->gnode);
84
@@ -1178,12 +1176,13 @@
85
     if (xact->tm_holding)
86
         ogs_timer_delete(xact->tm_holding);
87
 
88
-    if (xact->assoc_xact)
89
-        ogs_gtp_xact_deassociate(xact, xact->assoc_xact);
90
+    assoc_xact = ogs_gtp_xact_find_by_id(xact->assoc_xact_id);
91
+    if (assoc_xact)
92
+        ogs_gtp_xact_deassociate(xact, assoc_xact);
93
 
94
     ogs_list_remove(xact->org == OGS_GTP_LOCAL_ORIGINATOR ?
95
             &xact->gnode->local_list : &xact->gnode->remote_list, xact);
96
-    ogs_pool_free(&pool, xact);
97
+    ogs_pool_id_free(&pool, xact);
98
 
99
     return OGS_OK;
100
 }
101
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/gtp/xact.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/gtp/xact.h Changed
28
 
1
@@ -59,6 +59,8 @@
2
 typedef struct ogs_gtp_xact_s {
3
     ogs_lnode_t     node;           /**< A node of list */
4
 
5
+    ogs_pool_id_t   id;
6
+
7
     /*
8
      * Issues #3240
9
      *
10
@@ -110,7 +112,7 @@
11
     uint32_t        local_teid;     /**< Local TEID,
12
                                          expected in reply from peer */
13
 
14
-    void            *assoc_xact;    /**< Associated GTP transaction */
15
+    ogs_pool_id_t   assoc_xact_id;  /**< Associated GTP transaction ID */
16
     void            *pfcp_xact;     /**< Associated PFCP transaction */
17
 
18
 #define OGS_GTP_MODIFY_TFT_UPDATE ((uint64_t)1<<0)
19
@@ -159,7 +161,7 @@
20
         ogs_gtp2_header_t *hdesc, ogs_pkbuf_t *pkbuf,
21
         void (*cb)(ogs_gtp_xact_t *xact, void *data), void *data);
22
 
23
-ogs_gtp_xact_t *ogs_gtp_xact_cycle(ogs_gtp_xact_t *xact);
24
+ogs_gtp_xact_t *ogs_gtp_xact_find_by_id(ogs_pool_id_t id);
25
 void ogs_gtp_xact_delete_all(ogs_gtp_node_t *gnode);
26
 
27
 int ogs_gtp1_xact_update_tx(ogs_gtp_xact_t *xact,
28
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/pfcp/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/pfcp/context.c Changed
13
 
1
@@ -873,11 +873,6 @@
2
     return node;
3
 }
4
 
5
-ogs_pfcp_node_t *ogs_pfcp_node_cycle(ogs_pfcp_node_t *node)
6
-{
7
-    return ogs_pool_cycle(&ogs_pfcp_node_pool, node);
8
-}
9
-
10
 void ogs_pfcp_node_free(ogs_pfcp_node_t *node)
11
 {
12
     ogs_assert(node);
13
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/pfcp/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/pfcp/context.h Changed
9
 
1
@@ -393,7 +393,6 @@
2
 int ogs_pfcp_context_parse_config(const char *local, const char *remote);
3
 
4
 ogs_pfcp_node_t *ogs_pfcp_node_new(ogs_sockaddr_t *sa_list);
5
-ogs_pfcp_node_t *ogs_pfcp_node_cycle(ogs_pfcp_node_t *node);
6
 void ogs_pfcp_node_free(ogs_pfcp_node_t *node);
7
 
8
 ogs_pfcp_node_t *ogs_pfcp_node_add(
9
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/pfcp/xact.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/pfcp/xact.c Changed
44
 
1
@@ -75,9 +75,8 @@
2
 
3
     ogs_assert(node);
4
 
5
-    ogs_pool_alloc(&pool, &xact);
6
+    ogs_pool_id_calloc(&pool, &xact);
7
     ogs_assert(xact);
8
-    memset(xact, 0, sizeof *xact);
9
     xact->index = ogs_pool_index(&pool, xact);
10
 
11
     xact->org = OGS_PFCP_LOCAL_ORIGINATOR;
12
@@ -124,9 +123,8 @@
13
 
14
     ogs_assert(node);
15
 
16
-    ogs_pool_alloc(&pool, &xact);
17
+    ogs_pool_id_calloc(&pool, &xact);
18
     ogs_assert(xact);
19
-    memset(xact, 0, sizeof *xact);
20
     xact->index = ogs_pool_index(&pool, xact);
21
 
22
     xact->org = OGS_PFCP_REMOTE_ORIGINATOR;
23
@@ -171,6 +169,11 @@
24
         ogs_pfcp_xact_delete(xact);
25
 }
26
 
27
+ogs_pfcp_xact_t *ogs_pfcp_xact_find_by_id(ogs_pool_id_t id)
28
+{
29
+    return ogs_pool_find_by_id(&pool, id);
30
+}
31
+
32
 int ogs_pfcp_xact_update_tx(ogs_pfcp_xact_t *xact,
33
         ogs_pfcp_header_t *hdesc, ogs_pkbuf_t *pkbuf)
34
 {
35
@@ -802,7 +805,7 @@
36
 
37
     ogs_list_remove(xact->org == OGS_PFCP_LOCAL_ORIGINATOR ?
38
             &xact->node->local_list : &xact->node->remote_list, xact);
39
-    ogs_pool_free(&pool, xact);
40
+    ogs_pool_id_free(&pool, xact);
41
 
42
     return OGS_OK;
43
 }
44
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/pfcp/xact.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/pfcp/xact.h Changed
34
 
1
@@ -35,6 +35,8 @@
2
     ogs_lnode_t     lnode;          /**< A node of list */
3
     ogs_lnode_t     tmpnode;        /**< A node of temp-list */
4
 
5
+    ogs_pool_id_t   id;
6
+
7
     ogs_pool_id_t   index;
8
 
9
 #define OGS_PFCP_LOCAL_ORIGINATOR  0
10
@@ -68,13 +70,13 @@
11
     uint64_t        local_seid;     /**< Local SEID,
12
                                          expected in reply from peer */
13
 
14
-    void            *assoc_xact;    /**< Associated GTP transaction */
15
+    ogs_pool_id_t   assoc_xact_id;  /**< Associated GTP transaction ID */
16
     ogs_pkbuf_t     *gtpbuf;        /**< GTP packet buffer */
17
 
18
     uint8_t         gtp_pti;        /**< GTP Procedure transaction identity */
19
     uint8_t         gtp_cause;      /**< GTP Cause Value */
20
 
21
-    void            *assoc_stream;  /**< Associated SBI session */
22
+    ogs_pool_id_t   assoc_stream_id;  /**< Associated SBI session ID */
23
 
24
     bool            epc;            /**< EPC or 5GC */
25
 
26
@@ -134,6 +136,7 @@
27
 ogs_pfcp_xact_t *ogs_pfcp_xact_local_create(ogs_pfcp_node_t *node,
28
         void (*cb)(ogs_pfcp_xact_t *xact, void *data), void *data);
29
 void ogs_pfcp_xact_delete_all(ogs_pfcp_node_t *node);
30
+ogs_pfcp_xact_t *ogs_pfcp_xact_find_by_id(ogs_pool_id_t id);
31
 
32
 int ogs_pfcp_xact_update_tx(ogs_pfcp_xact_t *xact,
33
         ogs_pfcp_header_t *hdesc, ogs_pkbuf_t *pkbuf);
34
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/context.c Changed
80
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -2257,6 +2257,7 @@
9
 }
10
 
11
 ogs_sbi_xact_t *ogs_sbi_xact_add(
12
+        ogs_pool_id_t sbi_object_id,
13
         ogs_sbi_object_t *sbi_object,
14
         ogs_sbi_service_type_e service_type,
15
         ogs_sbi_discovery_option_t *discovery_option,
16
@@ -2266,13 +2267,13 @@
17
 
18
     ogs_assert(sbi_object);
19
 
20
-    ogs_pool_alloc(&xact_pool, &xact);
21
+    ogs_pool_id_calloc(&xact_pool, &xact);
22
     if (!xact) {
23
-        ogs_error("ogs_pool_alloc() failed");
24
+        ogs_error("ogs_pool_id_calloc() failed");
25
         return NULL;
26
     }
27
-    memset(xact, 0, sizeof(ogs_sbi_xact_t));
28
 
29
+    xact->sbi_object_id = sbi_object_id;
30
     xact->sbi_object = sbi_object;
31
     xact->service_type = service_type;
32
     xact->requester_nf_type = NF_INSTANCE_TYPE(ogs_sbi_self()->nf_instance);
33
@@ -2301,13 +2302,14 @@
34
     xact->discovery_option = discovery_option;
35
 
36
     xact->t_response = ogs_timer_add(
37
-            ogs_app()->timer_mgr, ogs_timer_sbi_client_wait_expire, xact);
38
+            ogs_app()->timer_mgr, ogs_timer_sbi_client_wait_expire,
39
+            OGS_UINT_TO_POINTER(xact->id));
40
     if (!xact->t_response) {
41
         ogs_error("ogs_timer_add() failed");
42
 
43
         if (xact->discovery_option)
44
             ogs_sbi_discovery_option_free(xact->discovery_option);
45
-        ogs_pool_free(&xact_pool, xact);
46
+        ogs_pool_id_free(&xact_pool, xact);
47
 
48
         return NULL;
49
     }
50
@@ -2324,7 +2326,7 @@
51
                 ogs_sbi_discovery_option_free(xact->discovery_option);
52
 
53
             ogs_timer_delete(xact->t_response);
54
-            ogs_pool_free(&xact_pool, xact);
55
+            ogs_pool_id_free(&xact_pool, xact);
56
 
57
             return NULL;
58
         }
59
@@ -2383,7 +2385,7 @@
60
         ogs_free(xact->target_apiroot);
61
 
62
     ogs_list_remove(&sbi_object->xact_list, xact);
63
-    ogs_pool_free(&xact_pool, xact);
64
+    ogs_pool_id_free(&xact_pool, xact);
65
 }
66
 
67
 void ogs_sbi_xact_remove_all(ogs_sbi_object_t *sbi_object)
68
@@ -2396,9 +2398,9 @@
69
         ogs_sbi_xact_remove(xact);
70
 }
71
 
72
-ogs_sbi_xact_t *ogs_sbi_xact_cycle(ogs_sbi_xact_t *xact)
73
+ogs_sbi_xact_t *ogs_sbi_xact_find_by_id(ogs_pool_id_t id)
74
 {
75
-    return ogs_pool_cycle(&xact_pool, xact);
76
+    return ogs_pool_find_by_id(&xact_pool, id);
77
 }
78
 
79
 ogs_sbi_subscription_spec_t *ogs_sbi_subscription_spec_add(
80
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/context.h Changed
41
 
1
@@ -216,6 +216,8 @@
2
 typedef struct ogs_sbi_xact_s {
3
     ogs_lnode_t lnode;
4
 
5
+    ogs_pool_id_t id;
6
+
7
     ogs_sbi_service_type_e service_type;
8
     OpenAPI_nf_type_e requester_nf_type;
9
     ogs_sbi_discovery_option_t *discovery_option;
10
@@ -223,11 +225,13 @@
11
     ogs_sbi_request_t *request;
12
     ogs_timer_t *t_response;
13
 
14
-    ogs_sbi_stream_t *assoc_stream;
15
+    ogs_pool_id_t assoc_stream_id;
16
+
17
     int state;
18
     char *target_apiroot;
19
 
20
     ogs_sbi_object_t *sbi_object;
21
+    ogs_pool_id_t sbi_object_id;
22
 } ogs_sbi_xact_t;
23
 
24
 typedef struct ogs_sbi_nf_service_s {
25
@@ -539,13 +543,14 @@
26
 void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object);
27
 
28
 ogs_sbi_xact_t *ogs_sbi_xact_add(
29
+        ogs_pool_id_t sbi_object_id,
30
         ogs_sbi_object_t *sbi_object,
31
         ogs_sbi_service_type_e service_type,
32
         ogs_sbi_discovery_option_t *discovery_option,
33
         ogs_sbi_build_f build, void *context, void *data);
34
 void ogs_sbi_xact_remove(ogs_sbi_xact_t *xact);
35
 void ogs_sbi_xact_remove_all(ogs_sbi_object_t *sbi_object);
36
-ogs_sbi_xact_t *ogs_sbi_xact_cycle(ogs_sbi_xact_t *xact);
37
+ogs_sbi_xact_t *ogs_sbi_xact_find_by_id(ogs_pool_id_t id);
38
 
39
 ogs_sbi_subscription_spec_t *ogs_sbi_subscription_spec_add(
40
         OpenAPI_nf_type_e nf_type, const char *service_name);
41
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/mhd-server.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/mhd-server.c Changed
106
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019,2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -41,6 +41,9 @@
9
 
10
 static ogs_sbi_server_t *server_from_stream(ogs_sbi_stream_t *stream);
11
 
12
+static ogs_pool_id_t id_from_stream(ogs_sbi_stream_t *stream);
13
+static void *stream_find_by_id(ogs_pool_id_t id);
14
+
15
 const ogs_sbi_server_actions_t ogs_mhd_server_actions = {
16
     server_init,
17
     server_final,
18
@@ -52,6 +55,8 @@
19
     server_send_response,
20
 
21
     server_from_stream,
22
+    id_from_stream,
23
+    stream_find_by_id,
24
 };
25
 
26
 static void run(short when, ogs_socket_t fd, void *data);
27
@@ -79,6 +84,8 @@
28
 typedef struct ogs_sbi_session_s {
29
     ogs_lnode_t             lnode;
30
 
31
+    ogs_pool_id_t           id;
32
+
33
     struct MHD_Connection   *connection;
34
 
35
     ogs_sbi_request_t       *request;
36
@@ -125,9 +132,8 @@
37
     ogs_assert(request);
38
     ogs_assert(connection);
39
 
40
-    ogs_pool_alloc(&session_pool, &sbi_sess);
41
+    ogs_pool_id_calloc(&session_pool, &sbi_sess);
42
     ogs_assert(sbi_sess);
43
-    memset(sbi_sess, 0, sizeof(ogs_sbi_session_t));
44
 
45
     sbi_sess->server = server;
46
     sbi_sess->request = request;
47
@@ -137,7 +143,7 @@
48
             ogs_app()->timer_mgr, session_timer_expired, sbi_sess);
49
     if (!sbi_sess->timer) {
50
         ogs_error("ogs_timer_add() failed");
51
-        ogs_pool_free(&session_pool, sbi_sess);
52
+        ogs_pool_id_free(&session_pool, sbi_sess);
53
         return NULL;
54
     }
55
 
56
@@ -170,7 +176,7 @@
57
 
58
     MHD_resume_connection(connection);
59
 
60
-    ogs_pool_free(&session_pool, sbi_sess);
61
+    ogs_pool_id_free(&session_pool, sbi_sess);
62
 }
63
 
64
 static void session_timer_expired(void *data)
65
@@ -320,12 +326,8 @@
66
     ogs_sbi_session_t *sbi_sess = NULL;
67
 
68
     ogs_assert(response);
69
-
70
-    sbi_sess = ogs_pool_cycle(&session_pool, (ogs_sbi_session_t *)stream);
71
-    if (!sbi_sess) {
72
-        ogs_error("session has already been removed");
73
-        return true;
74
-    }
75
+    sbi_sess = (ogs_sbi_session_t *)stream;
76
+    ogs_assert(sbi_sess);
77
 
78
     connection = sbi_sess->connection;
79
     ogs_assert(connection);
80
@@ -571,7 +573,7 @@
81
     ogs_assert(sbi_sess);
82
 
83
     ogs_assert(server->cb);
84
-    if (server->cb(request, sbi_sess) != OGS_OK) {
85
+    if (server->cb(request, OGS_UINT_TO_POINTER(sbi_sess->id)) != OGS_OK) {
86
         ogs_warn("server callback error");
87
         ogs_assert(true ==
88
                 ogs_sbi_server_send_error((ogs_sbi_stream_t *)sbi_sess,
89
@@ -608,3 +610,16 @@
90
 
91
     return sbi_sess->server;
92
 }
93
+
94
+static ogs_pool_id_t id_from_stream(ogs_sbi_stream_t *stream)
95
+{
96
+    ogs_sbi_session_t *sbi_sess = (ogs_sbi_session_t *)stream;
97
+
98
+    ogs_assert(sbi_sess);
99
+    return sbi_sess->id;
100
+}
101
+
102
+static void *stream_find_by_id(ogs_pool_id_t id)
103
+{
104
+    return ogs_pool_find_by_id(&session_pool, id);
105
+}
106
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/nghttp2-server.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/nghttp2-server.c Changed
120
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019,2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -39,6 +39,9 @@
9
 
10
 static ogs_sbi_server_t *server_from_stream(ogs_sbi_stream_t *stream);
11
 
12
+static ogs_pool_id_t id_from_stream(ogs_sbi_stream_t *stream);
13
+static void *stream_find_by_id(ogs_pool_id_t id);
14
+
15
 const ogs_sbi_server_actions_t ogs_nghttp2_server_actions = {
16
     server_init,
17
     server_final,
18
@@ -50,6 +53,9 @@
19
     server_send_response,
20
 
21
     server_from_stream,
22
+
23
+    id_from_stream,
24
+    stream_find_by_id,
25
 };
26
 
27
 struct h2_settings {
28
@@ -81,6 +87,8 @@
29
 typedef struct ogs_sbi_stream_s {
30
     ogs_lnode_t             lnode;
31
 
32
+    ogs_pool_id_t           id;
33
+
34
     int32_t                 stream_id;
35
     ogs_sbi_request_t       *request;
36
     bool                    memory_overflow;
37
@@ -360,7 +368,9 @@
38
                         SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
39
                         verify_callback);
40
 
41
-            context = ogs_sbi_server_id_context(server);
42
+            ogs_assert(server->id >= OGS_MIN_POOL_ID &&
43
+                    server->id <= OGS_MAX_POOL_ID);
44
+            context = ogs_msprintf("%d", server->id);
45
             if (!context) {
46
                 ogs_error("ogs_sbi_server_id_context() failed");
47
 
48
@@ -580,12 +590,7 @@
49
         return false;
50
     }
51
 
52
-    stream = ogs_pool_cycle(&stream_pool, stream);
53
-    if (!stream) {
54
-        ogs_error("stream has already been removed");
55
-        return true;
56
-    }
57
-
58
+    ogs_assert(stream);
59
     sbi_sess = stream->session;
60
     ogs_assert(sbi_sess);
61
     ogs_assert(sbi_sess->session);
62
@@ -706,17 +711,16 @@
63
 
64
     ogs_assert(sbi_sess);
65
 
66
-    ogs_pool_alloc(&stream_pool, &stream);
67
+    ogs_pool_id_calloc(&stream_pool, &stream);
68
     if (!stream) {
69
-        ogs_error("ogs_pool_alloc() failed");
70
+        ogs_error("ogs_pool_id_calloc() failed");
71
         return NULL;
72
     }
73
-    memset(stream, 0, sizeof(ogs_sbi_stream_t));
74
 
75
     stream->request = ogs_sbi_request_new();
76
     if (!stream->request) {
77
         ogs_error("ogs_sbi_request_new() failed");
78
-        ogs_pool_free(&stream_pool, stream);
79
+        ogs_pool_id_free(&stream_pool, stream);
80
         return NULL;
81
     }
82
 
83
@@ -743,7 +747,7 @@
84
     ogs_assert(stream->request);
85
     ogs_sbi_request_free(stream->request);
86
 
87
-    ogs_pool_free(&stream_pool, stream);
88
+    ogs_pool_id_free(&stream_pool, stream);
89
 }
90
 
91
 static void stream_remove_all(ogs_sbi_session_t *sbi_sess)
92
@@ -756,6 +760,17 @@
93
         stream_remove(stream);
94
 }
95
 
96
+static ogs_pool_id_t id_from_stream(ogs_sbi_stream_t *stream)
97
+{
98
+    ogs_assert(stream);
99
+    return stream->id;
100
+}
101
+
102
+static void *stream_find_by_id(ogs_pool_id_t id)
103
+{
104
+    return ogs_pool_find_by_id(&stream_pool, id);
105
+}
106
+
107
 static ogs_sbi_session_t *session_add(
108
         ogs_sbi_server_t *server, ogs_sock_t *sock)
109
 {
110
@@ -1169,7 +1184,8 @@
111
                 break;
112
             }
113
 
114
-            if (server->cb(request, stream) != OGS_OK) {
115
+            if (server->cb(request,
116
+                        OGS_UINT_TO_POINTER(stream->id)) != OGS_OK) {
117
                 ogs_warn("server callback error");
118
                 ogs_assert(true ==
119
                     ogs_sbi_server_send_error(stream,
120
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/path.c Changed
139
 
1
@@ -90,6 +90,7 @@
2
     ogs_event_t *e = NULL;
3
 
4
     ogs_sbi_xact_t *xact = NULL;
5
+    ogs_pool_id_t xact_id = 0;
6
     ogs_sbi_object_t *sbi_object = NULL;
7
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
8
     ogs_sbi_discovery_option_t *discovery_option = NULL;
9
@@ -99,10 +100,10 @@
10
     ogs_hash_index_t *hi = NULL;
11
     char *producer_id = NULL;
12
 
13
-    xact = data;
14
-    ogs_assert(xact);
15
+    xact_id = OGS_POINTER_TO_UINT(data);
16
+    ogs_assert(xact_id >= OGS_MIN_POOL_ID && xact_id <= OGS_MAX_POOL_ID);
17
 
18
-    xact = ogs_sbi_xact_cycle(xact);
19
+    xact = ogs_sbi_xact_find_by_id(xact_id);
20
     if (!xact) {
21
         ogs_error("SBI transaction has already been removed");
22
         if (response)
23
@@ -349,7 +350,8 @@
24
             ogs_free(apiroot);
25
 
26
             rc = ogs_sbi_client_send_via_scp_or_sepp(
27
-                    scp_client, ogs_sbi_client_handler, request, xact);
28
+                    scp_client, ogs_sbi_client_handler, request,
29
+                    OGS_UINT_TO_POINTER(xact->id));
30
             ogs_expect(rc == true);
31
             return (rc == true) ? OGS_OK : OGS_ERROR;
32
 
33
@@ -486,7 +488,8 @@
34
             }
35
 
36
             rc = ogs_sbi_client_send_via_scp_or_sepp(
37
-                    scp_client, client_discover_cb, request, xact);
38
+                    scp_client, client_discover_cb, request,
39
+                    OGS_UINT_TO_POINTER(xact->id));
40
             ogs_expect(rc == true);
41
             return (rc == true) ? OGS_OK : OGS_ERROR;
42
         }
43
@@ -498,7 +501,8 @@
44
 
45
         /* If `client` instance is available, use direct communication */
46
         rc = ogs_sbi_send_request_to_client(
47
-                client, ogs_sbi_client_handler, request, xact);
48
+                client, ogs_sbi_client_handler, request,
49
+                OGS_UINT_TO_POINTER(xact->id));
50
         ogs_expect(rc == true);
51
         return (rc == true) ? OGS_OK : OGS_ERROR;
52
 
53
@@ -558,7 +562,8 @@
54
         }
55
 
56
         rc = ogs_sbi_client_send_request(
57
-                client, ogs_sbi_client_handler, request, xact);
58
+                client, ogs_sbi_client_handler, request,
59
+                OGS_UINT_TO_POINTER(xact->id));
60
         ogs_expect(rc == true);
61
 
62
         ogs_sbi_request_free(request);
63
@@ -680,7 +685,8 @@
64
             }
65
 
66
             rc = ogs_sbi_client_send_request(
67
-                    nrf_client, sepp_discover_handler, nrf_request, xact);
68
+                    nrf_client, sepp_discover_handler, nrf_request,
69
+                    OGS_UINT_TO_POINTER(xact->id));
70
             if (rc == false) {
71
                 ogs_error("ogs_sbi_client_send_request() failed");
72
                 ogs_sbi_xact_remove(xact);
73
@@ -693,7 +699,8 @@
74
     }
75
 
76
     rc = ogs_sbi_send_request_to_client(
77
-            client, ogs_sbi_client_handler, request, xact);
78
+            client, ogs_sbi_client_handler, request,
79
+            OGS_UINT_TO_POINTER(xact->id));
80
     if (rc == false) {
81
         ogs_error("ogs_sbi_send_request_to_client() failed");
82
         ogs_sbi_xact_remove(xact);
83
@@ -856,26 +863,40 @@
84
     char *strerror = NULL;
85
     ogs_sbi_message_t message;
86
 
87
-    ogs_sbi_xact_t *xact = data;
88
+    ogs_sbi_xact_t *xact = NULL;
89
+    ogs_pool_id_t xact_id = 0;
90
 
91
     ogs_sbi_request_t *request = NULL;
92
     ogs_sbi_client_t *scp_client = NULL, *sepp_client = NULL;
93
 
94
-    ogs_assert(xact);
95
-    request = xact->request;
96
-    ogs_assert(request);
97
+    xact_id = OGS_POINTER_TO_UINT(data);
98
+    ogs_assert(xact_id >= OGS_MIN_POOL_ID && xact_id <= OGS_MAX_POOL_ID);
99
 
100
-    if (status != OGS_OK) {
101
+    xact = ogs_sbi_xact_find_by_id(xact_id);
102
+    if (!xact) {
103
+        ogs_error("SBI transaction has already been removed");
104
+        if (response)
105
+            ogs_sbi_response_free(response);
106
 
107
+        return OGS_ERROR;
108
+    }
109
+
110
+    if (status != OGS_OK) {
111
         ogs_log_message(
112
                 status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0,
113
                 "sepp_discover_handler() failed %d", status);
114
 
115
+        if (response)
116
+            ogs_sbi_response_free(response);
117
+
118
         ogs_sbi_xact_remove(xact);
119
+
120
         return OGS_ERROR;
121
     }
122
 
123
     ogs_assert(response);
124
+    request = xact->request;
125
+    ogs_assert(request);
126
 
127
     rv = ogs_sbi_parse_response(&message, response);
128
     if (rv != OGS_OK) {
129
@@ -915,7 +936,8 @@
130
 
131
     if (false == ogs_sbi_client_send_via_scp_or_sepp(
132
                 scp_client ? scp_client : sepp_client,
133
-                ogs_sbi_client_handler, request, xact)) {
134
+                ogs_sbi_client_handler, request,
135
+                OGS_UINT_TO_POINTER(xact->id))) {
136
         strerror = ogs_msprintf("ogs_sbi_client_send_via_scp_or_sepp() failed");
137
         goto cleanup;
138
     }
139
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/server.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/server.c Changed
49
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019,2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -62,9 +62,8 @@
9
     ogs_assert(addr);
10
     ogs_assert(scheme);
11
 
12
-    ogs_pool_alloc(&server_pool, &server);
13
+    ogs_pool_id_calloc(&server_pool, &server);
14
     ogs_assert(server);
15
-    memset(server, 0, sizeof(ogs_sbi_server_t));
16
 
17
     if (interface)
18
         server->interface = ogs_strdup(interface);
19
@@ -114,7 +113,7 @@
20
     if (server->cert)
21
         ogs_free(server->cert);
22
 
23
-    ogs_pool_free(&server_pool, server);
24
+    ogs_pool_id_free(&server_pool, server);
25
 }
26
 
27
 void ogs_sbi_server_remove_all(void)
28
@@ -238,12 +237,17 @@
29
 
30
 ogs_sbi_server_t *ogs_sbi_server_from_stream(ogs_sbi_stream_t *stream)
31
 {
32
-    return ogs_sbi_server_actions.from_stream(stream);
33
+    return ogs_sbi_server_actions.server_from_stream(stream);
34
 }
35
 
36
-char *ogs_sbi_server_id_context(ogs_sbi_server_t *server)
37
+ogs_pool_id_t ogs_sbi_id_from_stream(ogs_sbi_stream_t *stream)
38
 {
39
-    return ogs_msprintf("%d", (int)ogs_pool_index(&server_pool, server));
40
+    return ogs_sbi_server_actions.id_from_stream(stream);
41
+}
42
+
43
+void *ogs_sbi_stream_find_by_id(ogs_pool_id_t id)
44
+{
45
+    return ogs_sbi_server_actions.stream_find_by_id(id);
46
 }
47
 
48
 static ogs_sbi_server_t *ogs_sbi_server_find_by_interface(
49
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/lib/sbi/server.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/lib/sbi/server.h Changed
40
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019,2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -37,6 +37,8 @@
9
     ogs_socknode_t  node;
10
     ogs_sockaddr_t  *advertise;
11
 
12
+    ogs_pool_id_t   id;
13
+
14
     char *interface;
15
     OpenAPI_uri_scheme_e scheme;
16
     char *private_key, *cert;
17
@@ -64,7 +66,10 @@
18
     bool (*send_response)(
19
             ogs_sbi_stream_t *stream, ogs_sbi_response_t *response);
20
 
21
-    ogs_sbi_server_t *(*from_stream)(ogs_sbi_stream_t *stream);
22
+    ogs_sbi_server_t *(*server_from_stream)(ogs_sbi_stream_t *stream);
23
+
24
+    ogs_pool_id_t (*id_from_stream)(ogs_sbi_stream_t *stream);
25
+    void *(*stream_find_by_id)(ogs_pool_id_t id);
26
 } ogs_sbi_server_actions_t;
27
 
28
 void ogs_sbi_server_init(int num_of_session_pool, int num_of_stream_pool);
29
@@ -96,7 +101,9 @@
30
         ogs_sbi_stream_t *stream, OpenAPI_problem_details_t *problem);
31
 
32
 ogs_sbi_server_t *ogs_sbi_server_from_stream(ogs_sbi_stream_t *stream);
33
-char *ogs_sbi_server_id_context(ogs_sbi_server_t *server);
34
+
35
+ogs_pool_id_t ogs_sbi_id_from_stream(ogs_sbi_stream_t *stream);
36
+void *ogs_sbi_stream_find_by_id(ogs_pool_id_t id);
37
 
38
 ogs_sbi_server_t *ogs_sbi_server_first(void);
39
 ogs_sbi_server_t *ogs_sbi_server_next(ogs_sbi_server_t *current);
40
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/amf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/amf-sm.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -64,9 +64,12 @@
9
     amf_sess_t *sess = NULL;
10
 
11
     ogs_sbi_object_t *sbi_object = NULL;
12
+    ogs_pool_id_t sbi_object_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_xact_t *sbi_xact = NULL;
14
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
15
     int state = AMF_CREATE_SM_CONTEXT_NO_STATE;
16
     ogs_sbi_stream_t *stream = NULL;
17
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
18
     ogs_sbi_request_t *sbi_request = NULL;
19
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
20
 
21
@@ -89,8 +92,16 @@
22
     case OGS_EVENT_SBI_SERVER:
23
         sbi_request = e->h.sbi.request;
24
         ogs_assert(sbi_request);
25
-        stream = e->h.sbi.data;
26
-        ogs_assert(stream);
27
+
28
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
29
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
30
+                stream_id <= OGS_MAX_POOL_ID);
31
+
32
+        stream = ogs_sbi_stream_find_by_id(stream_id);
33
+        if (!stream) {
34
+            ogs_error("STREAM has already been removed %d", stream_id);
35
+            break;
36
+        }
37
 
38
         rv = ogs_sbi_parse_request(&sbi_message, sbi_request);
39
         if (rv != OGS_OK) {
40
@@ -365,8 +376,18 @@
41
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
42
             SWITCH(sbi_message.h.resource.component0)
43
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
44
-                sbi_xact = e->h.sbi.data;
45
-                ogs_assert(sbi_xact);
46
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
47
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
48
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
49
+
50
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
51
+                if (!sbi_xact) {
52
+                    /* CLIENT_WAIT timer could remove SBI transaction
53
+                     * before receiving SBI message */
54
+                    ogs_error("SBI transaction has already been removed %d",
55
+                            sbi_xact_id);
56
+                    break;
57
+                }
58
 
59
                 SWITCH(sbi_message.h.method)
60
                 CASE(OGS_SBI_HTTP_METHOD_GET)
61
@@ -395,25 +416,28 @@
62
         CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM)
63
         CASE(OGS_SBI_SERVICE_NAME_NPCF_AM_POLICY_CONTROL)
64
         CASE(OGS_SBI_SERVICE_NAME_NAMF_COMM)
65
-            sbi_xact = e->h.sbi.data;
66
-            ogs_assert(sbi_xact);
67
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
68
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
69
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
70
 
71
-            sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
72
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
73
             if (!sbi_xact) {
74
                 /* CLIENT_WAIT timer could remove SBI transaction
75
                  * before receiving SBI message */
76
-                ogs_error("SBI transaction has already been removed");
77
+                ogs_error("SBI transaction has already been removed %d",
78
+                        sbi_xact_id);
79
                 break;
80
             }
81
 
82
             state = sbi_xact->state;
83
 
84
-            amf_ue = (amf_ue_t *)sbi_xact->sbi_object;
85
-            ogs_assert(amf_ue);
86
+            sbi_object_id = sbi_xact->sbi_object_id;
87
+            ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
88
+                    sbi_object_id <= OGS_MAX_POOL_ID);
89
 
90
             ogs_sbi_xact_remove(sbi_xact);
91
 
92
-            amf_ue = amf_ue_cycle(amf_ue);
93
+            amf_ue = amf_ue_find_by_id(sbi_object_id);
94
             if (!amf_ue) {
95
                 ogs_error("UE(amf_ue) Context has already been removed");
96
                 break;
97
@@ -421,7 +445,7 @@
98
 
99
             ogs_assert(OGS_FSM_STATE(&amf_ue->sm));
100
 
101
-            e->amf_ue = amf_ue;
102
+            e->amf_ue_id = amf_ue->id;
103
             e->h.sbi.message = &sbi_message;;
104
             e->h.sbi.state = state;
105
 
106
@@ -429,25 +453,28 @@
107
             break;
108
 
109
         CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)
110
-            sbi_xact = e->h.sbi.data;
111
-            ogs_assert(sbi_xact);
112
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
113
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
114
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
115
 
116
-            sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
117
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
118
             if (!sbi_xact) {
119
                 /* CLIENT_WAIT timer could remove SBI transaction
120
                  * before receiving SBI message */
121
-                ogs_error("SBI transaction has already been removed");
122
+                ogs_error("SBI transaction has already been removed %d",
123
+                        sbi_xact_id);
124
                 break;
125
             }
126
 
127
             state = sbi_xact->state;
128
 
129
-            sess = (amf_sess_t *)sbi_xact->sbi_object;
130
-            ogs_assert(sess);
131
+            sbi_object_id = sbi_xact->sbi_object_id;
132
+            ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
133
+                    sbi_object_id <= OGS_MAX_POOL_ID);
134
 
135
             ogs_sbi_xact_remove(sbi_xact);
136
 
137
-            sess = amf_sess_cycle(sess);
138
+            sess = amf_sess_find_by_id(sbi_object_id);
139
             if (!sess) {
140
             /*
141
              * 1. If AMF-UE context is duplicated in Identity-Response,
142
@@ -485,15 +512,16 @@
143
                 break;
144
             }
145
 
146
-            amf_ue = sess->amf_ue;
147
-            ogs_assert(amf_ue);
148
-            amf_ue = amf_ue_cycle(amf_ue);
149
-            ogs_assert(amf_ue);
150
+            amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
151
+            if (!amf_ue) {
152
+                ogs_error("UE(amf-ue) context has already been removed");
153
+                break;
154
+            }
155
 
156
             ogs_assert(OGS_FSM_STATE(&amf_ue->sm));
157
 
158
-            e->amf_ue = amf_ue;
159
-            e->sess = sess;
160
+            e->amf_ue_id = amf_ue->id;
161
+            e->sess_id = sess->id;
162
             e->h.sbi.message = &sbi_message;;
163
 
164
             SWITCH(sbi_message.h.resource.component2)
165
@@ -545,39 +573,43 @@
166
             break;
167
 
168
         CASE(OGS_SBI_SERVICE_NAME_NNSSF_NSSELECTION)
169
-            sbi_xact = e->h.sbi.data;
170
-            ogs_assert(sbi_xact);
171
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
172
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
173
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
174
 
175
-            sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
176
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
177
             if (!sbi_xact) {
178
                 /* CLIENT_WAIT timer could remove SBI transaction
179
                  * before receiving SBI message */
180
-                ogs_error("SBI transaction has already been removed");
181
+                ogs_error("SBI transaction has already been removed %d",
182
+                        sbi_xact_id);
183
                 break;
184
             }
185
 
186
-            sess = (amf_sess_t *)sbi_xact->sbi_object;
187
-            ogs_assert(sess);
188
+            sbi_object_id = sbi_xact->sbi_object_id;
189
+            ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
190
+                    sbi_object_id <= OGS_MAX_POOL_ID);
191
 
192
             state = sbi_xact->state;
193
 
194
             ogs_sbi_xact_remove(sbi_xact);
195
 
196
-            sess = amf_sess_cycle(sess);
197
+            sess = amf_sess_find_by_id(sbi_object_id);
198
             if (!sess) {
199
                 ogs_error("Session has already been removed");
200
                 break;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/context.c Changed
201
 
1
@@ -1201,9 +1201,11 @@
2
     ogs_assert(sock);
3
     ogs_assert(addr);
4
 
5
-    ogs_pool_alloc(&amf_gnb_pool, &gnb);
6
-    ogs_assert(gnb);
7
-    memset(gnb, 0, sizeof *gnb);
8
+    ogs_pool_id_calloc(&amf_gnb_pool, &gnb);
9
+    if (!gnb) {
10
+        ogs_error("ogs_pool_id_calloc() failed");
11
+        return NULL;
12
+    }
13
 
14
     /* Defaut RAT-Type */
15
     gnb->rat_type = OpenAPI_rat_type_NR;
16
@@ -1227,7 +1229,7 @@
17
             gnb->sctp.addr, sizeof(ogs_sockaddr_t), gnb);
18
 
19
     memset(&e, 0, sizeof(e));
20
-    e.gnb = gnb;
21
+    e.gnb_id = gnb->id;
22
     ogs_fsm_init(&gnb->sm, ngap_state_initial, ngap_state_final, &e);
23
 
24
     ogs_list_add(&self.gnb_list, gnb);
25
@@ -1249,7 +1251,7 @@
26
     ogs_list_remove(&self.gnb_list, gnb);
27
 
28
     memset(&e, 0, sizeof(e));
29
-    e.gnb = gnb;
30
+    e.gnb_id = gnb->id;
31
     ogs_fsm_fini(&gnb->sm, &e);
32
 
33
     ogs_hash_set(self.gnb_addr_hash,
34
@@ -1258,7 +1260,7 @@
35
 
36
     ogs_sctp_flush_and_destroy(&gnb->sctp);
37
 
38
-    ogs_pool_free(&amf_gnb_pool, gnb);
39
+    ogs_pool_id_free(&amf_gnb_pool, gnb);
40
     amf_metrics_inst_global_dec(AMF_METR_GLOB_GAUGE_GNB);
41
     ogs_info("Removed Number of gNBs is now %d",
42
             ogs_list_count(&self.gnb_list));
43
@@ -1313,9 +1315,9 @@
44
     return SOCK_STREAM;
45
 }
46
 
47
-amf_gnb_t *amf_gnb_cycle(amf_gnb_t *gnb)
48
+amf_gnb_t *amf_gnb_find_by_id(ogs_pool_id_t id)
49
 {
50
-    return ogs_pool_cycle(&amf_gnb_pool, gnb);
51
+    return ogs_pool_find_by_id(&amf_gnb_pool, id);
52
 }
53
 
54
 /** ran_ue_context handling function */
55
@@ -1325,19 +1327,18 @@
56
 
57
     ogs_assert(gnb);
58
 
59
-    ogs_pool_alloc(&ran_ue_pool, &ran_ue);
60
+    ogs_pool_id_calloc(&ran_ue_pool, &ran_ue);
61
     if (ran_ue == NULL) {
62
         ogs_error("Could not allocate ran_ue context from pool");
63
         return NULL;
64
     }
65
 
66
-    memset(ran_ue, 0, sizeof *ran_ue);
67
-
68
     ran_ue->t_ng_holding = ogs_timer_add(
69
-            ogs_app()->timer_mgr, amf_timer_ng_holding_timer_expire, ran_ue);
70
+            ogs_app()->timer_mgr, amf_timer_ng_holding_timer_expire,
71
+            OGS_UINT_TO_POINTER(ran_ue->id));
72
     if (!ran_ue->t_ng_holding) {
73
         ogs_error("ogs_timer_add() failed");
74
-        ogs_pool_free(&ran_ue_pool, ran_ue);
75
+        ogs_pool_id_free(&ran_ue_pool, ran_ue);
76
         return NULL;
77
     }
78
 
79
@@ -1357,7 +1358,7 @@
80
     ran_ue->gnb_ostream_id =
81
         OGS_NEXT_ID(gnb->ostream_id, 1, gnb->max_num_of_ostreams-1);
82
 
83
-    ran_ue->gnb = gnb;
84
+    ran_ue->gnb_id = gnb->id;
85
 
86
     ogs_list_add(&gnb->ran_ue_list, ran_ue);
87
 
88
@@ -1368,33 +1369,40 @@
89
 
90
 void ran_ue_remove(ran_ue_t *ran_ue)
91
 {
92
+    amf_gnb_t *gnb = NULL;
93
+
94
     ogs_assert(ran_ue);
95
-    ogs_assert(ran_ue->gnb);
96
 
97
-    ogs_list_remove(&ran_ue->gnb->ran_ue_list, ran_ue);
98
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
99
+
100
+    if (gnb) ogs_list_remove(&gnb->ran_ue_list, ran_ue);
101
 
102
     ogs_assert(ran_ue->t_ng_holding);
103
     ogs_timer_delete(ran_ue->t_ng_holding);
104
 
105
-    ogs_pool_free(&ran_ue_pool, ran_ue);
106
+    ogs_pool_id_free(&ran_ue_pool, ran_ue);
107
 
108
     stats_remove_ran_ue();
109
 }
110
 
111
 void ran_ue_switch_to_gnb(ran_ue_t *ran_ue, amf_gnb_t *new_gnb)
112
 {
113
+    amf_gnb_t *gnb = NULL;
114
+
115
     ogs_assert(ran_ue);
116
-    ogs_assert(ran_ue->gnb);
117
     ogs_assert(new_gnb);
118
 
119
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
120
+    ogs_assert(gnb);
121
+
122
     /* Remove from the old gnb */
123
-    ogs_list_remove(&ran_ue->gnb->ran_ue_list, ran_ue);
124
+    ogs_list_remove(&gnb->ran_ue_list, ran_ue);
125
 
126
     /* Add to the new gnb */
127
     ogs_list_add(&new_gnb->ran_ue_list, ran_ue);
128
 
129
     /* Switch to gnb */
130
-    ran_ue->gnb = new_gnb;
131
+    ran_ue->gnb_id = new_gnb->id;
132
 }
133
 
134
 ran_ue_t *ran_ue_find_by_ran_ue_ngap_id(
135
@@ -1420,9 +1428,9 @@
136
     return ran_ue_find(amf_ue_ngap_id);
137
 }
138
 
139
-ran_ue_t *ran_ue_cycle(ran_ue_t *ran_ue)
140
+ran_ue_t *ran_ue_find_by_id(ogs_pool_id_t id)
141
 {
142
-    return ogs_pool_cycle(&ran_ue_pool, ran_ue);
143
+    return ogs_pool_find_by_id(&ran_ue_pool, id);
144
 }
145
 
146
 void amf_ue_new_guti(amf_ue_t *amf_ue)
147
@@ -1520,39 +1528,44 @@
148
     amf_ue_t *amf_ue = NULL;
149
 
150
     ogs_assert(ran_ue);
151
-    gnb = ran_ue->gnb;
152
-    ogs_assert(gnb);
153
 
154
-    ogs_pool_alloc(&amf_ue_pool, &amf_ue);
155
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
156
+    if (!gnb) {
157
+        ogs_error("%d gNB has already been removed", ran_ue->gnb_id);
158
+        return NULL;
159
+    }
160
+
161
+    ogs_pool_id_calloc(&amf_ue_pool, &amf_ue);
162
     if (amf_ue == NULL) {
163
         ogs_error("Could not allocate amf_ue context from pool");
164
         return NULL;
165
     }
166
 
167
-    memset(amf_ue, 0, sizeof *amf_ue);
168
-
169
     /* Add All Timers */
170
     amf_ue->t3513.timer = ogs_timer_add(
171
-            ogs_app()->timer_mgr, amf_timer_t3513_expire, amf_ue);
172
+            ogs_app()->timer_mgr, amf_timer_t3513_expire,
173
+            OGS_UINT_TO_POINTER(amf_ue->id));
174
     if (!amf_ue->t3513.timer) {
175
         ogs_error("ogs_timer_add() failed");
176
-        ogs_pool_free(&amf_ue_pool, amf_ue);
177
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
178
         return NULL;
179
     }
180
     amf_ue->t3513.pkbuf = NULL;
181
     amf_ue->t3522.timer = ogs_timer_add(
182
-            ogs_app()->timer_mgr, amf_timer_t3522_expire, amf_ue);
183
+            ogs_app()->timer_mgr, amf_timer_t3522_expire,
184
+            OGS_UINT_TO_POINTER(amf_ue->id));
185
     if (!amf_ue->t3522.timer) {
186
         ogs_error("ogs_timer_add() failed");
187
-        ogs_pool_free(&amf_ue_pool, amf_ue);
188
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
189
         return NULL;
190
     }
191
     amf_ue->t3522.pkbuf = NULL;
192
     amf_ue->t3550.timer = ogs_timer_add(
193
-            ogs_app()->timer_mgr, amf_timer_t3550_expire, amf_ue);
194
+            ogs_app()->timer_mgr, amf_timer_t3550_expire,
195
+            OGS_UINT_TO_POINTER(amf_ue->id));
196
     if (!amf_ue->t3550.timer) {
197
         ogs_error("ogs_timer_add() failed");
198
-        ogs_pool_free(&amf_ue_pool, amf_ue);
199
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
200
         return NULL;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/context.h Changed
201
 
1
@@ -127,6 +127,8 @@
2
 typedef struct amf_gnb_s {
3
     ogs_lnode_t     lnode;
4
 
5
+    ogs_pool_id_t   id;
6
+
7
     ogs_fsm_t       sm;         /* A state machine */
8
 
9
     uint32_t        gnb_id;     /* gNB_ID received from gNB */
10
@@ -162,6 +164,7 @@
11
 struct ran_ue_s {
12
     ogs_lnode_t     lnode;
13
     uint32_t        index;
14
+    ogs_pool_id_t   id;
15
 
16
     /* UE identity */
17
 #define INVALID_UE_NGAP_ID 0xffffffffffffffffULL /* Initial value of ran_ue_ngap_id */
18
@@ -176,13 +179,14 @@
19
 
20
 #define CONTEXT_SETUP_ESTABLISHED(__aMF) \
21
     CM_CONNECTED(__aMF) && \
22
-    ((__aMF)->ran_ue->initial_context_setup_response_received == true)
23
+    (ran_ue_find_by_id((__aMF)->ran_ue_id)-> \
24
+     initial_context_setup_response_received == true)
25
     bool            initial_context_setup_response_received;
26
     bool            ue_ambr_sent;
27
 
28
     /* Handover Info */
29
-    ran_ue_t        *source_ue;
30
-    ran_ue_t        *target_ue;
31
+    ogs_pool_id_t   source_ue_id;
32
+    ogs_pool_id_t   target_ue_id;
33
 
34
     /* Use amf_ue->nr_tai, amf_ue->nr_cgi.
35
      * Do not access ran_ue->saved.tai ran_ue->saved.nr_cgi.
36
@@ -214,12 +218,14 @@
37
     } psimask;
38
 
39
     /* Related Context */
40
-    amf_gnb_t       *gnb;
41
-    amf_ue_t        *amf_ue;
42
+    ogs_pool_id_t   gnb_id;
43
+    ogs_pool_id_t   amf_ue_id;
44
 }; 
45
 
46
 struct amf_ue_s {
47
     ogs_sbi_object_t sbi;
48
+    ogs_pool_id_t id;
49
+
50
     ogs_fsm_t sm;
51
 
52
     struct {
53
@@ -417,53 +423,67 @@
54
     uint64_t        am_policy_control_features; /* SBI Features */
55
 
56
 #define CM_CONNECTED(__aMF) \
57
-    ((__aMF) && ((__aMF)->ran_ue != NULL) && ran_ue_cycle((__aMF)->ran_ue))
58
+    ((__aMF) && \
59
+     ((__aMF)->ran_ue_id >= OGS_MIN_POOL_ID) && \
60
+     ((__aMF)->ran_ue_id <= OGS_MAX_POOL_ID) && \
61
+     (ran_ue_find_by_id((__aMF)->ran_ue_id)))
62
 #define CM_IDLE(__aMF) \
63
     ((__aMF) && \
64
-     (((__aMF)->ran_ue == NULL) || (ran_ue_cycle((__aMF)->ran_ue) == NULL)))
65
+     (((__aMF)->ran_ue_id < OGS_MIN_POOL_ID) || \
66
+      ((__aMF)->ran_ue_id > OGS_MAX_POOL_ID) || \
67
+      (ran_ue_find_by_id((__aMF)->ran_ue_id) == NULL)))
68
     /* NG UE context */
69
-    ran_ue_t        *ran_ue;
70
+    ogs_pool_id_t   ran_ue_id;
71
 
72
 #define HOLDING_NG_CONTEXT(__aMF) \
73
     do { \
74
-        ran_ue_deassociate((__aMF)->ran_ue); \
75
+        ran_ue_t *ran_ue_holding = NULL; \
76
+        \
77
+        (__aMF)->ran_ue_holding_id = OGS_INVALID_POOL_ID; \
78
         \
79
-        (__aMF)->ran_ue_holding = ran_ue_cycle((__aMF)->ran_ue); \
80
-        if ((__aMF)->ran_ue_holding) { \
81
+        ran_ue_holding = ran_ue_find_by_id((__aMF)->ran_ue_id); \
82
+        if (ran_ue_holding) { \
83
+            ran_ue_deassociate(ran_ue_holding); \
84
+            \
85
             ogs_warn("%s Holding NG Context", (__aMF)->suci); \
86
             ogs_warn("%s    RAN_UE_NGAP_ID%lld AMF_UE_NGAP_ID%lld", \
87
                     (__aMF)->suci, \
88
-                    (long long)(__aMF)->ran_ue_holding->ran_ue_ngap_id, \
89
-                    (long long)(__aMF)->ran_ue_holding->amf_ue_ngap_id); \
90
+                    (long long)ran_ue_holding->ran_ue_ngap_id, \
91
+                    (long long)ran_ue_holding->amf_ue_ngap_id); \
92
             \
93
-            (__aMF)->ran_ue_holding->ue_ctx_rel_action = \
94
+            ran_ue_holding->ue_ctx_rel_action = \
95
                 NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE; \
96
-            ogs_timer_start((__aMF)->ran_ue_holding->t_ng_holding, \
97
+            ogs_timer_start(ran_ue_holding->t_ng_holding, \
98
                     amf_timer_cfg(AMF_TIMER_NG_HOLDING)->duration); \
99
+            \
100
+            (__aMF)->ran_ue_holding_id = (__aMF)->ran_ue_id; \
101
         } else \
102
             ogs_error("%s NG Context has already been removed", \
103
                     (__aMF)->suci); \
104
     } while(0)
105
 #define CLEAR_NG_CONTEXT(__aMF) \
106
     do { \
107
-        if (ran_ue_cycle((__aMF)->ran_ue_holding)) { \
108
+        ran_ue_t *ran_ue_holding = NULL; \
109
+        \
110
+        ran_ue_holding = ran_ue_find_by_id((__aMF)->ran_ue_holding_id); \
111
+        if (ran_ue_holding) { \
112
             int r; \
113
             ogs_warn("%s Clear NG Context", (__aMF)->suci); \
114
             ogs_warn("%s    RAN_UE_NGAP_ID%lld AMF_UE_NGAP_ID%lld", \
115
                     (__aMF)->suci, \
116
-                    (long long)(__aMF)->ran_ue_holding->ran_ue_ngap_id, \
117
-                    (long long)(__aMF)->ran_ue_holding->amf_ue_ngap_id); \
118
+                    (long long)ran_ue_holding->ran_ue_ngap_id, \
119
+                    (long long)ran_ue_holding->amf_ue_ngap_id); \
120
             \
121
             r = ngap_send_ran_ue_context_release_command( \
122
-                    (__aMF)->ran_ue_holding, \
123
+                    ran_ue_holding, \
124
                     NGAP_Cause_PR_nas, NGAP_CauseNas_normal_release, \
125
                     NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0); \
126
             ogs_expect(r == OGS_OK); \
127
             ogs_assert(r != OGS_ERROR); \
128
         } \
129
-        (__aMF)->ran_ue_holding = NULL; \
130
+        (__aMF)->ran_ue_holding_id = OGS_INVALID_POOL_ID; \
131
     } while(0)
132
-    ran_ue_t        *ran_ue_holding;
133
+    ogs_pool_id_t   ran_ue_holding_id;
134
 
135
 #define CLEAR_AMF_UE_ALL_TIMERS(__aMF) \
136
     do { \
137
@@ -562,6 +582,7 @@
138
 
139
 typedef struct amf_sess_s {
140
     ogs_sbi_object_t sbi;
141
+    ogs_pool_id_t id;
142
 
143
     uint8_t psi;            /* PDU Session Identity */
144
     uint8_t pti;            /* Procedure Trasaction Identity */
145
@@ -656,10 +677,12 @@
146
 #define AMF_SESS_STORE_N2_TRANSFER(__sESS, __n2Type, __n2Buf) \
147
     do { \
148
         ogs_assert(__sESS); \
149
-        ogs_assert((__sESS)->amf_ue); \
150
         if ((__sESS)->transfer.__n2Type) { \
151
-            ogs_warn("%s:%d N2 transfer message duplicated. Overwritten", \
152
-                    ((__sESS)->amf_ue)->supi, (__sESS)->psi); \
153
+            amf_ue_t *amf_ue = amf_ue_find_by_id((__sESS)->amf_ue_id); \
154
+            if (amf_ue) \
155
+                ogs_warn("%s:%d " \
156
+                        "N2 transfer message duplicated. Overwritten", \
157
+                        amf_ue->supi, (__sESS)->psi); \
158
             ogs_pkbuf_free((__sESS)->transfer.__n2Type); \
159
         } \
160
         (__sESS)->transfer.__n2Type = __n2Buf; \
161
@@ -733,18 +756,21 @@
162
 
163
 #define AMF_SESS_STORE_5GSM_MESSAGE(__sESS, __tYPE, __n1Buf, __n2Buf) \
164
     do { \
165
+        amf_ue_t *amf_ue = NULL; \
166
         ogs_assert(__sESS); \
167
-        ogs_assert((__sESS)->amf_ue); \
168
+        amf_ue = amf_ue_find_by_id((__sESS)->amf_ue_id); \
169
         if ((__sESS)->gsm_message.n1buf) { \
170
-            ogs_warn("%s:%d N1 message duplicated. Overwritten", \
171
-                    ((__sESS)->amf_ue)->supi, (__sESS)->psi); \
172
+            if (amf_ue) \
173
+                ogs_warn("%s:%d N1 message duplicated. Overwritten", \
174
+                        amf_ue->supi, (__sESS)->psi); \
175
             ogs_pkbuf_free((__sESS)->gsm_message.n1buf); \
176
         } \
177
         (__sESS)->gsm_message.n1buf = __n1Buf; \
178
         \
179
         if ((__sESS)->gsm_message.n2buf) { \
180
-            ogs_warn("%s:%d N2 message duplicated. Overwritten", \
181
-                    ((__sESS)->amf_ue)->supi, (__sESS)->psi); \
182
+            if (amf_ue) \
183
+                ogs_warn("%s:%d N2 message duplicated. Overwritten", \
184
+                        amf_ue->supi, (__sESS)->psi); \
185
             ogs_pkbuf_free((__sESS)->gsm_message.n2buf); \
186
         } \
187
         (__sESS)->gsm_message.n2buf = __n2Buf; \
188
@@ -789,8 +815,8 @@
189
     ogs_list_t      bearer_list;
190
 
191
     /* Related Context */
192
-    amf_ue_t        *amf_ue;
193
-    ran_ue_t        *ran_ue;
194
+    ogs_pool_id_t   amf_ue_id;
195
+    ogs_pool_id_t   ran_ue_id;
196
 
197
     ogs_s_nssai_t s_nssai;
198
     ogs_s_nssai_t mapped_hplmn;
199
@@ -812,7 +838,7 @@
200
 amf_gnb_t *amf_gnb_find_by_gnb_id(uint32_t gnb_id);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/event.h Changed
17
 
1
@@ -74,11 +74,10 @@
2
         ogs_nas_5gs_message_t *message;
3
     } nas;
4
 
5
-    amf_gnb_t *gnb;
6
-    ran_ue_t *ran_ue;
7
-    amf_ue_t *amf_ue;
8
-    amf_sess_t *sess;
9
-    amf_bearer_t *bearer;
10
+    ogs_pool_id_t gnb_id;
11
+    ogs_pool_id_t ran_ue_id;
12
+    ogs_pool_id_t amf_ue_id;
13
+    ogs_pool_id_t sess_id;
14
 
15
     ogs_timer_t *timer;
16
 } amf_event_t;
17
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/gmm-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/gmm-build.c Changed
10
 
1
@@ -636,7 +636,7 @@
2
     ogs_nas_gprs_timer_3_t *back_off_timer_value = NULL;
3
 
4
     ogs_assert(sess);
5
-    amf_ue = sess->amf_ue;
6
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
7
     ogs_assert(amf_ue);
8
     ogs_assert(payload_container_type);
9
     ogs_assert(payload_container);
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/gmm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/gmm-handler.c Changed
57
 
1
@@ -50,7 +50,7 @@
2
     ogs_nas_ue_security_capability_t *ue_security_capability = NULL;
3
 
4
     ogs_assert(amf_ue);
5
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
6
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
7
     ogs_assert(ran_ue);
8
 
9
     ogs_assert(registration_request);
10
@@ -632,7 +632,7 @@
11
     ogs_nas_key_set_identifier_t *ngksi = NULL;
12
 
13
     ogs_assert(amf_ue);
14
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
15
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
16
     ogs_assert(ran_ue);
17
 
18
     ngksi = &service_request->ngksi;
19
@@ -850,7 +850,7 @@
20
     ogs_nas_de_registration_type_t *de_registration_type = NULL;
21
 
22
     ogs_assert(amf_ue);
23
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
24
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
25
     ogs_assert(ran_ue);
26
     ogs_assert(deregistration_request);
27
 
28
@@ -974,7 +974,7 @@
29
     ogs_assert(identity_response);
30
 
31
     ogs_assert(amf_ue);
32
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
33
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
34
     ogs_assert(ran_ue);
35
     ogs_assert(identity_response);
36
 
37
@@ -1040,7 +1040,7 @@
38
     ogs_nas_mobile_identity_imeisv_t *mobile_identity_imeisv = NULL;
39
 
40
     ogs_assert(amf_ue);
41
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
42
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
43
     ogs_assert(ran_ue);
44
     ogs_assert(security_mode_complete);
45
 
46
@@ -1139,8 +1139,8 @@
47
     ogs_nas_dnn_t *dnn = NULL;
48
     ogs_nas_5gsm_header_t *gsm_header = NULL;
49
 
50
-    ogs_assert(amf_ue_cycle(amf_ue));
51
-    ogs_assert(ran_ue_cycle(ran_ue));
52
+    ogs_assert(amf_ue);
53
+    ogs_assert(ran_ue);
54
     ogs_assert(ul_nas_transport);
55
 
56
     payload_container_type = &ul_nas_transport->payload_container_type;
57
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/gmm-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/gmm-sm.c Changed
201
 
1
@@ -74,12 +74,12 @@
2
 
3
     amf_sm_debug(e);
4
 
5
-    if (e->sess) {
6
-        sess = e->sess;
7
-        amf_ue = sess->amf_ue;
8
+    sess = amf_sess_find_by_id(e->sess_id);
9
+    if (sess) {
10
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
11
         ogs_assert(amf_ue);
12
     } else {
13
-        amf_ue = e->amf_ue;
14
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
15
         ogs_assert(amf_ue);
16
     }
17
 
18
@@ -575,7 +575,7 @@
19
 
20
                         xact_count = amf_sess_xact_count(amf_ue);
21
                         amf_sbi_send_release_all_sessions(
22
-                                amf_ue->ran_ue, amf_ue,
23
+                                ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
24
                                 AMF_RELEASE_SM_CONTEXT_NO_STATE);
25
 
26
                         if (!AMF_SESSION_RELEASE_PENDING(amf_ue) &&
27
@@ -630,12 +630,12 @@
28
 
29
     amf_sm_debug(e);
30
 
31
-    if (e->sess) {
32
-        sess = e->sess;
33
-        amf_ue = sess->amf_ue;
34
+    sess = amf_sess_find_by_id(e->sess_id);
35
+    if (sess) {
36
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
37
         ogs_assert(amf_ue);
38
     } else {
39
-        amf_ue = e->amf_ue;
40
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
41
         ogs_assert(amf_ue);
42
     }
43
 
44
@@ -1142,7 +1142,7 @@
45
 
46
                         if (amf_ue->explict_de_registered.n1_done == true) {
47
                             r = ngap_send_ran_ue_context_release_command(
48
-                                    amf_ue->ran_ue,
49
+                                    ran_ue_find_by_id(amf_ue->ran_ue_id),
50
                                     NGAP_Cause_PR_misc,
51
                                     NGAP_CauseMisc_om_intervention,
52
                                     NGAP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
53
@@ -1194,12 +1194,12 @@
54
 
55
     ogs_assert(e);
56
 
57
-    if (e->sess) {
58
-        sess = e->sess;
59
-        amf_ue = sess->amf_ue;
60
+    sess = amf_sess_find_by_id(e->sess_id);
61
+    if (sess) {
62
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
63
         ogs_assert(amf_ue);
64
     } else {
65
-        amf_ue = e->amf_ue;
66
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
67
         ogs_assert(amf_ue);
68
     }
69
 
70
@@ -1208,7 +1208,7 @@
71
         nas_message = e->nas.message;
72
         ogs_assert(nas_message);
73
 
74
-        ran_ue = ran_ue_cycle(amf_ue->ran_ue);
75
+        ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
76
         ogs_assert(ran_ue);
77
 
78
         h.type = e->nas.type;
79
@@ -1618,12 +1618,12 @@
80
 
81
     amf_sm_debug(e);
82
 
83
-    if (e->sess) {
84
-        sess = e->sess;
85
-        amf_ue = sess->amf_ue;
86
+    sess = amf_sess_find_by_id(e->sess_id);
87
+    if (sess) {
88
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
89
         ogs_assert(amf_ue);
90
     } else {
91
-        amf_ue = e->amf_ue;
92
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
93
         ogs_assert(amf_ue);
94
     }
95
 
96
@@ -1636,7 +1636,7 @@
97
         nas_message = e->nas.message;
98
         ogs_assert(nas_message);
99
 
100
-        ran_ue = ran_ue_cycle(amf_ue->ran_ue);
101
+        ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
102
         ogs_assert(ran_ue);
103
 
104
         h.type = e->nas.type;
105
@@ -1908,7 +1908,7 @@
106
 
107
     amf_sm_debug(e);
108
 
109
-    amf_ue = e->amf_ue;
110
+    amf_ue = amf_ue_find_by_id(e->amf_ue_id);
111
     ogs_assert(amf_ue);
112
 
113
     switch (e->h.id) {
114
@@ -1924,7 +1924,7 @@
115
         nas_message = e->nas.message;
116
         ogs_assert(nas_message);
117
 
118
-        ran_ue = ran_ue_cycle(amf_ue->ran_ue);
119
+        ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
120
         ogs_assert(ran_ue);
121
 
122
         h.type = e->nas.type;
123
@@ -2068,7 +2068,8 @@
124
             if (amf_ue->t3560.retry_count >=
125
                     amf_timer_cfg(AMF_TIMER_T3560)->max_count) {
126
                 ogs_warn("%s Retransmission failed. Stop", amf_ue->supi);
127
-                r = nas_5gs_send_gmm_reject(amf_ue->ran_ue, amf_ue,
128
+                r = nas_5gs_send_gmm_reject(
129
+                        ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
130
                         OGS_5GMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED);
131
                 ogs_expect(r == OGS_OK);
132
                 ogs_assert(r != OGS_ERROR);
133
@@ -2112,12 +2113,12 @@
134
 
135
     amf_sm_debug(e);
136
 
137
-    if (e->sess) {
138
-        sess = e->sess;
139
-        amf_ue = sess->amf_ue;
140
+    sess = amf_sess_find_by_id(e->sess_id);
141
+    if (sess) {
142
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
143
         ogs_assert(amf_ue);
144
     } else {
145
-        amf_ue = e->amf_ue;
146
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
147
         ogs_assert(amf_ue);
148
     }
149
 
150
@@ -2143,7 +2144,7 @@
151
                     ogs_error("%s HTTP response error %d",
152
                             amf_ue->supi, sbi_message->res_status);
153
                     r = nas_5gs_send_gmm_reject(
154
-                            amf_ue->ran_ue, amf_ue,
155
+                            ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
156
                             OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED);
157
                     ogs_expect(r == OGS_OK);
158
                     ogs_assert(r != OGS_ERROR);
159
@@ -2188,7 +2189,7 @@
160
                     ogs_error("%s HTTP response error %d",
161
                             amf_ue->supi, sbi_message->res_status);
162
                     r = nas_5gs_send_gmm_reject(
163
-                            amf_ue->ran_ue, amf_ue,
164
+                            ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
165
                             OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED);
166
                     ogs_expect(r == OGS_OK);
167
                     ogs_assert(r != OGS_ERROR);
168
@@ -2275,7 +2276,7 @@
169
         nas_message = e->nas.message;
170
         ogs_assert(nas_message);
171
 
172
-        ran_ue = ran_ue_cycle(amf_ue->ran_ue);
173
+        ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
174
         ogs_assert(ran_ue);
175
 
176
         h.type = e->nas.type;
177
@@ -2459,12 +2460,12 @@
178
 
179
     amf_sm_debug(e);
180
 
181
-    if (e->sess) {
182
-        sess = e->sess;
183
-        amf_ue = sess->amf_ue;
184
+    sess = amf_sess_find_by_id(e->sess_id);
185
+    if (sess) {
186
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
187
         ogs_assert(amf_ue);
188
     } else {
189
-        amf_ue = e->amf_ue;
190
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
191
         ogs_assert(amf_ue);
192
     }
193
 
194
@@ -2497,12 +2498,12 @@
195
 
196
     amf_sm_debug(e);
197
 
198
-    if (e->sess) {
199
-        sess = e->sess;
200
-        amf_ue = sess->amf_ue;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/namf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/namf-handler.c Changed
49
 
1
@@ -177,7 +177,7 @@
2
              * 4.3.2 PDU Session Establishment *
3
              ***********************************/
4
 
5
-            ran_ue = ran_ue_cycle(sess->ran_ue);
6
+            ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
7
             if (ran_ue) {
8
                 if (sess->pdu_session_establishment_accept) {
9
                     ogs_pkbuf_free(sess->pdu_session_establishment_accept);
10
@@ -480,7 +480,8 @@
11
         ogs_error("%d:%d PDU session establishment reject",
12
                 sess->psi, sess->pti);
13
 
14
-        r = nas_5gs_send_gsm_reject(sess->ran_ue, sess,
15
+        r = nas_5gs_send_gsm_reject(
16
+                ran_ue_find_by_id(sess->ran_ue_id), sess,
17
                 OGS_NAS_PAYLOAD_CONTAINER_N1_SM_INFORMATION, n1buf);
18
         ogs_expect(r == OGS_OK);
19
         ogs_assert(r != OGS_ERROR);
20
@@ -1003,7 +1004,7 @@
21
     }
22
 
23
     if (amf_ue) {
24
-        ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue);
25
+        ran_ue_t *ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
26
         if (!ran_ue) {
27
             ogs_error("NG context has already been removed");
28
             /* ran_ue is required for amf_ue_is_rat_restricted() */
29
@@ -1092,6 +1093,7 @@
30
     ogs_sbi_response_t *response = NULL;
31
     ogs_sbi_message_t sendmsg;
32
     amf_ue_t *amf_ue = NULL;
33
+    ran_ue_t *ran_ue = NULL;
34
 
35
     OpenAPI_ambr_t *UeAmbr = NULL;
36
     OpenAPI_list_t *MmContextList = NULL;
37
@@ -1246,8 +1248,9 @@
38
      * Context TRANSFERRED !!!
39
      * So, we removed UE context.
40
      */
41
-    if (amf_ue->ran_ue)
42
-        ran_ue_remove(amf_ue->ran_ue);
43
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
44
+    if (ran_ue)
45
+        ran_ue_remove(ran_ue);
46
     amf_ue_remove(amf_ue);
47
 
48
     return OGS_OK;
49
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/nas-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/nas-path.c Changed
201
 
1
@@ -25,16 +25,22 @@
2
 int nas_5gs_send_to_gnb(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf)
3
 {
4
     int rv;
5
+    ran_ue_t *ran_ue = NULL;
6
     ogs_assert(pkbuf);
7
 
8
-    amf_ue = amf_ue_cycle(amf_ue);
9
     if (!amf_ue) {
10
         ogs_error("UE(amf-ue) context has already been removed");
11
         ogs_pkbuf_free(pkbuf);
12
         return OGS_NOTFOUND;
13
     }
14
 
15
-    rv = ngap_send_to_ran_ue(amf_ue->ran_ue, pkbuf);
16
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
17
+    if (!ran_ue) {
18
+        ogs_error("%s RAN-NG Context has already been removed", amf_ue->suci);
19
+        return OGS_NOTFOUND;
20
+    }
21
+
22
+    rv = ngap_send_to_ran_ue(ran_ue, pkbuf);
23
     ogs_expect(rv == OGS_OK);
24
 
25
     return rv;
26
@@ -46,7 +52,7 @@
27
     int rv;
28
     ogs_pkbuf_t *ngapbuf = NULL;
29
 
30
-    ogs_assert(ran_ue_cycle(ran_ue));
31
+    ogs_assert(ran_ue);
32
     ogs_assert(pkbuf);
33
 
34
     ngapbuf = ngap_build_downlink_nas_transport(ran_ue, pkbuf, false, false);
35
@@ -71,14 +77,14 @@
36
     ogs_pkbuf_t *ngapbuf = NULL;
37
     ogs_pkbuf_t *gmmbuf = NULL;
38
 
39
-    if (!amf_ue_cycle(amf_ue)) {
40
+    if (!amf_ue) {
41
         ogs_error("UE(amf-ue) context has already been removed");
42
         return OGS_NOTFOUND;
43
     }
44
 
45
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
46
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
47
     if (!ran_ue) {
48
-        ogs_error("NG context has already been removed");
49
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
50
         return OGS_NOTFOUND;
51
     }
52
 
53
@@ -177,8 +183,8 @@
54
     int rv;
55
     ogs_pkbuf_t *gmmbuf = NULL;
56
 
57
-    ogs_assert(ran_ue_cycle(ran_ue));
58
-    ogs_assert(amf_ue_cycle(amf_ue));
59
+    ogs_assert(ran_ue);
60
+    ogs_assert(amf_ue);
61
 
62
     switch (amf_ue->nas.registration.value) {
63
     case OGS_NAS_5GS_REGISTRATION_TYPE_INITIAL:
64
@@ -225,14 +231,14 @@
65
     ogs_pkbuf_t *gmmbuf = NULL;
66
     ogs_pkbuf_t *ngapbuf = NULL;
67
 
68
-    if (!amf_ue_cycle(amf_ue)) {
69
+    if (!amf_ue) {
70
         ogs_error("UE(amf-ue) context has already been removed");
71
         return OGS_NOTFOUND;
72
     }
73
 
74
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
75
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
76
     if (!ran_ue) {
77
-        ogs_error("NG context has already been removed");
78
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
79
         return OGS_NOTFOUND;
80
     }
81
 
82
@@ -289,7 +295,7 @@
83
             rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf);
84
             ogs_expect(rv == OGS_OK);
85
         } else {
86
-            rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
87
+            rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
88
             ogs_expect(rv == OGS_OK);
89
         }
90
     }
91
@@ -303,8 +309,8 @@
92
     int rv;
93
     ogs_pkbuf_t *gmmbuf = NULL;
94
 
95
-    ogs_assert(ran_ue_cycle(ran_ue));
96
-    ogs_assert(amf_ue_cycle(amf_ue));
97
+    ogs_assert(ran_ue);
98
+    ogs_assert(amf_ue);
99
 
100
     ogs_debug("%s Service reject", amf_ue->supi);
101
 
102
@@ -327,14 +333,14 @@
103
     ran_ue_t *ran_ue = NULL;
104
     ogs_pkbuf_t *gmmbuf = NULL;
105
 
106
-    if (!amf_ue_cycle(amf_ue)) {
107
+    if (!amf_ue) {
108
         ogs_error("UE(amf-ue) context has already been removed");
109
         return OGS_NOTFOUND;
110
     }
111
 
112
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
113
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
114
     if (!ran_ue) {
115
-        ogs_error("NG context has already been removed");
116
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
117
         return OGS_NOTFOUND;
118
     }
119
 
120
@@ -349,7 +355,7 @@
121
             return OGS_ERROR;
122
         }
123
 
124
-        rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
125
+        rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
126
         if (rv != OGS_OK) {
127
             ogs_error("nas_5gs_send_to_downlink_nas_transport() failed");
128
             return rv;
129
@@ -374,14 +380,14 @@
130
     ran_ue_t *ran_ue = NULL;
131
     ogs_pkbuf_t *gmmbuf = NULL;
132
 
133
-    if (!amf_ue_cycle(amf_ue)) {
134
+    if (!amf_ue) {
135
         ogs_error("UE(amf-ue) context has already been removed");
136
         return OGS_NOTFOUND;
137
     }
138
 
139
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
140
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
141
     if (!ran_ue) {
142
-        ogs_error("NG context has already been removed");
143
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
144
         return OGS_NOTFOUND;
145
     }
146
 
147
@@ -407,7 +413,7 @@
148
     ogs_timer_start(amf_ue->t3522.timer,
149
             amf_timer_cfg(AMF_TIMER_T3522)->duration);
150
 
151
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
152
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
153
     ogs_expect(rv == OGS_OK);
154
 
155
     return rv;
156
@@ -416,15 +422,17 @@
157
 int nas_5gs_send_identity_request(amf_ue_t *amf_ue)
158
 {
159
     int rv;
160
+    ran_ue_t *ran_ue = NULL;
161
     ogs_pkbuf_t *gmmbuf = NULL;
162
 
163
-    if (!amf_ue_cycle(amf_ue)) {
164
+    if (!amf_ue) {
165
         ogs_error("UE(amf-ue) context has already been removed");
166
         return OGS_NOTFOUND;
167
     }
168
 
169
-    if (!ran_ue_cycle(amf_ue->ran_ue)) {
170
-        ogs_error("NG context has already been removed");
171
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
172
+    if (!ran_ue) {
173
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
174
         return OGS_NOTFOUND;
175
     }
176
 
177
@@ -449,7 +457,7 @@
178
     ogs_timer_start(amf_ue->t3570.timer,
179
             amf_timer_cfg(AMF_TIMER_T3570)->duration);
180
 
181
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
182
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
183
     ogs_expect(rv == OGS_OK);
184
 
185
     return rv;
186
@@ -458,15 +466,17 @@
187
 int nas_5gs_send_authentication_request(amf_ue_t *amf_ue)
188
 {
189
     int rv;
190
+    ran_ue_t *ran_ue = NULL;
191
     ogs_pkbuf_t *gmmbuf = NULL;
192
 
193
-    if (!amf_ue_cycle(amf_ue)) {
194
+    if (!amf_ue) {
195
         ogs_error("UE(amf-ue) context has already been removed");
196
         return OGS_NOTFOUND;
197
     }
198
 
199
-    if (!ran_ue_cycle(amf_ue->ran_ue)) {
200
-        ogs_error("NG context has already been removed");
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/ngap-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/ngap-build.c Changed
164
 
1
@@ -313,9 +313,8 @@
2
     NGAP_AllowedNSSAI_t *AllowedNSSAI = NULL;
3
 
4
     ogs_assert(gmmbuf);
5
-    ran_ue = ran_ue_cycle(ran_ue);
6
     ogs_assert(ran_ue);
7
-    amf_ue = amf_ue_cycle(ran_ue->amf_ue);
8
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
9
     ogs_assert(amf_ue);
10
 
11
     ogs_debug("DownlinkNASTransport");
12
@@ -470,9 +469,8 @@
13
     NGAP_MaskedIMEISV_t *MaskedIMEISV = NULL;
14
     NGAP_NAS_PDU_t *NAS_PDU = NULL;
15
 
16
-    amf_ue = amf_ue_cycle(amf_ue);
17
     ogs_assert(amf_ue);
18
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
19
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
20
     ogs_assert(ran_ue);
21
 
22
     ogs_debug("InitialContextSetupRequest(UE)");
23
@@ -781,9 +779,8 @@
24
     NGAP_UESecurityCapabilities_t *UESecurityCapabilities = NULL;
25
     NGAP_SecurityKey_t *SecurityKey = NULL;
26
 
27
-    amf_ue = amf_ue_cycle(amf_ue);
28
     ogs_assert(amf_ue);
29
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
30
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
31
     ogs_assert(ran_ue);
32
 
33
     ogs_debug("UEContextModificationRequest(UE)");
34
@@ -932,9 +929,8 @@
35
     NGAP_MaskedIMEISV_t *MaskedIMEISV = NULL;
36
 
37
     ogs_assert(sess);
38
-    amf_ue = amf_ue_cycle(sess->amf_ue);
39
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
40
     ogs_assert(amf_ue);
41
-    ran_ue = ran_ue_cycle(ran_ue);
42
     ogs_assert(ran_ue);
43
 
44
     ogs_debug("InitialContextSetupRequest(Session)");
45
@@ -1222,7 +1218,6 @@
46
     NGAP_UE_NGAP_IDs_t *UE_NGAP_IDs = NULL;
47
     NGAP_Cause_t *Cause = NULL;
48
 
49
-    ran_ue = ran_ue_cycle(ran_ue);
50
     ogs_assert(ran_ue);
51
 
52
     ogs_debug("UEContextReleaseCommand");
53
@@ -1298,9 +1293,8 @@
54
     NGAP_PDUSessionResourceSetupListSUReq_t *PDUSessionList = NULL;
55
     NGAP_PDUSessionResourceSetupItemSUReq_t *PDUSessionItem = NULL;
56
 
57
-    amf_ue = amf_ue_cycle(amf_ue);
58
     ogs_assert(amf_ue);
59
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
60
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
61
     ogs_assert(ran_ue);
62
 
63
     ogs_debug("PDUSessionResourceSetupRequest(UE)");
64
@@ -1466,9 +1460,8 @@
65
     ogs_assert(n2smbuf);
66
     ogs_assert(sess);
67
 
68
-    amf_ue = amf_ue_cycle(sess->amf_ue);
69
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
70
     ogs_assert(amf_ue);
71
-    ran_ue = ran_ue_cycle(ran_ue);
72
     ogs_assert(ran_ue);
73
 
74
     ogs_debug("PDUSessionResourceSetupRequest(Session)");
75
@@ -1609,9 +1602,9 @@
76
     ogs_assert(n2smbuf);
77
     ogs_assert(sess);
78
 
79
-    amf_ue = amf_ue_cycle(sess->amf_ue);
80
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
81
     ogs_assert(amf_ue);
82
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
83
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
84
     ogs_assert(ran_ue);
85
 
86
     ogs_debug("PDUSessionResourceModifyRequest");
87
@@ -1709,9 +1702,9 @@
88
     ogs_assert(n2smbuf);
89
     ogs_assert(sess);
90
 
91
-    amf_ue = amf_ue_cycle(sess->amf_ue);
92
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
93
     ogs_assert(amf_ue);
94
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
95
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
96
     ogs_assert(ran_ue);
97
 
98
     ogs_debug("PDUSessionResourceReleaseCommand");
99
@@ -1815,7 +1808,6 @@
100
     NGAP_TAIListForPagingItem_t *TAIItem = NULL;
101
     NGAP_TAI_t *tAI = NULL;
102
 
103
-    amf_ue = amf_ue_cycle(amf_ue);
104
     ogs_assert(amf_ue);
105
     ogs_debug("Paging");
106
 
107
@@ -1942,9 +1934,8 @@
108
     NGAP_PDUSessionResourceSwitchedList_t *PDUSessionResourceSwitchedList;
109
     NGAP_AllowedNSSAI_t *AllowedNSSAI = NULL;
110
 
111
-    amf_ue = amf_ue_cycle(amf_ue);
112
     ogs_assert(amf_ue);
113
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
114
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
115
     ogs_assert(ran_ue);
116
 
117
     ogs_debug("PathSwitchAcknowledge");
118
@@ -2110,9 +2101,8 @@
119
         *SourceToTarget_TransparentContainer = NULL;
120
     NGAP_GUAMI_t *GUAMI = NULL;
121
 
122
-    target_ue = ran_ue_cycle(target_ue);
123
     ogs_assert(target_ue);
124
-    amf_ue = amf_ue_cycle(target_ue->amf_ue);
125
+    amf_ue = amf_ue_find_by_id(target_ue->amf_ue_id);
126
     ogs_assert(amf_ue);
127
 
128
     ogs_debug("HandoverRequest");
129
@@ -2410,7 +2400,6 @@
130
     NGAP_RAN_UE_NGAP_ID_t *RAN_UE_NGAP_ID = NULL;
131
     NGAP_Cause_t *Cause = NULL;
132
 
133
-    source_ue = ran_ue_cycle(source_ue);
134
     ogs_assert(source_ue);
135
     ogs_assert(cause);
136
 
137
@@ -2495,9 +2484,8 @@
138
     NGAP_TargetToSource_TransparentContainer_t
139
         *TargetToSource_TransparentContainer = NULL;
140
 
141
-    source_ue = ran_ue_cycle(source_ue);
142
     ogs_assert(source_ue);
143
-    amf_ue = amf_ue_cycle(source_ue->amf_ue);
144
+    amf_ue = amf_ue_find_by_id(source_ue->amf_ue_id);
145
     ogs_assert(amf_ue);
146
 
147
     ogs_debug("HandoverCommand");
148
@@ -2614,7 +2602,6 @@
149
     NGAP_AMF_UE_NGAP_ID_t *AMF_UE_NGAP_ID = NULL;
150
     NGAP_RAN_UE_NGAP_ID_t *RAN_UE_NGAP_ID = NULL;
151
 
152
-    source_ue = ran_ue_cycle(source_ue);
153
     ogs_assert(source_ue);
154
 
155
     ogs_debug("HandoverCancelAcknowledge");
156
@@ -2680,7 +2667,6 @@
157
     NGAP_RANStatusTransfer_TransparentContainer_t
158
         *RANStatusTransfer_TransparentContainer = NULL;
159
 
160
-    target_ue = ran_ue_cycle(target_ue);
161
     ogs_assert(target_ue);
162
     ogs_assert(transfer);
163
 
164
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/ngap-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/ngap-handler.c Changed
201
 
1
@@ -696,7 +696,7 @@
2
         return;
3
     }
4
 
5
-    amf_ue = ran_ue->amf_ue;
6
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
7
     if (!amf_ue) {
8
         ogs_error("Cannot find AMF-UE Context %lld",
9
                 (long long)amf_ue_ngap_id);
10
@@ -783,6 +783,7 @@
11
     int i, r;
12
 
13
     ran_ue_t *ran_ue = NULL;
14
+    amf_ue_t *amf_ue = NULL;
15
     uint64_t amf_ue_ngap_id;
16
 
17
     NGAP_InitiatingMessage_t *initiatingMessage = NULL;
18
@@ -872,9 +873,9 @@
19
         return;
20
     }
21
 
22
-    if (ran_ue->amf_ue)
23
-        OGS_ASN_STORE_DATA(&ran_ue->amf_ue->ueRadioCapability,
24
-                UERadioCapability);
25
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
26
+    if (amf_ue)
27
+        OGS_ASN_STORE_DATA(&amf_ue->ueRadioCapability, UERadioCapability);
28
 }
29
 
30
 void ngap_handle_initial_context_setup_response(
31
@@ -969,7 +970,7 @@
32
 
33
     ran_ue->initial_context_setup_response_received = true;
34
 
35
-    amf_ue = ran_ue->amf_ue;
36
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
37
     if (!amf_ue) {
38
         ogs_error("Cannot find AMF-UE Context %lld",
39
                 (long long)amf_ue_ngap_id);
40
@@ -1268,7 +1269,7 @@
41
      * may in principle be adopted. The RAN should ensure
42
      * that no hanging resources remain at the RAN.
43
      */
44
-    amf_ue = ran_ue->amf_ue;
45
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
46
     if (amf_ue) {
47
         /*
48
          * if T3550 is running, Registration complete will be sent.
49
@@ -1569,7 +1570,7 @@
50
         break;
51
     }
52
 
53
-    amf_ue = ran_ue->amf_ue;
54
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
55
     if (!amf_ue) {
56
         ogs_error("Cannot find AMF-UE Context %lld",
57
                 (long long)amf_ue_ngap_id);
58
@@ -1720,12 +1721,7 @@
59
 
60
     ogs_assert(ran_ue);
61
 
62
-    if (ran_ue_cycle(ran_ue) == NULL) {
63
-        ogs_error("NG context has already been removed");
64
-        return;
65
-    }
66
-
67
-    amf_ue = ran_ue->amf_ue;
68
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
69
 
70
     ogs_info("UE Context Release Action:%d", ran_ue->ue_ctx_rel_action);
71
     ogs_info("    RAN_UE_NGAP_ID%lld AMF_UE_NGAP_ID%lld",
72
@@ -1821,12 +1817,14 @@
73
             ogs_error("No UE(amf-ue) context");
74
             return;
75
         }
76
-        if (!amf_ue->ran_ue) {
77
+
78
+        ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
79
+        if (!ran_ue) {
80
             ogs_error("No NG context");
81
             return;
82
         }
83
 
84
-        r = ngap_send_handover_cancel_ack(amf_ue->ran_ue);
85
+        r = ngap_send_handover_cancel_ack(ran_ue);
86
         ogs_expect(r == OGS_OK);
87
         ogs_assert(r != OGS_ERROR);
88
         break;
89
@@ -1945,7 +1943,7 @@
90
             (long long)ran_ue->ran_ue_ngap_id,
91
             (long long)ran_ue->amf_ue_ngap_id);
92
 
93
-    amf_ue = ran_ue->amf_ue;
94
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
95
     if (!amf_ue) {
96
         ogs_error("Cannot find AMF-UE Context %lld",
97
                 (long long)amf_ue_ngap_id);
98
@@ -2267,7 +2265,7 @@
99
             (long long)ran_ue->ran_ue_ngap_id,
100
             (long long)ran_ue->amf_ue_ngap_id);
101
 
102
-    amf_ue = ran_ue->amf_ue;
103
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
104
     if (!amf_ue) {
105
         ogs_error("Cannot find AMF-UE Context %lld",
106
                 (long long)amf_ue_ngap_id);
107
@@ -2454,7 +2452,7 @@
108
             (long long)ran_ue->ran_ue_ngap_id,
109
             (long long)ran_ue->amf_ue_ngap_id);
110
 
111
-    amf_ue = ran_ue->amf_ue;
112
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
113
     if (!amf_ue) {
114
         ogs_error("Cannot find AMF-UE Context %lld",
115
                 (long long)amf_ue_ngap_id);
116
@@ -2802,7 +2800,7 @@
117
         return;
118
     }
119
 
120
-    amf_ue = ran_ue->amf_ue;
121
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
122
     if (!amf_ue) {
123
         ogs_error("Cannot find AMF-UE Context %lld",
124
                 (long long)amf_ue_ngap_id);
125
@@ -3133,7 +3131,7 @@
126
         (long long)source_ue->ran_ue_ngap_id,
127
         (long long)source_ue->amf_ue_ngap_id);
128
 
129
-    amf_ue = source_ue->amf_ue;
130
+    amf_ue = amf_ue_find_by_id(source_ue->amf_ue_id);
131
     if (!amf_ue) {
132
         ogs_error("Cannot find AMF-UE Context %lld",
133
                 (long long)amf_ue_ngap_id);
134
@@ -3251,7 +3249,7 @@
135
         return;
136
     }
137
 
138
-    target_ue = ran_ue_cycle(source_ue->target_ue);
139
+    target_ue = ran_ue_find_by_id(source_ue->target_ue_id);
140
     if (target_ue) {
141
     /*
142
      * Issue #3014
143
@@ -3521,7 +3519,7 @@
144
 
145
     target_ue->ran_ue_ngap_id = *RAN_UE_NGAP_ID;
146
 
147
-    source_ue = target_ue->source_ue;
148
+    source_ue = ran_ue_find_by_id(target_ue->source_ue_id);
149
     if (!source_ue) {
150
         ogs_error("Cannot find Source-UE Context %lld",
151
                 (long long)amf_ue_ngap_id);
152
@@ -3533,7 +3531,7 @@
153
         ogs_assert(r != OGS_ERROR);
154
         return;
155
     }
156
-    amf_ue = target_ue->amf_ue;
157
+    amf_ue = amf_ue_find_by_id(target_ue->amf_ue_id);
158
     if (!amf_ue) {
159
         ogs_error("Cannot find AMF-UE Context %lld",
160
                 (long long)amf_ue_ngap_id);
161
@@ -3728,7 +3726,7 @@
162
         return;
163
     }
164
 
165
-    source_ue = target_ue->source_ue;
166
+    source_ue = ran_ue_find_by_id(target_ue->source_ue_id);
167
     if (!source_ue) {
168
         ogs_error("Cannot find Source-UE Context %lld",
169
                 (long long)amf_ue_ngap_id);
170
@@ -3853,7 +3851,7 @@
171
         return;
172
     }
173
 
174
-    target_ue = source_ue->target_ue;
175
+    target_ue = ran_ue_find_by_id(source_ue->target_ue_id);
176
     if (!target_ue) {
177
         ogs_error("Cannot find Source-UE Context %lld",
178
                 (long long)amf_ue_ngap_id);
179
@@ -3865,7 +3863,7 @@
180
         ogs_assert(r != OGS_ERROR);
181
         return;
182
     }
183
-    amf_ue = source_ue->amf_ue;
184
+    amf_ue = amf_ue_find_by_id(source_ue->amf_ue_id);
185
     if (!amf_ue) {
186
         ogs_error("Cannot find AMF-UE Context %lld",
187
                 (long long)amf_ue_ngap_id);
188
@@ -4005,7 +4003,7 @@
189
         return;
190
     }
191
 
192
-    target_ue = source_ue->target_ue;
193
+    target_ue = ran_ue_find_by_id(source_ue->target_ue_id);
194
     if (!target_ue) {
195
         ogs_error("Cannot find Source-UE Context %lld",
196
                 (long long)amf_ue_ngap_id);
197
@@ -4017,7 +4015,7 @@
198
         ogs_assert(r != OGS_ERROR);
199
         return;
200
     }
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/ngap-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/ngap-path.c Changed
201
 
1
@@ -51,12 +51,7 @@
2
     char bufOGS_ADDRSTRLEN;
3
 
4
     ogs_assert(pkbuf);
5
-
6
-    if (!amf_gnb_cycle(gnb)) {
7
-        ogs_error("gNB has already been removed");
8
-        ogs_pkbuf_free(pkbuf);
9
-        return OGS_NOTFOUND;
10
-    }
11
+    ogs_assert(gnb);
12
 
13
     ogs_assert(gnb->sctp.sock);
14
     if (gnb->sctp.sock->fd == INVALID_SOCKET) {
15
@@ -83,15 +78,24 @@
16
 int ngap_send_to_ran_ue(ran_ue_t *ran_ue, ogs_pkbuf_t *pkbuf)
17
 {
18
     int rv;
19
+    amf_gnb_t *gnb = NULL;
20
+
21
     ogs_assert(pkbuf);
22
 
23
-    if (!ran_ue_cycle(ran_ue)) {
24
+    if (!ran_ue) {
25
         ogs_error("NG context has already been removed");
26
         ogs_pkbuf_free(pkbuf);
27
         return OGS_NOTFOUND;
28
     }
29
 
30
-    rv = ngap_send_to_gnb(ran_ue->gnb, pkbuf, ran_ue->gnb_ostream_id);
31
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
32
+    if (!gnb) {
33
+        ogs_error("%d gNB has already been removed", ran_ue->gnb_id);
34
+        ogs_pkbuf_free(pkbuf);
35
+        return OGS_NOTFOUND;
36
+    }
37
+
38
+    rv = ngap_send_to_gnb(gnb, pkbuf, ran_ue->gnb_ostream_id);
39
     ogs_expect(rv == OGS_OK);
40
 
41
     return rv;
42
@@ -112,8 +116,7 @@
43
                 ogs_app()->timer_mgr, amf_timer_ng_delayed_send, e);
44
         ogs_assert(e->timer);
45
         e->pkbuf = pkbuf;
46
-        e->ran_ue = ran_ue;
47
-        e->gnb = ran_ue->gnb;
48
+        e->ran_ue_id = ran_ue->id;
49
 
50
         ogs_timer_start(e->timer, duration);
51
 
52
@@ -136,7 +139,7 @@
53
 
54
     e = amf_event_new(AMF_EVENT_5GSM_MESSAGE);
55
     ogs_assert(e);
56
-    e->amf_ue = amf_ue;
57
+    e->amf_ue_id = amf_ue->id;
58
     e->pkbuf = esmbuf;
59
     rv = ogs_queue_push(ogs_app()->queue, e);
60
     if (rv != OGS_OK) {
61
@@ -153,6 +156,8 @@
62
 {
63
     int rv;
64
 
65
+    amf_ue_t *amf_ue = NULL;
66
+
67
     ogs_nas_5gs_security_header_t *sh = NULL;
68
     ogs_nas_security_header_type_t security_header_type;
69
 
70
@@ -163,6 +168,8 @@
71
     ogs_assert(ran_ue);
72
     ogs_assert(nasPdu);
73
 
74
+    amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
75
+
76
     /* The Packet Buffer(pkbuf_t) for NAS message MUST make a HEADROOM. 
77
      * When calculating AES_CMAC, we need to use the headroom of the packet. */
78
     nasbuf = ogs_pkbuf_alloc(NULL, OGS_NAS_HEADROOM+nasPdu->size);
79
@@ -204,8 +211,8 @@
80
         return OGS_ERROR;
81
     }
82
 
83
-    if (ran_ue->amf_ue) {
84
-        if (nas_5gs_security_decode(ran_ue->amf_ue,
85
+    if (amf_ue) {
86
+        if (nas_5gs_security_decode(amf_ue,
87
                 security_header_type, nasbuf) != OGS_OK) {
88
             ogs_error("nas_eps_security_decode failed()");
89
             ran_ue_remove(ran_ue);
90
@@ -249,7 +256,7 @@
91
             ogs_pkbuf_free(nasbuf);
92
             return OGS_ERROR;
93
         }
94
-        e->ran_ue = ran_ue;
95
+        e->ran_ue_id = ran_ue->id;
96
         e->ngap.code = procedureCode;
97
         e->nas.type = security_header_type.type;
98
         e->pkbuf = nasbuf;
99
@@ -262,7 +269,6 @@
100
         return rv;
101
     } else if (h->extended_protocol_discriminator ==
102
             OGS_NAS_EXTENDED_PROTOCOL_DISCRIMINATOR_5GSM) {
103
-        amf_ue_t *amf_ue = ran_ue->amf_ue;
104
         if (!amf_ue) {
105
             ogs_error("No UE Context");
106
             ogs_pkbuf_free(nasbuf);
107
@@ -288,12 +294,9 @@
108
     int rv;
109
     ogs_pkbuf_t *ngap_buffer;
110
 
111
-    ogs_debug("NG-Setup response");
112
+    ogs_assert(gnb);
113
 
114
-    if (!amf_gnb_cycle(gnb)) {
115
-        ogs_error("gNB has already been removed");
116
-        return OGS_NOTFOUND;
117
-    }
118
+    ogs_debug("NG-Setup response");
119
 
120
     ngap_buffer = ngap_build_ng_setup_response();
121
     if (!ngap_buffer) {
122
@@ -313,12 +316,9 @@
123
     int rv;
124
     ogs_pkbuf_t *ngap_buffer;
125
 
126
-    ogs_debug("NG-Setup failure");
127
+    ogs_assert(gnb);
128
 
129
-    if (!amf_gnb_cycle(gnb)) {
130
-        ogs_error("gNB has already been removed");
131
-        return OGS_NOTFOUND;
132
-    }
133
+    ogs_debug("NG-Setup failure");
134
 
135
     ngap_buffer = ngap_build_ng_setup_failure(
136
             group, cause, NGAP_TimeToWait_v10s);
137
@@ -338,12 +338,9 @@
138
     int rv;
139
     ogs_pkbuf_t *ngap_buffer;
140
 
141
-    ogs_debug("RANConfigurationUpdateAcknowledge");
142
+    ogs_assert(gnb);
143
 
144
-    if (!amf_gnb_cycle(gnb)) {
145
-        ogs_error("gNB has already been removed");
146
-        return OGS_NOTFOUND;
147
-    }
148
+    ogs_debug("RANConfigurationUpdateAcknowledge");
149
 
150
     ngap_buffer = ngap_build_ran_configuration_update_ack();
151
     if (!ngap_buffer) {
152
@@ -363,12 +360,9 @@
153
     int rv;
154
     ogs_pkbuf_t *ngap_buffer;
155
 
156
-    ogs_debug("RANConfigurationUpdateFailure");
157
+    ogs_assert(gnb);
158
 
159
-    if (!amf_gnb_cycle(gnb)) {
160
-        ogs_error("gNB has already been removed");
161
-        return OGS_NOTFOUND;
162
-    }
163
+    ogs_debug("RANConfigurationUpdateFailure");
164
 
165
     ngap_buffer = ngap_build_ran_configuration_update_failure(
166
             group, cause, NGAP_TimeToWait_v10s);
167
@@ -390,7 +384,7 @@
168
     int rv;
169
     ogs_pkbuf_t *ngapbuf = NULL;
170
 
171
-    if (!ran_ue_cycle(ran_ue)) {
172
+    if (!ran_ue) {
173
         ogs_error("NG context has already been removed");
174
         return OGS_NOTFOUND;
175
     }
176
@@ -427,13 +421,14 @@
177
 {
178
     int rv;
179
 
180
-    if (!amf_ue_cycle(amf_ue)) {
181
+    if (!amf_ue) {
182
         ogs_error("UE(amf-ue) context has already been removed");
183
         return OGS_NOTFOUND;
184
     }
185
 
186
     rv = ngap_send_ran_ue_context_release_command(
187
-            amf_ue->ran_ue, group, cause, action, duration);
188
+            ran_ue_find_by_id(amf_ue->ran_ue_id),
189
+            group, cause, action, duration);
190
     ogs_expect(rv == OGS_OK);
191
     ogs_debug("    SUPI%s", amf_ue->supi);
192
 
193
@@ -449,7 +444,7 @@
194
 
195
     ogs_debug("NG-Paging");
196
 
197
-    if (!amf_ue_cycle(amf_ue)) {
198
+    if (!amf_ue) {
199
         ogs_error("UE(amf-ue) context has already been removed");
200
         return OGS_NOTFOUND;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/ngap-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/ngap-sm.c Changed
23
 
1
@@ -54,7 +54,7 @@
2
 
3
     amf_sm_debug(e);
4
 
5
-    gnb = e->gnb;
6
+    gnb = amf_gnb_find_by_id(e->gnb_id);
7
     ogs_assert(gnb);
8
 
9
     switch (e->h.id) {
10
@@ -191,10 +191,10 @@
11
     case AMF_EVENT_NGAP_TIMER:
12
         switch (e->h.timer_id) {
13
         case AMF_TIMER_NG_DELAYED_SEND:
14
-            ogs_assert(e->ran_ue);
15
             ogs_assert(e->pkbuf);
16
 
17
-            r = ngap_send_to_ran_ue(e->ran_ue, e->pkbuf);
18
+            r = ngap_send_to_ran_ue(
19
+                    ran_ue_find_by_id(e->ran_ue_id), e->pkbuf);
20
             ogs_expect(r == OGS_OK);
21
             ogs_assert(r != OGS_ERROR);
22
 
23
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/nnrf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/nnrf-handler.c Changed
19
 
1
@@ -84,13 +84,15 @@
2
             ogs_error("%d:%d (NF discover) No %s", sess->psi, sess->pti,
3
                         ogs_sbi_service_type_to_name(service_type));
4
             if (sess->payload_container_type) {
5
-                r = nas_5gs_send_back_gsm_message(sess->ran_ue, sess,
6
+                r = nas_5gs_send_back_gsm_message(
7
+                        ran_ue_find_by_id(sess->ran_ue_id), sess,
8
                         OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
9
                         AMF_NAS_BACKOFF_TIME);
10
                 ogs_expect(r == OGS_OK);
11
                 ogs_assert(r != OGS_ERROR);
12
             } else {
13
-                r = ngap_send_error_indication2(sess->ran_ue,
14
+                r = ngap_send_error_indication2(
15
+                        ran_ue_find_by_id(sess->ran_ue_id),
16
                         NGAP_Cause_PR_transport,
17
                         NGAP_CauseTransport_transport_resource_unavailable);
18
                 ogs_expect(r == OGS_OK);
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/nnssf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/nnssf-handler.c Changed
26
 
1
@@ -42,21 +42,20 @@
2
     ogs_assert(recvmsg);
3
     ogs_assert(!SESSION_CONTEXT_IN_SMF(sess));
4
 
5
-    sess = amf_sess_cycle(sess);
6
     if (!sess) {
7
         ogs_error("Session has already been removed");
8
         return OGS_ERROR;
9
     }
10
 
11
-    amf_ue = amf_ue_cycle(sess->amf_ue);
12
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
13
     if (!amf_ue) {
14
         ogs_error("UE(amf_ue) Context has already been removed");
15
         return OGS_ERROR;
16
     }
17
 
18
-    ran_ue = ran_ue_cycle(sess->ran_ue);
19
+    ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
20
     if (!ran_ue) {
21
-        ogs_error("NG context has already been removed");
22
+        ogs_error("%s RAN-NG Context has already been removed", amf_ue->supi);
23
         return OGS_ERROR;
24
     }
25
 
26
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/npcf-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/npcf-build.c Changed
10
 
1
@@ -38,7 +38,7 @@
2
 
3
     ogs_assert(amf_ue);
4
     ogs_assert(amf_ue->supi);
5
-    ogs_assert(ran_ue_cycle(amf_ue->ran_ue));
6
+    ogs_assert(ran_ue_find_by_id(amf_ue->ran_ue_id));
7
 
8
     memset(&message, 0, sizeof(message));
9
     message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/nsmf-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/nsmf-build.c Changed
46
 
1
@@ -39,10 +39,10 @@
2
     ogs_sbi_nf_instance_t *pcf_nf_instance = NULL;
3
 
4
     ogs_assert(sess);
5
-    amf_ue = sess->amf_ue;
6
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
7
     ogs_assert(amf_ue);
8
     ogs_assert(amf_ue->nas.access_type);
9
-    ogs_assert(ran_ue_cycle(amf_ue->ran_ue));
10
+    ogs_assert(ran_ue_find_by_id(amf_ue->ran_ue_id));
11
 
12
     memset(&message, 0, sizeof(message));
13
     message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
14
@@ -274,7 +274,7 @@
15
     ogs_assert(param);
16
     ogs_assert(sess);
17
     ogs_assert(sess->sm_context.resource_uri);
18
-    amf_ue = sess->amf_ue;
19
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
20
     ogs_assert(amf_ue);
21
 
22
     memset(&message, 0, sizeof(message));
23
@@ -407,8 +407,6 @@
24
 
25
     ogs_assert(sess);
26
     ogs_assert(sess->sm_context.resource_uri);
27
-    amf_ue = sess->amf_ue;
28
-    ogs_assert(amf_ue);
29
 
30
     memset(&message, 0, sizeof(message));
31
     message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
32
@@ -432,6 +430,13 @@
33
     }
34
 
35
     memset(&ueLocation, 0, sizeof(ueLocation));
36
+
37
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
38
+    if (!amf_ue) {
39
+        ogs_error("UE(amf_ue) Context has already been removed");
40
+        goto end;
41
+    }
42
+
43
     ueLocation.nr_location = ogs_sbi_build_nr_location(
44
             &amf_ue->nr_tai, &amf_ue->nr_cgi);
45
     if (!ueLocation.nr_location) {
46
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/nsmf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/nsmf-handler.c Changed
177
 
1
@@ -33,20 +33,19 @@
2
     ran_ue_t *ran_ue = NULL;
3
 
4
     ogs_assert(recvmsg);
5
-    ogs_assert(sess);
6
-    sess = amf_sess_cycle(sess);
7
+
8
     if (!sess) {
9
         ogs_error("Session has already been removed");
10
         return OGS_ERROR;
11
     }
12
 
13
-    amf_ue = amf_ue_cycle(sess->amf_ue);
14
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
15
     if (!amf_ue) {
16
         ogs_error("UE(amf_ue) Context has already been removed");
17
         return OGS_ERROR;
18
     }
19
 
20
-    ran_ue = ran_ue_cycle(sess->ran_ue);
21
+    ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
22
     if (!ran_ue) {
23
         ogs_error("%s RAN-NG Context has already been removed", amf_ue->supi);
24
         return OGS_ERROR;
25
@@ -255,20 +254,19 @@
26
     ran_ue_t *ran_ue = NULL;
27
 
28
     ogs_assert(recvmsg);
29
-    ogs_assert(sess);
30
-    sess = amf_sess_cycle(sess);
31
+
32
     if (!sess) {
33
         ogs_error("Session has already been removed");
34
         return OGS_ERROR;
35
     }
36
 
37
-    amf_ue = amf_ue_cycle(sess->amf_ue);
38
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
39
     if (!amf_ue) {
40
         ogs_error("UE(amf_ue) Context has already been removed");
41
         return OGS_ERROR;
42
     }
43
 
44
-    ran_ue = ran_ue_cycle(sess->ran_ue);
45
+    ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
46
 
47
     if (recvmsg->res_status == OGS_SBI_HTTP_STATUS_NO_CONTENT ||
48
         recvmsg->res_status == OGS_SBI_HTTP_STATUS_OK) {
49
@@ -711,9 +709,9 @@
50
                 if (AMF_SESSION_SYNC_DONE(amf_ue, state)) {
51
                     ran_ue_t *source_ue = NULL, *target_ue = NULL;
52
 
53
-                    source_ue = sess->ran_ue;
54
+                    source_ue = ran_ue_find_by_id(sess->ran_ue_id);
55
                     ogs_assert(source_ue);
56
-                    target_ue = ran_ue_cycle(source_ue->target_ue);
57
+                    target_ue = ran_ue_find_by_id(source_ue->target_ue_id);
58
                     if (target_ue) {
59
                         r = ngap_send_ran_ue_context_release_command(
60
                                 target_ue,
61
@@ -783,13 +781,14 @@
62
                     amf_ue_deassociate(amf_ue);
63
 
64
                     if (ran_ue) {
65
-                        amf_gnb_t *gnb = ran_ue->gnb;
66
-                        ogs_assert(gnb);
67
+                        amf_gnb_t *gnb = NULL;
68
+
69
+                        gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
70
 
71
                         ogs_debug("    SUPI%s", amf_ue->supi);
72
                         ran_ue_remove(ran_ue);
73
 
74
-                        if (ogs_list_count(&gnb->ran_ue_list) == 0) {
75
+                        if (gnb && ogs_list_count(&gnb->ran_ue_list) == 0) {
76
                             r = ngap_send_ng_reset_ack(gnb, NULL);
77
                             ogs_expect(r == OGS_OK);
78
                             ogs_assert(r != OGS_ERROR);
79
@@ -839,33 +838,35 @@
80
                     amf_ue_deassociate(amf_ue);
81
 
82
                     if (ran_ue) {
83
-                        amf_gnb_t *gnb = ran_ue->gnb;
84
-                        ogs_assert(gnb);
85
+                        amf_gnb_t *gnb = NULL;
86
+
87
+                        gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
88
 
89
                         ogs_debug("    SUPI%s", amf_ue->supi);
90
                         ran_ue_remove(ran_ue);
91
 
92
-                        ogs_list_for_each(&gnb->ran_ue_list, iter) {
93
-                            if (iter->part_of_ng_reset_requested == true) {
94
-                                /* The GNB_UE context
95
-                                 * where PartOfNG_interface was requested
96
-                                 * still remains */
97
-                                return OGS_OK;
98
+                        if (gnb) {
99
+                            ogs_list_for_each(&gnb->ran_ue_list, iter) {
100
+                                if (iter->part_of_ng_reset_requested == true) {
101
+                                    /* The GNB_UE context
102
+                                     * where PartOfNG_interface was requested
103
+                                     * still remains */
104
+                                    return OGS_OK;
105
+                                }
106
                             }
107
-                        }
108
 
109
-                        /* All GNB_UE context
110
-                         * where PartOfNG_interface was requested
111
-                         * REMOVED */
112
-                        ogs_assert(gnb->ng_reset_ack);
113
-                        r = ngap_send_to_gnb(
114
-                            gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING);
115
-                        ogs_expect(r == OGS_OK);
116
-                        ogs_assert(r != OGS_ERROR);
117
-
118
-                        /* Clear NG-Reset Ack Buffer */
119
-                        gnb->ng_reset_ack = NULL;
120
+                            /* All GNB_UE context
121
+                             * where PartOfNG_interface was requested
122
+                             * REMOVED */
123
+                            ogs_assert(gnb->ng_reset_ack);
124
+                            r = ngap_send_to_gnb(
125
+                                gnb, gnb->ng_reset_ack, NGAP_NON_UE_SIGNALLING);
126
+                            ogs_expect(r == OGS_OK);
127
+                            ogs_assert(r != OGS_ERROR);
128
 
129
+                            /* Clear NG-Reset Ack Buffer */
130
+                            gnb->ng_reset_ack = NULL;
131
+                        }
132
                     } else {
133
                         ogs_warn("%s RAN-NG Context has already been removed",
134
                                 amf_ue->supi);
135
@@ -936,8 +937,16 @@
136
         ogs_pkbuf_t *n2smbuf = NULL;
137
 #endif
138
 
139
-        amf_ue = sess->amf_ue;
140
-        ogs_assert(amf_ue);
141
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
142
+        if (!amf_ue) {
143
+            ogs_error("%d:%d UE context has already been removed %d",
144
+                    sess->psi, sess->pti, recvmsg->res_status);
145
+            r = ngap_send_error_indication2(ran_ue,
146
+                    NGAP_Cause_PR_protocol, NGAP_CauseProtocol_semantic_error);
147
+            ogs_expect(r == OGS_OK);
148
+            ogs_assert(r != OGS_ERROR);
149
+            return OGS_ERROR;
150
+        }
151
 
152
         SmContextUpdateError = recvmsg->SmContextUpdateError;
153
         if (!SmContextUpdateError) {
154
@@ -1072,20 +1081,18 @@
155
     amf_ue_t *amf_ue = NULL;
156
     ran_ue_t *ran_ue = NULL;
157
 
158
-    ogs_assert(sess);
159
-    sess = amf_sess_cycle(sess);
160
     if (!sess) {
161
         ogs_error("Session has already been removed");
162
         return OGS_ERROR;
163
     }
164
 
165
-    amf_ue = amf_ue_cycle(sess->amf_ue);
166
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
167
     if (!amf_ue) {
168
         ogs_error("UE(amf_ue) Context has already been removed");
169
         return OGS_ERROR;
170
     }
171
 
172
-    ran_ue = ran_ue_cycle(sess->ran_ue);
173
+    ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
174
 
175
     /*
176
      * To check if Reactivation Request has been used.
177
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/nudm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/nudm-handler.c Changed
19
 
1
@@ -144,7 +144,7 @@
2
         if (amf_update_allowed_nssai(amf_ue) == false) {
3
             ogs_error("No Allowed-NSSAI");
4
             r = nas_5gs_send_gmm_reject(
5
-                    amf_ue->ran_ue, amf_ue,
6
+                    ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
7
                     OGS_5GMM_CAUSE_NO_NETWORK_SLICES_AVAILABLE);
8
             ogs_expect(r == OGS_OK);
9
             ogs_assert(r != OGS_ERROR);
10
@@ -154,7 +154,7 @@
11
         if (amf_ue_is_rat_restricted(amf_ue)) {
12
             ogs_error("Registration rejected due to RAT restrictions");
13
             r = nas_5gs_send_gmm_reject(
14
-                    amf_ue->ran_ue, amf_ue,
15
+                    ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
16
                     OGS_5GMM_CAUSE_5GS_SERVICES_NOT_ALLOWED);
17
             ogs_expect(r == OGS_OK);
18
             ogs_assert(r != OGS_ERROR);
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/sbi-path.c Changed
148
 
1
@@ -127,7 +127,7 @@
2
     }
3
 
4
     xact = ogs_sbi_xact_add(
5
-            &amf_ue->sbi, service_type, discovery_option,
6
+            amf_ue->id, &amf_ue->sbi, service_type, discovery_option,
7
             (ogs_sbi_build_f)build, amf_ue, data);
8
     if (!xact) {
9
         ogs_error("amf_ue_sbi_discover_and_send() failed");
10
@@ -169,21 +169,18 @@
11
     ogs_assert(build);
12
 
13
     if (ran_ue) {
14
-        sess->ran_ue = ran_ue_cycle(ran_ue);
15
-        if (!sess->ran_ue) {
16
-            ogs_error("NG context has already been removed");
17
-            return OGS_NOTFOUND;
18
-        }
19
+        sess->ran_ue_id = ran_ue->id;
20
     } else
21
-        sess->ran_ue = NULL;
22
+        sess->ran_ue_id = OGS_INVALID_POOL_ID;
23
 
24
     xact = ogs_sbi_xact_add(
25
-            &sess->sbi, service_type, discovery_option,
26
+            sess->id, &sess->sbi, service_type, discovery_option,
27
             (ogs_sbi_build_f)build, sess, data);
28
     if (!xact) {
29
         ogs_error("amf_sess_sbi_discover_and_send() failed");
30
-        r = nas_5gs_send_back_gsm_message(sess->ran_ue, sess,
31
-            OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME);
32
+        r = nas_5gs_send_back_gsm_message(
33
+                ran_ue_find_by_id(sess->ran_ue_id), sess,
34
+                OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME);
35
         ogs_expect(r == OGS_OK);
36
         ogs_assert(r != OGS_ERROR);
37
         return OGS_ERROR;
38
@@ -195,8 +192,9 @@
39
     if (rv != OGS_OK) {
40
         ogs_error("amf_sess_sbi_discover_and_send() failed");
41
         ogs_sbi_xact_remove(xact);
42
-        r = nas_5gs_send_back_gsm_message(sess->ran_ue, sess,
43
-            OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME);
44
+        r = nas_5gs_send_back_gsm_message(
45
+                ran_ue_find_by_id(sess->ran_ue_id), sess,
46
+                OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED, AMF_NAS_BACKOFF_TIME);
47
         ogs_expect(r == OGS_OK);
48
         ogs_assert(r != OGS_ERROR);
49
         return rv;
50
@@ -211,6 +209,7 @@
51
     ogs_sbi_message_t message;
52
 
53
     ogs_sbi_xact_t *xact = NULL;
54
+    ogs_pool_id_t xact_id = OGS_INVALID_POOL_ID;
55
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
56
     OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
57
     ogs_sbi_discovery_option_t *discovery_option = NULL;
58
@@ -218,10 +217,10 @@
59
     ran_ue_t *ran_ue = NULL;
60
     amf_sess_t *sess = NULL;
61
 
62
-    xact = data;
63
-    ogs_assert(xact);
64
+    xact_id = OGS_POINTER_TO_UINT(data);
65
+    ogs_assert(xact_id >= OGS_MIN_POOL_ID && xact_id <= OGS_MAX_POOL_ID);
66
 
67
-    xact = ogs_sbi_xact_cycle(xact);
68
+    xact = ogs_sbi_xact_find_by_id(xact_id);
69
     if (!xact) {
70
         ogs_error("SBI transaction has already been removed");
71
         if (response)
72
@@ -229,16 +228,13 @@
73
         return OGS_ERROR;
74
     }
75
 
76
-    sess = (amf_sess_t *)xact->sbi_object;
77
-    ogs_assert(sess);
78
-
79
     service_type = xact->service_type;
80
     ogs_assert(service_type);
81
     requester_nf_type = xact->requester_nf_type;
82
     ogs_assert(requester_nf_type);
83
     discovery_option = xact->discovery_option;
84
 
85
-    sess = amf_sess_cycle(sess);
86
+    sess = amf_sess_find_by_id(xact->sbi_object_id);
87
     if (!sess) {
88
         ogs_error("Session has already been removed");
89
         ogs_sbi_xact_remove(xact);
90
@@ -248,7 +244,7 @@
91
     }
92
 
93
     ogs_assert(sess->sbi.type == OGS_SBI_OBJ_SESS_TYPE);
94
-    amf_ue = amf_ue_cycle(sess->amf_ue);
95
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
96
     if (!amf_ue) {
97
         ogs_error("UE(amf-ue) context has already been removed");
98
         ogs_sbi_xact_remove(xact);
99
@@ -256,7 +252,7 @@
100
             ogs_sbi_response_free(response);
101
         return OGS_ERROR;
102
     }
103
-    ran_ue = ran_ue_cycle(sess->ran_ue);
104
+    ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
105
     if (!ran_ue) {
106
         ogs_error("%s NG context has already been removed", amf_ue->supi);
107
         ogs_sbi_xact_remove(xact);
108
@@ -367,16 +363,13 @@
109
                 ogs_sbi_service_type_to_name(service_type));
110
 
111
     if (ran_ue) {
112
-        sess->ran_ue = ran_ue_cycle(ran_ue);
113
-        if (!sess->ran_ue) {
114
-            ogs_error("NG context has already been removed");
115
-            return OGS_NOTFOUND;
116
-        }
117
+        sess->ran_ue_id = ran_ue->id;
118
     } else
119
-        sess->ran_ue = NULL;
120
+        sess->ran_ue_id = OGS_INVALID_POOL_ID;
121
 
122
     xact = ogs_sbi_xact_add(
123
-            &sess->sbi, service_type, discovery_option, NULL, NULL, NULL);
124
+            sess->id, &sess->sbi,
125
+            service_type, discovery_option, NULL, NULL, NULL);
126
     if (!xact) {
127
         ogs_error("ogs_sbi_xact_add() failed");
128
         return OGS_ERROR;
129
@@ -391,7 +384,8 @@
130
     }
131
 
132
     return ogs_sbi_client_send_request(
133
-            client, client_discover_cb, xact->request, xact) == true ? OGS_OK : OGS_ERROR;
134
+            client, client_discover_cb, xact->request,
135
+            OGS_UINT_TO_POINTER(xact->id)) == true ? OGS_OK : OGS_ERROR;
136
 }
137
 
138
 void amf_sbi_send_activating_session(
139
@@ -457,7 +451,7 @@
140
     ogs_list_for_each_safe(&gnb->ran_ue_list, ran_ue_next, ran_ue) {
141
         int old_xact_count = 0, new_xact_count = 0;
142
 
143
-        amf_ue = amf_ue_cycle(ran_ue->amf_ue);
144
+        amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
145
 
146
         if (amf_ue) {
147
             old_xact_count = amf_sess_xact_count(amf_ue);
148
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/amf/timer.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/amf/timer.c Changed
50
 
1
@@ -49,9 +49,6 @@
2
         { .have = true, .duration = ogs_time_from_sec(30) },
3
 };
4
 
5
-static void gmm_timer_event_send(
6
-        amf_timer_e timer_id, amf_ue_t *amf_ue);
7
-
8
 amf_timer_cfg_t *amf_timer_cfg(amf_timer_e id)
9
 {
10
     ogs_assert(id < MAX_NUM_OF_AMF_TIMER);
11
@@ -124,16 +121,17 @@
12
 }
13
 
14
 static void gmm_timer_event_send(
15
-        amf_timer_e timer_id, amf_ue_t *amf_ue)
16
+        amf_timer_e timer_id, void *data)
17
 {
18
     int rv;
19
     amf_event_t *e = NULL;
20
-    ogs_assert(amf_ue);
21
+
22
+    ogs_assert(data);
23
 
24
     e = amf_event_new(AMF_EVENT_5GMM_TIMER);
25
     ogs_assert(e);
26
     e->h.timer_id = timer_id;
27
-    e->amf_ue = amf_ue;
28
+    e->amf_ue_id = OGS_POINTER_TO_UINT(data);
29
 
30
     rv = ogs_queue_push(ogs_app()->queue, e);
31
     if (rv != OGS_OK) {
32
@@ -172,16 +170,14 @@
33
 {
34
     int rv;
35
     amf_event_t *e = NULL;
36
-    ran_ue_t *ran_ue = NULL;
37
 
38
     ogs_assert(data);
39
-    ran_ue = data;
40
 
41
     e = amf_event_new(AMF_EVENT_NGAP_TIMER);
42
     ogs_assert(e);
43
 
44
     e->h.timer_id = AMF_TIMER_NG_HOLDING;
45
-    e->ran_ue = ran_ue;
46
+    e->ran_ue_id = OGS_POINTER_TO_UINT(data);
47
 
48
     rv = ogs_queue_push(ogs_app()->queue, e);
49
     if (rv != OGS_OK) {
50
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/ausf/ausf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/ausf/ausf-sm.c Changed
161
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -39,6 +39,7 @@
9
     int rv;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -46,8 +47,10 @@
17
     ogs_sbi_response_t *response = NULL;
18
     ogs_sbi_message_t message;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
21
 
22
     ausf_ue_t *ausf_ue = NULL;
23
+    ogs_pool_id_t ausf_ue_id = OGS_INVALID_POOL_ID;
24
 
25
     ausf_sm_debug(e);
26
 
27
@@ -63,8 +66,16 @@
28
     case OGS_EVENT_SBI_SERVER:
29
         request = e->h.sbi.request;
30
         ogs_assert(request);
31
-        stream = e->h.sbi.data;
32
-        ogs_assert(stream);
33
+
34
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
35
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
36
+                stream_id <= OGS_MAX_POOL_ID);
37
+
38
+        stream = ogs_sbi_stream_find_by_id(stream_id);
39
+        if (!stream) {
40
+            ogs_error("STREAM has already been removed %d", stream_id);
41
+            break;
42
+        }
43
 
44
         rv = ogs_sbi_parse_request(&message, request);
45
         if (rv != OGS_OK) {
46
@@ -154,7 +165,7 @@
47
 
48
             ogs_assert(OGS_FSM_STATE(&ausf_ue->sm));
49
 
50
-            e->ausf_ue = ausf_ue;
51
+            e->ausf_ue_id = ausf_ue->id;
52
             e->h.sbi.message = &message;
53
             ogs_fsm_dispatch(&ausf_ue->sm, e);
54
             if (OGS_FSM_CHECK(&ausf_ue->sm, ausf_ue_state_exception)) {
55
@@ -267,8 +278,18 @@
56
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
57
             SWITCH(message.h.resource.component0)
58
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
59
-                sbi_xact = e->h.sbi.data;
60
-                ogs_assert(sbi_xact);
61
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
62
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
63
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
64
+
65
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
66
+                if (!sbi_xact) {
67
+                    /* CLIENT_WAIT timer could remove SBI transaction
68
+                     * before receiving SBI message */
69
+                    ogs_error("SBI transaction has already been removed %d",
70
+                            sbi_xact_id);
71
+                    break;
72
+                }
73
 
74
                 SWITCH(message.h.method)
75
                 CASE(OGS_SBI_HTTP_METHOD_GET)
76
@@ -293,31 +314,36 @@
77
             break;
78
 
79
         CASE(OGS_SBI_SERVICE_NAME_NUDM_UEAU)
80
-            sbi_xact = e->h.sbi.data;
81
-            ogs_assert(sbi_xact);
82
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
83
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
84
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
85
 
86
-            sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
87
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
88
             if (!sbi_xact) {
89
                 /* CLIENT_WAIT timer could remove SBI transaction
90
                  * before receiving SBI message */
91
-                ogs_error("SBI transaction has already been removed");
92
+                ogs_error("SBI transaction has already been removed %d",
93
+                        sbi_xact_id);
94
                 break;
95
             }
96
 
97
-            ausf_ue = (ausf_ue_t *)sbi_xact->sbi_object;
98
-            ogs_assert(ausf_ue);
99
-
100
-            e->h.sbi.data = sbi_xact->assoc_stream;
101
+            ausf_ue_id = sbi_xact->sbi_object_id;
102
+            ogs_assert(ausf_ue_id >= OGS_MIN_POOL_ID &&
103
+                    ausf_ue_id <= OGS_MAX_POOL_ID);
104
+
105
+            ogs_assert(sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
106
+                    sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID);
107
+            e->h.sbi.data = OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
108
 
109
             ogs_sbi_xact_remove(sbi_xact);
110
 
111
-            ausf_ue = ausf_ue_cycle(ausf_ue);
112
+            ausf_ue = ausf_ue_find_by_id(ausf_ue_id);
113
             if (!ausf_ue) {
114
                 ogs_error("UE(ausf-ue) Context has already been removed");
115
                 break;
116
             }
117
 
118
-            e->ausf_ue = ausf_ue;
119
+            e->ausf_ue_id = ausf_ue->id;
120
             e->h.sbi.message = &message;
121
 
122
             ogs_fsm_dispatch(&ausf_ue->sm, e);
123
@@ -413,20 +439,32 @@
124
              * 4. timer expiration event is processed. (double-free SBI xact)
125
              *
126
              * To avoid double-free SBI xact,
127
-             * we need to check ogs_sbi_xact_cycle()
128
+             * we need to check ogs_sbi_xact_find_by_id()
129
              */
130
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
131
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
132
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
133
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
134
+
135
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
136
             if (!sbi_xact) {
137
-                ogs_error("SBI transaction has already been removed");
138
+                ogs_error("SBI transaction has already been removed %d",
139
+                        sbi_xact_id);
140
                 break;
141
             }
142
 
143
-            stream = sbi_xact->assoc_stream;
144
-            ogs_assert(stream);
145
+            ogs_assert(sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
146
+                    sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID);
147
+            stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
148
 
149
             ogs_sbi_xact_remove(sbi_xact);
150
 
151
             ogs_error("Cannot receive SBI message");
152
+
153
+            if (!stream) {
154
+                ogs_error("STREAM has alreadt been removed %d",
155
+                        sbi_xact->assoc_stream_id);
156
+                break;
157
+            }
158
             ogs_assert(true ==
159
                 ogs_sbi_server_send_error(stream,
160
                     OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL,
161
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/ausf/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/ausf/context.c Changed
56
 
1
@@ -131,13 +131,11 @@
2
 
3
     ogs_assert(suci);
4
 
5
-    ogs_pool_alloc(&ausf_ue_pool, &ausf_ue);
6
+    ogs_pool_id_calloc(&ausf_ue_pool, &ausf_ue);
7
     if (!ausf_ue) {
8
-        ogs_error("ogs_pool_alloc() failed");
9
+        ogs_error("ogs_pool_id_calloc() failed");
10
         return NULL;
11
     }
12
-    ogs_assert(ausf_ue);
13
-    memset(ausf_ue, 0, sizeof *ausf_ue);
14
 
15
     ausf_ue->ctx_id =
16
         ogs_msprintf("%d", (int)ogs_pool_index(&ausf_ue_pool, ausf_ue));
17
@@ -148,7 +146,7 @@
18
     ogs_hash_set(self.suci_hash, ausf_ue->suci, strlen(ausf_ue->suci), ausf_ue);
19
 
20
     memset(&e, 0, sizeof(e));
21
-    e.ausf_ue = ausf_ue;
22
+    e.ausf_ue_id = ausf_ue->id;
23
     ogs_fsm_init(&ausf_ue->sm, ausf_ue_state_initial, ausf_ue_state_final, &e);
24
 
25
     ogs_list_add(&self.ausf_ue_list, ausf_ue);
26
@@ -165,7 +163,7 @@
27
     ogs_list_remove(&self.ausf_ue_list, ausf_ue);
28
 
29
     memset(&e, 0, sizeof(e));
30
-    e.ausf_ue = ausf_ue;
31
+    e.ausf_ue_id = ausf_ue->id;
32
     ogs_fsm_fini(&ausf_ue->sm, &e);
33
 
34
     /* Free SBI object memory */
35
@@ -191,7 +189,7 @@
36
     if (ausf_ue->serving_network_name)
37
         ogs_free(ausf_ue->serving_network_name);
38
     
39
-    ogs_pool_free(&ausf_ue_pool, ausf_ue);
40
+    ogs_pool_id_free(&ausf_ue_pool, ausf_ue);
41
 }
42
 
43
 void ausf_ue_remove_all(void)
44
@@ -229,9 +227,9 @@
45
     return ogs_pool_find(&ausf_ue_pool, atoll(ctx_id));
46
 }
47
 
48
-ausf_ue_t *ausf_ue_cycle(ausf_ue_t *ausf_ue)
49
+ausf_ue_t *ausf_ue_find_by_id(ogs_pool_id_t id)
50
 {
51
-    return ogs_pool_cycle(&ausf_ue_pool, ausf_ue);
52
+    return ogs_pool_find_by_id(&ausf_ue_pool, id);
53
 }
54
 
55
 int get_ue_load(void)
56
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/ausf/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/ausf/context.h Changed
19
 
1
@@ -44,6 +44,7 @@
2
 
3
 struct ausf_ue_s {
4
     ogs_sbi_object_t sbi;
5
+    ogs_pool_id_t id;
6
     ogs_fsm_t sm;
7
 
8
     char *ctx_id;
9
@@ -93,8 +94,8 @@
10
 ausf_ue_t *ausf_ue_find_by_supi(char *supi);
11
 ausf_ue_t *ausf_ue_find_by_suci_or_supi(char *suci_or_supi);
12
 ausf_ue_t *ausf_ue_find_by_ctx_id(char *ctx_id);
13
+ausf_ue_t *ausf_ue_find_by_id(ogs_pool_id_t id);
14
 
15
-ausf_ue_t *ausf_ue_cycle(ausf_ue_t *ausf_ue);
16
 int get_ue_load(void);
17
 
18
 #ifdef __cplusplus
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/ausf/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/ausf/event.h Changed
10
 
1
@@ -31,7 +31,7 @@
2
 typedef struct ausf_event_s {
3
     ogs_event_t h;
4
 
5
-    ausf_ue_t *ausf_ue;
6
+    ogs_pool_id_t ausf_ue_id;
7
 } ausf_event_t;
8
 
9
 OGS_STATIC_ASSERT(OGS_EVENT_SIZE >= sizeof(ausf_event_t));
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/ausf/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/ausf/sbi-path.c Changed
25
 
1
@@ -88,8 +88,11 @@
2
     ogs_assert(stream);
3
     ogs_assert(build);
4
 
5
+    ogs_assert(ausf_ue->id >= OGS_MIN_POOL_ID &&
6
+            ausf_ue->id <= OGS_MAX_POOL_ID);
7
+
8
     xact = ogs_sbi_xact_add(
9
-            &ausf_ue->sbi, service_type, discovery_option,
10
+            ausf_ue->id, &ausf_ue->sbi, service_type, discovery_option,
11
             (ogs_sbi_build_f)build, ausf_ue, data);
12
     if (!xact) {
13
         ogs_error("ausf_sbi_discover_and_send() failed");
14
@@ -100,7 +103,9 @@
15
         return OGS_ERROR;
16
     }
17
 
18
-    xact->assoc_stream = stream;
19
+    xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
20
+    ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
21
+            xact->assoc_stream_id <= OGS_MAX_POOL_ID);
22
 
23
     r = ogs_sbi_discover_and_send(xact);
24
     if (r != OGS_OK) {
25
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/ausf/ue-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/ausf/ue-sm.c Changed
102
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -31,7 +31,7 @@
9
 
10
     ausf_sm_debug(e);
11
 
12
-    ausf_ue = e->ausf_ue;
13
+    ausf_ue = ausf_ue_find_by_id(e->ausf_ue_id);
14
     ogs_assert(ausf_ue);
15
 
16
     OGS_FSM_TRAN(s, &ausf_ue_state_operational);
17
@@ -46,7 +46,7 @@
18
 
19
     ausf_sm_debug(e);
20
 
21
-    ausf_ue = e->ausf_ue;
22
+    ausf_ue = ausf_ue_find_by_id(e->ausf_ue_id);
23
     ogs_assert(ausf_ue);
24
 }
25
 
26
@@ -56,6 +56,7 @@
27
     ausf_ue_t *ausf_ue = NULL;
28
 
29
     ogs_sbi_stream_t *stream = NULL;
30
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
31
     ogs_sbi_message_t *message = NULL;
32
 
33
     ogs_assert(s);
34
@@ -63,7 +64,7 @@
35
 
36
     ausf_sm_debug(e);
37
 
38
-    ausf_ue = e->ausf_ue;
39
+    ausf_ue = ausf_ue_find_by_id(e->ausf_ue_id);
40
     ogs_assert(ausf_ue);
41
 
42
     switch (e->h.id) {
43
@@ -76,8 +77,16 @@
44
     case OGS_EVENT_SBI_SERVER:
45
         message = e->h.sbi.message;
46
         ogs_assert(message);
47
-        stream = e->h.sbi.data;
48
-        ogs_assert(stream);
49
+
50
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
51
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
52
+                stream_id <= OGS_MAX_POOL_ID);
53
+
54
+        stream = ogs_sbi_stream_find_by_id(stream_id);
55
+        if (!stream) {
56
+            ogs_error("STREAM has already been removed %d", stream_id);
57
+            break;
58
+        }
59
 
60
         SWITCH(message->h.method)
61
         CASE(OGS_SBI_HTTP_METHOD_POST)
62
@@ -143,10 +152,18 @@
63
         message = e->h.sbi.message;
64
         ogs_assert(message);
65
 
66
-        ausf_ue = e->ausf_ue;
67
+        ausf_ue = ausf_ue_find_by_id(e->ausf_ue_id);
68
         ogs_assert(ausf_ue);
69
-        stream = e->h.sbi.data;
70
-        ogs_assert(stream);
71
+
72
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
73
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
74
+                stream_id <= OGS_MAX_POOL_ID);
75
+
76
+        stream = ogs_sbi_stream_find_by_id(stream_id);
77
+        if (!stream) {
78
+            ogs_error("STREAM has already been removed %d", stream_id);
79
+            break;
80
+        }
81
 
82
         SWITCH(message->h.service.name)
83
         CASE(OGS_SBI_SERVICE_NAME_NUDM_UEAU)
84
@@ -225,7 +242,7 @@
85
 
86
     ausf_sm_debug(e);
87
 
88
-    ausf_ue = e->ausf_ue;
89
+    ausf_ue = ausf_ue_find_by_id(e->ausf_ue_id);
90
     ogs_assert(ausf_ue);
91
 
92
     switch (e->h.id) {
93
@@ -249,7 +266,7 @@
94
 
95
     ausf_sm_debug(e);
96
 
97
-    ausf_ue = e->ausf_ue;
98
+    ausf_ue = ausf_ue_find_by_id(e->ausf_ue_id);
99
     ogs_assert(ausf_ue);
100
 
101
     switch (e->h.id) {
102
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/bsf/bsf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/bsf/bsf-sm.c Changed
91
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -44,6 +44,7 @@
9
     bsf_sess_t *sess = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -51,6 +52,7 @@
17
     ogs_sbi_response_t *response = NULL;
18
     ogs_sbi_message_t message;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
21
 
22
     bsf_sm_debug(e);
23
 
24
@@ -66,8 +68,16 @@
25
     case OGS_EVENT_SBI_SERVER:
26
         request = e->h.sbi.request;
27
         ogs_assert(request);
28
-        stream = e->h.sbi.data;
29
-        ogs_assert(stream);
30
+
31
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
32
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
33
+                stream_id <= OGS_MAX_POOL_ID);
34
+
35
+        stream = ogs_sbi_stream_find_by_id(stream_id);
36
+        if (!stream) {
37
+            ogs_error("STREAM has already been removed %d", stream_id);
38
+            break;
39
+        }
40
 
41
         rv = ogs_sbi_parse_request(&message, request);
42
         if (rv != OGS_OK) {
43
@@ -285,8 +295,18 @@
44
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
45
             SWITCH(message.h.resource.component0)
46
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
47
-                sbi_xact = e->h.sbi.data;
48
-                ogs_assert(sbi_xact);
49
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
50
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
51
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
52
+
53
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
54
+                if (!sbi_xact) {
55
+                    /* CLIENT_WAIT timer could remove SBI transaction
56
+                     * before receiving SBI message */
57
+                    ogs_error("SBI transaction has already been removed %d",
58
+                            sbi_xact_id);
59
+                    break;
60
+                }
61
 
62
                 SWITCH(message.h.method)
63
                 CASE(OGS_SBI_HTTP_METHOD_GET)
64
@@ -393,15 +413,22 @@
65
              * 4. timer expiration event is processed. (double-free SBI xact)
66
              *
67
              * To avoid double-free SBI xact,
68
-             * we need to check ogs_sbi_xact_cycle()
69
+             * we need to check ogs_sbi_xact_find_by_id()
70
              */
71
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
72
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
73
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
74
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
75
+
76
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
77
             if (!sbi_xact) {
78
-                ogs_error("SBI transaction has already been removed");
79
+                ogs_error("SBI transaction has already been removed %d",
80
+                        sbi_xact_id);
81
                 break;
82
             }
83
 
84
-            stream = sbi_xact->assoc_stream;
85
+            if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
86
+                sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
87
+                stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
88
             /* Here, we should not use ogs_assert(stream)
89
              * since 'namf-comm' service has no an associated stream. */
90
 
91
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/bsf/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/bsf/sbi-path.c Changed
21
 
1
@@ -89,7 +89,7 @@
2
     ogs_assert(build);
3
 
4
     xact = ogs_sbi_xact_add(
5
-            &sess->sbi, service_type, discovery_option,
6
+            0, &sess->sbi, service_type, discovery_option,
7
             (ogs_sbi_build_f)build, sess, data);
8
     if (!xact) {
9
         ogs_error("bsf_sbi_discover_and_send() failed");
10
@@ -100,7 +100,9 @@
11
         return OGS_ERROR;
12
     }
13
 
14
-    xact->assoc_stream = stream;
15
+    xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
16
+    ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
17
+            xact->assoc_stream_id <= OGS_MAX_POOL_ID);
18
 
19
     r = ogs_sbi_discover_and_send(xact);
20
     if (r != OGS_OK) {
21
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/emm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/emm-handler.c Changed
144
 
1
@@ -55,15 +55,14 @@
2
     char imsi_bcdOGS_MAX_IMSI_BCD_LEN+1;
3
 
4
     ogs_assert(mme_ue);
5
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
6
 
7
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
8
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
9
     ogs_assert(enb_ue);
10
 
11
     ogs_assert(esm_message_container);
12
     if (!esm_message_container->length) {
13
         ogs_error("No ESM Message Container");
14
-        r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
15
+        r = nas_eps_send_attach_reject(enb_ue, mme_ue,
16
                 OGS_NAS_EMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE,
17
                 OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
18
         ogs_expect(r == OGS_OK);
19
@@ -143,7 +142,7 @@
20
         /* Send Attach Reject */
21
         ogs_warn("Cannot find Served TAIPLMN_ID:%06x,TAC:%d",
22
             ogs_plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac);
23
-        r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
24
+        r = nas_eps_send_attach_reject(enb_ue, mme_ue,
25
                 OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED,
26
                 OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
27
         ogs_expect(r == OGS_OK);
28
@@ -187,7 +186,7 @@
29
             "but Integrity0x%x cannot be bypassed with EIA0",
30
             mme_selected_enc_algorithm(mme_ue),
31
             mme_selected_int_algorithm(mme_ue));
32
-        r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
33
+        r = nas_eps_send_attach_reject(enb_ue, mme_ue,
34
                 OGS_NAS_EMM_CAUSE_UE_SECURITY_CAPABILITIES_MISMATCH,
35
                 OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
36
         ogs_expect(r == OGS_OK);
37
@@ -210,7 +209,7 @@
38
         emm_cause = emm_cause_from_access_control(mme_ue);
39
         if (emm_cause != OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED) {
40
             ogs_error("Rejected by PLMN-ID access control");
41
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
42
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
43
                     emm_cause, OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
44
             ogs_expect(r == OGS_OK);
45
             ogs_assert(r != OGS_ERROR);
46
@@ -270,7 +269,6 @@
47
     struct tm gmt, local;
48
 
49
     ogs_assert(mme_ue);
50
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
51
 
52
     ogs_info("    IMSI%s", mme_ue->imsi_bcd);
53
 
54
@@ -358,7 +356,8 @@
55
         return OGS_ERROR;
56
     }
57
 
58
-    r = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
59
+    r = nas_eps_send_to_downlink_nas_transport(
60
+            enb_ue_find_by_id(mme_ue->enb_ue_id), emmbuf);
61
     ogs_expect(r == OGS_OK);
62
     ogs_assert(r != OGS_ERROR);
63
 
64
@@ -379,7 +378,7 @@
65
     ogs_assert(identity_response);
66
 
67
     ogs_assert(mme_ue);
68
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
69
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
70
     ogs_assert(enb_ue);
71
 
72
     mobile_identity = &identity_response->mobile_identity;
73
@@ -391,7 +390,7 @@
74
             ogs_error("mobile_identity length (%d != %d)",
75
                     (int)sizeof(ogs_nas_mobile_identity_imsi_t),
76
                     mobile_identity->length);
77
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
78
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
79
                     OGS_NAS_EMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE,
80
                     OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
81
             ogs_expect(r == OGS_OK);
82
@@ -404,7 +403,7 @@
83
         emm_cause = emm_cause_from_access_control(mme_ue);
84
         if (emm_cause != OGS_NAS_EMM_CAUSE_REQUEST_ACCEPTED) {
85
             ogs_error("Rejected by PLMN-ID access control");
86
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
87
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
88
                     emm_cause, OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
89
             ogs_expect(r == OGS_OK);
90
             ogs_assert(r != OGS_ERROR);
91
@@ -417,7 +416,7 @@
92
 
93
         if (mme_ue->imsi_len != OGS_MAX_IMSI_LEN) {
94
             ogs_error("Invalid IMSI LEN%d", mme_ue->imsi_len);
95
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
96
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
97
                     OGS_NAS_EMM_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE,
98
                     OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
99
             ogs_expect(r == OGS_OK);
100
@@ -595,7 +594,7 @@
101
     enb_ue_t *enb_ue = NULL;
102
 
103
     ogs_assert(mme_ue);
104
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
105
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
106
     ogs_assert(enb_ue);
107
 
108
     ogs_assert(pkbuf);
109
@@ -656,7 +655,7 @@
110
         /* Send TAU reject */
111
         ogs_warn("Cannot find Served TAIPLMN_ID:%06x,TAC:%d",
112
             ogs_plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac);
113
-        r = nas_eps_send_tau_reject(mme_ue->enb_ue, mme_ue,
114
+        r = nas_eps_send_tau_reject(enb_ue, mme_ue,
115
                 OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED);
116
         ogs_expect(r == OGS_OK);
117
         ogs_assert(r != OGS_ERROR);
118
@@ -750,7 +749,7 @@
119
     enb_ue_t *enb_ue = NULL;
120
 
121
     ogs_assert(mme_ue);
122
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
123
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
124
     ogs_assert(enb_ue);
125
 
126
     /* Set Service Type */
127
@@ -793,7 +792,7 @@
128
         /* Send TAU reject */
129
         ogs_warn("Cannot find Served TAIPLMN_ID:%06x,TAC:%d",
130
             ogs_plmn_id_hexdump(&mme_ue->tai.plmn_id), mme_ue->tai.tac);
131
-        r = nas_eps_send_tau_reject(mme_ue->enb_ue, mme_ue,
132
+        r = nas_eps_send_tau_reject(enb_ue, mme_ue,
133
                 OGS_NAS_EMM_CAUSE_TRACKING_AREA_NOT_ALLOWED);
134
         ogs_expect(r == OGS_OK);
135
         ogs_assert(r != OGS_ERROR);
136
@@ -823,7 +822,6 @@
137
     ogs_nas_mobile_identity_t *imeisv = &security_mode_complete->imeisv;
138
 
139
     ogs_assert(mme_ue);
140
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
141
 
142
     if (security_mode_complete->presencemask &
143
         OGS_NAS_EPS_SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT) {
144
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/emm-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/emm-sm.c Changed
159
 
1
@@ -72,7 +72,7 @@
2
 
3
     mme_sm_debug(e);
4
 
5
-    mme_ue = e->mme_ue;
6
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
7
     ogs_assert(mme_ue);
8
 
9
     switch (e->id) {
10
@@ -123,7 +123,7 @@
11
 
12
     mme_sm_debug(e);
13
 
14
-    mme_ue = e->mme_ue;
15
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
16
     ogs_assert(mme_ue);
17
 
18
     switch (e->id) {
19
@@ -297,7 +297,7 @@
20
 
21
     mme_sm_debug(e);
22
 
23
-    mme_ue = e->mme_ue;
24
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
25
     ogs_assert(mme_ue);
26
 
27
     switch (e->id) {
28
@@ -305,7 +305,7 @@
29
         message = e->nas_message;
30
         ogs_assert(message);
31
 
32
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
33
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
34
         ogs_assert(enb_ue);
35
 
36
         h.type = e->nas_type;
37
@@ -898,17 +898,22 @@
38
             } else {
39
                 S1AP_MME_UE_S1AP_ID_t MME_UE_S1AP_ID;
40
                 S1AP_ENB_UE_S1AP_ID_t ENB_UE_S1AP_ID;
41
+                mme_enb_t *enb = NULL;
42
 
43
                 ogs_warn("No connection of MSC/VLR");
44
                 MME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id;
45
                 ENB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id;
46
 
47
-                r = s1ap_send_error_indication(enb_ue->enb,
48
-                        &MME_UE_S1AP_ID, &ENB_UE_S1AP_ID,
49
-                        S1AP_Cause_PR_transport,
50
-                        S1AP_CauseTransport_transport_resource_unavailable);
51
-                ogs_expect(r == OGS_OK);
52
-                ogs_assert(r != OGS_ERROR);
53
+                enb = mme_enb_find_by_id(enb_ue->enb_id);
54
+                if (enb) {
55
+                    r = s1ap_send_error_indication(enb,
56
+                            &MME_UE_S1AP_ID, &ENB_UE_S1AP_ID,
57
+                            S1AP_Cause_PR_transport,
58
+                            S1AP_CauseTransport_transport_resource_unavailable);
59
+                    ogs_expect(r == OGS_OK);
60
+                    ogs_assert(r != OGS_ERROR);
61
+                } else
62
+                    ogs_error("eNB has already been removed");
63
             }
64
             break;
65
 
66
@@ -945,9 +950,8 @@
67
 
68
     mme_sm_debug(e);
69
 
70
-    mme_ue = e->mme_ue;
71
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
72
     ogs_assert(mme_ue);
73
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
74
 
75
     switch (e->id) {
76
     case OGS_FSM_ENTRY_SIG:
77
@@ -958,7 +962,7 @@
78
         message = e->nas_message;
79
         ogs_assert(message);
80
 
81
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
82
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
83
         ogs_assert(enb_ue);
84
 
85
         switch (message->emm.h.message_type) {
86
@@ -1146,7 +1150,7 @@
87
 
88
     mme_sm_debug(e);
89
 
90
-    mme_ue = e->mme_ue;
91
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
92
     ogs_assert(mme_ue);
93
 
94
     switch (e->id) {
95
@@ -1162,7 +1166,7 @@
96
         message = e->nas_message;
97
         ogs_assert(message);
98
 
99
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
100
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
101
         ogs_assert(enb_ue);
102
 
103
         if (message->emm.h.security_header_type
104
@@ -1327,7 +1331,8 @@
105
                         "Stop retransmission", mme_ue->imsi_bcd);
106
                 OGS_FSM_TRAN(&mme_ue->sm, &emm_state_exception);
107
 
108
-                r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
109
+                r = nas_eps_send_attach_reject(
110
+                        enb_ue_find_by_id(mme_ue->enb_ue_id), mme_ue,
111
                         OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED,
112
                         OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
113
                 ogs_expect(r == OGS_OK);
114
@@ -1364,7 +1369,7 @@
115
 
116
     mme_sm_debug(e);
117
 
118
-    mme_ue = e->mme_ue;
119
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
120
     ogs_assert(mme_ue);
121
 
122
     switch (e->id) {
123
@@ -1376,7 +1381,7 @@
124
         message = e->nas_message;
125
         ogs_assert(message);
126
 
127
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
128
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
129
         ogs_assert(enb_ue);
130
 
131
         xact_count = mme_ue_xact_count(mme_ue, OGS_GTP_LOCAL_ORIGINATOR);
132
@@ -1606,7 +1611,7 @@
133
                         mme_timer_cfg(MME_TIMER_T3450)->duration);
134
 
135
                 r = nas_eps_send_to_downlink_nas_transport(
136
-                        mme_ue->enb_ue, emmbuf);
137
+                        enb_ue_find_by_id(mme_ue->enb_ue_id), emmbuf);
138
                 ogs_expect(r == OGS_OK);
139
                 ogs_assert(r != OGS_ERROR);
140
             }
141
@@ -1635,7 +1640,7 @@
142
     ogs_assert(e);
143
     mme_sm_debug(e);
144
 
145
-    mme_ue = e->mme_ue;
146
+    mme_ue = mme_ue_find_by_id(e->mme_ue_id);
147
     ogs_assert(mme_ue);
148
 
149
     switch (e->id) {
150
@@ -1650,7 +1655,7 @@
151
         message = e->nas_message;
152
         ogs_assert(message);
153
 
154
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
155
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
156
         ogs_assert(enb_ue);
157
 
158
         h.type = e->nas_type;
159
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/esm-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/esm-build.c Changed
67
 
1
@@ -33,7 +33,7 @@
2
             &message.esm.pdn_connectivity_reject;
3
 
4
     ogs_assert(sess);
5
-    mme_ue = sess->mme_ue;
6
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
7
     ogs_assert(mme_ue);
8
 
9
     ogs_debug("PDN connectivity reject");
10
@@ -68,9 +68,9 @@
11
     mme_sess_t *sess = NULL;
12
 
13
     ogs_assert(bearer);
14
-    sess = bearer->sess;
15
+    sess = mme_sess_find_by_id(bearer->sess_id);
16
     ogs_assert(sess);
17
-    mme_ue = bearer->mme_ue;
18
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
19
     ogs_assert(mme_ue);
20
 
21
     ogs_debug("ESM information request");
22
@@ -117,7 +117,7 @@
23
     ogs_session_t *session = NULL;
24
 
25
     ogs_assert(sess);
26
-    mme_ue = sess->mme_ue;
27
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
28
     ogs_assert(mme_ue);
29
     session = sess->session;
30
     ogs_assert(session);
31
@@ -269,9 +269,9 @@
32
         &activate_dedicated_eps_bearer_context_request->tft;
33
     
34
     ogs_assert(bearer);
35
-    sess = bearer->sess;
36
+    sess = mme_sess_find_by_id(bearer->sess_id);
37
     ogs_assert(sess);
38
-    mme_ue = bearer->mme_ue;
39
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
40
     ogs_assert(mme_ue);
41
     linked_bearer = mme_linked_bearer(bearer); 
42
     ogs_assert(linked_bearer);
43
@@ -333,9 +333,9 @@
44
         &modify_eps_bearer_context_request->tft;
45
 
46
     ogs_assert(bearer);
47
-    sess = bearer->sess;
48
+    sess = mme_sess_find_by_id(bearer->sess_id);
49
     ogs_assert(sess);
50
-    mme_ue = bearer->mme_ue;
51
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
52
     ogs_assert(mme_ue);
53
 
54
     ogs_debug("Modify bearer context request");
55
@@ -383,9 +383,9 @@
56
             &message.esm.deactivate_eps_bearer_context_request;
57
     
58
     ogs_assert(bearer);
59
-    sess = bearer->sess;
60
+    sess = mme_sess_find_by_id(bearer->sess_id);
61
     ogs_assert(sess);
62
-    mme_ue = bearer->mme_ue;
63
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
64
     ogs_assert(mme_ue);
65
 
66
     ogs_debug("Deactivate bearer context request");
67
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/esm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/esm-handler.c Changed
47
 
1
@@ -37,11 +37,10 @@
2
     uint8_t security_protected_required = 0;
3
 
4
     ogs_assert(bearer);
5
-    sess = bearer->sess;
6
+    sess = mme_sess_find_by_id(bearer->sess_id);
7
     ogs_assert(sess);
8
-    mme_ue = sess->mme_ue;
9
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
10
     ogs_assert(mme_ue);
11
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
12
 
13
     ogs_assert(req);
14
 
15
@@ -180,9 +179,8 @@
16
     mme_ue_t *mme_ue = NULL;
17
 
18
     ogs_assert(sess);
19
-    mme_ue = sess->mme_ue;
20
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
21
     ogs_assert(mme_ue);
22
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
23
 
24
     ogs_assert(rsp);
25
 
26
@@ -278,9 +276,9 @@
27
     mme_sess_t *sess = NULL;
28
 
29
     ogs_assert(bearer);
30
-    sess = bearer->sess;
31
+    sess = mme_sess_find_by_id(bearer->sess_id);
32
     ogs_assert(sess);
33
-    mme_ue = sess->mme_ue;
34
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
35
     ogs_assert(mme_ue);
36
 
37
     r = nas_eps_send_bearer_resource_allocation_reject(
38
@@ -297,7 +295,7 @@
39
     mme_ue_t *mme_ue = NULL;
40
 
41
     ogs_assert(bearer);
42
-    mme_ue = bearer->mme_ue;
43
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
44
     ogs_assert(mme_ue);
45
 
46
     ogs_assert(OGS_OK ==
47
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/esm-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/esm-sm.c Changed
144
 
1
@@ -70,6 +70,8 @@
2
 {
3
     int r, rv;
4
     mme_ue_t *mme_ue = NULL;
5
+    sgw_ue_t *sgw_ue = NULL;
6
+    enb_ue_t *enb_ue = NULL;
7
     mme_sess_t *sess = NULL;
8
     mme_bearer_t *bearer = NULL;
9
     ogs_nas_eps_message_t *message = NULL;
10
@@ -83,13 +85,12 @@
11
 
12
     mme_sm_debug(e);
13
 
14
-    bearer = e->bearer;
15
+    bearer = mme_bearer_find_by_id(e->bearer_id);
16
     ogs_assert(bearer);
17
-    sess = bearer->sess;
18
+    sess = mme_sess_find_by_id(bearer->sess_id);
19
     ogs_assert(sess);
20
-    mme_ue = sess->mme_ue;
21
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
22
     ogs_assert(mme_ue);
23
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
24
 
25
     switch (e->id) {
26
     case OGS_FSM_ENTRY_SIG:
27
@@ -119,9 +120,12 @@
28
             ogs_debug("    IMSI%s PTI%d EBI%d",
29
                     mme_ue->imsi_bcd, sess->pti, bearer->ebi);
30
             if (MME_HAVE_SGW_S1U_PATH(sess)) {
31
+                sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
32
+                ogs_assert(sgw_ue);
33
+
34
                 ogs_assert(OGS_OK ==
35
-                    mme_gtp_send_delete_session_request(mme_ue->sgw_ue, sess,
36
-                    OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST));
37
+                    mme_gtp_send_delete_session_request(sgw_ue, sess,
38
+                        OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST));
39
             } else {
40
                 r = nas_eps_send_deactivate_bearer_context_request(bearer);
41
                 ogs_expect(r == OGS_OK);
42
@@ -141,15 +145,19 @@
43
             CLEAR_BEARER_TIMER(bearer->t3489);
44
 
45
             h.type = e->nas_type;
46
+            enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
47
+
48
             if (h.integrity_protected == 0) {
49
                 ogs_error("%s No Integrity Protected", mme_ue->imsi_bcd);
50
-                r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
51
+
52
+                ogs_assert(enb_ue);
53
+
54
+                r = nas_eps_send_attach_reject(enb_ue, mme_ue,
55
                         OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED,
56
                         OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
57
                 ogs_expect(r == OGS_OK);
58
                 ogs_assert(r != OGS_ERROR);
59
-                ogs_assert(mme_ue->enb_ue);
60
-                r = s1ap_send_ue_context_release_command(mme_ue->enb_ue,
61
+                r = s1ap_send_ue_context_release_command(enb_ue,
62
                         S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
63
                         S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
64
                 ogs_expect(r == OGS_OK);
65
@@ -160,13 +168,15 @@
66
 
67
             if (!SECURITY_CONTEXT_IS_VALID(mme_ue)) {
68
                 ogs_warn("%s No Security Context", mme_ue->imsi_bcd);
69
-                r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
70
+
71
+                ogs_assert(enb_ue);
72
+
73
+                r = nas_eps_send_attach_reject(enb_ue, mme_ue,
74
                         OGS_NAS_EMM_CAUSE_SECURITY_MODE_REJECTED_UNSPECIFIED,
75
                         OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
76
                 ogs_expect(r == OGS_OK);
77
                 ogs_assert(r != OGS_ERROR);
78
-                ogs_assert(mme_ue->enb_ue);
79
-                r = s1ap_send_ue_context_release_command(mme_ue->enb_ue,
80
+                r = s1ap_send_ue_context_release_command(enb_ue,
81
                         S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
82
                         S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
83
                 ogs_expect(r == OGS_OK);
84
@@ -268,6 +278,7 @@
85
 {
86
     int r, rv;
87
     mme_ue_t *mme_ue = NULL;
88
+    sgw_ue_t *sgw_ue = NULL;
89
     mme_sess_t *sess = NULL;
90
     mme_bearer_t *bearer = NULL;
91
     ogs_nas_eps_message_t *message = NULL;
92
@@ -277,11 +288,11 @@
93
 
94
     mme_sm_debug(e);
95
 
96
-    bearer = e->bearer;
97
+    bearer = mme_bearer_find_by_id(e->bearer_id);
98
     ogs_assert(bearer);
99
-    sess = bearer->sess;
100
+    sess = mme_sess_find_by_id(bearer->sess_id);
101
     ogs_assert(sess);
102
-    mme_ue = sess->mme_ue;
103
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
104
     ogs_assert(mme_ue);
105
 
106
     switch (e->id) {
107
@@ -313,8 +324,11 @@
108
             ogs_debug("    IMSI%s PTI%d EBI%d",
109
                     mme_ue->imsi_bcd, sess->pti, bearer->ebi);
110
             if (MME_HAVE_SGW_S1U_PATH(sess)) {
111
+                sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
112
+                ogs_assert(sgw_ue);
113
+
114
                 ogs_assert(OGS_OK ==
115
-                    mme_gtp_send_delete_session_request(mme_ue->sgw_ue, sess,
116
+                    mme_gtp_send_delete_session_request(sgw_ue, sess,
117
                     OGS_GTP_DELETE_SEND_DEACTIVATE_BEARER_CONTEXT_REQUEST));
118
             } else {
119
                 r = nas_eps_send_deactivate_bearer_context_request(bearer);
120
@@ -383,11 +397,11 @@
121
 
122
     mme_sm_debug(e);
123
 
124
-    bearer = e->bearer;
125
+    bearer = mme_bearer_find_by_id(e->bearer_id);
126
     ogs_assert(bearer);
127
-    sess = bearer->sess;
128
+    sess = mme_sess_find_by_id(bearer->sess_id);
129
     ogs_assert(sess);
130
-    mme_ue = sess->mme_ue;
131
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
132
     ogs_assert(mme_ue);
133
 
134
     switch (e->id) {
135
@@ -472,7 +486,7 @@
136
     ogs_assert(e);
137
     mme_sm_debug(e);
138
 
139
-    bearer = e->bearer;
140
+    bearer = mme_bearer_find_by_id(e->bearer_id);
141
 
142
     switch (e->id) {
143
     case OGS_FSM_ENTRY_SIG:
144
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-context.c Changed
201
 
1
@@ -2617,7 +2617,7 @@
2
     ogs_assert(sess);
3
     ogs_assert(sess->session);
4
     ogs_assert(sess->session->name);
5
-    mme_ue = sess->mme_ue;
6
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
7
     ogs_assert(mme_ue);
8
 
9
     for (i = 0; i < pgw->num_of_apn; i++)
10
@@ -2795,9 +2795,11 @@
11
     ogs_assert(sock);
12
     ogs_assert(addr);
13
 
14
-    ogs_pool_alloc(&mme_enb_pool, &enb);
15
-    ogs_assert(enb);
16
-    memset(enb, 0, sizeof *enb);
17
+    ogs_pool_id_calloc(&mme_enb_pool, &enb);
18
+    if (!enb) {
19
+        ogs_error("ogs_pool_id_calloc() failed");
20
+        return NULL;
21
+    }
22
 
23
     enb->sctp.sock = sock;
24
     enb->sctp.addr = addr;
25
@@ -2820,7 +2822,7 @@
26
             enb->sctp.addr, sizeof(ogs_sockaddr_t), enb);
27
 
28
     memset(&e, 0, sizeof(e));
29
-    e.enb = enb;
30
+    e.enb_id = enb->id;
31
     ogs_fsm_init(&enb->sm, s1ap_state_initial, s1ap_state_final, &e);
32
 
33
     ogs_list_add(&self.enb_list, enb);
34
@@ -2842,7 +2844,7 @@
35
     ogs_list_remove(&self.enb_list, enb);
36
 
37
     memset(&e, 0, sizeof(e));
38
-    e.enb = enb;
39
+    e.enb_id = enb->id;
40
     ogs_fsm_fini(&enb->sm, &e);
41
 
42
     ogs_hash_set(self.enb_addr_hash,
43
@@ -2858,7 +2860,7 @@
44
 
45
     ogs_sctp_flush_and_destroy(&enb->sctp);
46
 
47
-    ogs_pool_free(&mme_enb_pool, enb);
48
+    ogs_pool_id_free(&mme_enb_pool, enb);
49
     mme_metrics_inst_global_dec(MME_METR_GLOB_GAUGE_ENB);
50
     ogs_info("Removed Number of eNBs is now %d",
51
             ogs_list_count(&self.enb_list));
52
@@ -2917,9 +2919,9 @@
53
     return SOCK_STREAM;
54
 }
55
 
56
-mme_enb_t *mme_enb_cycle(mme_enb_t *enb)
57
+mme_enb_t *mme_enb_find_by_id(ogs_pool_id_t id)
58
 {
59
-    return ogs_pool_cycle(&mme_enb_pool, enb);
60
+    return ogs_pool_find_by_id(&mme_enb_pool, id);
61
 }
62
 
63
 /** enb_ue_context handling function */
64
@@ -2929,19 +2931,18 @@
65
 
66
     ogs_assert(enb);
67
 
68
-    ogs_pool_alloc(&enb_ue_pool, &enb_ue);
69
+    ogs_pool_id_calloc(&enb_ue_pool, &enb_ue);
70
     if (enb_ue == NULL) {
71
         ogs_error("Could not allocate enb_ue context from pool");
72
         return NULL;
73
     }
74
 
75
-    memset(enb_ue, 0, sizeof *enb_ue);
76
-
77
     enb_ue->t_s1_holding = ogs_timer_add(
78
-            ogs_app()->timer_mgr, mme_timer_s1_holding_timer_expire, enb_ue);
79
+            ogs_app()->timer_mgr, mme_timer_s1_holding_timer_expire,
80
+            OGS_UINT_TO_POINTER(enb_ue->id));
81
     if (!enb_ue->t_s1_holding) {
82
         ogs_error("ogs_timer_add() failed");
83
-        ogs_pool_free(&enb_ue_pool, enb_ue);
84
+        ogs_pool_id_free(&enb_ue_pool, enb_ue);
85
         return NULL;
86
     }
87
 
88
@@ -2961,7 +2962,7 @@
89
     enb_ue->enb_ostream_id =
90
         OGS_NEXT_ID(enb->ostream_id, 1, enb->max_num_of_ostreams-1);
91
 
92
-    enb_ue->enb = enb;
93
+    enb_ue->enb_id = enb->id;
94
 
95
     ogs_list_add(&enb->enb_ue_list, enb_ue);
96
 
97
@@ -2975,33 +2976,35 @@
98
     mme_enb_t *enb = NULL;
99
 
100
     ogs_assert(enb_ue);
101
-    enb = enb_ue->enb;
102
-    ogs_assert(enb);
103
 
104
-    ogs_list_remove(&enb->enb_ue_list, enb_ue);
105
+    enb = mme_enb_find_by_id(enb_ue->enb_id);
106
+
107
+    if (enb) ogs_list_remove(&enb->enb_ue_list, enb_ue);
108
 
109
     ogs_assert(enb_ue->t_s1_holding);
110
     ogs_timer_delete(enb_ue->t_s1_holding);
111
 
112
-    ogs_pool_free(&enb_ue_pool, enb_ue);
113
+    ogs_pool_id_free(&enb_ue_pool, enb_ue);
114
 
115
     stats_remove_enb_ue();
116
 }
117
 
118
 void enb_ue_switch_to_enb(enb_ue_t *enb_ue, mme_enb_t *new_enb)
119
 {
120
+    mme_enb_t *enb = NULL;
121
     ogs_assert(enb_ue);
122
-    ogs_assert(enb_ue->enb);
123
     ogs_assert(new_enb);
124
 
125
+    enb = mme_enb_find_by_id(enb_ue->enb_id);
126
+
127
     /* Remove from the old enb */
128
-    ogs_list_remove(&enb_ue->enb->enb_ue_list, enb_ue);
129
+    ogs_list_remove(&enb->enb_ue_list, enb_ue);
130
 
131
     /* Add to the new enb */
132
     ogs_list_add(&new_enb->enb_ue_list, enb_ue);
133
 
134
     /* Switch to enb */
135
-    enb_ue->enb = new_enb;
136
+    enb_ue->enb_id = new_enb->id;
137
 }
138
 
139
 enb_ue_t *enb_ue_find_by_enb_ue_s1ap_id(
140
@@ -3027,9 +3030,9 @@
141
     return enb_ue_find(mme_ue_s1ap_id);
142
 }
143
 
144
-enb_ue_t *enb_ue_cycle(enb_ue_t *enb_ue)
145
+enb_ue_t *enb_ue_find_by_id(ogs_pool_id_t id)
146
 {
147
-    return ogs_pool_cycle(&enb_ue_pool, enb_ue);
148
+    return ogs_pool_find_by_id(&enb_ue_pool, id);
149
 }
150
 
151
 /** sgw_ue_context handling function */
152
@@ -3039,15 +3042,15 @@
153
 
154
     ogs_assert(sgw);
155
 
156
-    ogs_pool_alloc(&sgw_ue_pool, &sgw_ue);
157
+    ogs_pool_id_calloc(&sgw_ue_pool, &sgw_ue);
158
     ogs_assert(sgw_ue);
159
-    memset(sgw_ue, 0, sizeof *sgw_ue);
160
 
161
     sgw_ue->t_s11_holding = ogs_timer_add(
162
-            ogs_app()->timer_mgr, mme_timer_s11_holding_timer_expire, sgw_ue);
163
+            ogs_app()->timer_mgr, mme_timer_s11_holding_timer_expire,
164
+            OGS_UINT_TO_POINTER(sgw_ue->id));
165
     if (!sgw_ue->t_s11_holding) {
166
         ogs_error("ogs_timer_add() failed");
167
-        ogs_pool_free(&sgw_ue_pool, sgw_ue);
168
+        ogs_pool_id_free(&sgw_ue_pool, sgw_ue);
169
         return NULL;
170
     }
171
 
172
@@ -3071,7 +3074,7 @@
173
     ogs_assert(sgw_ue->t_s11_holding);
174
     ogs_timer_delete(sgw_ue->t_s11_holding);
175
 
176
-    ogs_pool_free(&sgw_ue_pool, sgw_ue);
177
+    ogs_pool_id_free(&sgw_ue_pool, sgw_ue);
178
 }
179
 
180
 void sgw_ue_switch_to_sgw(sgw_ue_t *sgw_ue, mme_sgw_t *new_sgw)
181
@@ -3090,9 +3093,9 @@
182
     sgw_ue->sgw = new_sgw;
183
 }
184
 
185
-sgw_ue_t *sgw_ue_cycle(sgw_ue_t *sgw_ue)
186
+sgw_ue_t *sgw_ue_find_by_id(ogs_pool_id_t id)
187
 {
188
-    return ogs_pool_cycle(&sgw_ue_pool, sgw_ue);
189
+    return ogs_pool_find_by_id(&sgw_ue_pool, id);
190
 }
191
 
192
 sgw_relocation_e sgw_ue_check_if_relocated(mme_ue_t *mme_ue)
193
@@ -3102,9 +3105,9 @@
194
     mme_sgw_t *current = NULL, *changed = NULL;
195
 
196
     ogs_assert(mme_ue);
197
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
198
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
199
     ogs_assert(enb_ue);
200
-    source_ue = sgw_ue_cycle(mme_ue->sgw_ue);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-context.h Changed
201
 
1
@@ -146,45 +146,6 @@
2
     /* Generator for unique identification */
3
     uint32_t        mme_ue_s1ap_id;         /* mme_ue_s1ap_id generator */
4
 
5
-#define MME_UE_CHECK(level, __mME) \
6
-    do { \
7
-        sgw_ue_t *__sGW = (((mme_ue_t *)__mME)->sgw_ue); \
8
-        mme_sess_t *__sESS = NULL; \
9
-        mme_bearer_t *__bEARER = NULL; \
10
-        \
11
-        ogs_log_message(level, 0, "MME-UE Context Memory%p:%p", \
12
-                (__mME), mme_ue_cycle((__mME))); \
13
-        ogs_log_message(level, 0, "SGW-UE Context Memory%p:%p", \
14
-                (__sGW), sgw_ue_cycle((__sGW))); \
15
-        ogs_log_message(level, 0, \
16
-                "IMSI %s NAS-EPS Type%d", \
17
-                (__mME) ? ((mme_ue_t *)__mME)->imsi_bcd : "No MME_UE", \
18
-                (__mME) ? ((mme_ue_t *)__mME)->nas_eps.type : 0); \
19
-        ogs_log_message(level, 0, \
20
-                "MME_S11_TEID%d SGW_S11_TEID%d", \
21
-                (__mME) ? ((mme_ue_t *)__mME)->mme_s11_teid : 0, \
22
-                (__sGW) ? (__sGW)->sgw_s11_teid : 0); \
23
-        if (!mme_ue_cycle(__mME)) { \
24
-            ogs_log_message(level, 0, \
25
-                    "MME-UE Context has already been removed"); \
26
-            break; \
27
-        } \
28
-        ogs_list_for_each(&((mme_ue_t *)__mME)->sess_list, (__sESS)) { \
29
-            ogs_log_message(level, 0, "SESS(%p) %s:%d", (__sESS), \
30
-                    (__sESS)->session ? (__sESS)->session->name : "Unknown", \
31
-                    (__sESS)->pti); \
32
-            ogs_list_for_each(&(__sESS)->bearer_list, (__bEARER)) { \
33
-                ogs_log_message(level, 0, \
34
-                        "BEARER(%p) %d ENB_S1U_TEID%d SGW_S1U_TEID%d", \
35
-                        (__bEARER), (__bEARER)->ebi, \
36
-                        (__bEARER)->enb_s1u_teid, (__bEARER)->sgw_s1u_teid); \
37
-                ogs_assert((__bEARER)->sess == (__sESS)); \
38
-                ogs_assert((__bEARER)->mme_ue == (__mME)); \
39
-            } \
40
-            ogs_assert((__sESS)->mme_ue == (__mME)); \
41
-        } \
42
-    } while(0)
43
-
44
     ogs_list_t      mme_ue_list;
45
 
46
     ogs_hash_t *enb_addr_hash;  /* hash table for ENB Address */
47
@@ -273,6 +234,7 @@
48
 
49
 typedef struct mme_enb_s {
50
     ogs_lnode_t     lnode;
51
+    ogs_pool_id_t   id;
52
 
53
     ogs_fsm_t       sm;         /* A state machine */
54
 
55
@@ -298,6 +260,7 @@
56
 
57
 struct enb_ue_s {
58
     ogs_lnode_t     lnode;
59
+    ogs_pool_id_t   id;
60
     uint32_t        index;
61
 
62
     /* UE identity */
63
@@ -309,8 +272,8 @@
64
 
65
     /* Handover Info */
66
     S1AP_HandoverType_t handover_type;
67
-    enb_ue_t        *source_ue;
68
-    enb_ue_t        *target_ue;
69
+    ogs_pool_id_t source_ue_id;
70
+    ogs_pool_id_t target_ue_id;
71
 
72
     /* Use mme_ue->tai, mme_ue->e_cgi.
73
      * Do not access enb_ue->saved.tai enb_ue->saved.e_cgi.
74
@@ -339,15 +302,16 @@
75
     bool            part_of_s1_reset_requested;
76
 
77
     /* Related Context */
78
-    mme_enb_t       *enb;
79
-    mme_ue_t        *mme_ue;
80
+    ogs_pool_id_t   enb_id;
81
+    ogs_pool_id_t   mme_ue_id;
82
 };
83
 
84
 struct sgw_ue_s {
85
     ogs_lnode_t     lnode;
86
+    ogs_pool_id_t   id;
87
 
88
-    sgw_ue_t        *source_ue;
89
-    sgw_ue_t        *target_ue;
90
+    ogs_pool_id_t   source_ue_id;
91
+    ogs_pool_id_t   target_ue_id;
92
 
93
     /* UE identity */
94
     uint32_t        sgw_s11_teid;   /* SGW-S11-TEID is received from SGW */
95
@@ -360,11 +324,12 @@
96
         mme_sgw_t       *sgw;
97
         ogs_gtp_node_t  *gnode;
98
     };
99
-    mme_ue_t        *mme_ue;
100
+    ogs_pool_id_t mme_ue_id;
101
 };
102
 
103
 struct mme_ue_s {
104
     ogs_lnode_t     lnode;
105
+    ogs_pool_id_t   id;
106
     ogs_fsm_t       sm;     /* A state machine */
107
 
108
     struct {
109
@@ -536,50 +501,66 @@
110
 
111
     /* Paging Info */
112
 #define ECM_CONNECTED(__mME) \
113
-    ((__mME) && ((__mME)->enb_ue != NULL) && enb_ue_cycle((__mME)->enb_ue))
114
+    ((__mME) && \
115
+     ((__mME)->enb_ue_id >= OGS_MIN_POOL_ID) && \
116
+     ((__mME)->enb_ue_id <= OGS_MAX_POOL_ID) && \
117
+     (enb_ue_find_by_id((__mME)->enb_ue_id)))
118
 #define ECM_IDLE(__mME) \
119
     ((__mME) && \
120
-     (((__mME)->enb_ue == NULL) || (enb_ue_cycle((__mME)->enb_ue) == NULL)))
121
-    enb_ue_t        *enb_ue;    /* S1 UE context */
122
+     (((__mME)->enb_ue_id < OGS_MIN_POOL_ID) || \
123
+      ((__mME)->enb_ue_id > OGS_MAX_POOL_ID) || \
124
+      (enb_ue_find_by_id((__mME)->enb_ue_id) == NULL)))
125
+    ogs_pool_id_t   enb_ue_id;
126
 
127
 #define HOLDING_S1_CONTEXT(__mME) \
128
     do { \
129
-        enb_ue_deassociate((__mME)->enb_ue); \
130
+        enb_ue_t *enb_ue_holding = NULL; \
131
+        \
132
+        (__mME)->enb_ue_holding_id = OGS_INVALID_POOL_ID; \
133
         \
134
-        (__mME)->enb_ue_holding = enb_ue_cycle((__mME)->enb_ue); \
135
-        if ((__mME)->enb_ue_holding) { \
136
+        enb_ue_holding = enb_ue_find_by_id((__mME)->enb_ue_id); \
137
+        if (enb_ue_holding) { \
138
+            enb_ue_deassociate(enb_ue_holding); \
139
+            \
140
             ogs_warn("%s Holding S1 Context", (__mME)->imsi_bcd); \
141
             ogs_warn("%s    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d", \
142
-                    (__mME)->imsi_bcd, (__mME)->enb_ue_holding->enb_ue_s1ap_id, \
143
-                    (__mME)->enb_ue_holding->mme_ue_s1ap_id); \
144
+                    (__mME)->imsi_bcd, \
145
+                    enb_ue_holding->enb_ue_s1ap_id, \
146
+                    enb_ue_holding->mme_ue_s1ap_id); \
147
             \
148
-            (__mME)->enb_ue_holding->ue_ctx_rel_action = \
149
+            enb_ue_holding->ue_ctx_rel_action = \
150
                 S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE; \
151
-            ogs_timer_start((__mME)->enb_ue_holding->t_s1_holding, \
152
+            ogs_timer_start(enb_ue_holding->t_s1_holding, \
153
                     mme_timer_cfg(MME_TIMER_S1_HOLDING)->duration); \
154
+            \
155
+            (__mME)->enb_ue_holding_id = (__mME)->enb_ue_id; \
156
         } else \
157
             ogs_error("%s S1 Context has already been removed", \
158
                     (__mME)->imsi_bcd); \
159
     } while(0)
160
 #define CLEAR_S1_CONTEXT(__mME) \
161
     do { \
162
-        if (enb_ue_cycle((__mME)->enb_ue_holding)) { \
163
+        enb_ue_t *enb_ue_holding = NULL; \
164
+        \
165
+        enb_ue_holding = enb_ue_find_by_id((__mME)->enb_ue_holding_id); \
166
+        if (enb_ue_holding) { \
167
             int r; \
168
             ogs_warn("%s Clear S1 Context", (__mME)->imsi_bcd); \
169
             ogs_warn("%s    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d", \
170
-                    (__mME)->imsi_bcd, (__mME)->enb_ue_holding->enb_ue_s1ap_id, \
171
-                    (__mME)->enb_ue_holding->mme_ue_s1ap_id); \
172
+                    (__mME)->imsi_bcd, \
173
+                    enb_ue_holding->enb_ue_s1ap_id, \
174
+                    enb_ue_holding->mme_ue_s1ap_id); \
175
             \
176
             r = s1ap_send_ue_context_release_command( \
177
-                    (__mME)->enb_ue_holding, \
178
+                    enb_ue_holding, \
179
                     S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release, \
180
                     S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0); \
181
             ogs_expect(r == OGS_OK); \
182
             ogs_assert(r != OGS_ERROR); \
183
         } \
184
-        (__mME)->enb_ue_holding = NULL; \
185
+        (__mME)->enb_ue_holding_id = OGS_INVALID_POOL_ID; \
186
     } while(0)
187
-    enb_ue_t        *enb_ue_holding;
188
+    ogs_pool_id_t   enb_ue_holding_id;
189
 
190
     struct {
191
 #define MME_CLEAR_PAGING_INFO(__mME) \
192
@@ -596,7 +577,7 @@
193
         ogs_assert(__tYPE); \
194
         ogs_debug("%s Store Paging Info", mme_ue->imsi_bcd); \
195
         (__mME)->paging.type = __tYPE; \
196
-        (__mME)->paging.data = __dATA; \
197
+        (__mME)->paging.data = OGS_UINT_TO_POINTER(__dATA); \
198
     } while(0)
199
 
200
 #define MME_PAGING_ONGOING(__mME) ((__mME) && ((__mME)->paging.type))
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-event.h Changed
19
 
1
@@ -94,12 +94,11 @@
2
     ogs_diam_s6a_message_t *s6a_message;
3
 
4
     mme_vlr_t *vlr;
5
-    mme_enb_t *enb;
6
-    enb_ue_t *enb_ue;
7
-    sgw_ue_t *sgw_ue;
8
-    mme_ue_t *mme_ue;
9
-    mme_sess_t *sess;
10
-    mme_bearer_t *bearer;
11
+    ogs_pool_id_t enb_id;
12
+    ogs_pool_id_t enb_ue_id;
13
+    ogs_pool_id_t sgw_ue_id;
14
+    ogs_pool_id_t mme_ue_id;
15
+    ogs_pool_id_t bearer_id;
16
 
17
     ogs_timer_t *timer;
18
 } mme_event_t;
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-fd-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-fd-path.c Changed
177
 
1
@@ -34,8 +34,8 @@
2
     mme_ue_t *mme_ue, uint32_t *subdatamask);
3
 
4
 struct sess_state {
5
-    mme_ue_t *mme_ue;
6
-    enb_ue_t *enb_ue;
7
+    ogs_pool_id_t mme_ue_id;
8
+    ogs_pool_id_t enb_ue_id;
9
     struct timespec ts; /* Time of sending the message */
10
 };
11
 
12
@@ -678,12 +678,12 @@
13
 
14
     uint8_t resyncOGS_AUTS_LEN + OGS_RAND_LEN;
15
 
16
-    if (!mme_ue_cycle(mme_ue)) {
17
+    if (!mme_ue) {
18
         ogs_error("UE(mme-ue) context has already been removed");
19
         return;
20
     }
21
 
22
-    if (!enb_ue_cycle(enb_ue)) {
23
+    if (!enb_ue) {
24
         ogs_error("S1 context has already been removed");
25
         return;
26
     }
27
@@ -697,8 +697,8 @@
28
     sess_data = ogs_calloc(1, sizeof (*sess_data));
29
     ogs_assert(sess_data);
30
 
31
-    sess_data->mme_ue = mme_ue;
32
-    sess_data->enb_ue = enb_ue;
33
+    sess_data->mme_ue_id = mme_ue->id;
34
+    sess_data->enb_ue_id = enb_ue->id;
35
 
36
     /* Create the request */
37
     ret = fd_msg_new(ogs_diam_s6a_cmd_air, MSGFL_ALLOC_ETEID, &req);
38
@@ -870,9 +870,9 @@
39
         return;
40
     }
41
 
42
-    mme_ue = sess_data->mme_ue;
43
+    mme_ue = mme_ue_find_by_id(sess_data->mme_ue_id);
44
     ogs_assert(mme_ue);
45
-    enb_ue = sess_data->enb_ue;
46
+    enb_ue = enb_ue_find_by_id(sess_data->enb_ue_id);
47
     ogs_assert(enb_ue);
48
 
49
     /* Set Authentication-Information Command */
50
@@ -1033,8 +1033,8 @@
51
         int rv;
52
         e = mme_event_new(MME_EVENT_S6A_MESSAGE);
53
         ogs_assert(e);
54
-        e->mme_ue = mme_ue;
55
-        e->enb_ue = enb_ue;
56
+        e->mme_ue_id = mme_ue->id;
57
+        e->enb_ue_id = enb_ue->id;
58
         e->s6a_message = s6a_message;
59
         rv = ogs_queue_push(ogs_app()->queue, e);
60
         if (rv != OGS_OK) {
61
@@ -1102,12 +1102,12 @@
62
     struct session *session = NULL;
63
     ogs_nas_plmn_id_t nas_plmn_id;
64
 
65
-    if (!mme_ue_cycle(mme_ue)) {
66
+    if (!mme_ue) {
67
         ogs_error("UE(mme-ue) context has already been removed");
68
         return;
69
     }
70
 
71
-    if (!enb_ue_cycle(enb_ue)) {
72
+    if (!enb_ue) {
73
         ogs_error("S1 context has already been removed");
74
         return;
75
     }
76
@@ -1117,8 +1117,8 @@
77
     /* Create the random value to store with the session */
78
     sess_data = ogs_calloc(1, sizeof(*sess_data));
79
     ogs_assert(sess_data);
80
-    sess_data->mme_ue = mme_ue;
81
-    sess_data->enb_ue = enb_ue;
82
+    sess_data->mme_ue_id = mme_ue->id;
83
+    sess_data->enb_ue_id = enb_ue->id;
84
 
85
     /* Create the request */
86
     ret = fd_msg_new(ogs_diam_s6a_cmd_ulr, MSGFL_ALLOC_ETEID, &req);
87
@@ -1307,9 +1307,9 @@
88
         return;
89
     }
90
 
91
-    mme_ue = sess_data->mme_ue;
92
+    mme_ue = mme_ue_find_by_id(sess_data->mme_ue_id);
93
     ogs_assert(mme_ue);
94
-    enb_ue = sess_data->enb_ue;
95
+    enb_ue = enb_ue_find_by_id(sess_data->enb_ue_id);
96
     ogs_assert(enb_ue);
97
 
98
     /* Set Update-Location Command */
99
@@ -1451,8 +1451,8 @@
100
         int rv;
101
         e = mme_event_new(MME_EVENT_S6A_MESSAGE);
102
         ogs_assert(e);
103
-        e->mme_ue = mme_ue;
104
-        e->enb_ue = enb_ue;
105
+        e->mme_ue_id = mme_ue->id;
106
+        e->enb_ue_id = enb_ue->id;
107
         e->s6a_message = s6a_message;
108
         rv = ogs_queue_push(ogs_app()->queue, e);
109
         if (rv != OGS_OK) {
110
@@ -1524,12 +1524,12 @@
111
     struct sess_state *sess_data = NULL, *svg;
112
     struct session *session = NULL;
113
 
114
-    if (!mme_ue_cycle(mme_ue)) {
115
+    if (!mme_ue) {
116
         ogs_error("UE(mme-ue) context has already been removed");
117
         return;
118
     }
119
 
120
-    if (!enb_ue_cycle(enb_ue)) {
121
+    if (!enb_ue) {
122
         ogs_error("S1 context has already been removed");
123
         return;
124
     }
125
@@ -1539,8 +1539,8 @@
126
     /* Create the random value to store with the session */
127
     sess_data = ogs_calloc(1, sizeof(*sess_data));
128
     ogs_assert(sess_data);
129
-    sess_data->mme_ue = mme_ue;
130
-    sess_data->enb_ue = enb_ue;
131
+    sess_data->mme_ue_id = mme_ue->id;
132
+    sess_data->enb_ue_id = enb_ue->id;
133
 
134
     /* Create the request */
135
     ret = fd_msg_new(ogs_diam_s6a_cmd_pur, MSGFL_ALLOC_ETEID, &req);
136
@@ -1664,9 +1664,9 @@
137
         return;
138
     }
139
 
140
-    mme_ue = sess_data->mme_ue;
141
+    mme_ue = mme_ue_find_by_id(sess_data->mme_ue_id);
142
     ogs_assert(mme_ue);
143
-    enb_ue = sess_data->enb_ue;
144
+    enb_ue = enb_ue_find_by_id(sess_data->enb_ue_id);
145
     ogs_assert(enb_ue);
146
 
147
     /* Set Purge-UE Command */
148
@@ -1764,8 +1764,8 @@
149
         int rv;
150
         e = mme_event_new(MME_EVENT_S6A_MESSAGE);
151
         ogs_assert(e);
152
-        e->mme_ue = mme_ue;
153
-        e->enb_ue = enb_ue;
154
+        e->mme_ue_id = mme_ue->id;
155
+        e->enb_ue_id = enb_ue->id;
156
         e->s6a_message = s6a_message;
157
         rv = ogs_queue_push(ogs_app()->queue, e);
158
         if (rv != OGS_OK) {
159
@@ -1922,7 +1922,7 @@
160
 
161
     e = mme_event_new(MME_EVENT_S6A_MESSAGE);
162
     ogs_assert(e);
163
-    e->mme_ue = mme_ue;
164
+    e->mme_ue_id = mme_ue->id;
165
     e->s6a_message = s6a_message;
166
     rv = ogs_queue_push(ogs_app()->queue, e);
167
     if (rv != OGS_OK) {
168
@@ -2213,7 +2213,7 @@
169
     int rv;
170
     e = mme_event_new(MME_EVENT_S6A_MESSAGE);
171
     ogs_assert(e);
172
-    e->mme_ue = mme_ue;
173
+    e->mme_ue_id = mme_ue->id;
174
     e->s6a_message = s6a_message;
175
     rv = ogs_queue_push(ogs_app()->queue, e);
176
     if (rv != OGS_OK) {
177
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-gn-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-gn-build.c Changed
29
 
1
@@ -24,7 +24,11 @@
2
 
3
 static int sess_fill_mm_context_decoded(mme_sess_t *sess, ogs_gtp1_mm_context_decoded_t *mmctx_dec)
4
 {
5
-    mme_ue_t *mme_ue = sess->mme_ue;
6
+    mme_ue_t *mme_ue = NULL;
7
+
8
+    ogs_assert(sess);
9
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
10
+    ogs_assert(mme_ue);
11
     *mmctx_dec = (ogs_gtp1_mm_context_decoded_t) {
12
         .gupii = 1, /* Integrity Protection not required */
13
         .ugipai = 1, /* Ignore "Used GPRS integrity protection algorithm" field" */
14
@@ -55,8 +59,13 @@
15
 static void build_qos_profile_from_session(ogs_gtp1_qos_profile_decoded_t *qos_pdec,
16
         const mme_sess_t *sess, const mme_bearer_t *bearer)
17
 {
18
-    const mme_ue_t *mme_ue = sess->mme_ue;
19
+    mme_ue_t *mme_ue = NULL;
20
     const ogs_session_t *session = sess->session;
21
+
22
+    ogs_assert(sess);
23
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
24
+    ogs_assert(mme_ue);
25
+
26
     /* FIXME: Initialize with defaults: */
27
     memset(qos_pdec, 0, sizeof(*qos_pdec));
28
 
29
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-gn-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-gn-handler.c Changed
64
 
1
@@ -302,6 +302,7 @@
2
     char imsi_bcdOGS_MAX_IMSI_BCD_LEN+1;
3
     ogs_gtp1_mm_context_decoded_t gtp1_mm_ctx;
4
     ogs_gtp1_pdp_context_decoded_t gtp1_pdp_ctx;
5
+    enb_ue_t *enb_ue = NULL;
6
     mme_sess_t *sess = NULL;
7
     uint8_t ret_cause = OGS_GTP1_CAUSE_REQUEST_ACCEPTED;
8
 
9
@@ -318,6 +319,8 @@
10
         return OGS_GTP1_CAUSE_IMSI_IMEI_NOT_KNOWN;
11
     }
12
 
13
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
14
+
15
     switch (resp->cause.u8) {
16
      case OGS_GTP1_CAUSE_REQUEST_ACCEPTED:
17
         break; /* Handle below */
18
@@ -338,7 +341,7 @@
19
 
20
     if (resp->cause.u8 != OGS_GTP1_CAUSE_REQUEST_ACCEPTED) {
21
         ogs_error("Gn Rx SGSN Context Response cause:%u", resp->cause.u8);
22
-        rv = nas_eps_send_tau_reject(mme_ue->enb_ue, mme_ue, emm_cause);
23
+        rv = nas_eps_send_tau_reject(enb_ue, mme_ue, emm_cause);
24
         return OGS_GTP1_CAUSE_SYSTEM_FAILURE;
25
     }
26
 
27
@@ -428,7 +431,7 @@
28
 nack_and_reject:
29
     rv = mme_gtp1_send_sgsn_context_ack(mme_ue, gtp1_cause, xact);
30
     ogs_info("%s TAU Reject OGS_NAS_EMM_CAUSE:%d", mme_ue->imsi_bcd, emm_cause);
31
-    rv = nas_eps_send_tau_reject(mme_ue->enb_ue, mme_ue, emm_cause);
32
+    rv = nas_eps_send_tau_reject(enb_ue, mme_ue, emm_cause);
33
     return OGS_GTP1_CAUSE_SYSTEM_FAILURE;
34
 }
35
 
36
@@ -437,6 +440,7 @@
37
         ogs_gtp_xact_t *xact, mme_ue_t *mme_ue, ogs_gtp1_sgsn_context_acknowledge_t *req)
38
 {
39
     int rv;
40
+    enb_ue_t *enb_ue = NULL;
41
 
42
     ogs_debug("Gn Rx SGSN Context Acknowledge");
43
 
44
@@ -451,6 +455,8 @@
45
         return;
46
     }
47
 
48
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
49
+
50
     /* 3GPP TS 23.060 6.9.1.2.2 Step 4), 3GPP TS 23.401 D.3.5 Step 4)
51
     * The new SGSN sends an SGSN Context Acknowledge message to the old SGSN. The old MME (which is the old
52
     * SGSN from the new SGSN's point of view) marks in its context that the information in the GWs and the HSS are
53
@@ -473,8 +479,8 @@
54
     * connection is released by the source eNodeB. The source eNodeB confirms the release of the RRC connection
55
     * and of the S1-U connection by sending a S1-U Release Complete message to the source MME."
56
     */
57
-    if (mme_ue->enb_ue) {
58
-        rv = s1ap_send_ue_context_release_command(mme_ue->enb_ue,
59
+    if (enb_ue) {
60
+        rv = s1ap_send_ue_context_release_command(enb_ue,
61
             S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
62
             S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0);
63
         ogs_expect(rv == OGS_OK);
64
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-gtp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-gtp-path.c Changed
201
 
1
@@ -102,9 +102,12 @@
2
 {
3
     int r;
4
     mme_ue_t *mme_ue = NULL;
5
+    ogs_pool_id_t mme_ue_id = OGS_INVALID_POOL_ID;
6
     enb_ue_t *enb_ue = NULL;
7
     mme_sess_t *sess = NULL;
8
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
9
     mme_bearer_t *bearer = NULL;
10
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
11
     uint8_t type = 0;
12
 
13
     ogs_assert(xact);
14
@@ -115,22 +118,30 @@
15
     case OGS_GTP2_RELEASE_ACCESS_BEARERS_REQUEST_TYPE:
16
     case OGS_GTP2_CREATE_INDIRECT_DATA_FORWARDING_TUNNEL_REQUEST_TYPE:
17
     case OGS_GTP2_DELETE_INDIRECT_DATA_FORWARDING_TUNNEL_REQUEST_TYPE:
18
-        mme_ue = data;
19
+        mme_ue_id = OGS_POINTER_TO_UINT(data);
20
+        ogs_assert(mme_ue_id >= OGS_MIN_POOL_ID &&
21
+                mme_ue_id <= OGS_MAX_POOL_ID);
22
+        mme_ue = mme_ue_find_by_id(mme_ue_id);
23
         ogs_assert(mme_ue);
24
         break;
25
     case OGS_GTP2_CREATE_SESSION_REQUEST_TYPE:
26
     case OGS_GTP2_DELETE_SESSION_REQUEST_TYPE:
27
-        sess = data;
28
+        sess_id = OGS_POINTER_TO_UINT(data);
29
+        ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
30
+        sess = mme_sess_find_by_id(sess_id);
31
         ogs_assert(sess);
32
-        mme_ue = sess->mme_ue;
33
+        mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
34
         ogs_assert(mme_ue);
35
         break;
36
     case OGS_GTP2_BEARER_RESOURCE_COMMAND_TYPE:
37
-        bearer = data;
38
+        bearer_id = OGS_POINTER_TO_UINT(data);
39
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
40
+                bearer_id <= OGS_MAX_POOL_ID);
41
+        bearer = mme_bearer_find_by_id(bearer_id);
42
         ogs_assert(bearer);
43
-        sess = bearer->sess;
44
+        sess = mme_sess_find_by_id(bearer->sess_id);
45
         ogs_assert(sess);
46
-        mme_ue = sess->mme_ue;
47
+        mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
48
         ogs_assert(mme_ue);
49
         break;
50
     default:
51
@@ -154,7 +165,7 @@
52
          */
53
         CLEAR_SESSION_CONTEXT(mme_ue);
54
 
55
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
56
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
57
         if (enb_ue) {
58
             r = s1ap_send_ue_context_release_command(enb_ue,
59
                     S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
60
@@ -244,13 +255,13 @@
61
     mme_ue_t *mme_ue = NULL;
62
     sgw_ue_t *sgw_ue = NULL;
63
 
64
-    mme_ue = sess->mme_ue;
65
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
66
     ogs_assert(mme_ue);
67
-    sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
68
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
69
     ogs_assert(sgw_ue);
70
 
71
     if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) {
72
-        sgw_ue = sgw_ue_cycle(sgw_ue->target_ue);
73
+        sgw_ue = sgw_ue_find_by_id(sgw_ue->target_ue_id);
74
         ogs_assert(sgw_ue);
75
     }
76
 
77
@@ -264,7 +275,9 @@
78
         return OGS_ERROR;
79
     }
80
 
81
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, pkbuf, timeout, sess);
82
+    xact = ogs_gtp_xact_local_create(
83
+            sgw_ue->gnode, &h, pkbuf, timeout,
84
+            OGS_UINT_TO_POINTER(sess->id));
85
     if (!xact) {
86
         ogs_error("ogs_gtp_xact_local_create() failed");
87
         return OGS_ERROR;
88
@@ -290,7 +303,7 @@
89
     ogs_pkbuf_t *pkbuf = NULL;
90
 
91
     ogs_assert(mme_ue);
92
-    sgw_ue = mme_ue->sgw_ue;
93
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
94
     ogs_assert(sgw_ue);
95
 
96
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
97
@@ -303,7 +316,9 @@
98
         return OGS_ERROR;
99
     }
100
 
101
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, pkbuf, timeout, mme_ue);
102
+    xact = ogs_gtp_xact_local_create(
103
+            sgw_ue->gnode, &h, pkbuf, timeout,
104
+            OGS_UINT_TO_POINTER(mme_ue->id));
105
     if (!xact) {
106
         ogs_error("ogs_gtp_xact_local_create() failed");
107
         return OGS_ERROR;
108
@@ -328,7 +343,7 @@
109
 
110
     ogs_assert(action);
111
     ogs_assert(sess);
112
-    mme_ue = sess->mme_ue;
113
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
114
     ogs_assert(mme_ue);
115
     ogs_assert(sgw_ue);
116
 
117
@@ -342,7 +357,9 @@
118
         return OGS_ERROR;
119
     }
120
 
121
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, s11buf, timeout, sess);
122
+    xact = ogs_gtp_xact_local_create(
123
+            sgw_ue->gnode, &h, s11buf, timeout,
124
+            OGS_UINT_TO_POINTER(sess->id));
125
     if (!xact) {
126
         ogs_error("ogs_gtp_xact_local_create() failed");
127
         return OGS_ERROR;
128
@@ -363,11 +380,10 @@
129
     sgw_ue_t *sgw_ue = NULL;
130
 
131
     ogs_assert(mme_ue);
132
-    sgw_ue = mme_ue->sgw_ue;
133
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
134
     ogs_assert(sgw_ue);
135
     ogs_assert(action);
136
 
137
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
138
     ogs_list_for_each_safe(&mme_ue->sess_list, next_sess, sess) {
139
         if (MME_HAVE_SGW_S1U_PATH(sess)) {
140
             mme_gtp_send_delete_session_request(sgw_ue, sess, action);
141
@@ -390,16 +406,19 @@
142
     ogs_pkbuf_t *pkbuf = NULL;
143
 
144
     ogs_assert(bearer);
145
-    mme_ue = bearer->mme_ue;
146
-    ogs_assert(mme_ue);
147
-    sgw_ue = mme_ue->sgw_ue;
148
-    ogs_assert(sgw_ue);
149
-    xact = ogs_gtp_xact_cycle(bearer->create.xact);
150
+    ogs_assert(bearer->create.xact_id >= OGS_MIN_POOL_ID &&
151
+            bearer->create.xact_id <= OGS_MAX_POOL_ID);
152
+    xact = ogs_gtp_xact_find_by_id(bearer->create.xact_id);
153
     if (!xact) {
154
-        ogs_warn("GTP transaction(CREATE) has already been removed");
155
+        ogs_error("GTP transaction(CREATE) has already been removed");
156
         return OGS_OK;
157
     }
158
 
159
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
160
+    ogs_assert(mme_ue);
161
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
162
+    ogs_assert(sgw_ue);
163
+
164
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
165
     h.type = OGS_GTP2_CREATE_BEARER_RESPONSE_TYPE;
166
     h.teid = sgw_ue->sgw_s11_teid;
167
@@ -435,9 +454,9 @@
168
     ogs_pkbuf_t *pkbuf = NULL;
169
 
170
     ogs_assert(bearer);
171
-    mme_ue = bearer->mme_ue;
172
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
173
     ogs_assert(mme_ue);
174
-    sgw_ue = mme_ue->sgw_ue;
175
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
176
     ogs_assert(sgw_ue);
177
 
178
     /*
179
@@ -500,16 +519,19 @@
180
     ogs_pkbuf_t *pkbuf = NULL;
181
 
182
     ogs_assert(bearer);
183
-    mme_ue = bearer->mme_ue;
184
-    ogs_assert(mme_ue);
185
-    sgw_ue = mme_ue->sgw_ue;
186
-    ogs_assert(sgw_ue);
187
-    xact = ogs_gtp_xact_cycle(bearer->delete.xact);
188
+    ogs_assert(bearer->delete.xact_id >= OGS_MIN_POOL_ID &&
189
+            bearer->delete.xact_id <= OGS_MAX_POOL_ID);
190
+    xact = ogs_gtp_xact_find_by_id(bearer->delete.xact_id);
191
     if (!xact) {
192
-        ogs_warn("GTP transaction(DELETE) has already been removed");
193
+        ogs_error("GTP transaction(DELETE) has already been removed");
194
         return OGS_OK;
195
     }
196
 
197
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
198
+    ogs_assert(mme_ue);
199
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
200
+    ogs_assert(sgw_ue);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-path.c Changed
75
 
1
@@ -76,14 +76,13 @@
2
         if (!MME_SESSION_RELEASE_PENDING(mme_ue) &&
3
             mme_ue_xact_count(mme_ue, OGS_GTP_LOCAL_ORIGINATOR) ==
4
                 xact_count) {
5
-            enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue);
6
+            enb_ue_t *enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
7
             if (enb_ue) {
8
                 ogs_assert(OGS_OK ==
9
                     s1ap_send_ue_context_release_command(enb_ue,
10
                         S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
11
                         S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0));
12
             } else {
13
-                MME_UE_CHECK(OGS_LOG_WARN, mme_ue);
14
                 mme_ue_remove(mme_ue);
15
             }
16
         }
17
@@ -129,7 +128,7 @@
18
     if (!MME_SESSION_RELEASE_PENDING(mme_ue) &&
19
         mme_ue_xact_count(mme_ue, OGS_GTP_LOCAL_ORIGINATOR) ==
20
             xact_count) {
21
-        enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue);
22
+        enb_ue_t *enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
23
         if (enb_ue) {
24
             r = s1ap_send_ue_context_release_command(enb_ue,
25
                     S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
26
@@ -148,7 +147,7 @@
27
     mme_ue_t *mme_ue = NULL;
28
     ogs_assert(enb_ue);
29
 
30
-    mme_ue = enb_ue->mme_ue;
31
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
32
     if (mme_ue) {
33
         ogs_debug("%s Release access bearer request", mme_ue->imsi_bcd);
34
         ogs_assert(OGS_OK ==
35
@@ -173,7 +172,8 @@
36
 
37
     switch (mme_ue->paging.type) {
38
     case MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION:
39
-        bearer = mme_bearer_cycle(mme_ue->paging.data);
40
+        bearer = mme_bearer_find_by_id(
41
+                OGS_POINTER_TO_UINT(mme_ue->paging.data));
42
         if (!bearer) {
43
             ogs_error("No Bearer %d", mme_ue->paging.type);
44
             goto cleanup;
45
@@ -190,7 +190,8 @@
46
         }
47
         break;
48
     case MME_PAGING_TYPE_CREATE_BEARER:
49
-        bearer = mme_bearer_cycle(mme_ue->paging.data);
50
+        bearer = mme_bearer_find_by_id(
51
+                OGS_POINTER_TO_UINT(mme_ue->paging.data));
52
         if (!bearer) {
53
             ogs_error("No Bearer %d", mme_ue->paging.type);
54
             goto cleanup;
55
@@ -207,7 +208,8 @@
56
         }
57
         break;
58
     case MME_PAGING_TYPE_UPDATE_BEARER:
59
-        bearer = mme_bearer_cycle(mme_ue->paging.data);
60
+        bearer = mme_bearer_find_by_id(
61
+                OGS_POINTER_TO_UINT(mme_ue->paging.data));
62
         if (!bearer) {
63
             ogs_error("No Bearer %d", mme_ue->paging.type);
64
             goto cleanup;
65
@@ -240,7 +242,8 @@
66
         }
67
         break;
68
     case MME_PAGING_TYPE_DELETE_BEARER:
69
-        bearer = mme_bearer_cycle(mme_ue->paging.data);
70
+        bearer = mme_bearer_find_by_id(
71
+                OGS_POINTER_TO_UINT(mme_ue->paging.data));
72
         if (!bearer) {
73
             ogs_error("No Bearer %d", mme_ue->paging.type);
74
             goto cleanup;
75
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-s11-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-s11-build.c Changed
108
 
1
@@ -55,13 +55,13 @@
2
     session = sess->session;
3
     ogs_assert(session);
4
     ogs_assert(session->name);
5
-    mme_ue = sess->mme_ue;
6
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
7
     ogs_assert(mme_ue);
8
-    sgw_ue = mme_ue->sgw_ue;
9
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
10
     ogs_assert(sgw_ue);
11
 
12
     if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) {
13
-        sgw_ue = sgw_ue_cycle(sgw_ue->target_ue);
14
+        sgw_ue = sgw_ue_find_by_id(sgw_ue->target_ue_id);
15
         ogs_assert(sgw_ue);
16
     }
17
 
18
@@ -405,7 +405,7 @@
19
     ogs_debug("Modifty Bearer Request");
20
 
21
     ogs_assert(mme_ue);
22
-    sgw_ue = mme_ue->sgw_ue;
23
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
24
     ogs_assert(sgw_ue);
25
     ogs_assert(ogs_list_count(&mme_ue->bearer_to_modify_list));
26
 
27
@@ -448,7 +448,7 @@
28
     memset(&indication, 0, sizeof(ogs_gtp2_indication_t));
29
     ogs_list_for_each_entry(
30
             &mme_ue->bearer_to_modify_list, bearer, to_modify_node) {
31
-        mme_sess_t *sess = bearer->sess;
32
+        mme_sess_t *sess = mme_sess_find_by_id(bearer->sess_id);
33
         ogs_assert(sess);
34
 
35
         if (sess->ue_request_type.value == OGS_NAS_EPS_REQUEST_TYPE_HANDOVER) {
36
@@ -513,9 +513,9 @@
37
     sgw_ue_t *sgw_ue = NULL;
38
 
39
     ogs_assert(sess);
40
-    mme_ue = sess->mme_ue;
41
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
42
     ogs_assert(mme_ue);
43
-    sgw_ue = mme_ue->sgw_ue;
44
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
45
     ogs_assert(sgw_ue);
46
     bearer = mme_default_bearer_in_sess(sess);
47
     ogs_assert(bearer);
48
@@ -576,9 +576,9 @@
49
     sgw_ue_t *sgw_ue = NULL;
50
 
51
     ogs_assert(bearer);
52
-    mme_ue = bearer->mme_ue;
53
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
54
     ogs_assert(mme_ue);
55
-    sgw_ue = mme_ue->sgw_ue;
56
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
57
     ogs_assert(sgw_ue);
58
 
59
     ogs_debug("Create Bearer Response");
60
@@ -683,9 +683,9 @@
61
     sgw_ue_t *sgw_ue = NULL;
62
 
63
     ogs_assert(bearer);
64
-    mme_ue = bearer->mme_ue;
65
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
66
     ogs_assert(mme_ue);
67
-    sgw_ue = mme_ue->sgw_ue;
68
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
69
     ogs_assert(sgw_ue);
70
 
71
     ogs_debug("Update Bearer Response");
72
@@ -762,9 +762,9 @@
73
     sgw_ue_t *sgw_ue = NULL;
74
 
75
     ogs_assert(bearer);
76
-    mme_ue = bearer->mme_ue;
77
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
78
     ogs_assert(mme_ue);
79
-    sgw_ue = mme_ue->sgw_ue;
80
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
81
     ogs_assert(sgw_ue);
82
 
83
     ogs_debug("Delete Bearer Response");
84
@@ -918,7 +918,7 @@
85
     int len;
86
 
87
     ogs_assert(mme_ue);
88
-    sgw_ue = mme_ue->sgw_ue;
89
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
90
     ogs_assert(sgw_ue);
91
 
92
     ogs_debug("Create Indirect Data Forwarding Tunnel Request");
93
@@ -1002,11 +1002,11 @@
94
     mme_bearer_t *linked_bearer = NULL;
95
 
96
     ogs_assert(bearer);
97
-    sess = bearer->sess;
98
+    sess = mme_sess_find_by_id(bearer->sess_id);
99
     ogs_assert(sess);
100
-    mme_ue = sess->mme_ue;
101
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
102
     ogs_assert(mme_ue);
103
-    sgw_ue = mme_ue->sgw_ue;
104
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
105
     ogs_assert(sgw_ue);
106
 
107
     ogs_debug("Bearer Resource Command");
108
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-s11-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-s11-handler.c Changed
201
 
1
@@ -62,16 +62,13 @@
2
 static void gtp_remote_holding_timeout(ogs_gtp_xact_t *xact, void *data)
3
 {
4
     char bufOGS_ADDRSTRLEN;
5
-    mme_bearer_t *bearer = data;
6
+    mme_bearer_t *bearer = NULL;
7
     uint8_t type;
8
 
9
     ogs_assert(xact);
10
-    bearer = mme_bearer_cycle(bearer);
11
-    ogs_assert(bearer);
12
-
13
     type = xact->seqxact->step-1.type;
14
 
15
-    ogs_warn("%d %s HOLDING TIMEOUT "
16
+    ogs_error("%d %s HOLDING TIMEOUT "
17
             "for step %d type %d peer %s:%d",
18
             xact->xid,
19
             xact->org == OGS_GTP_LOCAL_ORIGINATOR ? "LOCAL " : "REMOTE",
20
@@ -79,6 +76,13 @@
21
             OGS_ADDR(&xact->gnode->addr, buf),
22
             OGS_PORT(&xact->gnode->addr));
23
 
24
+    ogs_assert(data);
25
+    bearer = mme_bearer_find_by_id(OGS_POINTER_TO_UINT(data));
26
+    if (!bearer) {
27
+        ogs_error("Bearer has already been removed %d", type);
28
+        return;
29
+    }
30
+
31
     /*
32
      * Issues #3240
33
      *
34
@@ -182,6 +186,7 @@
35
     mme_sess_t *sess = NULL;
36
     mme_ue_t *mme_ue = NULL;
37
     sgw_ue_t *source_ue = NULL, *target_ue = NULL;
38
+    enb_ue_t *enb_ue = NULL;
39
     ogs_session_t *session = NULL;
40
     ogs_gtp2_bearer_qos_t bearer_qos;
41
     ogs_gtp2_ambr_t *ambr = NULL;
42
@@ -197,11 +202,10 @@
43
      ********************/
44
     ogs_assert(xact);
45
     create_action = xact->create_action;
46
-    sess = xact->data;
47
+    sess = mme_sess_find_by_id(OGS_POINTER_TO_UINT(xact->data));
48
     ogs_assert(sess);
49
 
50
-    MME_UE_CHECK(OGS_LOG_DEBUG, sess->mme_ue);
51
-    mme_ue = mme_ue_cycle(sess->mme_ue);
52
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
53
 
54
     rv = ogs_gtp_xact_commit(xact);
55
     if (rv != OGS_OK) {
56
@@ -213,11 +217,12 @@
57
         ogs_error("MME-UE Context has already been removed");
58
         return;
59
     }
60
-    source_ue = sgw_ue_cycle(mme_ue->sgw_ue);
61
+    source_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
62
     ogs_assert(source_ue);
63
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
64
 
65
     if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) {
66
-        target_ue = sgw_ue_cycle(source_ue->target_ue);
67
+        target_ue = sgw_ue_find_by_id(source_ue->target_ue_id);
68
         ogs_assert(target_ue);
69
     } else {
70
         target_ue = source_ue;
71
@@ -248,7 +253,7 @@
72
         if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) {
73
             ogs_error("%s Attach reject Cause:%d",
74
                     mme_ue->imsi_bcd, session_cause);
75
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
76
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
77
                     OGS_NAS_EMM_CAUSE_NETWORK_FAILURE,
78
                     OGS_NAS_ESM_CAUSE_NETWORK_FAILURE);
79
             ogs_expect(r == OGS_OK);
80
@@ -299,7 +304,7 @@
81
         if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) {
82
             ogs_error("%s Attach reject Cause:%d",
83
                     mme_ue->imsi_bcd, session_cause);
84
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
85
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
86
                     OGS_NAS_EMM_CAUSE_NETWORK_FAILURE,
87
                     OGS_NAS_ESM_CAUSE_NETWORK_FAILURE);
88
             ogs_expect(r == OGS_OK);
89
@@ -307,7 +312,7 @@
90
         } else if (create_action == OGS_GTP_CREATE_IN_TRACKING_AREA_UPDATE) {
91
             ogs_error("%s TAU reject Cause:%d",
92
                     mme_ue->imsi_bcd, session_cause);
93
-            r = nas_eps_send_tau_reject(mme_ue->enb_ue, mme_ue,
94
+            r = nas_eps_send_tau_reject(enb_ue, mme_ue,
95
                     OGS_NAS_EMM_CAUSE_NETWORK_FAILURE);
96
             ogs_expect(r == OGS_OK);
97
             ogs_assert(r != OGS_ERROR);
98
@@ -338,7 +343,7 @@
99
                     mme_ue->imsi_bcd, bearer_cause);
100
             if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) {
101
                 ogs_error("%s Attach reject", mme_ue->imsi_bcd);
102
-                r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
103
+                r = nas_eps_send_attach_reject(enb_ue, mme_ue,
104
                         OGS_NAS_EMM_CAUSE_NETWORK_FAILURE,
105
                         OGS_NAS_ESM_CAUSE_NETWORK_FAILURE);
106
                 ogs_expect(r == OGS_OK);
107
@@ -358,7 +363,7 @@
108
         ogs_error("%s GTP Cause VALUE:%d", mme_ue->imsi_bcd, session_cause);
109
         if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) {
110
             ogs_error("%s Attach reject", mme_ue->imsi_bcd);
111
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
112
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
113
                     OGS_NAS_EMM_CAUSE_NETWORK_FAILURE,
114
                     OGS_NAS_ESM_CAUSE_NETWORK_FAILURE);
115
             ogs_expect(r == OGS_OK);
116
@@ -525,7 +530,7 @@
117
 
118
     } else if (create_action == OGS_GTP_CREATE_IN_TRACKING_AREA_UPDATE) {
119
         /* 3GPP TS 23.401 D.3.6 step 13, 14: */
120
-        mme_s6a_send_ulr(mme_ue->enb_ue, mme_ue);
121
+        mme_s6a_send_ulr(enb_ue, mme_ue);
122
     } else if (create_action == OGS_GTP_CREATE_IN_UPLINK_NAS_TRANSPORT) {
123
         r = nas_eps_send_activate_default_bearer_context_request(
124
                 bearer, create_action);
125
@@ -571,8 +576,7 @@
126
     ogs_assert(xact);
127
     modify_action = xact->modify_action;
128
 
129
-    MME_UE_CHECK(OGS_LOG_DEBUG, xact->data);
130
-    mme_ue = mme_ue_cycle(xact->data);
131
+    mme_ue = mme_ue_find_by_id(OGS_POINTER_TO_UINT(xact->data));
132
 
133
     rv = ogs_gtp_xact_commit(xact);
134
     if (rv != OGS_OK) {
135
@@ -584,7 +588,7 @@
136
         ogs_error("MME-UE Context has already been removed");
137
         return;
138
     }
139
-    sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
140
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
141
     ogs_assert(sgw_ue);
142
 
143
     /************************
144
@@ -673,6 +677,7 @@
145
     sgw_ue_t *source_ue = NULL, *target_ue = NULL;
146
     mme_sess_t *sess = NULL;
147
     mme_ue_t *mme_ue = NULL;
148
+    enb_ue_t *enb_ue = NULL;
149
 
150
     ogs_assert(rsp);
151
 
152
@@ -684,12 +689,11 @@
153
     ogs_assert(xact);
154
     action = xact->delete_action;
155
     ogs_assert(action);
156
-    sess = xact->data;
157
+    sess = mme_sess_find_by_id(OGS_POINTER_TO_UINT(xact->data));
158
     ogs_assert(sess);
159
 
160
     ogs_debug("delete_session_response - xact:%p, sess:%p", xact, sess);
161
-    MME_UE_CHECK(OGS_LOG_DEBUG, sess->mme_ue);
162
-    mme_ue = mme_ue_cycle(sess->mme_ue);
163
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
164
 
165
     rv = ogs_gtp_xact_commit(xact);
166
     if (rv != OGS_OK) {
167
@@ -701,11 +705,11 @@
168
         ogs_error("MME-UE Context has already been removed");
169
         return;
170
     }
171
-    target_ue = sgw_ue_cycle(mme_ue->sgw_ue);
172
+    target_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
173
     ogs_assert(target_ue);
174
 
175
     if (action == OGS_GTP_DELETE_IN_PATH_SWITCH_REQUEST) {
176
-        source_ue = sgw_ue_cycle(target_ue->source_ue);
177
+        source_ue = sgw_ue_find_by_id(target_ue->source_ue_id);
178
         if (!source_ue) /* InterRAT to 2G/3G (SGSN) case: */
179
              source_ue = target_ue;
180
         ogs_assert(source_ue);
181
@@ -754,6 +758,8 @@
182
     ogs_assert(target_ue);
183
     ogs_assert(source_ue);
184
 
185
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
186
+
187
     ogs_debug("    MME_S11_TEID%d SGW_S11_TEID%d",
188
             mme_ue->mme_s11_teid, source_ue->sgw_s11_teid);
189
 
190
@@ -763,7 +769,7 @@
191
          * of the detach accept from UE */
192
     } else if (action == OGS_GTP_DELETE_SEND_AUTHENTICATION_REQUEST) {
193
         if (mme_sess_count(mme_ue) == 1) /* Last Session */ {
194
-            mme_s6a_send_air(mme_ue->enb_ue, mme_ue, NULL);
195
+            mme_s6a_send_air(enb_ue, mme_ue, NULL);
196
         }
197
 
198
     } else if (action == OGS_GTP_DELETE_SEND_DETACH_ACCEPT) {
199
@@ -791,11 +797,9 @@
200
     } else if (action == OGS_GTP_DELETE_SEND_RELEASE_WITH_UE_CONTEXT_REMOVE) {
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-s6a-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-s6a-handler.c Changed
33
 
1
@@ -153,7 +153,6 @@
2
     if (s6a_message->result_code != ER_DIAMETER_SUCCESS) {
3
         ogs_error("Purge UE failed for IMSI%s %d", mme_ue->imsi_bcd,
4
             s6a_message->result_code);
5
-        MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
6
         mme_ue_remove(mme_ue);
7
         return OGS_ERROR;
8
     }
9
@@ -161,7 +160,6 @@
10
     if (pua_message->pua_flags & OGS_DIAM_S6A_PUA_FLAGS_FREEZE_MTMSI)
11
         ogs_debug("Freeze M-TMSI requested but not implemented.");
12
 
13
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
14
     mme_ue_remove(mme_ue);
15
 
16
     return OGS_OK;
17
@@ -220,7 +218,6 @@
18
     clr_message = &s6a_message->clr_message;
19
     ogs_assert(clr_message);
20
 
21
-    mme_ue = mme_ue_cycle(mme_ue);
22
     if (!mme_ue) {
23
         ogs_warn("UE(mme-ue) context has already been removed");
24
         return;
25
@@ -236,7 +233,6 @@
26
      */
27
     if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_de_registered)) {
28
         ogs_warn("UE has already been de-registered");
29
-        MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
30
         mme_ue_remove(mme_ue);
31
         return;
32
     }
33
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-sm.c Changed
201
 
1
@@ -111,7 +111,11 @@
2
         enb = mme_enb_find_by_addr(addr);
3
         if (!enb) {
4
             enb = mme_enb_add(sock, addr);
5
-            ogs_assert(enb);
6
+            if (!enb) {
7
+                ogs_error("mme_enb_add() failed");
8
+                ogs_sock_destroy(sock);
9
+                ogs_free(addr);
10
+            }
11
         } else {
12
             ogs_warn("eNB context duplicated with IP-address %s!!!",
13
                     OGS_ADDR(addr, buf));
14
@@ -136,7 +140,10 @@
15
         enb = mme_enb_find_by_addr(addr);
16
         if (!enb) {
17
             enb = mme_enb_add(sock, addr);
18
-            ogs_assert(enb);
19
+            if (!enb) {
20
+                ogs_error("amf_enb_add() failed");
21
+                ogs_free(addr);
22
+            }
23
         } else {
24
             ogs_free(addr);
25
         }
26
@@ -193,7 +200,7 @@
27
 
28
         rc = ogs_s1ap_decode(&s1ap_message, pkbuf);
29
         if (rc == OGS_OK) {
30
-            e->enb = enb;
31
+            e->enb_id = enb->id;
32
             e->s1ap_message = &s1ap_message;
33
             ogs_fsm_dispatch(&enb->sm, e);
34
         } else {
35
@@ -210,13 +217,14 @@
36
         break;
37
 
38
     case MME_EVENT_S1AP_TIMER:
39
-        enb_ue = e->enb_ue;
40
-        ogs_assert(enb_ue);
41
+        enb_ue = enb_ue_find_by_id(e->enb_ue_id);
42
+        if (!enb_ue) {
43
+            ogs_error("S1 Context has already been removed");
44
+            break;
45
+        }
46
 
47
         switch (e->timer_id) {
48
         case MME_TIMER_S1_DELAYED_SEND:
49
-            enb = e->enb;
50
-            ogs_assert(enb);
51
             pkbuf = e->pkbuf;
52
             ogs_assert(pkbuf);
53
 
54
@@ -239,18 +247,22 @@
55
         break;
56
 
57
     case MME_EVENT_EMM_MESSAGE:
58
-        enb_ue = e->enb_ue;
59
-        ogs_assert(enb_ue);
60
         pkbuf = e->pkbuf;
61
         ogs_assert(pkbuf);
62
 
63
+        enb_ue = enb_ue_find_by_id(e->enb_ue_id);
64
+        if (!enb_ue) {
65
+            ogs_error("S1 Context has already been removed");
66
+            break;
67
+        }
68
+
69
         if (ogs_nas_emm_decode(&nas_message, pkbuf) != OGS_OK) {
70
             ogs_error("ogs_nas_emm_decode() failed");
71
             ogs_pkbuf_free(pkbuf);
72
             return;
73
         }
74
 
75
-        mme_ue = enb_ue->mme_ue;
76
+        mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
77
         if (!mme_ue) {
78
             mme_ue = mme_ue_find_by_message(&nas_message);
79
             if (!mme_ue) {
80
@@ -266,7 +278,6 @@
81
                     return;
82
                 }
83
 
84
-                MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
85
                 ogs_assert(ECM_IDLE(mme_ue));
86
             } else {
87
                 /* Here, if the MME_UE Context is found,
88
@@ -326,14 +337,12 @@
89
                     enb_ue ? enb_ue->enb_ue_s1ap_id : 0,
90
                     enb_ue ? enb_ue->mme_ue_s1ap_id : 0);
91
             ogs_fatal("context %p:%p", enb_ue, mme_ue);
92
-            ogs_fatal("cycle %p:%p",
93
-                    enb_ue_cycle(enb_ue), mme_ue_cycle(mme_ue));
94
             ogs_fatal("IMSI %s", mme_ue ? mme_ue->imsi_bcd : "No MME_UE");
95
             ogs_assert_if_reached();
96
         }
97
         ogs_assert(OGS_FSM_STATE(&mme_ue->sm));
98
 
99
-        e->mme_ue = mme_ue;
100
+        e->mme_ue_id = mme_ue->id;
101
         e->nas_message = &nas_message;
102
 
103
         ogs_fsm_dispatch(&mme_ue->sm, e);
104
@@ -344,7 +353,7 @@
105
         ogs_pkbuf_free(pkbuf);
106
         break;
107
     case MME_EVENT_EMM_TIMER:
108
-        mme_ue = e->mme_ue;
109
+        mme_ue = mme_ue_find_by_id(e->mme_ue_id);
110
         ogs_assert(mme_ue);
111
         ogs_assert(OGS_FSM_STATE(&mme_ue->sm));
112
 
113
@@ -352,7 +361,7 @@
114
         break;
115
 
116
     case MME_EVENT_ESM_MESSAGE:
117
-        mme_ue = e->mme_ue;
118
+        mme_ue = mme_ue_find_by_id(e->mme_ue_id);
119
         ogs_assert(mme_ue);
120
 
121
         pkbuf = e->pkbuf;
122
@@ -438,24 +447,20 @@
123
      */
124
         if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_de_registered)) {
125
             ESM_MESSAGE_CHECK;
126
-            MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
127
             ogs_pkbuf_free(pkbuf);
128
             break;
129
         } else if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_authentication)) {
130
             ESM_MESSAGE_CHECK;
131
-            MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
132
             ogs_pkbuf_free(pkbuf);
133
             break;
134
         } else if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_security_mode)) {
135
             ESM_MESSAGE_CHECK;
136
-            MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
137
             ogs_pkbuf_free(pkbuf);
138
             break;
139
         } else if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_initial_context_setup)) {
140
         } else if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_registered)) {
141
         } else if (OGS_FSM_CHECK(&mme_ue->sm, emm_state_exception)) {
142
             ESM_MESSAGE_CHECK;
143
-            MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
144
             ogs_pkbuf_free(pkbuf);
145
             break;
146
         }
147
@@ -467,12 +472,12 @@
148
             break;
149
         }
150
 
151
-        sess = bearer->sess;
152
+        sess = mme_sess_find_by_id(bearer->sess_id);
153
         ogs_assert(sess);
154
         default_bearer = mme_default_bearer_in_sess(sess);
155
         ogs_assert(default_bearer);
156
 
157
-        e->bearer = bearer;
158
+        e->bearer_id = bearer->id;
159
         e->nas_message = &nas_message;
160
 
161
         ogs_fsm_dispatch(&bearer->sm, e);
162
@@ -508,7 +513,7 @@
163
         break;
164
 
165
     case MME_EVENT_ESM_TIMER:
166
-        bearer = e->bearer;
167
+        bearer = mme_bearer_find_by_id(e->bearer_id);
168
         ogs_assert(bearer);
169
         ogs_assert(OGS_FSM_STATE(&bearer->sm));
170
 
171
@@ -560,13 +565,13 @@
172
          * decide whether to process or
173
          * ignore the Authentication-Information-Answer as shown below.
174
          */
175
-        mme_ue = mme_ue_cycle(e->mme_ue);
176
+        mme_ue = mme_ue_find_by_id(e->mme_ue_id);
177
         if (!mme_ue) {
178
             ogs_error("UE(mme-ue) context has already been removed");
179
             goto cleanup;
180
         }
181
 
182
-        enb_ue = enb_ue_cycle(e->enb_ue);
183
+        enb_ue = enb_ue_find_by_id(e->enb_ue_id);
184
         /*
185
          * The 'enb_ue' context is not checked
186
          * because the status is checked in the sending routine.
187
@@ -616,7 +621,7 @@
188
 
189
                 r = s1ap_send_ue_context_release_command(enb_ue,
190
                         S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
191
-                        mme_ue_cycle(enb_ue->mme_ue) ?
192
+                        mme_ue_find_by_id(enb_ue->mme_ue_id) ?
193
                             S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE :
194
                             S1AP_UE_CTX_REL_S1_CONTEXT_REMOVE, 0);
195
                 ogs_expect(r == OGS_OK);
196
@@ -775,10 +780,16 @@
197
         break;
198
 
199
     case MME_EVENT_S11_TIMER:
200
-        sgw_ue = e->sgw_ue;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/mme-timer.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/mme-timer.c Changed
110
 
1
@@ -63,11 +63,6 @@
2
         { .have = true, .duration = ogs_time_from_sec(20) },
3
 };
4
 
5
-static void emm_timer_event_send(
6
-        mme_timer_e timer_id, mme_ue_t *mme_ue);
7
-static void esm_timer_event_send(
8
-        mme_timer_e timer_id, mme_bearer_t *bearer);
9
-
10
 mme_timer_cfg_t *mme_timer_cfg(mme_timer_e id)
11
 {
12
     ogs_assert(id < MAX_NUM_OF_MME_TIMER);
13
@@ -129,16 +124,16 @@
14
 }
15
 
16
 
17
-static void emm_timer_event_send(
18
-        mme_timer_e timer_id, mme_ue_t *mme_ue)
19
+static void emm_timer_event_send(mme_timer_e timer_id, void *data)
20
 {
21
     int rv;
22
     mme_event_t *e = NULL;
23
-    ogs_assert(mme_ue);
24
+
25
+    ogs_assert(data);
26
 
27
     e = mme_event_new(MME_EVENT_EMM_TIMER);
28
     e->timer_id = timer_id;
29
-    e->mme_ue = mme_ue;
30
+    e->mme_ue_id = OGS_POINTER_TO_UINT(data);
31
 
32
     rv = ogs_queue_push(ogs_app()->queue, e);
33
     if (rv != OGS_OK) {
34
@@ -176,20 +171,16 @@
35
     emm_timer_event_send(MME_TIMER_IMPLICIT_DETACH, data);
36
 }
37
 
38
-static void esm_timer_event_send(
39
-        mme_timer_e timer_id, mme_bearer_t *bearer)
40
+static void esm_timer_event_send(mme_timer_e timer_id, void *data)
41
 {
42
     int rv;
43
     mme_event_t *e = NULL;
44
-    mme_ue_t *mme_ue = NULL;
45
-    ogs_assert(bearer);
46
-    mme_ue = bearer->mme_ue;
47
-    ogs_assert(bearer);
48
+
49
+    ogs_assert(data);
50
 
51
     e = mme_event_new(MME_EVENT_ESM_TIMER);
52
     e->timer_id = timer_id;
53
-    e->mme_ue = mme_ue;
54
-    e->bearer = bearer;
55
+    e->bearer_id = OGS_POINTER_TO_UINT(data);
56
 
57
     rv = ogs_queue_push(ogs_app()->queue, e);
58
     if (rv != OGS_OK) {
59
@@ -224,15 +215,13 @@
60
 {
61
     int rv;
62
     mme_event_t *e = NULL;
63
-    enb_ue_t *enb_ue = NULL;
64
 
65
     ogs_assert(data);
66
-    enb_ue = data;
67
 
68
     e = mme_event_new(MME_EVENT_S1AP_TIMER);
69
 
70
     e->timer_id = MME_TIMER_S1_HOLDING;
71
-    e->enb_ue = enb_ue;
72
+    e->enb_ue_id = OGS_POINTER_TO_UINT(data);
73
 
74
     rv = ogs_queue_push(ogs_app()->queue, e);
75
     if (rv != OGS_OK) {
76
@@ -245,15 +234,13 @@
77
 {
78
     int rv;
79
     mme_event_t *e = NULL;
80
-    sgw_ue_t *sgw_ue = NULL;
81
 
82
     ogs_assert(data);
83
-    sgw_ue = data;
84
 
85
     e = mme_event_new(MME_EVENT_S11_TIMER);
86
 
87
     e->timer_id = MME_TIMER_S11_HOLDING;
88
-    e->sgw_ue = sgw_ue;
89
+    e->sgw_ue_id = OGS_POINTER_TO_UINT(data);
90
 
91
     rv = ogs_queue_push(ogs_app()->queue, e);
92
     if (rv != OGS_OK) {
93
@@ -266,15 +253,13 @@
94
 {
95
     int rv;
96
     mme_event_t *e = NULL;
97
-    mme_ue_t *mme_ue;
98
 
99
     ogs_assert(data);
100
-    mme_ue = data;
101
 
102
     e = mme_event_new(MME_EVENT_GN_TIMER);
103
 
104
     e->timer_id = MME_TIMER_GN_HOLDING;
105
-    e->mme_ue = mme_ue;
106
+    e->mme_ue_id = OGS_POINTER_TO_UINT(data);
107
 
108
     rv = ogs_queue_push(ogs_app()->queue, e);
109
     if (rv != OGS_OK) {
110
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/nas-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/nas-path.c Changed
201
 
1
@@ -29,16 +29,24 @@
2
 int nas_eps_send_to_enb(mme_ue_t *mme_ue, ogs_pkbuf_t *pkbuf)
3
 {
4
     int rv;
5
+    enb_ue_t *enb_ue = NULL;
6
 
7
     ogs_assert(pkbuf);
8
 
9
-    if (!mme_ue_cycle(mme_ue)) {
10
+    if (!mme_ue) {
11
         ogs_error("UE(mme-ue) context has already been removed");
12
         ogs_pkbuf_free(pkbuf);
13
         return OGS_NOTFOUND;
14
     }
15
 
16
-    rv = s1ap_send_to_enb_ue(mme_ue->enb_ue, pkbuf);
17
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
18
+    if (!enb_ue) {
19
+        ogs_error("S1 context has already been removed");
20
+        ogs_pkbuf_free(pkbuf);
21
+        return OGS_NOTFOUND;
22
+    }
23
+
24
+    rv = s1ap_send_to_enb_ue(enb_ue, pkbuf);
25
     ogs_expect(rv == OGS_OK);
26
 
27
     return rv;
28
@@ -56,7 +64,7 @@
29
         return OGS_ERROR;
30
     }
31
 
32
-    if (!mme_ue_cycle(mme_ue)) {
33
+    if (!mme_ue) {
34
         ogs_error("UE(mme-ue) context has already been removed");
35
         return OGS_NOTFOUND;
36
     }
37
@@ -84,7 +92,7 @@
38
 
39
     ogs_assert(pkbuf);
40
 
41
-    if (!enb_ue_cycle(enb_ue)) {
42
+    if (!enb_ue) {
43
         ogs_error("S1 context has already been removed");
44
         ogs_pkbuf_free(pkbuf);
45
         return OGS_NOTFOUND;
46
@@ -105,16 +113,18 @@
47
 int nas_eps_send_attach_accept(mme_ue_t *mme_ue)
48
 {
49
     int rv;
50
+    enb_ue_t *enb_ue = NULL;
51
     mme_sess_t *sess = NULL;
52
     ogs_pkbuf_t *s1apbuf = NULL;
53
     ogs_pkbuf_t *esmbuf = NULL, *emmbuf = NULL;
54
 
55
-    if (!mme_ue_cycle(mme_ue)) {
56
+    if (!mme_ue) {
57
         ogs_error("UE(mme-ue) context has already been removed");
58
         return OGS_NOTFOUND;
59
     }
60
 
61
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
62
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
63
+    if (!enb_ue) {
64
         ogs_error("S1 context has already been removed");
65
         return OGS_NOTFOUND;
66
     }
67
@@ -184,12 +194,12 @@
68
     mme_sess_t *sess = NULL;
69
     ogs_pkbuf_t *esmbuf = NULL, *emmbuf = NULL;
70
 
71
-    if (!mme_ue_cycle(mme_ue)) {
72
+    if (!mme_ue) {
73
         ogs_error("UE(mme-ue) context has already been removed");
74
         return OGS_NOTFOUND;
75
     }
76
 
77
-    if (!enb_ue_cycle(enb_ue)) {
78
+    if (!enb_ue) {
79
         ogs_error("S1 context has already been removed");
80
         return OGS_NOTFOUND;
81
     }
82
@@ -221,14 +231,16 @@
83
 int nas_eps_send_identity_request(mme_ue_t *mme_ue)
84
 {
85
     int rv;
86
+    enb_ue_t *enb_ue = NULL;
87
     ogs_pkbuf_t *emmbuf = NULL;
88
 
89
-    if (!mme_ue_cycle(mme_ue)) {
90
+    if (!mme_ue) {
91
         ogs_error("UE(mme-ue) context has already been removed");
92
         return OGS_NOTFOUND;
93
     }
94
 
95
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
96
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
97
+    if (!enb_ue) {
98
         ogs_error("S1 context has already been removed");
99
         return OGS_NOTFOUND;
100
     }
101
@@ -254,7 +266,7 @@
102
     ogs_timer_start(mme_ue->t3470.timer, 
103
             mme_timer_cfg(MME_TIMER_T3470)->duration);
104
 
105
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
106
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
107
     ogs_expect(rv == OGS_OK);
108
 
109
     return rv;
110
@@ -263,14 +275,16 @@
111
 int nas_eps_send_authentication_request(mme_ue_t *mme_ue)
112
 {
113
     int rv;
114
+    enb_ue_t *enb_ue = NULL;
115
     ogs_pkbuf_t *emmbuf = NULL;
116
 
117
-    if (!mme_ue_cycle(mme_ue)) {
118
+    if (!mme_ue) {
119
         ogs_error("UE(mme-ue) context has already been removed");
120
         return OGS_NOTFOUND;
121
     }
122
 
123
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
124
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
125
+    if (!enb_ue) {
126
         ogs_error("S1 context has already been removed");
127
         return OGS_NOTFOUND;
128
     }
129
@@ -296,7 +310,7 @@
130
     ogs_timer_start(mme_ue->t3460.timer, 
131
             mme_timer_cfg(MME_TIMER_T3460)->duration);
132
 
133
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
134
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
135
     ogs_expect(rv == OGS_OK);
136
 
137
     return rv;
138
@@ -305,14 +319,16 @@
139
 int nas_eps_send_security_mode_command(mme_ue_t *mme_ue)
140
 {
141
     int rv;
142
+    enb_ue_t *enb_ue = NULL;
143
     ogs_pkbuf_t *emmbuf = NULL;
144
 
145
-    if (!mme_ue_cycle(mme_ue)) {
146
+    if (!mme_ue) {
147
         ogs_error("UE(mme-ue) context has already been removed");
148
         return OGS_NOTFOUND;
149
     }
150
 
151
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
152
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
153
+    if (!enb_ue) {
154
         ogs_error("S1 context has already been removed");
155
         return OGS_NOTFOUND;
156
     }
157
@@ -338,7 +354,7 @@
158
     ogs_timer_start(mme_ue->t3460.timer, 
159
             mme_timer_cfg(MME_TIMER_T3460)->duration);
160
 
161
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
162
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
163
     ogs_expect(rv == OGS_OK);
164
 
165
     return rv;
166
@@ -347,14 +363,16 @@
167
 int nas_eps_send_authentication_reject(mme_ue_t *mme_ue)
168
 {
169
     int rv;
170
+    enb_ue_t *enb_ue = NULL;
171
     ogs_pkbuf_t *emmbuf = NULL;
172
 
173
-    if (!mme_ue_cycle(mme_ue)) {
174
+    if (!mme_ue) {
175
         ogs_error("UE(mme-ue) context has already been removed");
176
         return OGS_NOTFOUND;
177
     }
178
 
179
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
180
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
181
+    if (!enb_ue) {
182
         ogs_error("S1 context has already been removed");
183
         return OGS_NOTFOUND;
184
     }
185
@@ -367,7 +385,7 @@
186
         return OGS_ERROR;
187
     }
188
 
189
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
190
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
191
     ogs_expect(rv == OGS_OK);
192
 
193
     return rv;
194
@@ -376,14 +394,16 @@
195
 int nas_eps_send_detach_request(mme_ue_t *mme_ue)
196
 {
197
     int rv;
198
+    enb_ue_t *enb_ue = NULL;
199
     ogs_pkbuf_t *emmbuf = NULL;
200
 
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/s1ap-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/s1ap-build.c Changed
159
 
1
@@ -283,7 +283,6 @@
2
     S1AP_NAS_PDU_t *NAS_PDU = NULL;
3
 
4
     ogs_assert(emmbuf);
5
-    enb_ue = enb_ue_cycle(enb_ue);
6
     ogs_assert(enb_ue);
7
 
8
     ogs_debug("DownlinkNASTransport");
9
@@ -427,9 +426,8 @@
10
     mme_sess_t *sess = NULL;
11
     mme_bearer_t *bearer = NULL;
12
 
13
-    mme_ue = mme_ue_cycle(mme_ue);
14
     ogs_assert(mme_ue);
15
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
16
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
17
     ogs_assert(enb_ue);
18
 
19
     ogs_debug("InitialContextSetupRequest");
20
@@ -621,7 +619,6 @@
21
     }
22
 
23
     if (!E_RABToBeSetupListCtxtSUReq->list.count) {
24
-        MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
25
         ogs_list_for_each(&mme_ue->sess_list, sess) {
26
             ogs_error("    APN%s",
27
                     sess->session ? sess->session->name : "Unknown");
28
@@ -847,9 +844,8 @@
29
 
30
     enb_ue_t *enb_ue = NULL;
31
 
32
-    mme_ue = mme_ue_cycle(mme_ue);
33
     ogs_assert(mme_ue);
34
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
35
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
36
     ogs_assert(enb_ue);
37
 
38
     ogs_debug("UEContextModificationRequest");
39
@@ -983,7 +979,6 @@
40
     S1AP_UE_S1AP_IDs_t *UE_S1AP_IDs = NULL;
41
     S1AP_Cause_t *Cause = NULL;
42
 
43
-    enb_ue = enb_ue_cycle(enb_ue);
44
     ogs_assert(enb_ue);
45
 
46
     if (enb_ue->mme_ue_s1ap_id == 0) {
47
@@ -1069,9 +1064,9 @@
48
     ogs_assert(esmbuf);
49
     ogs_assert(bearer);
50
 
51
-    mme_ue = mme_ue_cycle(bearer->mme_ue);
52
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
53
     ogs_assert(mme_ue);
54
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
55
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
56
     ogs_assert(enb_ue);
57
 
58
     ogs_debug("E-RABSetupRequest");
59
@@ -1202,9 +1197,9 @@
60
     ogs_assert(esmbuf);
61
     ogs_assert(bearer);
62
 
63
-    mme_ue = mme_ue_cycle(bearer->mme_ue);
64
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
65
     ogs_assert(mme_ue);
66
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
67
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
68
     ogs_assert(enb_ue);
69
 
70
     ogs_debug("E-RABModifyRequest");
71
@@ -1330,9 +1325,9 @@
72
     ogs_assert(esmbuf);
73
     ogs_assert(bearer);
74
 
75
-    mme_ue = mme_ue_cycle(bearer->mme_ue);
76
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
77
     ogs_assert(mme_ue);
78
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
79
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
80
     ogs_assert(enb_ue);
81
 
82
     ogs_debug("E-RABReleaseCommand");
83
@@ -1451,9 +1446,8 @@
84
     mme_sess_t *sess = NULL;
85
     mme_bearer_t *bearer = NULL;
86
 
87
-    mme_ue = mme_ue_cycle(mme_ue);
88
     ogs_assert(mme_ue);
89
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
90
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
91
     ogs_assert(enb_ue);
92
 
93
     ogs_debug("E-RABModificationConfirm");
94
@@ -1553,7 +1547,6 @@
95
     uint64_t ue_imsi_value = 0;
96
     int i = 0;
97
 
98
-    mme_ue = mme_ue_cycle(mme_ue);
99
     ogs_assert(mme_ue);
100
 
101
     ogs_debug("Paging");
102
@@ -1776,9 +1769,8 @@
103
     mme_bearer_t *bearer = NULL;
104
     enb_ue_t *enb_ue = NULL;
105
 
106
-    mme_ue = mme_ue_cycle(mme_ue);
107
     ogs_assert(mme_ue);
108
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
109
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
110
     ogs_assert(enb_ue);
111
 
112
     ogs_debug("PathSwitchAcknowledge");
113
@@ -1973,9 +1965,8 @@
114
     mme_sess_t *sess = NULL;
115
     mme_bearer_t *bearer = NULL;
116
 
117
-    source_ue = enb_ue_cycle(source_ue);
118
     ogs_assert(source_ue);
119
-    mme_ue = mme_ue_cycle(source_ue->mme_ue);
120
+    mme_ue = mme_ue_find_by_id(source_ue->mme_ue_id);
121
     ogs_assert(mme_ue);
122
 
123
     ogs_debug("HandoverCommand");
124
@@ -2132,7 +2123,6 @@
125
     S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
126
     S1AP_Cause_t *Cause = NULL;
127
 
128
-    source_ue = enb_ue_cycle(source_ue);
129
     ogs_assert(source_ue);
130
     ogs_assert(group);
131
 
132
@@ -2225,9 +2215,8 @@
133
     ogs_assert(cause);
134
     ogs_assert(source_totarget_transparentContainer);
135
 
136
-    target_ue = enb_ue_cycle(target_ue);
137
     ogs_assert(target_ue);
138
-    mme_ue = mme_ue_cycle(target_ue->mme_ue);
139
+    mme_ue = mme_ue_find_by_id(target_ue->mme_ue_id);
140
     ogs_assert(mme_ue);
141
 
142
     ogs_debug("HandoverRequest");
143
@@ -2460,7 +2449,6 @@
144
     S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
145
     S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
146
 
147
-    source_ue = enb_ue_cycle(source_ue);
148
     ogs_assert(source_ue);
149
 
150
     ogs_debug("HandoverCancelAcknowledge");
151
@@ -2524,7 +2512,6 @@
152
     S1AP_ENB_StatusTransfer_TransparentContainer_t
153
         *ENB_StatusTransfer_TransparentContainer = NULL;
154
 
155
-    target_ue = enb_ue_cycle(target_ue);
156
     ogs_assert(target_ue);
157
     ogs_assert(enb_statustransfer_transparentContainer);
158
 
159
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/s1ap-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/s1ap-handler.c Changed
201
 
1
@@ -505,7 +505,6 @@
2
                 ogs_info("Unknown UE by S_TMSIG:%d,C:%d,M_TMSI:0x%x",
3
                         nas_guti.mme_gid, nas_guti.mme_code, nas_guti.m_tmsi);
4
             } else {
5
-                MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
6
                 ogs_info("    S_TMSIG:%d,C:%d,M_TMSI:0x%x IMSI:%s",
7
                         mme_ue->current.guti.mme_gid,
8
                         mme_ue->current.guti.mme_code,
9
@@ -542,16 +541,15 @@
10
             }
11
         }
12
     } else {
13
+        mme_ue_t *mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
14
         ogs_error("Known UE ENB_UE_S1AP_ID%d %p:%p",
15
-                (int)*ENB_UE_S1AP_ID, enb_ue, enb_ue->mme_ue);
16
-        if (enb_ue->mme_ue) {
17
-            MME_UE_CHECK(OGS_LOG_DEBUG, enb_ue->mme_ue);
18
+                (int)*ENB_UE_S1AP_ID, enb_ue, mme_ue);
19
+        if (mme_ue) {
20
             ogs_error("    S_TMSIG:%d,C:%d,M_TMSI:0x%x IMSI:%s",
21
-                enb_ue->mme_ue->current.guti.mme_gid,
22
-                enb_ue->mme_ue->current.guti.mme_code,
23
-                enb_ue->mme_ue->current.guti.m_tmsi,
24
-                MME_UE_HAVE_IMSI(enb_ue->mme_ue)
25
-                ? enb_ue->mme_ue->imsi_bcd : "Unknown");
26
+                mme_ue->current.guti.mme_gid,
27
+                mme_ue->current.guti.mme_code,
28
+                mme_ue->current.guti.m_tmsi,
29
+                MME_UE_HAVE_IMSI(mme_ue) ? mme_ue->imsi_bcd : "Unknown");
30
         }
31
     }
32
 
33
@@ -631,6 +629,7 @@
34
     S1AP_CellIdentity_t *cell_ID = NULL;
35
 
36
     enb_ue_t *enb_ue = NULL;
37
+    mme_ue_t *mme_ue = NULL;
38
 
39
     ogs_eps_tai_t tai;
40
     int served_tai_index = 0;
41
@@ -784,10 +783,8 @@
42
         enb_ue->saved.tai.tac, enb_ue->saved.e_cgi.cell_id);
43
 
44
     /* Copy Stream-No/TAI/ECGI from enb_ue */
45
-    if (enb_ue->mme_ue) {
46
-        mme_ue_t *mme_ue = enb_ue->mme_ue;
47
-
48
-        MME_UE_CHECK(OGS_LOG_DEBUG, enb_ue->mme_ue);
49
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
50
+    if (mme_ue) {
51
         memcpy(&mme_ue->tai, &enb_ue->saved.tai, sizeof(ogs_eps_tai_t));
52
         memcpy(&mme_ue->e_cgi, &enb_ue->saved.e_cgi, sizeof(ogs_e_cgi_t));
53
         mme_ue->ue_location_timestamp = ogs_time_now();
54
@@ -814,6 +811,7 @@
55
     S1AP_UERadioCapability_t *UERadioCapability = NULL;
56
 
57
     enb_ue_t *enb_ue = NULL;
58
+    mme_ue_t *mme_ue = NULL;
59
 
60
     ogs_assert(enb);
61
     ogs_assert(enb->sctp.sock);
62
@@ -889,11 +887,10 @@
63
     ogs_debug("    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
64
             enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
65
 
66
-    if (enb_ue->mme_ue) {
67
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
68
+    if (mme_ue) {
69
         ogs_assert(UERadioCapability);
70
-        MME_UE_CHECK(OGS_LOG_DEBUG, enb_ue->mme_ue);
71
-        OGS_ASN_STORE_DATA(&enb_ue->mme_ue->ueRadioCapability,
72
-                UERadioCapability);
73
+        OGS_ASN_STORE_DATA(&mme_ue->ueRadioCapability, UERadioCapability);
74
     }
75
 }
76
 
77
@@ -989,13 +986,12 @@
78
     ogs_debug("    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
79
             enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
80
 
81
-    mme_ue = enb_ue->mme_ue;
82
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
83
     if (!mme_ue) {
84
         ogs_error("No UE(mme-ue) context");
85
         return;
86
     }
87
 
88
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
89
     if (E_RABSetupListCtxtSURes) {
90
         int uli_presence = 0;
91
 
92
@@ -1188,7 +1184,7 @@
93
     ogs_debug("    CauseGroup:%d Cause:%d",
94
             Cause->present, (int)Cause->choice.radioNetwork);
95
 
96
-    mme_ue = enb_ue->mme_ue;
97
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
98
 
99
     if (mme_ue) {
100
         /*
101
@@ -1300,7 +1296,7 @@
102
     ogs_debug("    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
103
             enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
104
 
105
-    mme_ue = enb_ue->mme_ue;
106
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
107
     if (!mme_ue) {
108
         ogs_error("No UE(mme-ue) context");
109
         return;
110
@@ -1412,7 +1408,7 @@
111
     ogs_debug("    CauseGroup:%d Cause:%d",
112
             Cause->present, (int)Cause->choice.radioNetwork);
113
 
114
-    mme_ue = enb_ue->mme_ue;
115
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
116
     if (!mme_ue) {
117
         ogs_error("No UE(mme-ue) context");
118
         return;
119
@@ -1522,7 +1518,7 @@
120
     ogs_debug("    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
121
         enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
122
 
123
-    mme_ue = enb_ue->mme_ue;
124
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
125
     if (!mme_ue) {
126
         ogs_error("No UE(mme-ue) context");
127
         return;
128
@@ -1857,9 +1853,7 @@
129
     int r;
130
     mme_ue_t *mme_ue = NULL;
131
 
132
-    ogs_assert(enb_ue);
133
-
134
-    if (enb_ue_cycle(enb_ue) == NULL) {
135
+    if (!enb_ue) {
136
         ogs_error("S1 context has already been removed");
137
         return;
138
     }
139
@@ -1868,7 +1862,7 @@
140
     ogs_info("    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
141
             enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
142
 
143
-    mme_ue = mme_ue_cycle(enb_ue->mme_ue);
144
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
145
     if (mme_ue) {
146
         ogs_info("    IMSI%s", mme_ue->imsi_bcd);
147
 
148
@@ -1964,7 +1958,6 @@
149
             return;
150
         }
151
 
152
-        MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
153
         mme_ue_remove(mme_ue);
154
         break;
155
     case S1AP_UE_CTX_REL_S1_HANDOVER_COMPLETE:
156
@@ -2008,11 +2001,12 @@
157
             ogs_warn("  Packet could be dropped during S1-Handover");
158
             mme_ue_clear_indirect_tunnel(mme_ue);
159
 
160
-            if (!mme_ue->enb_ue) {
161
+            enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
162
+            if (!enb_ue) {
163
                 ogs_error("No S1 context");
164
                 return;
165
             }
166
-            r = s1ap_send_handover_cancel_ack(mme_ue->enb_ue);
167
+            r = s1ap_send_handover_cancel_ack(enb_ue);
168
             ogs_expect(r == OGS_OK);
169
             ogs_assert(r != OGS_ERROR);
170
         }
171
@@ -2153,13 +2147,12 @@
172
         return;
173
     }
174
 
175
-    mme_ue = enb_ue->mme_ue;
176
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
177
     if (!mme_ue) {
178
         ogs_error("No UE(mme-ue) context");
179
         return;
180
     }
181
 
182
-    MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
183
     ogs_list_init(&mme_ue->bearer_to_modify_list);
184
 
185
     for (i = 0; i < E_RABToBeModifiedListBearerModInd->list.count; i++) {
186
@@ -2510,7 +2503,7 @@
187
         return;
188
     }
189
 
190
-    mme_ue = mme_ue_cycle(enb_ue->mme_ue);
191
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
192
     if (!mme_ue) {
193
         ogs_error("No UE(mme-ue) context");
194
         return;
195
@@ -2816,7 +2809,7 @@
196
         return;
197
     }
198
 
199
-    mme_ue = source_ue->mme_ue;
200
+    mme_ue = mme_ue_find_by_id(source_ue->mme_ue_id);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/s1ap-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/s1ap-path.c Changed
201
 
1
@@ -52,12 +52,7 @@
2
     char bufOGS_ADDRSTRLEN;
3
 
4
     ogs_assert(pkbuf);
5
-
6
-    if (!mme_enb_cycle(enb)) {
7
-        ogs_error("eNB has already been removed");
8
-        ogs_pkbuf_free(pkbuf);
9
-        return OGS_NOTFOUND;
10
-    }
11
+    ogs_assert(enb);
12
 
13
     ogs_assert(enb->sctp.sock);
14
     if (enb->sctp.sock->fd == INVALID_SOCKET) {
15
@@ -84,15 +79,24 @@
16
 int s1ap_send_to_enb_ue(enb_ue_t *enb_ue, ogs_pkbuf_t *pkbuf)
17
 {
18
     int rv;
19
+    mme_enb_t *enb = NULL;
20
+
21
     ogs_assert(pkbuf);
22
 
23
-    if (!enb_ue_cycle(enb_ue)) {
24
+    if (!enb_ue) {
25
         ogs_error("S1 context has already been removed");
26
         ogs_pkbuf_free(pkbuf);
27
         return OGS_NOTFOUND;
28
     }
29
 
30
-    rv = s1ap_send_to_enb(enb_ue->enb, pkbuf, enb_ue->enb_ostream_id);
31
+    enb = mme_enb_find_by_id(enb_ue->enb_id);
32
+    if (!enb) {
33
+        ogs_error("%d eNB has already been removed", enb_ue->enb_id);
34
+        ogs_pkbuf_free(pkbuf);
35
+        return OGS_NOTFOUND;
36
+    }
37
+
38
+    rv = s1ap_send_to_enb(enb, pkbuf, enb_ue->enb_ostream_id);
39
     ogs_expect(rv == OGS_OK);
40
 
41
     return rv;
42
@@ -113,8 +117,7 @@
43
                 ogs_app()->timer_mgr, mme_timer_s1_delayed_send, e);
44
         ogs_assert(e->timer);
45
         e->pkbuf = pkbuf;
46
-        e->enb_ue = enb_ue;
47
-        e->enb = enb_ue->enb;
48
+        e->enb_ue_id = enb_ue->id;
49
 
50
         ogs_timer_start(e->timer, duration);
51
 
52
@@ -139,7 +142,7 @@
53
 
54
     e = mme_event_new(MME_EVENT_ESM_MESSAGE);
55
     ogs_assert(e);
56
-    e->mme_ue = mme_ue;
57
+    e->mme_ue_id = mme_ue->id;
58
     e->pkbuf = esmbuf;
59
     e->nas_type = nas_type;
60
     e->create_action = create_action;
61
@@ -157,6 +160,9 @@
62
         S1AP_ProcedureCode_t procedureCode, S1AP_NAS_PDU_t *nasPdu)
63
 {
64
     int rv;
65
+
66
+    mme_ue_t *mme_ue = NULL;
67
+
68
     ogs_nas_eps_security_header_t *sh = NULL;
69
     ogs_nas_security_header_type_t security_header_type;
70
 
71
@@ -167,6 +173,8 @@
72
     ogs_assert(enb_ue);
73
     ogs_assert(nasPdu);
74
 
75
+    mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
76
+
77
     /* The Packet Buffer(pkbuf_t) for NAS message MUST make a HEADROOM.
78
      * When calculating AES_CMAC, we need to use the headroom of the packet. */
79
     nasbuf = ogs_pkbuf_alloc(NULL, OGS_NAS_HEADROOM+nasPdu->size);
80
@@ -211,8 +219,8 @@
81
         return OGS_ERROR;
82
     }
83
 
84
-    if (enb_ue->mme_ue) {
85
-        if (nas_eps_security_decode(enb_ue->mme_ue,
86
+    if (mme_ue) {
87
+        if (nas_eps_security_decode(mme_ue,
88
                 security_header_type, nasbuf) != OGS_OK) {
89
             ogs_error("nas_eps_security_decode failed()");
90
             enb_ue_remove(enb_ue);
91
@@ -259,7 +267,7 @@
92
             ogs_pkbuf_free(nasbuf);
93
             return OGS_ERROR;
94
         }
95
-        e->enb_ue = enb_ue;
96
+        e->enb_ue_id = enb_ue->id;
97
         e->s1ap_code = procedureCode;
98
         e->nas_type = security_header_type.type;
99
         e->pkbuf = nasbuf;
100
@@ -272,7 +280,6 @@
101
         return rv;
102
     } else if (h->protocol_discriminator ==
103
             OGS_NAS_PROTOCOL_DISCRIMINATOR_ESM) {
104
-        mme_ue_t *mme_ue = enb_ue->mme_ue;
105
         if (!mme_ue) {
106
             ogs_error("No UE Context");
107
             ogs_pkbuf_free(nasbuf);
108
@@ -299,12 +306,9 @@
109
     int rv;
110
     ogs_pkbuf_t *s1ap_buffer;
111
 
112
-    ogs_debug("S1-Setup response");
113
+    ogs_assert(enb);
114
 
115
-    if (!mme_enb_cycle(enb)) {
116
-        ogs_error("eNB has already been removed");
117
-        return OGS_NOTFOUND;
118
-    }
119
+    ogs_debug("S1-Setup response");
120
 
121
     s1ap_buffer = s1ap_build_setup_rsp();
122
     if (!s1ap_buffer) {
123
@@ -324,12 +328,9 @@
124
     int rv;
125
     ogs_pkbuf_t *s1ap_buffer;
126
 
127
-    ogs_debug("S1-Setup failure");
128
+    ogs_assert(enb);
129
 
130
-    if (!mme_enb_cycle(enb)) {
131
-        ogs_error("eNB has already been removed");
132
-        return OGS_NOTFOUND;
133
-    }
134
+    ogs_debug("S1-Setup failure");
135
 
136
     s1ap_buffer = s1ap_build_setup_failure(group, cause, S1AP_TimeToWait_v10s);
137
     if (!s1ap_buffer) {
138
@@ -348,12 +349,9 @@
139
     int rv;
140
     ogs_pkbuf_t *s1ap_buffer;
141
 
142
-    ogs_debug("ENBConfigurationUpdateAcknowledge");
143
+    ogs_assert(enb);
144
 
145
-    if (!mme_enb_cycle(enb)) {
146
-        ogs_error("eNB has already been removed");
147
-        return OGS_NOTFOUND;
148
-    }
149
+    ogs_debug("ENBConfigurationUpdateAcknowledge");
150
 
151
     s1ap_buffer = s1ap_build_enb_configuration_update_ack();
152
     if (!s1ap_buffer) {
153
@@ -373,12 +371,9 @@
154
     int rv;
155
     ogs_pkbuf_t *s1ap_buffer;
156
 
157
-    ogs_debug("ENBConfigurationUpdateFailure");
158
+    ogs_assert(enb);
159
 
160
-    if (!mme_enb_cycle(enb)) {
161
-        ogs_error("eNB has already been removed");
162
-        return OGS_NOTFOUND;
163
-    }
164
+    ogs_debug("ENBConfigurationUpdateFailure");
165
 
166
     s1ap_buffer = s1ap_build_enb_configuration_update_failure(
167
             group, cause, S1AP_TimeToWait_v10s);
168
@@ -400,12 +395,12 @@
169
 
170
     ogs_debug("InitialContextSetupRequest");
171
 
172
-    if (!mme_ue_cycle(mme_ue)) {
173
+    if (!mme_ue) {
174
         ogs_error("UE(mme-ue) context has already been removed");
175
         return OGS_NOTFOUND;
176
     }
177
 
178
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
179
+    if (!enb_ue_find_by_id(mme_ue->enb_ue_id)) {
180
         ogs_error("S1 context has already been removed");
181
         return OGS_NOTFOUND;
182
     }
183
@@ -429,12 +424,12 @@
184
 
185
     ogs_debug("UEContextModificationRequest");
186
 
187
-    if (!mme_ue_cycle(mme_ue)) {
188
+    if (!mme_ue) {
189
         ogs_error("UE(mme-ue) context has already been removed");
190
         return OGS_NOTFOUND;
191
     }
192
 
193
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
194
+    if (!enb_ue_find_by_id(mme_ue->enb_ue_id)) {
195
         ogs_error("S1 context has already been removed");
196
         return OGS_NOTFOUND;
197
     }
198
@@ -460,7 +455,7 @@
199
 
200
     ogs_debug("UEContextReleaseCommand");
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/s1ap-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/s1ap-sm.c Changed
10
 
1
@@ -59,7 +59,7 @@
2
 
3
     mme_sm_debug(e);
4
 
5
-    enb = e->enb;
6
+    enb = mme_enb_find_by_id(e->enb_id);
7
     ogs_assert(enb);
8
 
9
     switch (e->id) {
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/mme/sgsap-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/mme/sgsap-handler.c Changed
11
 
1
@@ -124,7 +124,8 @@
2
     return;
3
 
4
 error:
5
-    r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
6
+    r = nas_eps_send_attach_reject(
7
+            enb_ue_find_by_id(mme_ue->enb_ue_id), mme_ue,
8
             OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,
9
             OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
10
     ogs_expect(r == OGS_OK);
11
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/nrf/nf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/nrf/nf-sm.c Changed
62
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019,2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -85,6 +85,7 @@
9
     ogs_sbi_nf_instance_t *nf_instance = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_message_t *message = NULL;
14
 
15
     ogs_assert(s);
16
@@ -105,8 +106,16 @@
17
     case OGS_EVENT_SBI_SERVER:
18
         message = e->h.sbi.message;
19
         ogs_assert(message);
20
-        stream = e->h.sbi.data;
21
-        ogs_assert(stream);
22
+
23
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
24
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
25
+                stream_id <= OGS_MAX_POOL_ID);
26
+
27
+        stream = ogs_sbi_stream_find_by_id(stream_id);
28
+        if (!stream) {
29
+            ogs_error("STREAM has already been removed %d", stream_id);
30
+            break;
31
+        }
32
 
33
         SWITCH(message->h.service.name)
34
         CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM)
35
@@ -176,6 +185,7 @@
36
     ogs_sbi_nf_instance_t *nf_instance = NULL;
37
 
38
     ogs_sbi_stream_t *stream = NULL;
39
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
40
     ogs_sbi_message_t *message = NULL;
41
     ogs_sbi_response_t *response = NULL;
42
 
43
@@ -218,8 +228,16 @@
44
     case OGS_EVENT_SBI_SERVER:
45
         message = e->h.sbi.message;
46
         ogs_assert(message);
47
-        stream = e->h.sbi.data;
48
-        ogs_assert(stream);
49
+
50
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
51
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
52
+                stream_id <= OGS_MAX_POOL_ID);
53
+
54
+        stream = ogs_sbi_stream_find_by_id(stream_id);
55
+        if (!stream) {
56
+            ogs_error("STREAM has already been removed %d", stream_id);
57
+            break;
58
+        }
59
 
60
         SWITCH(message->h.service.name)
61
         CASE(OGS_SBI_SERVICE_NAME_NNRF_NFM)
62
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/nrf/nrf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/nrf/nrf-sm.c Changed
34
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -40,6 +40,7 @@
9
 {
10
     int rv;
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -63,8 +64,15 @@
17
     case OGS_EVENT_SBI_SERVER:
18
         request = e->h.sbi.request;
19
         ogs_assert(request);
20
-        stream = e->h.sbi.data;
21
-        ogs_assert(stream);
22
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
23
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
24
+                stream_id <= OGS_MAX_POOL_ID);
25
+
26
+        stream = ogs_sbi_stream_find_by_id(stream_id);
27
+        if (!stream) {
28
+            ogs_error("STREAM has already been removed %d", stream_id);
29
+            break;
30
+        }
31
 
32
         rv = ogs_sbi_parse_request(&message, request);
33
         if (rv != OGS_OK) {
34
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/nssf/nssf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/nssf/nssf-sm.c Changed
35
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -43,6 +43,7 @@
9
     const char *api_version = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -64,8 +65,16 @@
17
     case OGS_EVENT_SBI_SERVER:
18
         request = e->h.sbi.request;
19
         ogs_assert(request);
20
-        stream = e->h.sbi.data;
21
-        ogs_assert(stream);
22
+
23
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
24
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
25
+                stream_id <= OGS_MAX_POOL_ID);
26
+
27
+        stream = ogs_sbi_stream_find_by_id(stream_id);
28
+        if (!stream) {
29
+            ogs_error("STREAM has already been removed %d", stream_id);
30
+            break;
31
+        }
32
 
33
         rv = ogs_sbi_parse_request(&message, request);
34
         if (rv != OGS_OK) {
35
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/am-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/am-sm.c Changed
81
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -40,6 +40,7 @@
9
     pcf_ue_t *pcf_ue = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id;
13
     ogs_sbi_message_t *message = NULL;
14
 
15
     ogs_assert(s);
16
@@ -47,7 +48,7 @@
17
 
18
     pcf_sm_debug(e);
19
 
20
-    pcf_ue = e->pcf_ue;
21
+    pcf_ue = pcf_ue_find_by_id(e->pcf_ue_id);
22
     ogs_assert(pcf_ue);
23
 
24
     switch (e->h.id) {
25
@@ -60,8 +61,16 @@
26
     case OGS_EVENT_SBI_SERVER:
27
         message = e->h.sbi.message;
28
         ogs_assert(message);
29
-        stream = e->h.sbi.data;
30
-        ogs_assert(stream);
31
+
32
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
33
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
34
+                stream_id <= OGS_MAX_POOL_ID);
35
+
36
+        stream = ogs_sbi_stream_find_by_id(stream_id);
37
+        if (!stream) {
38
+            ogs_error("STREAM has already been removed %d", stream_id);
39
+            break;
40
+        }
41
 
42
         SWITCH(message->h.method)
43
         CASE(OGS_SBI_HTTP_METHOD_POST)
44
@@ -91,8 +100,16 @@
45
     case OGS_EVENT_SBI_CLIENT:
46
         message = e->h.sbi.message;
47
         ogs_assert(message);
48
-        stream = e->h.sbi.data;
49
-        ogs_assert(stream);
50
+
51
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
52
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
53
+                stream_id <= OGS_MAX_POOL_ID);
54
+
55
+        stream = ogs_sbi_stream_find_by_id(stream_id);
56
+        if (!stream) {
57
+            ogs_error("STREAM has already been removed %d", stream_id);
58
+            break;
59
+        }
60
 
61
         SWITCH(message->h.service.name)
62
         CASE(OGS_SBI_SERVICE_NAME_NUDR_DR)
63
@@ -160,7 +177,7 @@
64
 
65
     pcf_sm_debug(e);
66
 
67
-    pcf_ue = e->pcf_ue;
68
+    pcf_ue = pcf_ue_find_by_id(e->pcf_ue_id);
69
     ogs_assert(pcf_ue);
70
 
71
     switch (e->h.id) {
72
@@ -184,7 +201,7 @@
73
 
74
     pcf_sm_debug(e);
75
 
76
-    pcf_ue = e->pcf_ue;
77
+    pcf_ue = pcf_ue_find_by_id(e->pcf_ue_id);
78
     ogs_assert(pcf_ue);
79
 
80
     switch (e->h.id) {
81
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/context.c Changed
115
 
1
@@ -331,9 +331,8 @@
2
 
3
     ogs_assert(supi);
4
 
5
-    ogs_pool_alloc(&pcf_ue_pool, &pcf_ue);
6
+    ogs_pool_id_calloc(&pcf_ue_pool, &pcf_ue);
7
     ogs_assert(pcf_ue);
8
-    memset(pcf_ue, 0, sizeof *pcf_ue);
9
 
10
     /* SBI Type */
11
     pcf_ue->sbi.type = OGS_SBI_OBJ_UE_TYPE;
12
@@ -351,7 +350,7 @@
13
     ogs_hash_set(self.supi_hash, pcf_ue->supi, strlen(pcf_ue->supi), pcf_ue);
14
 
15
     memset(&e, 0, sizeof(e));
16
-    e.pcf_ue = pcf_ue;
17
+    e.pcf_ue_id = pcf_ue->id;
18
     ogs_fsm_init(&pcf_ue->sm, pcf_am_state_initial, pcf_am_state_final, &e);
19
 
20
     ogs_list_add(&self.pcf_ue_list, pcf_ue);
21
@@ -368,7 +367,7 @@
22
     ogs_list_remove(&self.pcf_ue_list, pcf_ue);
23
 
24
     memset(&e, 0, sizeof(e));
25
-    e.pcf_ue = pcf_ue;
26
+    e.pcf_ue_id = pcf_ue->id;
27
     ogs_fsm_fini(&pcf_ue->sm, &e);
28
 
29
     /* Free SBI object memory */
30
@@ -400,7 +399,7 @@
31
     if (pcf_ue->pei)
32
         ogs_free(pcf_ue->pei);
33
 
34
-    ogs_pool_free(&pcf_ue_pool, pcf_ue);
35
+    ogs_pool_id_free(&pcf_ue_pool, pcf_ue);
36
 }
37
 
38
 void pcf_ue_remove_all(void)
39
@@ -431,9 +430,8 @@
40
     ogs_assert(pcf_ue);
41
     ogs_assert(psi != OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED);
42
 
43
-    ogs_pool_alloc(&pcf_sess_pool, &sess);
44
+    ogs_pool_id_calloc(&pcf_sess_pool, &sess);
45
     ogs_assert(sess);
46
-    memset(sess, 0, sizeof *sess);
47
 
48
     ogs_list_init(&sess->app_list);
49
 
50
@@ -456,14 +454,14 @@
51
             (int)ogs_pool_index(&pcf_sess_pool, sess));
52
     ogs_assert(sess->sm_policy_id);
53
 
54
-    sess->pcf_ue = pcf_ue;
55
+    sess->pcf_ue_id = pcf_ue->id;
56
     sess->psi = psi;
57
 
58
     sess->s_nssai.sst = 0;
59
     sess->s_nssai.sd.v = OGS_S_NSSAI_NO_SD_VALUE;
60
 
61
     memset(&e, 0, sizeof(e));
62
-    e.sess = sess;
63
+    e.sess_id = sess->id;
64
     ogs_fsm_init(&sess->sm, pcf_sm_state_initial, pcf_sm_state_final, &e);
65
 
66
     ogs_list_add(&pcf_ue->sess_list, sess);
67
@@ -474,14 +472,16 @@
68
 void pcf_sess_remove(pcf_sess_t *sess)
69
 {
70
     pcf_event_t e;
71
+    pcf_ue_t *pcf_ue = NULL;
72
 
73
     ogs_assert(sess);
74
-    ogs_assert(sess->pcf_ue);
75
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
76
+    ogs_assert(pcf_ue);
77
 
78
-    ogs_list_remove(&sess->pcf_ue->sess_list, sess);
79
+    ogs_list_remove(&pcf_ue->sess_list, sess);
80
 
81
     memset(&e, 0, sizeof(e));
82
-    e.sess = sess;
83
+    e.sess_id = sess->id;
84
     ogs_fsm_fini(&sess->sm, &e);
85
 
86
     /* Free SBI object memory */
87
@@ -520,7 +520,7 @@
88
     if (sess->subscribed_default_qos)
89
         OpenAPI_subscribed_default_qos_free(sess->subscribed_default_qos);
90
 
91
-    ogs_pool_free(&pcf_sess_pool, sess);
92
+    ogs_pool_id_free(&pcf_sess_pool, sess);
93
 }
94
 
95
 void pcf_sess_remove_all(pcf_ue_t *pcf_ue)
96
@@ -710,14 +710,14 @@
97
             &ipv6prefix, (ipv6prefix.len >> 3) + 1);
98
 }
99
 
100
-pcf_ue_t *pcf_ue_cycle(pcf_ue_t *pcf_ue)
101
+pcf_ue_t *pcf_ue_find_by_id(ogs_pool_id_t id)
102
 {
103
-    return ogs_pool_cycle(&pcf_ue_pool, pcf_ue);
104
+    return ogs_pool_find_by_id(&pcf_ue_pool, id);
105
 }
106
 
107
-pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess)
108
+pcf_sess_t *pcf_sess_find_by_id(ogs_pool_id_t id)
109
 {
110
-    return ogs_pool_cycle(&pcf_sess_pool, sess);
111
+    return ogs_pool_find_by_id(&pcf_sess_pool, id);
112
 }
113
 
114
 pcf_app_t *pcf_app_add(pcf_sess_t *sess)
115
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/context.h Changed
37
 
1
@@ -47,6 +47,7 @@
2
 
3
 struct pcf_ue_s {
4
     ogs_sbi_object_t sbi;
5
+    ogs_pool_id_t id;
6
     ogs_fsm_t sm;
7
 
8
     char *association_id;
9
@@ -75,6 +76,7 @@
10
 
11
 struct pcf_sess_s {
12
     ogs_sbi_object_t sbi;
13
+    ogs_pool_id_t id;
14
     ogs_fsm_t sm;
15
 
16
     char *sm_policy_id;
17
@@ -154,7 +156,7 @@
18
     ogs_list_t app_list;
19
 
20
     /* Related Context */
21
-    pcf_ue_t *pcf_ue;
22
+    ogs_pool_id_t pcf_ue_id;
23
 };
24
 
25
 typedef struct pcf_app_s {
26
@@ -202,8 +204,8 @@
27
 int pcf_sessions_number_by_snssai_and_dnn(
28
         pcf_ue_t *pcf_ue, ogs_s_nssai_t *s_nssai, char *dnn);
29
 
30
-pcf_ue_t *pcf_ue_cycle(pcf_ue_t *pcf_ue);
31
-pcf_sess_t *pcf_sess_cycle(pcf_sess_t *sess);
32
+pcf_ue_t *pcf_ue_find_by_id(ogs_pool_id_t id);
33
+pcf_sess_t *pcf_sess_find_by_id(ogs_pool_id_t id);
34
 
35
 pcf_app_t *pcf_app_add(pcf_sess_t *sess);
36
 int pcf_app_remove(pcf_app_t *app);
37
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/event.h Changed
12
 
1
@@ -33,8 +33,8 @@
2
 typedef struct pcf_event_s {
3
     ogs_event_t h;
4
 
5
-    pcf_ue_t *pcf_ue;
6
-    pcf_sess_t *sess;
7
+    ogs_pool_id_t pcf_ue_id;
8
+    ogs_pool_id_t sess_id;
9
     pcf_app_t *app;
10
 } pcf_event_t;
11
 
12
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/nbsf-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/nbsf-build.c Changed
19
 
1
@@ -38,7 +38,7 @@
2
     int i;
3
 
4
     ogs_assert(sess);
5
-    pcf_ue = sess->pcf_ue;
6
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
7
     ogs_assert(pcf_ue);
8
 
9
     nf_instance = data;
10
@@ -187,7 +187,7 @@
11
     ogs_sbi_request_t *request = NULL;
12
 
13
     ogs_assert(sess);
14
-    pcf_ue = sess->pcf_ue;
15
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
16
     ogs_assert(pcf_ue);
17
     ogs_assert(sess->binding.resource_uri);
18
 
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/nbsf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/nbsf-handler.c Changed
19
 
1
@@ -70,7 +70,7 @@
2
     ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
3
 
4
     ogs_assert(sess);
5
-    pcf_ue = sess->pcf_ue;
6
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
7
     ogs_assert(pcf_ue);
8
     ogs_assert(stream);
9
     server = ogs_sbi_server_from_stream(stream);
10
@@ -423,7 +423,7 @@
11
     if (SmPolicyDecision.supp_feat)
12
         ogs_free(SmPolicyDecision.supp_feat);
13
 
14
-    pcf_metrics_inst_by_slice_add(&sess->pcf_ue->guami.plmn_id,
15
+    pcf_metrics_inst_by_slice_add(&pcf_ue->guami.plmn_id,
16
             &sess->s_nssai, PCF_METR_CTR_PA_POLICYSMASSOSUCC, 1);
17
 
18
     OGS_SESSION_DATA_FREE(&session_data);
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/nnrf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/nnrf-handler.c Changed
42
 
1
@@ -26,6 +26,7 @@
2
     int r;
3
     ogs_sbi_nf_instance_t *nf_instance = NULL;
4
     ogs_sbi_object_t *sbi_object = NULL;
5
+    ogs_pool_id_t sbi_object_id = OGS_INVALID_POOL_ID;
6
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
7
     ogs_sbi_discovery_option_t *discovery_option = NULL;
8
     ogs_sbi_stream_t *stream = NULL;
9
@@ -48,8 +49,15 @@
10
     requester_nf_type = xact->requester_nf_type;
11
     ogs_assert(requester_nf_type);
12
 
13
+    sbi_object_id = xact->sbi_object_id;
14
+    ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
15
+            sbi_object_id <= OGS_MAX_POOL_ID);
16
+
17
     discovery_option = xact->discovery_option;
18
-    stream = xact->assoc_stream;
19
+
20
+    if (xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
21
+        xact->assoc_stream_id <= OGS_MAX_POOL_ID)
22
+        stream = ogs_sbi_stream_find_by_id(xact->assoc_stream_id);
23
 
24
     SearchResult = recvmsg->SearchResult;
25
     if (!SearchResult) {
26
@@ -58,12 +66,12 @@
27
     }
28
 
29
     if (sbi_object->type == OGS_SBI_OBJ_UE_TYPE) {
30
-        pcf_ue = (pcf_ue_t *)sbi_object;
31
+        pcf_ue = pcf_ue_find_by_id(sbi_object_id);
32
         ogs_assert(pcf_ue);
33
     } else if (sbi_object->type == OGS_SBI_OBJ_SESS_TYPE) {
34
-        sess = (pcf_sess_t *)sbi_object;
35
+        sess = pcf_sess_find_by_id(sbi_object_id);
36
         ogs_assert(sess);
37
-        pcf_ue = sess->pcf_ue;
38
+        pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
39
         ogs_assert(pcf_ue);
40
     } else {
41
         ogs_fatal("(NF discover) Not implemented %s:%d",
42
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/npcf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/npcf-handler.c Changed
37
 
1
@@ -235,7 +235,7 @@
2
     char *home_network_domain = NULL;
3
 
4
     ogs_assert(sess);
5
-    pcf_ue = sess->pcf_ue;
6
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
7
     ogs_assert(stream);
8
     ogs_assert(message);
9
 
10
@@ -580,7 +580,7 @@
11
     OpenAPI_sm_policy_delete_data_t *SmPolicyDeleteData = NULL;
12
 
13
     ogs_assert(sess);
14
-    pcf_ue = sess->pcf_ue;
15
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
16
     ogs_assert(stream);
17
     ogs_assert(message);
18
 
19
@@ -681,7 +681,7 @@
20
     OpenAPI_lnode_t *node = NULL, *node2 = NULL, *node3 = NULL;
21
 
22
     ogs_assert(sess);
23
-    pcf_ue = sess->pcf_ue;
24
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
25
     ogs_assert(stream);
26
     ogs_assert(recvmsg);
27
 
28
@@ -1188,7 +1188,7 @@
29
     OpenAPI_lnode_t *node = NULL, *node2 = NULL, *node3 = NULL;
30
 
31
     ogs_assert(sess);
32
-    pcf_ue = sess->pcf_ue;
33
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
34
     ogs_assert(app_session);
35
     ogs_assert(stream);
36
     ogs_assert(recvmsg);
37
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/nudr-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/nudr-build.c Changed
10
 
1
@@ -51,7 +51,7 @@
2
     ogs_sbi_request_t *request = NULL;
3
 
4
     ogs_assert(sess);
5
-    pcf_ue = sess->pcf_ue;
6
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
7
     ogs_assert(pcf_ue);
8
 
9
     memset(&message, 0, sizeof(message));
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/nudr-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/nudr-handler.c Changed
10
 
1
@@ -193,7 +193,7 @@
2
     int r;
3
 
4
     ogs_assert(sess);
5
-    pcf_ue = sess->pcf_ue;
6
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
7
     ogs_assert(pcf_ue);
8
     ogs_assert(stream);
9
     server = ogs_sbi_server_from_stream(stream);
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/pcf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/pcf-sm.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -39,6 +39,7 @@
9
     int rv;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -48,11 +49,14 @@
17
 
18
     ogs_sbi_object_t *sbi_object = NULL;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
21
 
22
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
23
 
24
     pcf_ue_t *pcf_ue = NULL;
25
+    ogs_pool_id_t pcf_ue_id = OGS_INVALID_POOL_ID;
26
     pcf_sess_t *sess = NULL;
27
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
28
     pcf_app_t *app_session = NULL;
29
 
30
     pcf_sm_debug(e);
31
@@ -69,8 +73,16 @@
32
     case OGS_EVENT_SBI_SERVER:
33
         request = e->h.sbi.request;
34
         ogs_assert(request);
35
-        stream = e->h.sbi.data;
36
-        ogs_assert(stream);
37
+
38
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
39
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
40
+                stream_id <= OGS_MAX_POOL_ID);
41
+
42
+        stream = ogs_sbi_stream_find_by_id(stream_id);
43
+        if (!stream) {
44
+            ogs_error("STREAM has already been removed %d", stream_id);
45
+            break;
46
+        }
47
 
48
         rv = ogs_sbi_parse_request(&message, request);
49
         if (rv != OGS_OK) {
50
@@ -159,7 +171,7 @@
51
 
52
             ogs_assert(OGS_FSM_STATE(&pcf_ue->sm));
53
 
54
-            e->pcf_ue = pcf_ue;
55
+            e->pcf_ue_id = pcf_ue->id;
56
             e->h.sbi.message = &message;
57
             ogs_fsm_dispatch(&pcf_ue->sm, e);
58
             if (OGS_FSM_CHECK(&pcf_ue->sm, pcf_am_state_exception)) {
59
@@ -264,7 +276,7 @@
60
 
61
             ogs_assert(OGS_FSM_STATE(&sess->sm));
62
 
63
-            e->sess = sess;
64
+            e->sess_id = sess->id;
65
             e->h.sbi.message = &message;
66
             ogs_fsm_dispatch(&sess->sm, e);
67
             if (OGS_FSM_CHECK(&sess->sm, pcf_sm_state_exception)) {
68
@@ -314,7 +326,7 @@
69
 
70
             ogs_assert(OGS_FSM_STATE(&sess->sm));
71
 
72
-            e->sess = sess;
73
+            e->sess_id = sess->id;
74
             e->app = app_session;
75
             e->h.sbi.message = &message;
76
             ogs_fsm_dispatch(&sess->sm, e);
77
@@ -428,8 +440,18 @@
78
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
79
             SWITCH(message.h.resource.component0)
80
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
81
-                sbi_xact = e->h.sbi.data;
82
-                ogs_assert(sbi_xact);
83
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
84
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
85
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
86
+
87
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
88
+                if (!sbi_xact) {
89
+                    /* CLIENT_WAIT timer could remove SBI transaction
90
+                     * before receiving SBI message */
91
+                    ogs_error("SBI transaction has already been removed %d",
92
+                            sbi_xact_id);
93
+                    break;
94
+                }
95
 
96
                 SWITCH(message.h.method)
97
                 CASE(OGS_SBI_HTTP_METHOD_GET)
98
@@ -458,32 +480,39 @@
99
             CASE(OGS_SBI_RESOURCE_NAME_POLICY_DATA)
100
                 SWITCH(message.h.resource.component3)
101
                 CASE(OGS_SBI_RESOURCE_NAME_AM_DATA)
102
-                    sbi_xact = e->h.sbi.data;
103
-                    ogs_assert(sbi_xact);
104
+                    sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
105
+                    ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
106
+                            sbi_xact_id <= OGS_MAX_POOL_ID);
107
 
108
-                    sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
109
+                    sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
110
                     if (!sbi_xact) {
111
                         /* CLIENT_WAIT timer could remove SBI transaction
112
                          * before receiving SBI message */
113
-                        ogs_error("SBI transaction has already been removed");
114
+                        ogs_error(
115
+                                "SBI transaction has already been removed %d",
116
+                                sbi_xact_id);
117
                         break;
118
                     }
119
 
120
-                    pcf_ue = (pcf_ue_t *)sbi_xact->sbi_object;
121
-                    ogs_assert(pcf_ue);
122
-
123
-                    e->h.sbi.data = sbi_xact->assoc_stream;
124
+                    pcf_ue_id = sbi_xact->sbi_object_id;
125
+                    ogs_assert(pcf_ue_id >= OGS_MIN_POOL_ID &&
126
+                            pcf_ue_id <= OGS_MAX_POOL_ID);
127
+
128
+                    if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
129
+                        sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
130
+                        e->h.sbi.data =
131
+                            OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
132
 
133
                     ogs_sbi_xact_remove(sbi_xact);
134
 
135
-                    pcf_ue = pcf_ue_cycle(pcf_ue);
136
+                    pcf_ue = pcf_ue_find_by_id(pcf_ue_id);
137
                     if (!pcf_ue) {
138
                         ogs_error("UE(pcf_ue) Context "
139
                                     "has already been removed");
140
                         break;
141
                     }
142
 
143
-                    e->pcf_ue = pcf_ue;
144
+                    e->pcf_ue_id = pcf_ue->id;
145
                     e->h.sbi.message = &message;
146
 
147
                     ogs_fsm_dispatch(&pcf_ue->sm, e);
148
@@ -494,36 +523,41 @@
149
                     break;
150
 
151
                 CASE(OGS_SBI_RESOURCE_NAME_SM_DATA)
152
-                    sbi_xact = e->h.sbi.data;
153
-                    ogs_assert(sbi_xact);
154
+                    sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
155
+                    ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
156
+                            sbi_xact_id <= OGS_MAX_POOL_ID);
157
 
158
-                    sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
159
+                    sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
160
                     if (!sbi_xact) {
161
                         /* CLIENT_WAIT timer could remove SBI transaction
162
                          * before receiving SBI message */
163
-                        ogs_error("SBI transaction has already been removed");
164
+                        ogs_error(
165
+                                "SBI transaction has already been removed %d",
166
+                                sbi_xact_id);
167
                         break;
168
                     }
169
 
170
-                    sess = (pcf_sess_t *)sbi_xact->sbi_object;
171
-                    ogs_assert(sess);
172
-
173
-                    e->h.sbi.data = sbi_xact->assoc_stream;
174
+                    sess_id = sbi_xact->sbi_object_id;
175
+                    ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
176
+                            sess_id <= OGS_MAX_POOL_ID);
177
+
178
+                    if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
179
+                        sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
180
+                        e->h.sbi.data =
181
+                            OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
182
 
183
                     ogs_sbi_xact_remove(sbi_xact);
184
 
185
-                    sess = pcf_sess_cycle(sess);
186
+                    sess = pcf_sess_find_by_id(sess_id);
187
                     if (!sess) {
188
                         ogs_error("Session has already been removed");
189
                         break;
190
                     }
191
 
192
-                    pcf_ue = sess->pcf_ue;
193
-                    ogs_assert(pcf_ue);
194
-                    pcf_ue = pcf_ue_cycle(pcf_ue);
195
+                    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
196
                     ogs_assert(pcf_ue);
197
 
198
-                    e->sess = sess;
199
+                    e->sess_id = sess->id;
200
                     e->h.sbi.message = &message;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/sbi-path.c Changed
77
 
1
@@ -124,6 +124,7 @@
2
 }
3
 
4
 static int pcf_sbi_discover_and_send(
5
+        ogs_pool_id_t sbi_object_id,
6
         ogs_sbi_object_t *sbi_object,
7
         ogs_sbi_service_type_e service_type,
8
         ogs_sbi_discovery_option_t *discovery_option,
9
@@ -138,15 +139,22 @@
10
     ogs_assert(stream);
11
     ogs_assert(build);
12
 
13
+    ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
14
+            sbi_object_id <= OGS_MAX_POOL_ID);
15
+
16
     xact = ogs_sbi_xact_add(
17
-            sbi_object, service_type, discovery_option,
18
+            sbi_object_id, sbi_object, service_type, discovery_option,
19
             build, context, data);
20
     if (!xact) {
21
         ogs_error("ogs_sbi_xact_add() failed");
22
         return OGS_ERROR;
23
     }
24
 
25
-    xact->assoc_stream = stream;
26
+    if (stream) {
27
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
28
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
29
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
30
+    }
31
 
32
     r = ogs_sbi_discover_and_send(xact);
33
     if (r != OGS_OK) {
34
@@ -167,8 +175,8 @@
35
     int r;
36
 
37
     r = pcf_sbi_discover_and_send(
38
-                &pcf_ue->sbi, service_type, discovery_option,
39
-                (ogs_sbi_build_f)build, pcf_ue, stream, data);
40
+            pcf_ue->id, &pcf_ue->sbi, service_type, discovery_option,
41
+            (ogs_sbi_build_f)build, pcf_ue, stream, data);
42
     if (r != OGS_OK) {
43
         ogs_error("pcf_ue_sbi_discover_and_send() failed");
44
         ogs_assert(true ==
45
@@ -190,13 +198,18 @@
46
     ogs_assert(sess);
47
     ogs_assert(service_type);
48
 
49
-    xact = ogs_sbi_xact_add(&sess->sbi, service_type, NULL, NULL, NULL, NULL);
50
+    xact = ogs_sbi_xact_add(
51
+            0, &sess->sbi, service_type, NULL, NULL, NULL, NULL);
52
     if (!xact) {
53
         ogs_error("ogs_sbi_xact_add() failed");
54
         return OGS_ERROR;
55
     }
56
 
57
-    xact->assoc_stream = stream;
58
+    if (stream) {
59
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
60
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
61
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
62
+    }
63
 
64
     return ogs_sbi_discover_only(xact);
65
 }
66
@@ -210,8 +223,8 @@
67
     int r;
68
 
69
     r = pcf_sbi_discover_and_send(
70
-                &sess->sbi, service_type, discovery_option,
71
-                (ogs_sbi_build_f)build, sess, stream, data);
72
+            sess->id, &sess->sbi, service_type, discovery_option,
73
+            (ogs_sbi_build_f)build, sess, stream, data);
74
     if (r != OGS_OK) {
75
         ogs_error("pcf_sess_sbi_discover_and_send() failed");
76
         ogs_assert(true ==
77
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/pcf/sm-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/pcf/sm-sm.c Changed
104
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -42,6 +42,7 @@
9
     pcf_sess_t *sess = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id;
13
     ogs_sbi_message_t *message = NULL;
14
 
15
     ogs_assert(s);
16
@@ -49,9 +50,9 @@
17
 
18
     pcf_sm_debug(e);
19
 
20
-    sess = e->sess;
21
+    sess = pcf_sess_find_by_id(e->sess_id);
22
     ogs_assert(sess);
23
-    pcf_ue = sess->pcf_ue;
24
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
25
     ogs_assert(pcf_ue);
26
 
27
     switch (e->h.id) {
28
@@ -64,8 +65,16 @@
29
     case OGS_EVENT_SBI_SERVER:
30
         message = e->h.sbi.message;
31
         ogs_assert(message);
32
-        stream = e->h.sbi.data;
33
-        ogs_assert(stream);
34
+
35
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
36
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
37
+                stream_id <= OGS_MAX_POOL_ID);
38
+
39
+        stream = ogs_sbi_stream_find_by_id(stream_id);
40
+        if (!stream) {
41
+            ogs_error("STREAM has already been removed %d", stream_id);
42
+            break;
43
+        }
44
 
45
         SWITCH(message->h.service.name)
46
         CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)
47
@@ -161,8 +170,16 @@
48
     case OGS_EVENT_SBI_CLIENT:
49
         message = e->h.sbi.message;
50
         ogs_assert(message);
51
-        stream = e->h.sbi.data;
52
-        ogs_assert(stream);
53
+
54
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
55
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
56
+                stream_id <= OGS_MAX_POOL_ID);
57
+
58
+        stream = ogs_sbi_stream_find_by_id(stream_id);
59
+        if (!stream) {
60
+            ogs_error("STREAM has already been removed %d", stream_id);
61
+            break;
62
+        }
63
 
64
         SWITCH(message->h.service.name)
65
         CASE(OGS_SBI_SERVICE_NAME_NUDR_DR)
66
@@ -317,15 +334,14 @@
67
 
68
     pcf_sm_debug(e);
69
 
70
-    sess = e->sess;
71
+    sess = pcf_sess_find_by_id(e->sess_id);
72
     ogs_assert(sess);
73
-    pcf_ue = sess->pcf_ue;
74
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
75
     ogs_assert(pcf_ue);
76
 
77
     switch (e->h.id) {
78
     case OGS_FSM_ENTRY_SIG:
79
-        ogs_assert(sess->pcf_ue);
80
-        pcf_metrics_inst_by_slice_add(&sess->pcf_ue->guami.plmn_id,
81
+        pcf_metrics_inst_by_slice_add(&pcf_ue->guami.plmn_id,
82
                 &sess->s_nssai, PCF_METR_GAUGE_PA_SESSIONNBR, -1);
83
         break;
84
 
85
@@ -349,15 +365,14 @@
86
 
87
     pcf_sm_debug(e);
88
 
89
-    sess = e->sess;
90
+    sess = pcf_sess_find_by_id(e->sess_id);
91
     ogs_assert(sess);
92
-    pcf_ue = sess->pcf_ue;
93
+    pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
94
     ogs_assert(pcf_ue);
95
 
96
     switch (e->h.id) {
97
     case OGS_FSM_ENTRY_SIG:
98
-        ogs_assert(sess->pcf_ue);
99
-        pcf_metrics_inst_by_slice_add(&sess->pcf_ue->guami.plmn_id,
100
+        pcf_metrics_inst_by_slice_add(&pcf_ue->guami.plmn_id,
101
                 &sess->s_nssai, PCF_METR_GAUGE_PA_SESSIONNBR, -1);
102
         break;
103
 
104
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/scp/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/scp/context.c Changed
24
 
1
@@ -304,11 +304,11 @@
2
     return OGS_OK;
3
 }
4
 
5
-scp_assoc_t *scp_assoc_add(ogs_sbi_stream_t *stream)
6
+scp_assoc_t *scp_assoc_add(ogs_pool_id_t stream_id)
7
 {
8
     scp_assoc_t *assoc = NULL;
9
 
10
-    ogs_assert(stream);
11
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID);
12
 
13
     ogs_pool_alloc(&scp_assoc_pool, &assoc);
14
     if (!assoc) {
15
@@ -318,7 +318,7 @@
16
     }
17
     memset(assoc, 0, sizeof *assoc);
18
 
19
-    assoc->stream = stream;
20
+    assoc->stream_id = stream_id;
21
 
22
     assoc->discovery_option = ogs_sbi_discovery_option_new();
23
     ogs_assert(assoc->discovery_option);
24
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/scp/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/scp/context.h Changed
19
 
1
@@ -43,7 +43,7 @@
2
 typedef struct scp_assoc_s {
3
     ogs_lnode_t lnode;
4
 
5
-    ogs_sbi_stream_t *stream;
6
+    ogs_pool_id_t stream_id;
7
 
8
     ogs_sbi_client_t *client;
9
     ogs_sbi_client_t *nrf_client;
10
@@ -67,7 +67,7 @@
11
 
12
 int scp_context_parse_config(void);
13
 
14
-scp_assoc_t *scp_assoc_add(ogs_sbi_stream_t *stream);
15
+scp_assoc_t *scp_assoc_add(ogs_pool_id_t stream_id);
16
 void scp_assoc_remove(scp_assoc_t *assoc);
17
 void scp_assoc_remove_all(void);
18
 
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/scp/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/scp/sbi-path.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -110,7 +110,8 @@
9
     ogs_hash_index_t *hi;
10
     ogs_sbi_client_t *client = NULL, *nrf_client = NULL, *next_scp = NULL;
11
     ogs_sbi_client_t *sepp_client = NULL;
12
-    ogs_sbi_stream_t *stream = data;
13
+    ogs_sbi_stream_t *stream = NULL;
14
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
15
 
16
     OpenAPI_nf_type_e target_nf_type = OpenAPI_nf_type_NULL;
17
     OpenAPI_nf_type_e requester_nf_type = OpenAPI_nf_type_NULL;
18
@@ -133,10 +134,19 @@
19
 
20
     ogs_assert(request);
21
     ogs_assert(request->h.uri);
22
-    ogs_assert(stream);
23
+
24
+    stream_id = OGS_POINTER_TO_UINT(data);
25
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
26
+            stream_id <= OGS_MAX_POOL_ID);
27
+
28
+    stream = ogs_sbi_stream_find_by_id(stream_id);
29
+    if (!stream) {
30
+        ogs_error("STREAM has already been removed %d", stream_id);
31
+        return OGS_ERROR;
32
+    }
33
 
34
     /* SCP Context */
35
-    assoc = scp_assoc_add(stream);
36
+    assoc = scp_assoc_add(stream_id);
37
     if (!assoc) {
38
         ogs_error("scp_assoc_add() failed");
39
         return OGS_ERROR;
40
@@ -621,10 +631,13 @@
41
 {
42
     scp_assoc_t *assoc = data;
43
     ogs_sbi_stream_t *stream = NULL;
44
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
45
 
46
     ogs_assert(assoc);
47
-    stream = assoc->stream;
48
-    ogs_assert(stream);
49
+
50
+    stream_id = assoc->stream_id;
51
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID);
52
+    stream = ogs_sbi_stream_find_by_id(stream_id);
53
 
54
     if (status != OGS_OK) {
55
 
56
@@ -632,13 +645,17 @@
57
                 status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0,
58
                 "response_handler() failed %d", status);
59
 
60
+        scp_assoc_remove(assoc);
61
+
62
+        if (!stream) {
63
+            ogs_error("STREAM has already been removed %d", stream_id);
64
+            return OGS_ERROR;
65
+        }
66
         ogs_assert(true ==
67
             ogs_sbi_server_send_error(stream,
68
                 OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
69
                 "response_handler() failed", NULL, NULL));
70
 
71
-        scp_assoc_remove(assoc);
72
-
73
         return OGS_ERROR;
74
     }
75
 
76
@@ -652,9 +669,14 @@
77
             ogs_error("No NF-Instance ID");
78
     }
79
 
80
-    ogs_expect(true == ogs_sbi_server_send_response(stream, response));
81
     scp_assoc_remove(assoc);
82
 
83
+    if (!stream) {
84
+        ogs_error("STREAM has already been removed %d", stream_id);
85
+        return OGS_ERROR;
86
+    }
87
+    ogs_expect(true == ogs_sbi_server_send_response(stream, response));
88
+
89
     return OGS_OK;
90
 }
91
 
92
@@ -667,6 +689,7 @@
93
 
94
     scp_assoc_t *assoc = data;
95
     ogs_sbi_stream_t *stream = NULL;
96
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
97
 
98
     ogs_sbi_request_t *request = NULL;
99
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
100
@@ -680,9 +703,6 @@
101
     ogs_sbi_client_t *sepp_client = NULL;
102
 
103
     ogs_assert(assoc);
104
-    stream = assoc->stream;
105
-
106
-    ogs_assert(stream);
107
     request = assoc->request;
108
     ogs_assert(request);
109
     service_type = assoc->service_type;
110
@@ -695,18 +715,27 @@
111
     discovery_option = assoc->discovery_option;
112
     ogs_assert(discovery_option);
113
 
114
+    stream_id = assoc->stream_id;
115
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID);
116
+    stream = ogs_sbi_stream_find_by_id(stream_id);
117
+
118
     if (status != OGS_OK) {
119
 
120
         ogs_log_message(
121
                 status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0,
122
                 "nf_discover_handler() failed %d", status);
123
 
124
+        scp_assoc_remove(assoc);
125
+
126
+        if (!stream) {
127
+            ogs_error("STREAM has already been removed %d", stream_id);
128
+            return OGS_ERROR;
129
+        }
130
         ogs_assert(true ==
131
             ogs_sbi_server_send_error(stream,
132
                 OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
133
                 "nf_discover_handler() failed", NULL, NULL));
134
 
135
-        scp_assoc_remove(assoc);
136
         return OGS_ERROR;
137
     }
138
 
139
@@ -789,6 +818,12 @@
140
     ogs_assert(strerror);
141
     ogs_error("%s", strerror);
142
 
143
+    scp_assoc_remove(assoc);
144
+
145
+    if (!stream) {
146
+        ogs_error("STREAM has already been removed %d", stream_id);
147
+        return OGS_ERROR;
148
+    }
149
     ogs_assert(true ==
150
         ogs_sbi_server_send_error(
151
             stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, NULL, strerror, NULL,
152
@@ -796,8 +831,6 @@
153
 
154
     ogs_free(strerror);
155
 
156
-    scp_assoc_remove(assoc);
157
-
158
     ogs_sbi_response_free(response);
159
     ogs_sbi_message_free(&message);
160
 
161
@@ -813,17 +846,17 @@
162
 
163
     scp_assoc_t *assoc = data;
164
     ogs_sbi_stream_t *stream = NULL;
165
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
166
 
167
     ogs_sbi_request_t *request = NULL;
168
 
169
     ogs_sbi_client_t *sepp_client = NULL;
170
 
171
     ogs_assert(assoc);
172
-    ogs_assert(assoc->target_apiroot);
173
-    stream = assoc->stream;
174
-    ogs_assert(stream);
175
-    request = assoc->request;
176
-    ogs_assert(request);
177
+
178
+    stream_id = assoc->stream_id;
179
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID);
180
+    stream = ogs_sbi_stream_find_by_id(stream_id);
181
 
182
     if (status != OGS_OK) {
183
 
184
@@ -831,12 +864,17 @@
185
                 status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0,
186
                 "sepp_discover_handler() failed %d", status);
187
 
188
+        scp_assoc_remove(assoc);
189
+
190
+        if (!stream) {
191
+            ogs_error("STREAM has already been removed %d", stream_id);
192
+            return OGS_ERROR;
193
+        }
194
         ogs_assert(true ==
195
             ogs_sbi_server_send_error(stream,
196
                 OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
197
                 "sepp_discover_handler() failed", NULL, NULL));
198
 
199
-        scp_assoc_remove(assoc);
200
         return OGS_ERROR;
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/scp/scp-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/scp/scp-sm.c Changed
70
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -40,6 +40,7 @@
9
     int rv;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -47,6 +48,7 @@
17
     ogs_sbi_response_t *response = NULL;
18
     ogs_sbi_message_t message;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
21
 
22
     scp_sm_debug(e);
23
 
24
@@ -62,8 +64,16 @@
25
     case OGS_EVENT_SBI_SERVER:
26
         request = e->h.sbi.request;
27
         ogs_assert(request);
28
-        stream = e->h.sbi.data;
29
-        ogs_assert(stream);
30
+
31
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
32
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
33
+                stream_id <= OGS_MAX_POOL_ID);
34
+
35
+        stream = ogs_sbi_stream_find_by_id(stream_id);
36
+        if (!stream) {
37
+            ogs_error("STREAM has already been removed %d", stream_id);
38
+            break;
39
+        }
40
 
41
         rv = ogs_sbi_parse_request(&message, request);
42
         if (rv != OGS_OK) {
43
@@ -297,15 +307,22 @@
44
              * 4. timer expiration event is processed. (double-free SBI xact)
45
              *
46
              * To avoid double-free SBI xact,
47
-             * we need to check ogs_sbi_xact_cycle()
48
+             * we need to check ogs_sbi_xact_find_by_id()
49
              */
50
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
51
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
52
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
53
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
54
+
55
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
56
             if (!sbi_xact) {
57
-                ogs_error("SBI transaction has already been removed");
58
+                ogs_error("SBI transaction has already been removed %d",
59
+                        sbi_xact_id);
60
                 break;
61
             }
62
 
63
-            stream = sbi_xact->assoc_stream;
64
+            if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
65
+                sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
66
+                stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
67
             /* Here, we should not use ogs_assert(stream)
68
              * since 'namf-comm' service has no an associated stream. */
69
 
70
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sepp/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sepp/context.c Changed
24
 
1
@@ -538,11 +538,11 @@
2
     return NULL;
3
 }
4
 
5
-sepp_assoc_t *sepp_assoc_add(ogs_sbi_stream_t *stream)
6
+sepp_assoc_t *sepp_assoc_add(ogs_pool_id_t stream_id)
7
 {
8
     sepp_assoc_t *assoc = NULL;
9
 
10
-    ogs_assert(stream);
11
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID);
12
 
13
     ogs_pool_alloc(&sepp_assoc_pool, &assoc);
14
     if (!assoc) {
15
@@ -552,7 +552,7 @@
16
     }
17
     memset(assoc, 0, sizeof *assoc);
18
 
19
-    assoc->stream = stream;
20
+    assoc->stream_id = stream_id;
21
 
22
     ogs_list_add(&self.assoc_list, assoc);
23
 
24
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sepp/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sepp/context.h Changed
19
 
1
@@ -82,7 +82,7 @@
2
 typedef struct sepp_assoc_s {
3
     ogs_lnode_t lnode;
4
 
5
-    ogs_sbi_stream_t *stream;
6
+    ogs_pool_id_t stream_id;
7
 
8
     ogs_sbi_client_t *client;
9
     ogs_sbi_client_t *nrf_client;
10
@@ -106,7 +106,7 @@
11
 sepp_node_t *sepp_node_find_by_receiver(char *receiver);
12
 sepp_node_t *sepp_node_find_by_plmn_id(uint16_t mcc, uint16_t mnc);
13
 
14
-sepp_assoc_t *sepp_assoc_add(ogs_sbi_stream_t *stream);
15
+sepp_assoc_t *sepp_assoc_add(ogs_pool_id_t stream_id);
16
 void sepp_assoc_remove(sepp_assoc_t *assoc);
17
 void sepp_assoc_remove_all(void);
18
 
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sepp/handshake-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sepp/handshake-sm.c Changed
89
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2023-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -87,6 +87,7 @@
9
     sepp_node_t *sepp_node = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_message_t *message = NULL;
14
 
15
     ogs_assert(s);
16
@@ -118,8 +119,16 @@
17
     case OGS_EVENT_SBI_SERVER:
18
         message = e->h.sbi.message;
19
         ogs_assert(message);
20
-        stream = e->h.sbi.data;
21
-        ogs_assert(stream);
22
+
23
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
24
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
25
+                stream_id <= OGS_MAX_POOL_ID);
26
+
27
+        stream = ogs_sbi_stream_find_by_id(stream_id);
28
+        if (!stream) {
29
+            ogs_error("STREAM has already been removed %d", stream_id);
30
+            break;
31
+        }
32
 
33
         SWITCH(message->h.service.name)
34
         CASE(OGS_SBI_SERVICE_NAME_N32C_HANDSHAKE)
35
@@ -282,6 +291,7 @@
36
     sepp_node_t *sepp_node = NULL;
37
 
38
     ogs_sbi_stream_t *stream = NULL;
39
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
40
     ogs_sbi_message_t *message = NULL;
41
 
42
     ogs_assert(s);
43
@@ -304,8 +314,16 @@
44
     case OGS_EVENT_SBI_SERVER:
45
         message = e->h.sbi.message;
46
         ogs_assert(message);
47
-        stream = e->h.sbi.data;
48
-        ogs_assert(stream);
49
+
50
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
51
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
52
+                stream_id <= OGS_MAX_POOL_ID);
53
+
54
+        stream = ogs_sbi_stream_find_by_id(stream_id);
55
+        if (!stream) {
56
+            ogs_error("STREAM has already been removed %d", stream_id);
57
+            break;
58
+        }
59
 
60
         SWITCH(message->h.service.name)
61
         CASE(OGS_SBI_SERVICE_NAME_N32C_HANDSHAKE)
62
@@ -420,6 +438,7 @@
63
     sepp_node_t *sepp_node = NULL;
64
 
65
     ogs_sbi_stream_t *stream = NULL;
66
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
67
     ogs_sbi_message_t *message = NULL;
68
 
69
     ogs_assert(s);
70
@@ -447,8 +466,16 @@
71
     case OGS_EVENT_SBI_SERVER:
72
         message = e->h.sbi.message;
73
         ogs_assert(message);
74
-        stream = e->h.sbi.data;
75
-        ogs_assert(stream);
76
+
77
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
78
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
79
+                stream_id <= OGS_MAX_POOL_ID);
80
+
81
+        stream = ogs_sbi_stream_find_by_id(stream_id);
82
+        if (!stream) {
83
+            ogs_error("STREAM has already been removed %d", stream_id);
84
+            break;
85
+        }
86
 
87
         SWITCH(message->h.service.name)
88
         CASE(OGS_SBI_SERVICE_NAME_N32C_HANDSHAKE)
89
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sepp/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sepp/sbi-path.c Changed
94
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2023-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -158,6 +158,7 @@
9
     ogs_hash_index_t *hi;
10
     ogs_sbi_client_t *client = NULL, *scp_client = NULL;
11
     ogs_sbi_stream_t *stream = data;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_server_t *server = NULL;
14
 
15
     ogs_sbi_request_t sepp_request;
16
@@ -177,7 +178,17 @@
17
 
18
     ogs_assert(request);
19
     ogs_assert(request->h.uri);
20
-    ogs_assert(stream);
21
+
22
+    stream_id = OGS_POINTER_TO_UINT(data);
23
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
24
+            stream_id <= OGS_MAX_POOL_ID);
25
+
26
+    stream = ogs_sbi_stream_find_by_id(stream_id);
27
+    if (!stream) {
28
+        ogs_error("STREAM has already been removed %d", stream_id);
29
+        return OGS_ERROR;
30
+    }
31
+
32
     server = ogs_sbi_server_from_stream(stream);
33
     ogs_assert(server);
34
 
35
@@ -207,7 +218,7 @@
36
         sepp_node_t *sepp_node = NULL;
37
         bool do_not_remove_custom_header;
38
 
39
-        assoc = sepp_assoc_add(stream);
40
+        assoc = sepp_assoc_add(stream_id);
41
         if (!assoc) {
42
             ogs_error("sepp_assoc_add() failed");
43
             return OGS_ERROR;
44
@@ -408,10 +419,13 @@
45
 {
46
     sepp_assoc_t *assoc = data;
47
     ogs_sbi_stream_t *stream = NULL;
48
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
49
 
50
     ogs_assert(assoc);
51
-    stream = assoc->stream;
52
-    ogs_assert(stream);
53
+
54
+    stream_id = assoc->stream_id;
55
+    ogs_assert(stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID);
56
+    stream = ogs_sbi_stream_find_by_id(stream_id);
57
 
58
     if (status != OGS_OK) {
59
 
60
@@ -419,21 +433,30 @@
61
                 status == OGS_DONE ? OGS_LOG_DEBUG : OGS_LOG_WARN, 0,
62
                 "response_handler() failed %d", status);
63
 
64
+        sepp_assoc_remove(assoc);
65
+
66
+        if (!stream) {
67
+            ogs_error("STREAM has already been removed %d", stream_id);
68
+            return OGS_ERROR;
69
+        }
70
         ogs_assert(true ==
71
             ogs_sbi_server_send_error(stream,
72
                 OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
73
                 "response_handler() failed", NULL, NULL));
74
 
75
-        sepp_assoc_remove(assoc);
76
-
77
         return OGS_ERROR;
78
     }
79
 
80
     ogs_assert(response);
81
 
82
-    ogs_expect(true == ogs_sbi_server_send_response(stream, response));
83
     sepp_assoc_remove(assoc);
84
 
85
+    if (!stream) {
86
+        ogs_error("STREAM has already been removed %d", stream_id);
87
+        return OGS_ERROR;
88
+    }
89
+    ogs_expect(true == ogs_sbi_server_send_response(stream, response));
90
+
91
     return OGS_OK;
92
 }
93
 
94
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sepp/sepp-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sepp/sepp-sm.c Changed
29
 
1
@@ -42,6 +42,7 @@
2
     sepp_node_t *sepp_node = NULL;
3
 
4
     ogs_sbi_stream_t *stream = NULL;
5
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
6
     ogs_sbi_request_t *request = NULL;
7
     ogs_sbi_server_t *server = NULL;
8
 
9
@@ -64,8 +65,17 @@
10
     case OGS_EVENT_SBI_SERVER:
11
         request = e->h.sbi.request;
12
         ogs_assert(request);
13
-        stream = e->h.sbi.data;
14
-        ogs_assert(stream);
15
+
16
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
17
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
18
+                stream_id <= OGS_MAX_POOL_ID);
19
+
20
+        stream = ogs_sbi_stream_find_by_id(stream_id);
21
+        if (!stream) {
22
+            ogs_error("STREAM has already been removed %d", stream_id);
23
+            break;
24
+        }
25
+
26
         server = ogs_sbi_server_from_stream(stream);
27
         ogs_assert(server);
28
 
29
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/context.c Changed
201
 
1
@@ -212,9 +212,8 @@
2
     ogs_assert(imsi);
3
     ogs_assert(imsi_len);
4
 
5
-    ogs_pool_alloc(&sgwc_ue_pool, &sgwc_ue);
6
+    ogs_pool_id_calloc(&sgwc_ue_pool, &sgwc_ue);
7
     ogs_assert(sgwc_ue);
8
-    memset(sgwc_ue, 0, sizeof *sgwc_ue);
9
 
10
     /* Set SGW-S11-TEID */
11
     ogs_pool_alloc(&sgwc_s11_teid_pool, &sgwc_ue->sgw_s11_teid_node);
12
@@ -255,7 +254,7 @@
13
     sgwc_sess_remove_all(sgwc_ue);
14
 
15
     ogs_pool_free(&sgwc_s11_teid_pool, sgwc_ue->sgw_s11_teid_node);
16
-    ogs_pool_free(&sgwc_ue_pool, sgwc_ue);
17
+    ogs_pool_id_free(&sgwc_ue_pool, sgwc_ue);
18
 
19
     ogs_info("Removed Number of SGWC-UEs is now %d",
20
             ogs_list_count(&self.sgw_ue_list));
21
@@ -295,19 +294,23 @@
22
     return ogs_hash_get(self.sgw_s11_teid_hash, &teid, sizeof(teid));
23
 }
24
 
25
+sgwc_ue_t *sgwc_ue_find_by_id(ogs_pool_id_t id)
26
+{
27
+    return ogs_pool_find_by_id(&sgwc_ue_pool, id);
28
+}
29
+
30
 sgwc_sess_t *sgwc_sess_add(sgwc_ue_t *sgwc_ue, char *apn)
31
 {
32
     sgwc_sess_t *sess = NULL;
33
 
34
     ogs_assert(sgwc_ue);
35
 
36
-    ogs_pool_alloc(&sgwc_sess_pool, &sess);
37
+    ogs_pool_id_calloc(&sgwc_sess_pool, &sess);
38
     if (!sess) {
39
         ogs_error("Maximum number of session%lld reached",
40
                     (long long)ogs_app()->pool.sess);
41
         return NULL;
42
     }
43
-    memset(sess, 0, sizeof *sess);
44
 
45
     ogs_pfcp_pool_init(&sess->pfcp);
46
 
47
@@ -328,7 +331,7 @@
48
     sess->session.name = ogs_strdup(apn);
49
     ogs_assert(sess->session.name);
50
 
51
-    sess->sgwc_ue = sgwc_ue;
52
+    sess->sgwc_ue_id = sgwc_ue->id;
53
 
54
     ogs_list_add(&sgwc_ue->sess_list, sess);
55
 
56
@@ -344,7 +347,7 @@
57
 
58
     ogs_assert(node);
59
     ogs_assert(sess);
60
-    sgwc_ue = sess->sgwc_ue;
61
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
62
     ogs_assert(sgwc_ue);
63
 
64
     ogs_assert(sess->session.name);
65
@@ -430,7 +433,7 @@
66
     sgwc_ue_t *sgwc_ue = NULL;
67
 
68
     ogs_assert(sess);
69
-    sgwc_ue = sess->sgwc_ue;
70
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
71
     ogs_assert(sgwc_ue);
72
 
73
     ogs_list_remove(&sgwc_ue->sess_list, sess);
74
@@ -449,7 +452,7 @@
75
     ogs_free(sess->session.name);
76
 
77
     ogs_pool_free(&sgwc_sxa_seid_pool, sess->sgwc_sxa_seid_node);
78
-    ogs_pool_free(&sgwc_sess_pool, sess);
79
+    ogs_pool_id_free(&sgwc_sess_pool, sess);
80
 
81
     stats_remove_sgwc_session();
82
 
83
@@ -497,14 +500,14 @@
84
 
85
     bearer = sgwc_bearer_find_by_ue_ebi(sgwc_ue, ebi);
86
     if (bearer)
87
-        return bearer->sess;
88
+        return sgwc_sess_find_by_id(bearer->sess_id);
89
 
90
     return NULL;
91
 }
92
 
93
-sgwc_sess_t *sgwc_sess_cycle(sgwc_sess_t *sess)
94
+sgwc_sess_t *sgwc_sess_find_by_id(ogs_pool_id_t id)
95
 {
96
-    return ogs_pool_cycle(&sgwc_sess_pool, sess);
97
+    return ogs_pool_find_by_id(&sgwc_sess_pool, id);
98
 }
99
 
100
 int sgwc_sess_pfcp_xact_count(
101
@@ -518,14 +521,24 @@
102
     ogs_list_for_each(&sgwc_ue->sess_list, sess) {
103
         ogs_pfcp_node_t *pfcp_node = sess->pfcp_node;
104
         ogs_pfcp_xact_t *pfcp_xact = NULL;
105
+
106
         ogs_assert(pfcp_node);
107
         ogs_list_for_each(&pfcp_node->local_list, pfcp_xact) {
108
-            if (sess != pfcp_xact->data)
109
-                continue;
110
+            ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
111
+
112
             if (pfcp_type && pfcp_type != pfcp_xact->seq0.type)
113
                 continue;
114
+            if (!(pfcp_xact->modify_flags & OGS_PFCP_MODIFY_SESSION))
115
+                continue;
116
             if (modify_flags && modify_flags != pfcp_xact->modify_flags)
117
                 continue;
118
+
119
+            sess_id = OGS_POINTER_TO_UINT(pfcp_xact->data);
120
+            ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
121
+                    sess_id <= OGS_MAX_POOL_ID);
122
+            if (sess->id != sess_id)
123
+                continue;
124
+
125
             xact_count++;
126
         }
127
     }
128
@@ -540,15 +553,14 @@
129
     sgwc_ue_t *sgwc_ue = NULL;
130
 
131
     ogs_assert(sess);
132
-    sgwc_ue = sess->sgwc_ue;
133
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
134
     ogs_assert(sgwc_ue);
135
 
136
-    ogs_pool_alloc(&sgwc_bearer_pool, &bearer);
137
+    ogs_pool_id_calloc(&sgwc_bearer_pool, &bearer);
138
     ogs_assert(bearer);
139
-    memset(bearer, 0, sizeof *bearer);
140
 
141
-    bearer->sgwc_ue = sgwc_ue;
142
-    bearer->sess = sess;
143
+    bearer->sgwc_ue_id = sgwc_ue->id;
144
+    bearer->sess_id = sess->id;
145
 
146
     /* Downlink */
147
     tunnel = sgwc_tunnel_add(bearer, OGS_GTP2_F_TEID_S5_S8_SGW_GTP_U);
148
@@ -565,14 +577,17 @@
149
 
150
 int sgwc_bearer_remove(sgwc_bearer_t *bearer)
151
 {
152
+    sgwc_sess_t *sess = NULL;
153
+
154
     ogs_assert(bearer);
155
-    ogs_assert(bearer->sess);
156
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
157
+    ogs_assert(sess);
158
 
159
-    ogs_list_remove(&bearer->sess->bearer_list, bearer);
160
+    ogs_list_remove(&sess->bearer_list, bearer);
161
 
162
     sgwc_tunnel_remove_all(bearer);
163
 
164
-    ogs_pool_free(&sgwc_bearer_pool, bearer);
165
+    ogs_pool_id_free(&sgwc_bearer_pool, bearer);
166
 
167
     return OGS_OK;
168
 }
169
@@ -618,9 +633,9 @@
170
     return ogs_list_first(&sess->bearer_list);
171
 }
172
 
173
-sgwc_bearer_t *sgwc_bearer_cycle(sgwc_bearer_t *bearer)
174
+sgwc_bearer_t *sgwc_bearer_find_by_id(ogs_pool_id_t id)
175
 {
176
-    return ogs_pool_cycle(&sgwc_bearer_pool, bearer);
177
+    return ogs_pool_find_by_id(&sgwc_bearer_pool, id);
178
 }
179
 
180
 sgwc_tunnel_t *sgwc_tunnel_add(
181
@@ -636,7 +651,7 @@
182
     uint8_t dst_if = OGS_PFCP_INTERFACE_UNKNOWN;
183
 
184
     ogs_assert(bearer);
185
-    sess = bearer->sess;
186
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
187
     ogs_assert(sess);
188
 
189
     switch (interface_type) {
190
@@ -663,9 +678,8 @@
191
         ogs_assert_if_reached();
192
     }
193
 
194
-    ogs_pool_alloc(&sgwc_tunnel_pool, &tunnel);
195
+    ogs_pool_id_calloc(&sgwc_tunnel_pool, &tunnel);
196
     ogs_assert(tunnel);
197
-    memset(tunnel, 0, sizeof *tunnel);
198
 
199
     tunnel->interface_type = interface_type;
200
 
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/context.h Changed
88
 
1
@@ -51,6 +51,7 @@
2
 
3
 typedef struct sgwc_ue_s {
4
     ogs_lnode_t     lnode;
5
+    ogs_pool_id_t   id;
6
     ogs_pool_id_t   *sgw_s11_teid_node; /* A node of SGW-S11-TEID */
7
 
8
     uint32_t        sgw_s11_teid;   /* SGW-S11-TEID is derived from NODE */
9
@@ -74,6 +75,7 @@
10
 #define SGWC_SESS(pfcp_sess) ogs_container_of(pfcp_sess, sgwc_sess_t, pfcp)
11
 typedef struct sgwc_sess_s {
12
     ogs_lnode_t     lnode;                  /* A node of list_t */
13
+    ogs_pool_id_t   id;
14
     ogs_pool_id_t   *sgwc_sxa_seid_node;    /* A node of SGWC-SXA-SEID */
15
 
16
     ogs_pfcp_sess_t pfcp;           /* PFCP session context */
17
@@ -93,22 +95,24 @@
18
     ogs_gtp_node_t  *gnode;
19
     ogs_pfcp_node_t *pfcp_node;
20
 
21
-    sgwc_ue_t       *sgwc_ue;
22
+    ogs_pool_id_t   sgwc_ue_id;
23
 } sgwc_sess_t;
24
 
25
 typedef struct sgwc_bearer_s {
26
     ogs_lnode_t     lnode;
27
+    ogs_pool_id_t   id;
28
     ogs_lnode_t     to_modify_node;
29
 
30
     uint8_t         ebi;
31
 
32
     ogs_list_t      tunnel_list;
33
-    sgwc_sess_t     *sess;
34
-    sgwc_ue_t       *sgwc_ue;
35
+    ogs_pool_id_t   sess_id;
36
+    ogs_pool_id_t   sgwc_ue_id;
37
 } sgwc_bearer_t;
38
 
39
 typedef struct sgwc_tunnel_s {
40
     ogs_lnode_t     lnode;
41
+    ogs_pool_id_t   id;
42
 
43
     uint8_t         interface_type;
44
 
45
@@ -123,7 +127,7 @@
46
     ogs_ip_t        remote_ip;
47
 
48
     /* Related Context */
49
-    sgwc_bearer_t   *bearer;
50
+    ogs_pool_id_t   bearer_id;
51
     ogs_gtp_node_t  *gnode;
52
 } sgwc_tunnel_t;
53
 
54
@@ -141,6 +145,7 @@
55
 sgwc_ue_t *sgwc_ue_add(uint8_t *imsi, int imsi_len);
56
 int sgwc_ue_remove(sgwc_ue_t *sgwc_ue);
57
 void sgwc_ue_remove_all(void);
58
+sgwc_ue_t *sgwc_ue_find_by_id(ogs_pool_id_t id);
59
 
60
 sgwc_sess_t *sgwc_sess_add(sgwc_ue_t *sgwc_ue, char *apn);
61
 
62
@@ -154,7 +159,7 @@
63
 
64
 sgwc_sess_t *sgwc_sess_find_by_apn(sgwc_ue_t *sgwc_ue, char *apn);
65
 sgwc_sess_t *sgwc_sess_find_by_ebi(sgwc_ue_t *sgwc_ue, uint8_t ebi);
66
-sgwc_sess_t *sgwc_sess_cycle(sgwc_sess_t *sess);
67
+sgwc_sess_t *sgwc_sess_find_by_id(ogs_pool_id_t id);
68
 
69
 #define SGWC_SESSION_SYNC_DONE(__sGWC, __tYPE, __fLAGS) \
70
     (sgwc_sess_pfcp_xact_count(__sGWC, __tYPE, __fLAGS) == 0)
71
@@ -169,7 +174,7 @@
72
 sgwc_bearer_t *sgwc_bearer_find_by_ue_ebi(
73
                                 sgwc_ue_t *sgwc_ue, uint8_t ebi);
74
 sgwc_bearer_t *sgwc_default_bearer_in_sess(sgwc_sess_t *sess);
75
-sgwc_bearer_t *sgwc_bearer_cycle(sgwc_bearer_t *bearer);
76
+sgwc_bearer_t *sgwc_bearer_find_by_id(ogs_pool_id_t id);
77
 
78
 sgwc_tunnel_t *sgwc_tunnel_add(
79
         sgwc_bearer_t *bearer, uint8_t interface_type);
80
@@ -184,6 +189,7 @@
81
         sgwc_sess_t *sess, ogs_pfcp_far_id_t far_id);
82
 sgwc_tunnel_t *sgwc_dl_tunnel_in_bearer(sgwc_bearer_t *bearer);
83
 sgwc_tunnel_t *sgwc_ul_tunnel_in_bearer(sgwc_bearer_t *bearer);
84
+sgwc_tunnel_t *sgwc_tunnel_find_by_id(ogs_pool_id_t id);
85
 
86
 #ifdef __cplusplus
87
 }
88
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/event.h Changed
13
 
1
@@ -57,10 +57,8 @@
2
     ogs_gtp2_message_t *gtp_message;
3
 
4
     ogs_pfcp_node_t *pfcp_node;
5
-    ogs_pfcp_xact_t *pfcp_xact;
6
+    ogs_pool_id_t pfcp_xact_id;
7
     ogs_pfcp_message_t *pfcp_message;
8
-
9
-    sgwc_bearer_t *bearer;
10
 } sgwc_event_t;
11
 
12
 OGS_STATIC_ASSERT(OGS_EVENT_SIZE >= sizeof(sgwc_event_t));
13
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/gtp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/gtp-path.c Changed
67
 
1
@@ -144,19 +144,29 @@
2
 static void bearer_timeout(ogs_gtp_xact_t *xact, void *data)
3
 {
4
     sgwc_bearer_t *bearer = data;
5
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
6
     sgwc_sess_t *sess = NULL;
7
     sgwc_ue_t *sgwc_ue = NULL;
8
     uint8_t type = 0;
9
 
10
     ogs_assert(xact);
11
-    ogs_assert(bearer);
12
-    sess = bearer->sess;
13
+    type = xact->seq0.type;
14
+
15
+    ogs_assert(data);
16
+    bearer_id = OGS_POINTER_TO_UINT(data);
17
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
18
+
19
+    bearer = sgwc_bearer_find_by_id(bearer_id);
20
+    if (!bearer) {
21
+        ogs_error("Bearer has already been removed %d", type);
22
+        return;
23
+    }
24
+
25
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
26
     ogs_assert(sess);
27
-    sgwc_ue = sess->sgwc_ue;
28
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
29
     ogs_assert(sgwc_ue);
30
 
31
-    type = xact->seq0.type;
32
-
33
     switch (type) {
34
     case OGS_GTP2_DOWNLINK_DATA_NOTIFICATION_TYPE:
35
         ogs_warn("%s No Downlink Data Notification ACK", sgwc_ue->imsi_bcd);
36
@@ -178,7 +188,7 @@
37
     ogs_pkbuf_t *pkbuf = NULL;
38
 
39
     ogs_assert(sess);
40
-    sgwc_ue = sess->sgwc_ue;
41
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
42
     ogs_assert(sgwc_ue);
43
     ogs_assert(xact);
44
 
45
@@ -219,9 +229,9 @@
46
 
47
     ogs_assert(bearer);
48
 
49
-    sess = bearer->sess;
50
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
51
     ogs_assert(sess);
52
-    sgwc_ue = bearer->sgwc_ue;
53
+    sgwc_ue = sgwc_ue_find_by_id(bearer->sgwc_ue_id);
54
     ogs_assert(sgwc_ue);
55
     ogs_assert(sgwc_ue->gnode);
56
 
57
@@ -240,7 +250,8 @@
58
     }
59
 
60
     gtp_xact = ogs_gtp_xact_local_create(
61
-            sgwc_ue->gnode, &h, pkbuf, bearer_timeout, bearer);
62
+            sgwc_ue->gnode, &h, pkbuf, bearer_timeout,
63
+            OGS_UINT_TO_POINTER(bearer->id));
64
     if (!gtp_xact) {
65
         ogs_error("ogs_gtp_xact_local_create() failed");
66
         return OGS_ERROR;
67
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/pfcp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/pfcp-path.c Changed
157
 
1
@@ -170,11 +170,23 @@
2
 
3
 static void sess_timeout(ogs_pfcp_xact_t *xact, void *data)
4
 {
5
+    sgwc_sess_t *sess = NULL;
6
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
7
     uint8_t type;
8
 
9
     ogs_assert(xact);
10
     type = xact->seq0.type;
11
 
12
+    ogs_assert(data);
13
+    sess_id = OGS_POINTER_TO_UINT(data);
14
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
15
+
16
+    sess = sgwc_sess_find_by_id(sess_id);
17
+    if (!sess) {
18
+        ogs_error("Session has already been removed %d", type);
19
+        return;
20
+    }
21
+
22
     switch (type) {
23
     case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
24
         ogs_error("No PFCP session establishment response");
25
@@ -193,11 +205,23 @@
26
 
27
 static void bearer_timeout(ogs_pfcp_xact_t *xact, void *data)
28
 {
29
+    sgwc_bearer_t *bearer = NULL;
30
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
31
     uint8_t type;
32
 
33
     ogs_assert(xact);
34
     type = xact->seq0.type;
35
 
36
+    ogs_assert(data);
37
+    bearer_id = OGS_POINTER_TO_UINT(data);
38
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
39
+
40
+    bearer = sgwc_bearer_find_by_id(bearer_id);
41
+    if (!bearer) {
42
+        ogs_error("Bearer has already been removed %d", type);
43
+        return;
44
+    }
45
+
46
     switch (type) {
47
     case OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE:
48
         ogs_error("No PFCP session modification response");
49
@@ -243,7 +267,7 @@
50
 }
51
 
52
 int sgwc_pfcp_send_session_establishment_request(
53
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf,
54
+        sgwc_sess_t *sess, ogs_pool_id_t gtp_xact_id, ogs_pkbuf_t *gtpbuf,
55
         uint64_t flags)
56
 {
57
     int rv;
58
@@ -253,13 +277,14 @@
59
 
60
     ogs_assert(sess);
61
 
62
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_timeout, sess);
63
+    xact = ogs_pfcp_xact_local_create(
64
+            sess->pfcp_node, sess_timeout, OGS_UINT_TO_POINTER(sess->id));
65
     if (!xact) {
66
         ogs_error("ogs_pfcp_xact_local_create() failed");
67
         return OGS_ERROR;
68
     }
69
 
70
-    xact->assoc_xact = gtp_xact;
71
+    xact->assoc_xact_id = gtp_xact_id;
72
     if (gtpbuf) {
73
         xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
74
         if (!xact->gtpbuf) {
75
@@ -323,7 +348,7 @@
76
 }
77
 
78
 int sgwc_pfcp_send_session_modification_request(
79
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact,
80
+        sgwc_sess_t *sess, ogs_pool_id_t gtp_xact_id,
81
         ogs_pkbuf_t *gtpbuf, uint64_t flags)
82
 {
83
     ogs_pfcp_xact_t *xact = NULL;
84
@@ -331,13 +356,14 @@
85
 
86
     ogs_assert(sess);
87
 
88
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_timeout, sess);
89
+    xact = ogs_pfcp_xact_local_create(
90
+            sess->pfcp_node, sess_timeout, OGS_UINT_TO_POINTER(sess->id));
91
     if (!xact) {
92
         ogs_error("ogs_pfcp_xact_local_create() failed");
93
         return OGS_ERROR;
94
     }
95
 
96
-    xact->assoc_xact = gtp_xact;
97
+    xact->assoc_xact_id = gtp_xact_id;
98
     xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION;
99
     if (gtpbuf) {
100
         xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
101
@@ -355,7 +381,7 @@
102
 }
103
 
104
 int sgwc_pfcp_send_bearer_modification_request(
105
-        sgwc_bearer_t *bearer, ogs_gtp_xact_t *gtp_xact,
106
+        sgwc_bearer_t *bearer, ogs_pool_id_t gtp_xact_id,
107
         ogs_pkbuf_t *gtpbuf, uint64_t flags)
108
 {
109
     int rv;
110
@@ -365,16 +391,17 @@
111
     sgwc_sess_t *sess = NULL;
112
 
113
     ogs_assert(bearer);
114
-    sess = bearer->sess;
115
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
116
     ogs_assert(sess);
117
 
118
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, bearer_timeout, bearer);
119
+    xact = ogs_pfcp_xact_local_create(
120
+            sess->pfcp_node, bearer_timeout, OGS_UINT_TO_POINTER(bearer->id));
121
     if (!xact) {
122
         ogs_error("ogs_pfcp_xact_local_create() failed");
123
         return OGS_ERROR;
124
     }
125
 
126
-    xact->assoc_xact = gtp_xact;
127
+    xact->assoc_xact_id = gtp_xact_id;
128
     xact->modify_flags = flags;
129
     if (gtpbuf) {
130
         xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
131
@@ -410,7 +437,7 @@
132
 }
133
 
134
 int sgwc_pfcp_send_session_deletion_request(
135
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf)
136
+        sgwc_sess_t *sess, ogs_pool_id_t gtp_xact_id, ogs_pkbuf_t *gtpbuf)
137
 {
138
     int rv;
139
     ogs_pkbuf_t *sxabuf = NULL;
140
@@ -419,13 +446,14 @@
141
 
142
     ogs_assert(sess);
143
 
144
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_timeout, sess);
145
+    xact = ogs_pfcp_xact_local_create(
146
+            sess->pfcp_node, sess_timeout, OGS_UINT_TO_POINTER(sess->id));
147
     if (!xact) {
148
         ogs_error("ogs_pfcp_xact_local_create() failed");
149
         return OGS_ERROR;
150
     }
151
 
152
-    xact->assoc_xact = gtp_xact;
153
+    xact->assoc_xact_id = gtp_xact_id;
154
     if (gtpbuf) {
155
         xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
156
         if (!xact->gtpbuf) {
157
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/pfcp-path.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/pfcp-path.h Changed
24
 
1
@@ -33,18 +33,18 @@
2
         sgwc_sess_t *sess, ogs_pfcp_xact_t *xact);
3
 
4
 int sgwc_pfcp_send_session_establishment_request(
5
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf,
6
+        sgwc_sess_t *sess, ogs_pool_id_t gtp_xact_id, ogs_pkbuf_t *gtpbuf,
7
         uint64_t flags);
8
 
9
 int sgwc_pfcp_send_session_modification_request(
10
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact,
11
+        sgwc_sess_t *sess, ogs_pool_id_t gtp_xact_id,
12
         ogs_pkbuf_t *gtpbuf, uint64_t flags);
13
 int sgwc_pfcp_send_bearer_modification_request(
14
-        sgwc_bearer_t *bearer, ogs_gtp_xact_t *gtp_xact,
15
+        sgwc_bearer_t *bearer, ogs_pool_id_t gtp_xact_id,
16
         ogs_pkbuf_t *gtpbuf, uint64_t flags);
17
 
18
 int sgwc_pfcp_send_session_deletion_request(
19
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf);
20
+        sgwc_sess_t *sess, ogs_pool_id_t gtp_xact_id, ogs_pkbuf_t *gtpbuf);
21
 
22
 int sgwc_pfcp_send_session_report_response(
23
         ogs_pfcp_xact_t *xact, sgwc_sess_t *sess, uint8_t cause);
24
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/pfcp-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/pfcp-sm.c Changed
28
 
1
@@ -121,7 +121,7 @@
2
     case SGWC_EVT_SXA_MESSAGE:
3
         message = e->pfcp_message;
4
         ogs_assert(message);
5
-        xact = e->pfcp_xact;
6
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
7
         ogs_assert(xact);
8
 
9
         switch (message->h.type) {
10
@@ -203,7 +203,7 @@
11
     case SGWC_EVT_SXA_MESSAGE:
12
         message = e->pfcp_message;
13
         ogs_assert(message);
14
-        xact = e->pfcp_xact;
15
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
16
         ogs_assert(xact);
17
 
18
         if (message->h.seid_presence && message->h.seid != 0) {
19
@@ -400,7 +400,7 @@
20
                     sgwc_ue->imsi_bcd, sess->session.name);
21
                 ogs_assert(OGS_OK ==
22
                     sgwc_pfcp_send_session_establishment_request(
23
-                        sess, NULL, NULL,
24
+                        sess, OGS_INVALID_POOL_ID, NULL,
25
                         OGS_PFCP_CREATE_RESTORATION_INDICATION));
26
             }
27
         }
28
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/s11-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/s11-build.c Changed
19
 
1
@@ -44,7 +44,7 @@
2
     ogs_debug("SGWC Create Session Response");
3
 
4
     ogs_assert(sess);
5
-    sgwc_ue = sess->sgwc_ue;
6
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
7
     ogs_assert(sgwc_ue);
8
 
9
     ogs_debug("    SGW_S5C_TEID0x%x PGW_S5C_TEID0x%x",
10
@@ -141,7 +141,7 @@
11
     sgwc_sess_t *sess = NULL;
12
 
13
     ogs_assert(bearer);
14
-    sess = bearer->sess;
15
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
16
     ogs_assert(sess);
17
 
18
     /* Build downlink notification message */
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/s11-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/s11-handler.c Changed
201
 
1
@@ -24,27 +24,33 @@
2
 
3
 static void gtp_sess_timeout(ogs_gtp_xact_t *xact, void *data)
4
 {
5
-    sgwc_sess_t *sess = data;
6
+    sgwc_sess_t *sess = NULL;
7
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
8
     sgwc_ue_t *sgwc_ue = NULL;
9
     uint8_t type = 0;
10
 
11
     ogs_assert(xact);
12
-    ogs_assert(sess);
13
-    sgwc_ue = sess->sgwc_ue;
14
-    ogs_assert(sgwc_ue);
15
-
16
     type = xact->seq0.type;
17
 
18
+    ogs_assert(data);
19
+    sess_id = OGS_POINTER_TO_UINT(data);
20
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
21
+
22
+    sess = sgwc_sess_find_by_id(sess_id);
23
+    if (!sess) {
24
+        ogs_error("Session has already been removed %d", type);
25
+        return;
26
+    }
27
+
28
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
29
+    ogs_assert(sgwc_ue);
30
+
31
     switch (type) {
32
     case OGS_GTP2_DELETE_SESSION_REQUEST_TYPE:
33
         ogs_error("%s No Delete Session Response", sgwc_ue->imsi_bcd);
34
-        if (!sgwc_sess_cycle(sess)) {
35
-            ogs_error("%s Session has already been removed",
36
-                    sgwc_ue->imsi_bcd);
37
-            break;
38
-        }
39
         ogs_assert(OGS_OK ==
40
-            sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL));
41
+            sgwc_pfcp_send_session_deletion_request(
42
+                sess, OGS_INVALID_POOL_ID, NULL));
43
         break;
44
     default:
45
         ogs_error("GTP Timeout : IMSI%s Message-Type%d",
46
@@ -54,31 +60,53 @@
47
 
48
 static void gtp_bearer_timeout(ogs_gtp_xact_t *xact, void *data)
49
 {
50
-    sgwc_bearer_t *bearer = data;
51
+    sgwc_bearer_t *bearer = NULL;
52
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
53
     sgwc_sess_t *sess = NULL;
54
     sgwc_ue_t *sgwc_ue = NULL;
55
     uint8_t type = 0;
56
 
57
     ogs_assert(xact);
58
-    ogs_assert(bearer);
59
-    sess = bearer->sess;
60
+    type = xact->seq0.type;
61
+
62
+    ogs_assert(data);
63
+    bearer_id = OGS_POINTER_TO_UINT(data);
64
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
65
+
66
+    bearer = sgwc_bearer_find_by_id(bearer_id);
67
+    if (!bearer) {
68
+        ogs_error("Bearer has already been removed %d", type);
69
+        return;
70
+    }
71
+
72
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
73
     ogs_assert(sess);
74
-    sgwc_ue = sess->sgwc_ue;
75
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
76
     ogs_assert(sgwc_ue);
77
 
78
-    type = xact->seq0.type;
79
-
80
     ogs_error("GTP Timeout : IMSI%s Message-Type%d",
81
             sgwc_ue->imsi_bcd, type);
82
 }
83
 
84
 static void pfcp_sess_timeout(ogs_pfcp_xact_t *xact, void *data)
85
 {
86
+    sgwc_sess_t *sess = NULL;
87
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
88
     uint8_t type;
89
 
90
     ogs_assert(xact);
91
     type = xact->seq0.type;
92
 
93
+    ogs_assert(data);
94
+    sess_id = OGS_POINTER_TO_UINT(data);
95
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
96
+
97
+    sess = sgwc_sess_find_by_id(sess_id);
98
+    if (!sess) {
99
+        ogs_error("Session has already been removed %d", type);
100
+        return;
101
+    }
102
+
103
     switch (type) {
104
     case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
105
         ogs_error("No PFCP session establishment response");
106
@@ -383,7 +411,7 @@
107
 
108
     ogs_assert(OGS_OK ==
109
         sgwc_pfcp_send_session_establishment_request(
110
-            sess, s11_xact, gtpbuf, 0));
111
+            sess, s11_xact->id, gtpbuf, 0));
112
 }
113
 
114
 void sgwc_s11_handle_modify_bearer_request(
115
@@ -465,22 +493,28 @@
116
             break;
117
         }
118
 
119
-        sess = bearer->sess;
120
+        sess = sgwc_sess_find_by_id(bearer->sess_id);
121
         ogs_assert(sess);
122
 
123
         ogs_list_for_each_entry(&pfcp_xact_list, pfcp_xact, tmpnode) {
124
-            if (sess == pfcp_xact->data) {
125
-                current_xact = pfcp_xact;
126
-                break;
127
+            if (pfcp_xact->modify_flags & OGS_PFCP_MODIFY_SESSION) {
128
+                ogs_pool_id_t sess_id = OGS_POINTER_TO_UINT(pfcp_xact->data);
129
+                ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
130
+                        sess_id <= OGS_MAX_POOL_ID);
131
+                if (sess->id == sess_id) {
132
+                    current_xact = pfcp_xact;
133
+                    break;
134
+                }
135
             }
136
         }
137
 
138
         if (!current_xact) {
139
             current_xact = ogs_pfcp_xact_local_create(
140
-                    sess->pfcp_node, pfcp_sess_timeout, sess);
141
+                    sess->pfcp_node, pfcp_sess_timeout,
142
+                    OGS_UINT_TO_POINTER(sess->id));
143
             ogs_assert(current_xact);
144
 
145
-            current_xact->assoc_xact = s11_xact;
146
+            current_xact->assoc_xact_id = s11_xact->id;
147
             current_xact->modify_flags = OGS_PFCP_MODIFY_SESSION|
148
                 OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE;
149
             if (gtpbuf) {
150
@@ -566,8 +600,20 @@
151
     ogs_debug("    ENB_S1U_TEID%d SGW_S1U_TEID%d",
152
         dl_tunnel->remote_teid, dl_tunnel->local_teid);
153
 
154
-    ogs_list_for_each_entry(&pfcp_xact_list, pfcp_xact, tmpnode)
155
-        sgwc_pfcp_send_bearer_to_modify_list(pfcp_xact->data, pfcp_xact);
156
+    ogs_list_for_each_entry(&pfcp_xact_list, pfcp_xact, tmpnode) {
157
+        if (pfcp_xact->modify_flags & OGS_PFCP_MODIFY_SESSION) {
158
+            sgwc_sess_t *sess = NULL;
159
+
160
+            ogs_pool_id_t sess_id = OGS_POINTER_TO_UINT(pfcp_xact->data);
161
+            ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
162
+                    sess_id <= OGS_MAX_POOL_ID);
163
+
164
+            sess = sgwc_sess_find_by_id(sess_id);
165
+            ogs_assert(sess);
166
+
167
+            sgwc_pfcp_send_bearer_to_modify_list(sess, pfcp_xact);
168
+        }
169
+    }
170
 }
171
 
172
 void sgwc_s11_handle_delete_session_request(
173
@@ -657,7 +703,8 @@
174
         indication->scope_indication == 1) {
175
 
176
         ogs_assert(OGS_OK ==
177
-            sgwc_pfcp_send_session_deletion_request(sess, s11_xact, gtpbuf));
178
+            sgwc_pfcp_send_session_deletion_request(
179
+                sess, s11_xact->id, gtpbuf));
180
 
181
     } else {
182
         message->h.type = OGS_GTP2_DELETE_SESSION_REQUEST_TYPE;
183
@@ -670,7 +717,8 @@
184
         }
185
 
186
         s5c_xact = ogs_gtp_xact_local_create(
187
-                sess->gnode, &message->h, gtpbuf, gtp_sess_timeout, sess);
188
+                sess->gnode, &message->h, gtpbuf, gtp_sess_timeout,
189
+                OGS_UINT_TO_POINTER(sess->id));
190
         if (!s5c_xact) {
191
             ogs_error("ogs_gtp_xact_local_create() failed");
192
             return;
193
@@ -695,6 +743,7 @@
194
 
195
     sgwc_sess_t *sess = NULL;
196
     sgwc_bearer_t *bearer = NULL;
197
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
198
     sgwc_tunnel_t *dl_tunnel = NULL, *ul_tunnel = NULL;
199
     ogs_pfcp_far_t *far = NULL;
200
 
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/s5c-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/s5c-handler.c Changed
201
 
1
@@ -24,34 +24,39 @@
2
 
3
 static void bearer_timeout(ogs_gtp_xact_t *xact, void *data)
4
 {
5
-    sgwc_bearer_t *bearer = data;
6
+    sgwc_bearer_t *bearer = NULL;
7
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
8
     sgwc_sess_t *sess = NULL;
9
     sgwc_ue_t *sgwc_ue = NULL;
10
     uint8_t type = 0;
11
 
12
     ogs_assert(xact);
13
-    ogs_assert(bearer);
14
-    sess = bearer->sess;
15
+    type = xact->seq0.type;
16
+
17
+    ogs_assert(data);
18
+    bearer_id = OGS_POINTER_TO_UINT(data);
19
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
20
+
21
+    bearer = sgwc_bearer_find_by_id(bearer_id);
22
+    if (!bearer) {
23
+        ogs_error("Bearer has already been removed %d", type);
24
+        return;
25
+    }
26
+
27
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
28
     ogs_assert(sess);
29
-    sgwc_ue = sess->sgwc_ue;
30
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
31
     ogs_assert(sgwc_ue);
32
 
33
-    type = xact->seq0.type;
34
-
35
     switch (type) {
36
     case OGS_GTP2_UPDATE_BEARER_REQUEST_TYPE:
37
         ogs_error("%s No Update Bearer Response", sgwc_ue->imsi_bcd);
38
         break;
39
     case OGS_GTP2_DELETE_BEARER_REQUEST_TYPE:
40
         ogs_error("%s No Delete Bearer Response", sgwc_ue->imsi_bcd);
41
-        if (!sgwc_bearer_cycle(bearer)) {
42
-            ogs_error("%s Bearer has already been removed",
43
-                    sgwc_ue->imsi_bcd);
44
-            break;
45
-        }
46
         ogs_assert(OGS_OK ==
47
             sgwc_pfcp_send_bearer_modification_request(
48
-                bearer, NULL, NULL, OGS_PFCP_MODIFY_REMOVE));
49
+                bearer, OGS_INVALID_POOL_ID, NULL, OGS_PFCP_MODIFY_REMOVE));
50
         break;
51
     default:
52
         ogs_error("GTP Timeout : IMSI%s Message-Type%d",
53
@@ -91,7 +96,7 @@
54
      * Check Transaction
55
      ********************/
56
     ogs_assert(s5c_xact);
57
-    s11_xact = s5c_xact->assoc_xact;
58
+    s11_xact = ogs_gtp_xact_find_by_id(s5c_xact->assoc_xact_id);
59
     ogs_assert(s11_xact);
60
 
61
     rv = ogs_gtp_xact_commit(s5c_xact);
62
@@ -117,7 +122,7 @@
63
         ogs_error("No Context in TEID Cause:%d", session_cause);
64
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
65
     } else {
66
-        sgwc_ue = sess->sgwc_ue;
67
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
68
         ogs_assert(sgwc_ue);
69
     }
70
 
71
@@ -280,7 +285,7 @@
72
 
73
     ogs_assert(OGS_OK ==
74
         sgwc_pfcp_send_session_modification_request(
75
-            sess, s11_xact, gtpbuf,
76
+            sess, s11_xact->id, gtpbuf,
77
             OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_ACTIVATE));
78
 }
79
 
80
@@ -309,7 +314,7 @@
81
      * Check Transaction
82
      ********************/
83
     ogs_assert(s5c_xact);
84
-    s11_xact = s5c_xact->assoc_xact;
85
+    s11_xact = ogs_gtp_xact_find_by_id(s5c_xact->assoc_xact_id);
86
     ogs_assert(s11_xact);
87
     modify_action = s5c_xact->modify_action;
88
 
89
@@ -336,7 +341,7 @@
90
         ogs_error("No Context in TEID Cause:%d", session_cause);
91
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
92
     } else {
93
-        sgwc_ue = sess->sgwc_ue;
94
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
95
         ogs_assert(sgwc_ue);
96
     }
97
 
98
@@ -450,7 +455,7 @@
99
      * Check Transaction
100
      ********************/
101
     ogs_assert(s5c_xact);
102
-    s11_xact = s5c_xact->assoc_xact;
103
+    s11_xact = ogs_gtp_xact_find_by_id(s5c_xact->assoc_xact_id);
104
     ogs_assert(s11_xact);
105
 
106
     rv = ogs_gtp_xact_commit(s5c_xact);
107
@@ -476,7 +481,7 @@
108
         ogs_error("No Context in TEID Cause:%d", session_cause);
109
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
110
     } else {
111
-        sgwc_ue = sess->sgwc_ue;
112
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
113
         ogs_assert(sgwc_ue);
114
     }
115
 
116
@@ -518,7 +523,7 @@
117
      * 2. SMF sends Delete Session Response to SGW/MME.
118
      */
119
     ogs_assert(OGS_OK ==
120
-        sgwc_pfcp_send_session_deletion_request(sess, s11_xact, gtpbuf));
121
+        sgwc_pfcp_send_session_deletion_request(sess, s11_xact->id, gtpbuf));
122
 }
123
 
124
 void sgwc_s5c_handle_create_bearer_request(
125
@@ -556,7 +561,7 @@
126
         ogs_error("No Context in TEID");
127
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
128
     } else {
129
-        sgwc_ue = sess->sgwc_ue;
130
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
131
         ogs_assert(sgwc_ue);
132
     }
133
 
134
@@ -637,7 +642,7 @@
135
 
136
     ogs_assert(OGS_OK ==
137
         sgwc_pfcp_send_bearer_modification_request(
138
-            bearer, s5c_xact, gtpbuf,
139
+            bearer, s5c_xact->id, gtpbuf,
140
             OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_CREATE));
141
 }
142
 
143
@@ -673,7 +678,7 @@
144
         ogs_error("No Context in TEID");
145
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
146
     } else {
147
-        sgwc_ue = sess->sgwc_ue;
148
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
149
         ogs_assert(sgwc_ue);
150
 
151
         if (req->bearer_contexts.presence == 0) {
152
@@ -725,10 +730,11 @@
153
         return;
154
     }
155
 
156
-    s11_xact = s5c_xact->assoc_xact;
157
+    s11_xact = ogs_gtp_xact_find_by_id(s5c_xact->assoc_xact_id);
158
     if (!s11_xact) {
159
         s11_xact = ogs_gtp_xact_local_create(
160
-                sgwc_ue->gnode, &message->h, pkbuf, bearer_timeout, bearer);
161
+                sgwc_ue->gnode, &message->h, pkbuf, bearer_timeout,
162
+                OGS_UINT_TO_POINTER(bearer->id));
163
         if (!s11_xact) {
164
             ogs_error("ogs_gtp_xact_local_create() failed");
165
             return;
166
@@ -783,7 +789,7 @@
167
         ogs_error("No Context in TEID");
168
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
169
     } else {
170
-        sgwc_ue = sess->sgwc_ue;
171
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
172
         ogs_assert(sgwc_ue);
173
 
174
         if (req->linked_eps_bearer_id.presence == 0 &&
175
@@ -866,7 +872,7 @@
176
         return;
177
     }
178
 
179
-    s11_xact = s5c_xact->assoc_xact;
180
+    s11_xact = ogs_gtp_xact_find_by_id(s5c_xact->assoc_xact_id);
181
     if (!s11_xact) {
182
        /*
183
         * 1. SMF sends Delete Bearer Request(DEFAULT BEARER) to SGW/MME.
184
@@ -883,7 +889,8 @@
185
         * 2. MME sends Delete Bearer Response(DEDICATED BEARER) to SGW/SMF.
186
         */
187
         s11_xact = ogs_gtp_xact_local_create(
188
-                sgwc_ue->gnode, &message->h, pkbuf, bearer_timeout, bearer);
189
+                sgwc_ue->gnode, &message->h, pkbuf, bearer_timeout,
190
+                OGS_UINT_TO_POINTER(bearer->id));
191
         if (!s11_xact) {
192
             ogs_error("ogs_gtp_xact_local_create() failed");
193
             return;
194
@@ -929,7 +936,7 @@
195
      * Check Transaction
196
      ********************/
197
     ogs_assert(s5c_xact);
198
-    s11_xact = s5c_xact->assoc_xact;
199
+    s11_xact = ogs_gtp_xact_find_by_id(s5c_xact->assoc_xact_id);
200
     ogs_assert(s11_xact);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/sgwc-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/sgwc-sm.c Changed
10
 
1
@@ -114,7 +114,7 @@
2
         }
3
 
4
         e->pfcp_message = pfcp_message;
5
-        e->pfcp_xact = pfcp_xact;
6
+        e->pfcp_xact_id = pfcp_xact ? pfcp_xact->id : OGS_INVALID_POOL_ID;
7
 
8
         e->gtp_message = NULL;
9
         if (pfcp_xact->gtpbuf) {
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwc/sxa-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwc/sxa-handler.c Changed
201
 
1
@@ -62,13 +62,25 @@
2
 
3
 static void sess_timeout(ogs_gtp_xact_t *xact, void *data)
4
 {
5
-    sgwc_sess_t *sess = data;
6
+    sgwc_sess_t *sess = NULL;
7
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
8
     sgwc_ue_t *sgwc_ue = NULL;
9
     uint8_t type = 0;
10
 
11
     ogs_assert(xact);
12
-    ogs_assert(sess);
13
-    sgwc_ue = sess->sgwc_ue;
14
+    type = xact->seq0.type;
15
+
16
+    ogs_assert(data);
17
+    sess_id = OGS_POINTER_TO_UINT(data);
18
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
19
+
20
+    sess = sgwc_sess_find_by_id(sess_id);
21
+    if (!sess) {
22
+        ogs_error("Session has already been removed %d", type);
23
+        return;
24
+    }
25
+
26
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
27
     ogs_assert(sgwc_ue);
28
 
29
     type = xact->seq0.type;
30
@@ -76,13 +88,9 @@
31
     switch (type) {
32
     case OGS_GTP2_CREATE_SESSION_REQUEST_TYPE:
33
         ogs_error("%s No Create Session Response", sgwc_ue->imsi_bcd);
34
-        if (!sgwc_sess_cycle(sess)) {
35
-            ogs_warn("%s Session has already been removed",
36
-                    sgwc_ue->imsi_bcd);
37
-            break;
38
-        }
39
         ogs_assert(OGS_OK ==
40
-            sgwc_pfcp_send_session_deletion_request(sess, NULL, NULL));
41
+            sgwc_pfcp_send_session_deletion_request(
42
+                sess, OGS_INVALID_POOL_ID, NULL));
43
         break;
44
     default:
45
         ogs_error("GTP Timeout : IMSI%s Message-Type%d",
46
@@ -92,30 +100,36 @@
47
 
48
 static void bearer_timeout(ogs_gtp_xact_t *xact, void *data)
49
 {
50
-    sgwc_bearer_t *bearer = data;
51
+    sgwc_bearer_t *bearer = NULL;
52
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
53
     sgwc_sess_t *sess = NULL;
54
     sgwc_ue_t *sgwc_ue = NULL;
55
     uint8_t type = 0;
56
 
57
     ogs_assert(xact);
58
-    ogs_assert(bearer);
59
-    sess = bearer->sess;
60
+    type = xact->seq0.type;
61
+
62
+    ogs_assert(data);
63
+    bearer_id = OGS_POINTER_TO_UINT(data);
64
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
65
+
66
+    bearer = sgwc_bearer_find_by_id(bearer_id);
67
+    if (!bearer) {
68
+        ogs_error("Bearer has already been removed %d", type);
69
+        return;
70
+    }
71
+
72
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
73
     ogs_assert(sess);
74
-    sgwc_ue = sess->sgwc_ue;
75
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
76
     ogs_assert(sgwc_ue);
77
 
78
-    type = xact->seq0.type;
79
-
80
     switch (type) {
81
     case OGS_GTP2_CREATE_BEARER_REQUEST_TYPE:
82
         ogs_error("%s No Create Bearer Response", sgwc_ue->imsi_bcd);
83
-        if (!sgwc_bearer_cycle(bearer)) {
84
-            ogs_warn("%s Bearer has already been removed", sgwc_ue->imsi_bcd);
85
-            break;
86
-        }
87
         ogs_assert(OGS_OK ==
88
             sgwc_pfcp_send_bearer_modification_request(
89
-                bearer, NULL, NULL,
90
+                bearer, OGS_INVALID_POOL_ID, NULL,
91
                 OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE));
92
         break;
93
     default:
94
@@ -164,7 +178,7 @@
95
     create_session_request = &recv_message->create_session_request;
96
     ogs_assert(create_session_request);
97
 
98
-    s11_xact = pfcp_xact->assoc_xact;
99
+    s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
100
     ogs_assert(s11_xact);
101
 
102
     ogs_pfcp_xact_commit(pfcp_xact);
103
@@ -244,7 +258,7 @@
104
     }
105
 
106
     if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
107
-        if (sess) sgwc_ue = sess->sgwc_ue;
108
+        if (sess) sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
109
         ogs_gtp_send_error_message(
110
                 s11_xact, sgwc_ue ? sgwc_ue->mme_s11_teid : 0,
111
                 OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE, cause_value);
112
@@ -383,7 +397,8 @@
113
 
114
         ogs_assert(sess->gnode);
115
         s5c_xact = ogs_gtp_xact_local_create(
116
-                sess->gnode, &send_message.h, pkbuf, sess_timeout, sess);
117
+                sess->gnode, &send_message.h, pkbuf, sess_timeout,
118
+                OGS_UINT_TO_POINTER(sess->id));
119
         if (!s5c_xact) {
120
             ogs_error("ogs_gtp_xact_local_create() failed");
121
             return;
122
@@ -427,7 +442,8 @@
123
 
124
         ogs_assert(sess->gnode);
125
         s5c_xact = ogs_gtp_xact_local_create(
126
-                sess->gnode, &recv_message->h, pkbuf, sess_timeout, sess);
127
+                sess->gnode, &recv_message->h, pkbuf, sess_timeout,
128
+                OGS_UINT_TO_POINTER(sess->id));
129
         if (!s5c_xact) {
130
             ogs_error("ogs_gtp_xact_local_create() failed");
131
             return;
132
@@ -475,31 +491,41 @@
133
 
134
     if (flags & OGS_PFCP_MODIFY_SESSION) {
135
         if (!sess) {
136
+            ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
137
+
138
             ogs_error("No Context");
139
 
140
-            sess = pfcp_xact->data;
141
+            sess_id = OGS_POINTER_TO_UINT(pfcp_xact->data);
142
+            ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
143
+                    sess_id <= OGS_MAX_POOL_ID);
144
+
145
+            sess = sgwc_sess_find_by_id(sess_id);
146
             ogs_assert(sess);
147
 
148
             cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
149
         }
150
 
151
-        sgwc_ue = sess->sgwc_ue;
152
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
153
         ogs_assert(sgwc_ue);
154
 
155
     } else {
156
-        bearer = pfcp_xact->data;
157
+        ogs_pool_id_t bearer_id = OGS_POINTER_TO_UINT(pfcp_xact->data);
158
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
159
+                bearer_id <= OGS_MAX_POOL_ID);
160
+
161
+        bearer = sgwc_bearer_find_by_id(bearer_id);
162
         ogs_assert(bearer);
163
 
164
         if (!sess) {
165
             ogs_error("No Context");
166
 
167
-            sess = bearer->sess;
168
+            sess = sgwc_sess_find_by_id(bearer->sess_id);
169
             ogs_assert(sess);
170
 
171
             cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
172
         }
173
 
174
-        sgwc_ue = bearer->sgwc_ue;
175
+        sgwc_ue = sgwc_ue_find_by_id(bearer->sgwc_ue_id);
176
         ogs_assert(sgwc_ue);
177
     }
178
 
179
@@ -578,7 +604,7 @@
180
          *    }
181
          */
182
         if (flags & OGS_PFCP_MODIFY_REMOVE) {
183
-            s5c_xact = pfcp_xact->assoc_xact;
184
+            s5c_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
185
 
186
             if (s5c_xact) {
187
                 ogs_gtp_send_error_message(
188
@@ -588,7 +614,7 @@
189
 
190
             sgwc_bearer_remove(bearer);
191
         } else if (flags & OGS_PFCP_MODIFY_CREATE) {
192
-            s5c_xact = pfcp_xact->assoc_xact;
193
+            s5c_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
194
             ogs_assert(s5c_xact);
195
 
196
             ogs_gtp_send_error_message(
197
@@ -598,7 +624,7 @@
198
 
199
         } else if (flags & OGS_PFCP_MODIFY_ACTIVATE) {
200
             if (flags & OGS_PFCP_MODIFY_UL_ONLY) {
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwu/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwu/context.c Changed
33
 
1
@@ -141,9 +141,8 @@
2
 
3
     ogs_assert(cp_f_seid);
4
 
5
-    ogs_pool_alloc(&sgwu_sess_pool, &sess);
6
+    ogs_pool_id_calloc(&sgwu_sess_pool, &sess);
7
     ogs_assert(sess);
8
-    memset(sess, 0, sizeof *sess);
9
 
10
     ogs_pfcp_pool_init(&sess->pfcp);
11
 
12
@@ -197,7 +196,7 @@
13
     ogs_pfcp_pool_final(&sess->pfcp);
14
 
15
     ogs_pool_free(&sgwu_sxa_seid_pool, sess->sgwu_sxa_seid_node);
16
-    ogs_pool_free(&sgwu_sess_pool, sess);
17
+    ogs_pool_id_free(&sgwu_sess_pool, sess);
18
 
19
     ogs_info("Removed Number of SGWU-sessions is now %d",
20
             ogs_list_count(&self.sess_list));
21
@@ -238,6 +237,11 @@
22
     return ogs_hash_get(self.sgwu_sxa_seid_hash, &seid, sizeof(seid));
23
 }
24
 
25
+sgwu_sess_t *sgwu_sess_find_by_id(ogs_pool_id_t id)
26
+{
27
+    return ogs_pool_find_by_id(&sgwu_sess_pool, id);
28
+}
29
+
30
 sgwu_sess_t *sgwu_sess_add_by_message(ogs_pfcp_message_t *message)
31
 {
32
     sgwu_sess_t *sess = NULL;
33
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwu/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwu/context.h Changed
17
 
1
@@ -47,6 +47,7 @@
2
 #define SGWU_SESS(pfcp_sess) ogs_container_of(pfcp_sess, sgwu_sess_t, pfcp)
3
 typedef struct sgwu_sess_s {
4
     ogs_lnode_t     lnode;
5
+    ogs_pool_id_t   id;
6
     ogs_pool_id_t   *sgwu_sxa_seid_node;    /* A node of SGWU-SXA-SEID */
7
 
8
     ogs_pfcp_sess_t pfcp;
9
@@ -74,6 +75,7 @@
10
 sgwu_sess_t *sgwu_sess_find_by_sgwc_sxa_seid(uint64_t seid);
11
 sgwu_sess_t *sgwu_sess_find_by_sgwc_sxa_f_seid(ogs_pfcp_f_seid_t *f_seid);
12
 sgwu_sess_t *sgwu_sess_find_by_sgwu_sxa_seid(uint64_t seid);
13
+sgwu_sess_t *sgwu_sess_find_by_id(ogs_pool_id_t id);
14
 
15
 #ifdef __cplusplus
16
 }
17
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwu/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwu/event.h Changed
10
 
1
@@ -52,7 +52,7 @@
2
     ogs_gtp_node_t *gnode;
3
 
4
     ogs_pfcp_node_t *pfcp_node;
5
-    ogs_pfcp_xact_t *pfcp_xact;
6
+    ogs_pool_id_t pfcp_xact_id;
7
     ogs_pfcp_message_t *pfcp_message;
8
 
9
     sgwu_bearer_t *bearer;
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwu/pfcp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwu/pfcp-path.c Changed
35
 
1
@@ -267,11 +267,23 @@
2
 
3
 static void sess_timeout(ogs_pfcp_xact_t *xact, void *data)
4
 {
5
+    sgwu_sess_t *sess = NULL;
6
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
7
     uint8_t type;
8
 
9
     ogs_assert(xact);
10
     type = xact->seq0.type;
11
 
12
+    ogs_assert(data);
13
+    sess_id = OGS_POINTER_TO_UINT(data);
14
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
15
+
16
+    sess = sgwu_sess_find_by_id(sess_id);
17
+    if (!sess) {
18
+        ogs_error("Session has already been removed %d", type);
19
+        return;
20
+    }
21
+
22
     switch (type) {
23
     case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
24
         ogs_error("No PFCP session report response");
25
@@ -297,7 +309,8 @@
26
     h.type = OGS_PFCP_SESSION_REPORT_REQUEST_TYPE;
27
     h.seid = sess->sgwc_sxa_f_seid.seid;
28
 
29
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_timeout, sess);
30
+    xact = ogs_pfcp_xact_local_create(
31
+            sess->pfcp_node, sess_timeout, OGS_UINT_TO_POINTER(sess->id));
32
     if (!xact) {
33
         ogs_error("ogs_pfcp_xact_local_create() failed");
34
         return OGS_ERROR;
35
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwu/pfcp-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwu/pfcp-sm.c Changed
19
 
1
@@ -117,7 +117,7 @@
2
     case SGWU_EVT_SXA_MESSAGE:
3
         message = e->pfcp_message;
4
         ogs_assert(message);
5
-        xact = e->pfcp_xact;
6
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
7
         ogs_assert(xact);
8
 
9
         switch (message->h.type) {
10
@@ -199,7 +199,7 @@
11
     case SGWU_EVT_SXA_MESSAGE:
12
         message = e->pfcp_message;
13
         ogs_assert(message);
14
-        xact = e->pfcp_xact;
15
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
16
         ogs_assert(xact);
17
 
18
         if (message->h.seid_presence && message->h.seid != 0)
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/sgwu/sgwu-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/sgwu/sgwu-sm.c Changed
10
 
1
@@ -82,7 +82,7 @@
2
         }
3
 
4
         e->pfcp_message = pfcp_message;
5
-        e->pfcp_xact = xact;
6
+        e->pfcp_xact_id = xact ? xact->id : OGS_INVALID_POOL_ID;
7
         ogs_fsm_dispatch(&node->sm, e);
8
         if (OGS_FSM_CHECK(&node->sm, sgwu_pfcp_state_exception)) {
9
             ogs_error("PFCP state machine exception");
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/binding.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/binding.c Changed
96
 
1
@@ -26,29 +26,36 @@
2
 
3
 static void gtp_bearer_timeout(ogs_gtp_xact_t *xact, void *data)
4
 {
5
-    smf_bearer_t *bearer = data;
6
+    smf_bearer_t *bearer = NULL;
7
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
8
     smf_sess_t *sess = NULL;
9
     smf_ue_t *smf_ue = NULL;
10
     uint8_t type = 0;
11
 
12
-    ogs_assert(bearer);
13
-    sess = bearer->sess;
14
+    ogs_assert(xact);
15
+    type = xact->seq0.type;
16
+
17
+    ogs_assert(data);
18
+    bearer_id = OGS_POINTER_TO_UINT(data);
19
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
20
+
21
+    bearer = smf_bearer_find_by_id(bearer_id);
22
+    if (!bearer) {
23
+        ogs_error("Bearer has already been removed %d", type);
24
+        return;
25
+    }
26
+
27
+    sess = smf_sess_find_by_id(bearer->sess_id);
28
     ogs_assert(sess);
29
-    smf_ue = sess->smf_ue;
30
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
31
     ogs_assert(smf_ue);
32
 
33
-    type = xact->seq0.type;
34
-
35
     switch (type) {
36
     case OGS_GTP2_CREATE_BEARER_REQUEST_TYPE:
37
         ogs_error("%s No Create Bearer Response", smf_ue->imsi_bcd);
38
-        if (!smf_bearer_cycle(bearer)) {
39
-            ogs_warn("%s Bearer has already been removed", smf_ue->imsi_bcd);
40
-            break;
41
-        }
42
         ogs_assert(OGS_OK ==
43
             smf_epc_pfcp_send_one_bearer_modification_request(
44
-                bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
45
+                bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
46
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
47
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
48
         break;
49
@@ -348,7 +355,7 @@
50
 
51
                 ogs_assert(OGS_OK ==
52
                     smf_epc_pfcp_send_one_bearer_modification_request(
53
-                        bearer, NULL, OGS_PFCP_MODIFY_CREATE,
54
+                        bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_CREATE,
55
                         OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
56
                         OGS_GTP2_CAUSE_UNDEFINED_VALUE));
57
             } else {
58
@@ -376,7 +383,8 @@
59
                 }
60
 
61
                 xact = ogs_gtp_xact_local_create(
62
-                        sess->gnode, &h, pkbuf, gtp_bearer_timeout, bearer);
63
+                        sess->gnode, &h, pkbuf, gtp_bearer_timeout,
64
+                        OGS_UINT_TO_POINTER(bearer->id));
65
                 if (!xact) {
66
                     ogs_error("ogs_gtp_xact_local_create() failed");
67
                     return;
68
@@ -413,7 +421,7 @@
69
              */
70
             ogs_assert(OGS_OK ==
71
                 smf_epc_pfcp_send_one_bearer_modification_request(
72
-                    bearer, NULL,
73
+                    bearer, OGS_INVALID_POOL_ID,
74
                     OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE,
75
                     OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
76
                     OGS_GTP2_CAUSE_UNDEFINED_VALUE));
77
@@ -435,7 +443,7 @@
78
     ogs_gtp2_tft_t tft;
79
 
80
     ogs_assert(bearer);
81
-    sess = bearer->sess;
82
+    sess = smf_sess_find_by_id(bearer->sess_id);
83
     ogs_assert(sess);
84
 
85
     h.type = OGS_GTP2_CREATE_BEARER_REQUEST_TYPE;
86
@@ -452,7 +460,8 @@
87
     }
88
 
89
     xact = ogs_gtp_xact_local_create(
90
-            sess->gnode, &h, pkbuf, gtp_bearer_timeout, bearer);
91
+            sess->gnode, &h, pkbuf, gtp_bearer_timeout,
92
+            OGS_UINT_TO_POINTER(bearer->id));
93
     if (!xact) {
94
         ogs_error("ogs_gtp_xact_local_create() failed");
95
         return OGS_ERROR;
96
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/context.c Changed
201
 
1
@@ -1003,13 +1003,12 @@
2
 {
3
     smf_ue_t *smf_ue = NULL;
4
 
5
-    ogs_pool_alloc(&smf_ue_pool, &smf_ue);
6
+    ogs_pool_id_calloc(&smf_ue_pool, &smf_ue);
7
     if (!smf_ue) {
8
         ogs_error("Maximum number of smf_ue%lld reached",
9
                     (long long)ogs_global_conf()->max.ue);
10
         return NULL;
11
     }
12
-    memset(smf_ue, 0, sizeof *smf_ue);
13
 
14
     ogs_list_init(&smf_ue->sess_list);
15
 
16
@@ -1074,7 +1073,7 @@
17
         ogs_hash_set(self.imsi_hash, smf_ue->imsi, smf_ue->imsi_len, NULL);
18
     }
19
 
20
-    ogs_pool_free(&smf_ue_pool, smf_ue);
21
+    ogs_pool_id_free(&smf_ue_pool, smf_ue);
22
 
23
     smf_metrics_inst_global_dec(SMF_METR_GLOB_GAUGE_UES_ACTIVE);
24
     ogs_info("Removed Number of SMF-UEs is now %d",
25
@@ -1200,13 +1199,12 @@
26
     ogs_assert(smf_ue);
27
     ogs_assert(apn);
28
 
29
-    ogs_pool_alloc(&smf_sess_pool, &sess);
30
+    ogs_pool_id_calloc(&smf_sess_pool, &sess);
31
     if (!sess) {
32
         ogs_error("Maximum number of session%lld reached",
33
                     (long long)ogs_app()->pool.sess);
34
         return NULL;
35
     }
36
-    memset(sess, 0, sizeof *sess);
37
 
38
     ogs_pfcp_pool_init(&sess->pfcp);
39
     smf_qfi_pool_init(sess);
40
@@ -1243,10 +1241,10 @@
41
     sess->epc = true;
42
 
43
     memset(&e, 0, sizeof(e));
44
-    e.sess = sess;
45
+    e.sess_id = sess->id;
46
     ogs_fsm_init(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final, &e);
47
 
48
-    sess->smf_ue = smf_ue;
49
+    sess->smf_ue_id = smf_ue->id;
50
 
51
     ogs_list_add(&smf_ue->sess_list, sess);
52
 
53
@@ -1412,13 +1410,12 @@
54
     ogs_assert(smf_ue);
55
     ogs_assert(psi != OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED);
56
 
57
-    ogs_pool_alloc(&smf_sess_pool, &sess);
58
+    ogs_pool_id_calloc(&smf_sess_pool, &sess);
59
     if (!sess) {
60
         ogs_error("Maximum number of session%lld reached",
61
             (long long)ogs_app()->pool.sess);
62
         return NULL;
63
     }
64
-    memset(sess, 0, sizeof *sess);
65
 
66
     /* SBI Features */
67
     OGS_SBI_FEATURES_SET(sess->smpolicycontrol_features,
68
@@ -1461,10 +1458,10 @@
69
     sess->charging.id = sess->index;
70
 
71
     memset(&e, 0, sizeof(e));
72
-    e.sess = sess;
73
+    e.sess_id = sess->id;
74
     ogs_fsm_init(&sess->sm, smf_gsm_state_initial, smf_gsm_state_final, &e);
75
 
76
-    sess->smf_ue = smf_ue;
77
+    sess->smf_ue_id = smf_ue->id;
78
 
79
     ogs_list_add(&smf_ue->sess_list, sess);
80
 
81
@@ -1528,7 +1525,7 @@
82
     uint8_t cause_value = OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
83
 
84
     ogs_assert(sess);
85
-    smf_ue = sess->smf_ue;
86
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
87
     ogs_assert(smf_ue);
88
 
89
     if (sess->session.session_type == OGS_PDU_SESSION_TYPE_IPV4V6) {
90
@@ -1675,7 +1672,7 @@
91
     char buf2OGS_ADDRSTRLEN;
92
 
93
     ogs_assert(sess);
94
-    smf_ue = sess->smf_ue;
95
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
96
     ogs_assert(smf_ue);
97
 
98
     ogs_info("Removed Session: UE IMSI:%s DNN:%s:%d IPv4:%s IPv6:%s",
99
@@ -1687,7 +1684,7 @@
100
     ogs_list_remove(&smf_ue->sess_list, sess);
101
 
102
     memset(&e, 0, sizeof(e));
103
-    e.sess = sess;
104
+    e.sess_id = sess->id;
105
     ogs_fsm_fini(&sess->sm, &e);
106
 
107
     OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco);
108
@@ -1799,7 +1796,7 @@
109
     stats_remove_smf_session(sess);
110
 
111
     ogs_pool_free(&smf_n4_seid_pool, sess->smf_n4_seid_node);
112
-    ogs_pool_free(&smf_sess_pool, sess);
113
+    ogs_pool_id_free(&smf_sess_pool, sess);
114
 }
115
 
116
 void smf_sess_remove_all(smf_ue_t *smf_ue)
117
@@ -1923,9 +1920,8 @@
118
 
119
     ogs_assert(sess);
120
 
121
-    ogs_pool_alloc(&smf_bearer_pool, &qos_flow);
122
+    ogs_pool_id_calloc(&smf_bearer_pool, &qos_flow);
123
     ogs_assert(qos_flow);
124
-    memset(qos_flow, 0, sizeof *qos_flow);
125
 
126
     smf_pf_identifier_pool_init(qos_flow);
127
 
128
@@ -2022,7 +2018,7 @@
129
 
130
     qos_flow->qfi = ul_pdr->qfi = qer->qfi = *(qos_flow->qfi_node);
131
 
132
-    qos_flow->sess = sess;
133
+    qos_flow->sess_id = sess->id;
134
 
135
     ogs_list_add(&sess->bearer_list, qos_flow);
136
     smf_metrics_inst_by_5qi_add(&sess->serving_plmn_id, &sess->s_nssai,
137
@@ -2364,9 +2360,8 @@
138
 
139
     ogs_assert(sess);
140
 
141
-    ogs_pool_alloc(&smf_bearer_pool, &bearer);
142
+    ogs_pool_id_calloc(&smf_bearer_pool, &bearer);
143
     ogs_assert(bearer);
144
-    memset(bearer, 0, sizeof *bearer);
145
 
146
     smf_pf_identifier_pool_init(bearer);
147
 
148
@@ -2435,7 +2430,7 @@
149
 
150
     ul_far->apply_action = OGS_PFCP_APPLY_ACTION_FORW;
151
 
152
-    bearer->sess = sess;
153
+    bearer->sess_id = sess->id;
154
 
155
     ogs_list_add(&sess->bearer_list, bearer);
156
 
157
@@ -2445,10 +2440,12 @@
158
 
159
 int smf_bearer_remove(smf_bearer_t *bearer)
160
 {
161
+    smf_sess_t *sess = NULL;
162
     ogs_assert(bearer);
163
-    ogs_assert(bearer->sess);
164
+    sess = smf_sess_find_by_id(bearer->sess_id);
165
+    ogs_assert(sess);
166
 
167
-    ogs_list_remove(&bearer->sess->bearer_list, bearer);
168
+    ogs_list_remove(&sess->bearer_list, bearer);
169
 
170
     ogs_assert(bearer->dl_pdr);
171
     ogs_pfcp_pdr_remove(bearer->dl_pdr);
172
@@ -2477,9 +2474,9 @@
173
     smf_pf_identifier_pool_final(bearer);
174
 
175
     if (SMF_IS_QOF_FLOW(bearer))
176
-        ogs_pool_free(&bearer->sess->qfi_pool, bearer->qfi_node);
177
+        ogs_pool_free(&sess->qfi_pool, bearer->qfi_node);
178
 
179
-    ogs_pool_free(&smf_bearer_pool, bearer);
180
+    ogs_pool_id_free(&smf_bearer_pool, bearer);
181
 
182
     smf_metrics_inst_global_dec(SMF_METR_GLOB_GAUGE_BEARERS_ACTIVE);
183
     return OGS_OK;
184
@@ -2614,7 +2611,7 @@
185
     ogs_pfcp_qer_t *qer = NULL;
186
 
187
     ogs_assert(bearer);
188
-    sess = bearer->sess;
189
+    sess = smf_sess_find_by_id(bearer->sess_id);
190
     ogs_assert(sess);
191
 
192
     dl_pdr = bearer->dl_pdr;
193
@@ -2644,24 +2641,29 @@
194
     return ogs_list_first(&sess->bearer_list);
195
 }
196
 
197
-smf_ue_t *smf_ue_cycle(smf_ue_t *smf_ue)
198
+smf_ue_t *smf_ue_find_by_id(ogs_pool_id_t id)
199
+{
200
+    return ogs_pool_find_by_id(&smf_ue_pool, id);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/context.h Changed
88
 
1
@@ -112,6 +112,7 @@
2
 
3
 typedef struct smf_ue_s {
4
     ogs_lnode_t lnode;
5
+    ogs_pool_id_t id;
6
 
7
     /* SUPI */
8
     char *supi;
9
@@ -138,7 +139,7 @@
10
     do { \
11
         smf_ue_t *smf_ue = NULL; \
12
         ogs_assert(__sESS); \
13
-        smf_ue = (__sESS)->smf_ue; \
14
+        smf_ue = smf_ue_find_by_id((__sESS)->smf_ue_id); \
15
         ogs_assert(smf_ue); \
16
         smf_metrics_inst_by_slice_add(&(__sESS)->serving_plmn_id, \
17
                 &(__sESS)->s_nssai, SMF_METR_GAUGE_SM_SESSIONNBR, -1); \
18
@@ -155,6 +156,8 @@
19
     ogs_lnode_t     lnode;
20
     ogs_lnode_t     to_add_node;
21
 
22
+    ogs_pool_id_t   id;
23
+
24
 ED3(uint8_t spare:2;,
25
     uint8_t direction:2;,
26
     uint8_t identifier:4;)
27
@@ -169,11 +172,12 @@
28
     ogs_ipfw_rule_t ipfw_rule;
29
     char *flow_description;
30
 
31
-    smf_bearer_t    *bearer;
32
+    ogs_pool_id_t bearer_id;
33
 } smf_pf_t;
34
 
35
 typedef struct smf_bearer_s {
36
     ogs_lnode_t     lnode;          /**< A node of list_t */
37
+    ogs_pool_id_t   id;
38
 
39
     ogs_lnode_t     to_modify_node;
40
     ogs_lnode_t     to_delete_node;
41
@@ -212,12 +216,13 @@
42
     uint8_t num_of_pf_to_delete;
43
     uint8_t pf_to_deleteOGS_MAX_NUM_OF_FLOW_IN_NAS;
44
 
45
-    smf_sess_t      *sess;
46
+    ogs_pool_id_t   sess_id;
47
 } smf_bearer_t;
48
 
49
 #define SMF_SESS(pfcp_sess) ogs_container_of(pfcp_sess, smf_sess_t, pfcp)
50
 typedef struct smf_sess_s {
51
     ogs_sbi_object_t sbi;
52
+    ogs_pool_id_t id;
53
 
54
     uint32_t        index;              /* An index of this node */
55
     ogs_pool_id_t   *smf_n4_seid_node;  /* A node of SMF-N4-SEID */
56
@@ -464,7 +469,7 @@
57
     ogs_gtp_node_t  *gnode;
58
     ogs_pfcp_node_t *pfcp_node;
59
 
60
-    smf_ue_t *smf_ue;
61
+    ogs_pool_id_t smf_ue_id;
62
 
63
     bool n1_released;
64
     bool n2_released;
65
@@ -544,15 +549,17 @@
66
 void smf_bearer_tft_update(smf_bearer_t *bearer);
67
 void smf_bearer_qos_update(smf_bearer_t *bearer);
68
 
69
-smf_ue_t *smf_ue_cycle(smf_ue_t *smf_ue);
70
-smf_sess_t *smf_sess_cycle(smf_sess_t *sess);
71
-smf_bearer_t *smf_qos_flow_cycle(smf_bearer_t *qos_flow);
72
-smf_bearer_t *smf_bearer_cycle(smf_bearer_t *bearer);
73
+smf_ue_t *smf_ue_find_by_id(ogs_pool_id_t id);
74
+smf_sess_t *smf_sess_find_by_id(ogs_pool_id_t id);
75
+smf_bearer_t *smf_bearer_find_by_id(ogs_pool_id_t id);
76
+smf_bearer_t *smf_qos_flow_find_by_id(ogs_pool_id_t id);
77
+smf_pf_t *smf_pf_find_by_id(ogs_pool_id_t id);
78
 
79
 smf_pf_t *smf_pf_add(smf_bearer_t *bearer);
80
 int smf_pf_remove(smf_pf_t *pf);
81
 void smf_pf_remove_all(smf_bearer_t *bearer);
82
-smf_pf_t *smf_pf_find_by_id(smf_bearer_t *smf_bearer, uint8_t id);
83
+smf_pf_t *smf_pf_find_by_identifier(
84
+        smf_bearer_t *bearer, uint8_t identifier);
85
 smf_pf_t *smf_pf_find_by_flow(
86
     smf_bearer_t *bearer, uint8_t direction, char *flow_description);
87
 smf_pf_t *smf_pf_first(smf_bearer_t *bearer);
88
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/event.h Changed
23
 
1
@@ -72,10 +72,10 @@
2
     ogs_pkbuf_t *pkbuf;
3
 
4
     smf_gtp_node_t *gnode;
5
-    ogs_gtp_xact_t *gtp_xact;
6
+    ogs_pool_id_t gtp_xact_id;
7
 
8
     ogs_pfcp_node_t *pfcp_node;
9
-    ogs_pfcp_xact_t *pfcp_xact;
10
+    ogs_pool_id_t pfcp_xact_id;
11
     ogs_pfcp_message_t *pfcp_message;
12
 
13
     union {
14
@@ -99,7 +99,7 @@
15
         ogs_nas_5gs_message_t *message;
16
     } nas;
17
 
18
-    smf_sess_t *sess;
19
+    ogs_pool_id_t sess_id;
20
 } smf_event_t;
21
 
22
 OGS_STATIC_ASSERT(OGS_EVENT_SIZE >= sizeof(smf_event_t));
23
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/fd-path.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/fd-path.h Changed
13
 
1
@@ -38,9 +38,9 @@
2
 int smf_s6b_init(void);
3
 void smf_s6b_final(void);
4
 
5
-void smf_gx_send_ccr(smf_sess_t *sess, ogs_gtp_xact_t *xact,
6
+void smf_gx_send_ccr(smf_sess_t *sess, ogs_pool_id_t xact_id,
7
         uint32_t cc_request_type);
8
-void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
9
+void smf_gy_send_ccr(smf_sess_t *sess, ogs_pool_id_t xact_id,
10
         uint32_t cc_request_type);
11
 
12
 void smf_s6b_send_aar(smf_sess_t *sess, ogs_gtp_xact_t *xact);
13
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gn-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gn-handler.c Changed
37
 
1
@@ -118,7 +118,7 @@
2
     if (cause_value != OGS_GTP1_CAUSE_REQUEST_ACCEPTED)
3
         return cause_value;
4
 
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
 
9
     /* Store NSAPI */
10
@@ -383,7 +383,7 @@
11
     }
12
 
13
     ogs_assert(sess);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
 
18
     ogs_debug("    SGW_S5C_TEID0x%x SMF_N4_TEID0x%x",
19
@@ -485,7 +485,7 @@
20
     h.teid = sess->sgw_s5c_teid;
21
 
22
     /* Set bearer so it's accessible later when handling PFCP Session Modification Response */
23
-    xact->data = bearer;
24
+    xact->data = OGS_UINT_TO_POINTER(bearer->id);
25
 
26
     /* Update remote TEID and GTP-U IP address on the UPF. UpdatePDPContextResp
27
      * will be sent when UPF answers back this request
28
@@ -509,7 +509,7 @@
29
         }
30
     }
31
 
32
-    rv = smf_epc_pfcp_send_all_pdr_modification_request(sess, xact, NULL,
33
+    rv = smf_epc_pfcp_send_all_pdr_modification_request(sess, xact->id, NULL,
34
             OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE,
35
             OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
36
             OGS_GTP1_CAUSE_REACTIACTION_REQUESTED);
37
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gsm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gsm-handler.c Changed
37
 
1
@@ -212,7 +212,7 @@
2
     ogs_pkbuf_t *n1smbuf = NULL;
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(stream);
9
     ogs_assert(pdu_session_modification_request);
10
@@ -256,7 +256,7 @@
11
                 for (j = 0; j < qos_rulei.num_of_packet_filter &&
12
                             j < OGS_MAX_NUM_OF_FLOW_IN_NAS; j++) {
13
 
14
-                    pf = smf_pf_find_by_id(
15
+                    pf = smf_pf_find_by_identifier(
16
                             qos_flow, qos_rulei.pfj.identifier+1);
17
                     if (pf) {
18
                         ogs_assert(
19
@@ -328,7 +328,7 @@
20
                 for (j = 0; j < qos_rulei.num_of_packet_filter &&
21
                             j < OGS_MAX_NUM_OF_FLOW_IN_NAS; j++) {
22
 
23
-                    pf = smf_pf_find_by_id(
24
+                    pf = smf_pf_find_by_identifier(
25
                             qos_flow, qos_rulei.pfj.identifier+1);
26
                     if (!pf)
27
                         pf = smf_pf_add(qos_flow);
28
@@ -405,7 +405,7 @@
29
                 for (j = 0; j < qos_rulei.num_of_packet_filter &&
30
                             j < OGS_MAX_NUM_OF_FLOW_IN_NAS; j++) {
31
 
32
-                    pf = smf_pf_find_by_id(
33
+                    pf = smf_pf_find_by_identifier(
34
                             qos_flow, qos_rulei.pfj.identifier+1);
35
                     if (pf) {
36
                         qos_flow->pf_to_delete
37
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gsm-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gsm-sm.c Changed
201
 
1
@@ -1,6 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
-
5
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
6
  *
7
  * This file is part of Open5GS.
8
  *
9
@@ -89,7 +88,7 @@
10
             OGS_GTP2_DELETE_SESSION_RESPONSE_TYPE, gtp_cause);
11
 }
12
 
13
-static bool send_ccr_init_req_gx_gy(smf_sess_t *sess, smf_event_t *e)
14
+static bool send_ccr_init_req_gx_gy(smf_sess_t *sess, ogs_gtp_xact_t *gtp_xact)
15
 {
16
     int use_gy = smf_use_gy_iface();
17
 
18
@@ -97,28 +96,31 @@
19
         ogs_error("No Gy Diameter Peer");
20
         /* TODO: drop Gx connection here,
21
          * possibly move to another "releasing" state! */
22
-        uint8_t gtp_cause = (e->gtp_xact->gtp_version == 1) ?
23
+        uint8_t gtp_cause = (gtp_xact->gtp_version == 1) ?
24
                 OGS_GTP1_CAUSE_NO_RESOURCES_AVAILABLE :
25
                 OGS_GTP2_CAUSE_UE_NOT_AUTHORISED_BY_OCS_OR_EXTERNAL_AAA_SERVER;
26
-        send_gtp_create_err_msg(sess, e->gtp_xact, gtp_cause);
27
+        send_gtp_create_err_msg(sess, gtp_xact, gtp_cause);
28
         return false;
29
     }
30
 
31
     sess->sm_data.gx_ccr_init_in_flight = true;
32
-    smf_gx_send_ccr(sess, e->gtp_xact,
33
-        OGS_DIAM_GX_CC_REQUEST_TYPE_INITIAL_REQUEST);
34
+    smf_gx_send_ccr(
35
+            sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID,
36
+            OGS_DIAM_GX_CC_REQUEST_TYPE_INITIAL_REQUEST);
37
 
38
     if (use_gy == 1) {
39
         /* Gy is available,
40
          * set up session for the bearer before accepting it towards the UE */
41
         sess->sm_data.gy_ccr_init_in_flight = true;
42
-        smf_gy_send_ccr(sess, e->gtp_xact,
43
-            OGS_DIAM_GY_CC_REQUEST_TYPE_INITIAL_REQUEST);
44
+        smf_gy_send_ccr(
45
+                sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID,
46
+                OGS_DIAM_GY_CC_REQUEST_TYPE_INITIAL_REQUEST);
47
     }
48
     return true;
49
 }
50
 
51
-static bool send_ccr_termination_req_gx_gy_s6b(smf_sess_t *sess, smf_event_t *e)
52
+static bool send_ccr_termination_req_gx_gy_s6b(
53
+        smf_sess_t *sess, ogs_gtp_xact_t *gtp_xact)
54
 {
55
     /* TODO: we should take into account here whether "sess" has an active Gy
56
        session created, not whether one was supposedly created as per policy */
57
@@ -128,29 +130,31 @@
58
         ogs_error("No Gy Diameter Peer");
59
         /* TODO: drop Gx connection here,
60
          * possibly move to another "releasing" state! */
61
-        uint8_t gtp_cause = (e->gtp_xact->gtp_version == 1) ?
62
+        uint8_t gtp_cause = (gtp_xact->gtp_version == 1) ?
63
                 OGS_GTP1_CAUSE_NO_RESOURCES_AVAILABLE :
64
                 OGS_GTP2_CAUSE_UE_NOT_AUTHORISED_BY_OCS_OR_EXTERNAL_AAA_SERVER;
65
-        send_gtp_delete_err_msg(sess, e->gtp_xact, gtp_cause);
66
+        send_gtp_delete_err_msg(sess, gtp_xact, gtp_cause);
67
         return false;
68
     }
69
 
70
     if (sess->gtp_rat_type == OGS_GTP2_RAT_TYPE_WLAN) {
71
         sess->sm_data.s6b_str_in_flight = true;
72
-        smf_s6b_send_str(sess, e->gtp_xact,
73
+        smf_s6b_send_str(sess, gtp_xact,
74
             OGS_DIAM_TERMINATION_CAUSE_DIAMETER_LOGOUT);
75
     }
76
 
77
     sess->sm_data.gx_ccr_term_in_flight = true;
78
-    smf_gx_send_ccr(sess, e->gtp_xact,
79
-        OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST);
80
+    smf_gx_send_ccr(
81
+            sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID,
82
+            OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST);
83
 
84
     if (use_gy == 1) {
85
         /* Gy is available,
86
          * set up session for the bearer before accepting it towards the UE */
87
         sess->sm_data.gy_ccr_term_in_flight = true;
88
-        smf_gy_send_ccr(sess, e->gtp_xact,
89
-            OGS_DIAM_GY_CC_REQUEST_TYPE_TERMINATION_REQUEST);
90
+        smf_gy_send_ccr(
91
+                sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID,
92
+                OGS_DIAM_GY_CC_REQUEST_TYPE_TERMINATION_REQUEST);
93
     }
94
     return true;
95
 }
96
@@ -165,10 +169,12 @@
97
     ogs_gtp1_message_t *gtp1_message = NULL;
98
     ogs_gtp2_message_t *gtp2_message = NULL;
99
     uint8_t gtp1_cause, gtp2_cause;
100
+    ogs_gtp_xact_t *gtp_xact = NULL;
101
 
102
     ogs_nas_5gs_message_t *nas_message = NULL;
103
 
104
     ogs_sbi_stream_t *stream = NULL;
105
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
106
     ogs_sbi_message_t *sbi_message = NULL;
107
 
108
     ogs_assert(s);
109
@@ -176,7 +182,7 @@
110
 
111
     smf_sm_debug(e);
112
 
113
-    sess = e->sess;
114
+    sess = smf_sess_find_by_id(e->sess_id);
115
     ogs_assert(sess);
116
 
117
     switch (e->h.id) {
118
@@ -196,17 +202,18 @@
119
     case SMF_EVT_GN_MESSAGE:
120
         gtp1_message = e->gtp1_message;
121
         ogs_assert(gtp1_message);
122
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
123
 
124
         switch(gtp1_message->h.type) {
125
         case OGS_GTP1_CREATE_PDP_CONTEXT_REQUEST_TYPE:
126
             gtp1_cause = smf_gn_handle_create_pdp_context_request(sess,
127
-                            e->gtp_xact,
128
+                            gtp_xact,
129
                             &e->gtp1_message->create_pdp_context_request);
130
             if (gtp1_cause != OGS_GTP1_CAUSE_REQUEST_ACCEPTED) {
131
-                send_gtp_create_err_msg(sess, e->gtp_xact, gtp1_cause);
132
+                send_gtp_create_err_msg(sess, gtp_xact, gtp1_cause);
133
                 return;
134
             }
135
-            if (send_ccr_init_req_gx_gy(sess, e) == true)
136
+            if (send_ccr_init_req_gx_gy(sess, gtp_xact) == true)
137
                 OGS_FSM_TRAN(s, smf_gsm_state_wait_epc_auth_initial);
138
         }
139
         break;
140
@@ -214,23 +221,24 @@
141
     case SMF_EVT_S5C_MESSAGE:
142
         gtp2_message = e->gtp2_message;
143
         ogs_assert(gtp2_message);
144
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
145
 
146
         switch(gtp2_message->h.type) {
147
         case OGS_GTP2_CREATE_SESSION_REQUEST_TYPE:
148
             gtp2_cause = smf_s5c_handle_create_session_request(sess,
149
-                            e->gtp_xact,
150
+                            gtp_xact,
151
                             &e->gtp2_message->create_session_request);
152
             if (gtp2_cause != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
153
-                send_gtp_create_err_msg(sess, e->gtp_xact, gtp2_cause);
154
+                send_gtp_create_err_msg(sess, gtp_xact, gtp2_cause);
155
                 return;
156
             }
157
             switch (sess->gtp_rat_type) {
158
             case OGS_GTP2_RAT_TYPE_EUTRAN:
159
-                if (send_ccr_init_req_gx_gy(sess, e) == true)
160
+                if (send_ccr_init_req_gx_gy(sess, gtp_xact) == true)
161
                     OGS_FSM_TRAN(s, smf_gsm_state_wait_epc_auth_initial);
162
                 break;
163
             case OGS_GTP2_RAT_TYPE_WLAN:
164
-                smf_s6b_send_aar(sess, e->gtp_xact);
165
+                smf_s6b_send_aar(sess, gtp_xact);
166
                 sess->sm_data.s6b_aar_in_flight = true;
167
                 OGS_FSM_TRAN(s, smf_gsm_state_wait_epc_auth_initial);
168
                 /* Gx/Gy Init Req is done after s6b AAR + AAA */
169
@@ -249,8 +257,16 @@
170
     case OGS_EVENT_SBI_SERVER:
171
         sbi_message = e->h.sbi.message;
172
         ogs_assert(sbi_message);
173
-        stream = e->h.sbi.data;
174
-        ogs_assert(stream);
175
+
176
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
177
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
178
+                stream_id <= OGS_MAX_POOL_ID);
179
+
180
+        stream = ogs_sbi_stream_find_by_id(stream_id);
181
+        if (!stream) {
182
+            ogs_error("STREAM has already been removed %d", stream_id);
183
+            break;
184
+        }
185
 
186
         SWITCH(sbi_message->h.service.name)
187
         CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)
188
@@ -289,11 +305,19 @@
189
     case SMF_EVT_5GSM_MESSAGE:
190
         nas_message = e->nas.message;
191
         ogs_assert(nas_message);
192
-        stream = e->h.sbi.data;
193
-        ogs_assert(stream);
194
-        smf_ue = sess->smf_ue;
195
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
196
         ogs_assert(smf_ue);
197
 
198
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
199
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
200
+                stream_id <= OGS_MAX_POOL_ID);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gtp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gtp-path.c Changed
97
 
1
@@ -369,7 +369,7 @@
2
     smf_sess_t *sess = NULL;
3
 
4
     ogs_assert(bearer);
5
-    sess = bearer->sess;
6
+    sess = smf_sess_find_by_id(bearer->sess_id);
7
     ogs_assert(sess);
8
 
9
     memset(&h, 0, sizeof(ogs_gtp1_header_t));
10
@@ -384,7 +384,8 @@
11
     }
12
 
13
     xact = ogs_gtp1_xact_local_create(
14
-            sess->gnode, &h, pkbuf, bearer_timeout, bearer);
15
+            sess->gnode, &h, pkbuf, bearer_timeout,
16
+            OGS_UINT_TO_POINTER(bearer->id));
17
     if (!xact) {
18
         ogs_error("ogs_gtp1_xact_local_create() failed");
19
         return OGS_ERROR;
20
@@ -409,7 +410,7 @@
21
 
22
     ogs_assert(bearer);
23
     ogs_assert(xact);
24
-    sess = bearer->sess;
25
+    sess = smf_sess_find_by_id(bearer->sess_id);
26
     ogs_assert(sess);
27
 
28
     memset(&h, 0, sizeof(ogs_gtp1_header_t));
29
@@ -546,7 +547,7 @@
30
     smf_sess_t *sess = NULL;
31
 
32
     ogs_assert(bearer);
33
-    sess = bearer->sess;
34
+    sess = smf_sess_find_by_id(bearer->sess_id);
35
     ogs_assert(sess);
36
 
37
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
38
@@ -561,7 +562,8 @@
39
     }
40
 
41
     xact = ogs_gtp_xact_local_create(
42
-            sess->gnode, &h, pkbuf, bearer_timeout, bearer);
43
+            sess->gnode, &h, pkbuf, bearer_timeout,
44
+            OGS_UINT_TO_POINTER(bearer->id));
45
     if (!xact) {
46
         ogs_error("ogs_gtp_xact_local_create() failed");
47
         return OGS_ERROR;
48
@@ -730,30 +732,36 @@
49
 
50
 static void bearer_timeout(ogs_gtp_xact_t *xact, void *data)
51
 {
52
-    smf_bearer_t *bearer = data;
53
+    smf_bearer_t *bearer = NULL;
54
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
55
     smf_sess_t *sess = NULL;
56
     smf_ue_t *smf_ue = NULL;
57
     uint8_t type = 0;
58
 
59
-    ogs_assert(bearer);
60
-    sess = bearer->sess;
61
+    ogs_assert(xact);
62
+    type = xact->seq0.type;
63
+
64
+    ogs_assert(data);
65
+    bearer_id = OGS_POINTER_TO_UINT(data);
66
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
67
+
68
+    bearer = smf_bearer_find_by_id(bearer_id);
69
+    if (!bearer) {
70
+        ogs_error("Bearer has already been removed %d", type);
71
+        return;
72
+    }
73
+
74
+    sess = smf_sess_find_by_id(bearer->sess_id);
75
     ogs_assert(sess);
76
-    smf_ue = sess->smf_ue;
77
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
78
     ogs_assert(smf_ue);
79
 
80
-    type = xact->seq0.type;
81
-
82
     switch (type) {
83
     case OGS_GTP2_DELETE_BEARER_REQUEST_TYPE:
84
         ogs_error("%s No Delete Bearer Response", smf_ue->imsi_bcd);
85
-        if (!smf_bearer_cycle(bearer)) {
86
-            ogs_warn("%s Bearer has already been removed", smf_ue->imsi_bcd);
87
-            break;
88
-        }
89
-
90
         ogs_assert(OGS_OK ==
91
             smf_epc_pfcp_send_one_bearer_modification_request(
92
-                bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
93
+                bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
94
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
95
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
96
         break;
97
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gx-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gx-path.c Changed
92
 
1
@@ -29,10 +29,10 @@
2
     os0_t       peer_host;          /* Peer Host */
3
 
4
 #define NUM_CC_REQUEST_SLOT 4
5
-    smf_sess_t *sess;
6
+    ogs_pool_id_t sess_id;
7
     struct {
8
         uint32_t cc_req_no;
9
-        ogs_gtp_xact_t *ptr;
10
+        ogs_pool_id_t id;
11
     } xact_dataNUM_CC_REQUEST_SLOT;
12
 
13
     uint32_t cc_request_type;
14
@@ -88,7 +88,7 @@
15
 }
16
 
17
 /* 3GPP TS 29.212 5.6.2 Credit-Control-Request */
18
-void smf_gx_send_ccr(smf_sess_t *sess, ogs_gtp_xact_t *xact,
19
+void smf_gx_send_ccr(smf_sess_t *sess, ogs_pool_id_t xact_id,
20
         uint32_t cc_request_type)
21
 {
22
     int ret;
23
@@ -112,7 +112,7 @@
24
     ogs_assert(sess);
25
 
26
     ogs_assert(sess->ipv4 || sess->ipv6);
27
-    smf_ue = sess->smf_ue;
28
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
29
     ogs_assert(smf_ue);
30
 
31
     ogs_debug("Credit-Control-Request");
32
@@ -198,9 +198,9 @@
33
         sess_data->cc_request_type, sess_data->cc_request_number);
34
 
35
     /* Update session state */
36
-    sess_data->sess = sess;
37
+    sess_data->sess_id = sess->id;
38
     req_slot = sess_data->cc_request_number % NUM_CC_REQUEST_SLOT;
39
-    sess_data->xact_datareq_slot.ptr = xact;
40
+    sess_data->xact_datareq_slot.id = xact_id;
41
     sess_data->xact_datareq_slot.cc_req_no = sess_data->cc_request_number;
42
 
43
     /* Set Origin-Host & Origin-Realm */
44
@@ -718,7 +718,6 @@
45
     int new;
46
     struct msg *req = NULL;
47
     smf_event_t *e = NULL;
48
-    ogs_gtp_xact_t *xact = NULL;
49
     smf_sess_t *sess = NULL;
50
     ogs_diam_gx_message_t *gx_message = NULL;
51
     uint32_t req_slot, cc_request_number = 0;
52
@@ -767,8 +766,7 @@
53
 
54
     ogs_debug("    CC-Request-Number%d", cc_request_number);
55
 
56
-    xact = sess_data->xact_datareq_slot.ptr;
57
-    sess = sess_data->sess;
58
+    sess = smf_sess_find_by_id(sess_data->sess_id);
59
     ogs_assert(sess_data->xact_datareq_slot.cc_req_no == cc_request_number);
60
     ogs_assert(sess);
61
 
62
@@ -1039,9 +1037,9 @@
63
         e = smf_event_new(SMF_EVT_GX_MESSAGE);
64
         ogs_assert(e);
65
 
66
-        e->sess = sess;
67
+        e->sess_id = sess->id;
68
         e->gx_message = gx_message;
69
-        e->gtp_xact = xact;
70
+        e->gtp_xact_id = sess_data->xact_datareq_slot.id;
71
         rv = ogs_queue_push(ogs_app()->queue, e);
72
         if (rv != OGS_OK) {
73
             ogs_error("ogs_queue_push() failed:%d", (int)rv);
74
@@ -1166,7 +1164,7 @@
75
     }
76
 
77
     /* Get Session Information */
78
-    sess = sess_data->sess;
79
+    sess = smf_sess_find_by_id(sess_data->sess_id);
80
     ogs_assert(sess);
81
 
82
     ret = fd_msg_browse(qry, MSG_BRW_FIRST_CHILD, &avp, NULL);
83
@@ -1283,7 +1281,7 @@
84
     e = smf_event_new(SMF_EVT_GX_MESSAGE);
85
     ogs_assert(e);
86
 
87
-    e->sess = sess;
88
+    e->sess_id = sess->id;
89
     e->gx_message = gx_message;
90
     rv = ogs_queue_push(ogs_app()->queue, e);
91
     if (rv != OGS_OK) {
92
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gy-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gy-handler.c Changed
10
 
1
@@ -257,7 +257,7 @@
2
     if (modify_flags) {
3
         modify_flags |= OGS_PFCP_MODIFY_URR|OGS_PFCP_MODIFY_UL_ONLY;
4
         rv = smf_epc_pfcp_send_all_pdr_modification_request(
5
-                sess, pfcp_xact, NULL, modify_flags,
6
+                sess, OGS_INVALID_POOL_ID, NULL, modify_flags,
7
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
8
                 OGS_GTP1_CAUSE_REACTIACTION_REQUESTED);
9
         ogs_assert(rv == OGS_OK);
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/gy-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/gy-path.c Changed
140
 
1
@@ -31,11 +31,11 @@
2
 
3
 #define NUM_CC_REQUEST_SLOT 4
4
 
5
-    smf_sess_t *sess;
6
+    ogs_pool_id_t sess_id;
7
     struct {
8
         uint32_t cc_req_no;
9
         bool pfcp;
10
-        void *ptr; /* INITIAL: ogs_gtp_xact_t, UPDATE: ogs_pfcp_xact_t */
11
+        ogs_pool_id_t id; /* INITIAL: ogs_gtp_xact_t, UPDATE: ogs_pfcp_xact_t */
12
     } xact_dataNUM_CC_REQUEST_SLOT;
13
     uint32_t cc_request_type;
14
     uint32_t cc_request_number;
15
@@ -345,6 +345,12 @@
16
     char bufOGS_PLMNIDSTRLEN;
17
     char digit;
18
 
19
+    smf_ue_t *smf_ue = NULL;
20
+
21
+    ogs_assert(sess);
22
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
23
+    ogs_assert(smf_ue);
24
+
25
     /* PS-Information, TS 32.299 sec 7.2.158 */
26
     ret = fd_msg_avp_new(ogs_diam_gy_ps_information, 0, &avpch1);
27
     ogs_assert(ret == 0);
28
@@ -555,7 +561,7 @@
29
     ret = fd_msg_avp_add(avpch1, MSG_BRW_LAST_CHILD, avpch2);
30
     ogs_assert(ret == 0);
31
 
32
-    if (sess->smf_ue->imeisv_len > 0) {
33
+    if (smf_ue->imeisv_len > 0) {
34
         /* User-Equipment-Info, 3GPP TS 32.299 7.1.17 */
35
         ret = fd_msg_avp_new(ogs_diam_gy_user_equipment_info, 0, &avpch2);
36
 
37
@@ -572,7 +578,7 @@
38
         ret = fd_msg_avp_new(ogs_diam_gy_user_equipment_info_value, 0, &avpch3);
39
         ogs_assert(ret == 0);
40
         digit = '0';
41
-        val.os.data = (uint8_t*)&sess->smf_ue->imeisv_bcd0;
42
+        val.os.data = (uint8_t*)&smf_ue->imeisv_bcd0;
43
         val.os.len = 16;
44
         ret = fd_msg_avp_setvalue(avpch3, &val);
45
         ogs_assert(ret == 0);
46
@@ -610,7 +616,7 @@
47
 }
48
 
49
 /* 3GPP TS 32.299  6.4.2 Credit-Control-Request message */
50
-void smf_gy_send_ccr(smf_sess_t *sess, void *xact,
51
+void smf_gy_send_ccr(smf_sess_t *sess, ogs_pool_id_t xact_id,
52
         uint32_t cc_request_type)
53
 {
54
 
55
@@ -630,7 +636,7 @@
56
     ogs_assert(sess);
57
 
58
     ogs_assert(sess->ipv4 || sess->ipv6);
59
-    smf_ue = sess->smf_ue;
60
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
61
     ogs_assert(smf_ue);
62
 
63
     ogs_debug("GyCredit-Control-Request");
64
@@ -713,14 +719,14 @@
65
         sess_data->cc_request_type, sess_data->cc_request_number);
66
 
67
     /* Update session state */
68
-    sess_data->sess = sess;
69
+    sess_data->sess_id = sess->id;
70
     req_slot = sess_data->cc_request_number % NUM_CC_REQUEST_SLOT;
71
     if (cc_request_type == OGS_DIAM_GY_CC_REQUEST_TYPE_UPDATE_REQUEST)
72
         sess_data->xact_datareq_slot.pfcp = true;
73
     else
74
         sess_data->xact_datareq_slot.pfcp = false;
75
     sess_data->xact_datareq_slot.cc_req_no = sess_data->cc_request_number;
76
-    sess_data->xact_datareq_slot.ptr = xact;
77
+    sess_data->xact_datareq_slot.id = xact_id;
78
 
79
 
80
     /* Origin-Host & Origin-Realm */
81
@@ -958,7 +964,6 @@
82
     int new;
83
     struct msg *req = NULL;
84
     smf_event_t *e = NULL;
85
-    void *xact = NULL;
86
     smf_sess_t *sess = NULL;
87
     ogs_diam_gy_message_t *gy_message = NULL;
88
     uint32_t req_slot, cc_request_number = 0;
89
@@ -1007,9 +1012,8 @@
90
 
91
     ogs_debug("    CC-Request-Number%d", cc_request_number);
92
 
93
-    xact = sess_data->xact_datareq_slot.ptr;
94
     ogs_assert(sess_data->xact_datareq_slot.cc_req_no == cc_request_number);
95
-    sess = sess_data->sess;
96
+    sess = smf_sess_find_by_id(sess_data->sess_id);
97
     ogs_assert(sess);
98
 
99
     gy_message = ogs_calloc(1, sizeof(ogs_diam_gy_message_t));
100
@@ -1175,15 +1179,13 @@
101
         e = smf_event_new(SMF_EVT_GY_MESSAGE);
102
         ogs_assert(e);
103
 
104
-        e->sess = sess;
105
+        e->sess_id = sess->id;
106
         e->gy_message = gy_message;
107
-        if (gy_message->cc_request_type == OGS_DIAM_GY_CC_REQUEST_TYPE_UPDATE_REQUEST) {
108
-            ogs_assert(sess_data->xact_datareq_slot.pfcp == true);
109
-            e->pfcp_xact = xact;
110
-        } else {
111
-            ogs_assert(sess_data->xact_datareq_slot.pfcp == false);
112
-            e->gtp_xact = xact;
113
-        }
114
+        if (sess_data->xact_datareq_slot.pfcp == true)
115
+            e->pfcp_xact_id = sess_data->xact_datareq_slot.id;
116
+        else
117
+            e->gtp_xact_id = sess_data->xact_datareq_slot.id;
118
+
119
         rv = ogs_queue_push(ogs_app()->queue, e);
120
         if (rv != OGS_OK) {
121
             ogs_error("ogs_queue_push() failed:%d", (int)rv);
122
@@ -1302,7 +1304,7 @@
123
     }
124
 
125
     /* Get Session Information */
126
-    sess = sess_data->sess;
127
+    sess = smf_sess_find_by_id(sess_data->sess_id);
128
     ogs_assert(sess);
129
 
130
     /* TODO: parsing of msg into gy_message */
131
@@ -1311,7 +1313,7 @@
132
     e = smf_event_new(SMF_EVT_GY_MESSAGE);
133
     ogs_assert(e);
134
 
135
-    e->sess = sess;
136
+    e->sess_id = sess->id;
137
     e->gy_message = gy_message;
138
     rv = ogs_queue_push(ogs_app()->queue, e);
139
     if (rv != OGS_OK) {
140
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/n4-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/n4-build.c Changed
10
 
1
@@ -44,7 +44,7 @@
2
 
3
     ogs_debug("Session Establishment Request");
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(xact);
9
 
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/n4-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/n4-handler.c Changed
127
 
1
@@ -258,15 +258,16 @@
2
     ogs_assert(flags);
3
 
4
     /* 'stream' could be NULL in smf_qos_flow_binding() */
5
-    stream = xact->assoc_stream;
6
+    if (xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
7
+            xact->assoc_stream_id <= OGS_MAX_POOL_ID)
8
+        stream = ogs_sbi_stream_find_by_id(xact->assoc_stream_id);
9
 
10
     if (flags & OGS_PFCP_MODIFY_SESSION) {
11
         /* If smf_5gc_pfcp_send_all_pdr_modification_request() is called */
12
 
13
     } else {
14
         /* If smf_5gc_pfcp_send_qos_flow_modification_request() is called */
15
-        qos_flow = xact->data;
16
-        ogs_assert(qos_flow);
17
+        qos_flow = smf_qos_flow_find_by_id(OGS_POINTER_TO_UINT(xact->data));
18
     }
19
 
20
     ogs_list_copy(&pdr_to_create_list, &xact->pdr_to_create_list);
21
@@ -494,10 +495,12 @@
22
 
23
             ogs_list_for_each_entry_safe(&sess->qos_flow_to_modify_list,
24
                     next, qos_flow, to_modify_node) {
25
+                smf_sess_t *sess = smf_sess_find_by_id(qos_flow->sess_id);
26
+                ogs_assert(sess);
27
                 smf_metrics_inst_by_5qi_add(
28
-                        &qos_flow->sess->serving_plmn_id,
29
-                        &qos_flow->sess->s_nssai,
30
-                        qos_flow->sess->session.qos.index,
31
+                        &sess->serving_plmn_id,
32
+                        &sess->s_nssai,
33
+                        sess->session.qos.index,
34
                         SMF_METR_GAUGE_SM_QOSFLOWNBR, -1);
35
                 smf_bearer_remove(qos_flow);
36
             }
37
@@ -526,10 +529,12 @@
38
 
39
             ogs_list_for_each_entry_safe(&sess->qos_flow_to_modify_list,
40
                     next, qos_flow, to_modify_node) {
41
+                smf_sess_t *sess = smf_sess_find_by_id(qos_flow->sess_id);
42
+                ogs_assert(sess);
43
                 smf_metrics_inst_by_5qi_add(
44
-                        &qos_flow->sess->serving_plmn_id,
45
-                        &qos_flow->sess->s_nssai,
46
-                        qos_flow->sess->session.qos.index,
47
+                        &sess->serving_plmn_id,
48
+                        &sess->s_nssai,
49
+                        sess->session.qos.index,
50
                         SMF_METR_GAUGE_SM_QOSFLOWNBR, -1);
51
                 smf_bearer_remove(qos_flow);
52
             }
53
@@ -855,8 +860,7 @@
54
         /* If smf_epc_pfcp_send_pdr_modification_request() is called */
55
     } else {
56
         /* If smf_epc_pfcp_send_bearer_modification_request() is called */
57
-        bearer = xact->data;
58
-        ogs_assert(bearer);
59
+        bearer = smf_bearer_find_by_id(OGS_POINTER_TO_UINT(xact->data));
60
     }
61
     flags = xact->modify_flags;
62
     ogs_assert(flags);
63
@@ -865,7 +869,7 @@
64
        PFCP Session Report Request, xact->assoc_xact is not a gtp_xact. No
65
        need to do anything. */
66
     if (!(flags & OGS_PFCP_MODIFY_URR)) {
67
-        gtp_xact = xact->assoc_xact;
68
+        gtp_xact = ogs_gtp_xact_find_by_id(xact->assoc_xact_id);
69
         gtp_pti = xact->gtp_pti;
70
         gtp_cause = xact->gtp_cause;
71
     }
72
@@ -1003,7 +1007,7 @@
73
          *
74
          * To do this, I saved Bearer Context in Transaction Context.
75
          */
76
-            gtp_xact->data = bearer;
77
+            gtp_xact->data = OGS_UINT_TO_POINTER(bearer->id);
78
 
79
             rv = ogs_gtp_xact_commit(gtp_xact);
80
             ogs_expect(rv == OGS_OK);
81
@@ -1057,9 +1061,15 @@
82
 
83
             /* SMF send Update PDP Context Response (GTPv1C) to SGSN */
84
             if (gtp_xact->gtp_version == 1) {
85
+                ogs_pool_id_t bearer_id = OGS_POINTER_TO_UINT(gtp_xact->data);
86
 
87
-                bearer = gtp_xact->data;
88
-                smf_gtp1_send_update_pdp_context_response(bearer, gtp_xact);
89
+                ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
90
+                        bearer_id <= OGS_MAX_POOL_ID);
91
+                bearer = smf_bearer_find_by_id(bearer_id);
92
+                if (bearer)
93
+                    smf_gtp1_send_update_pdp_context_response(bearer, gtp_xact);
94
+                else
95
+                    ogs_error("Bearer has already been removed");
96
 
97
             } else {
98
 
99
@@ -1191,7 +1201,7 @@
100
     }
101
 
102
     ogs_assert(sess);
103
-    smf_ue = sess->smf_ue;
104
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
105
     ogs_assert(smf_ue);
106
 
107
     report_type.value = pfcp_req->report_type.u8;
108
@@ -1337,7 +1347,8 @@
109
         switch (smf_use_gy_iface()) {
110
         case 1:
111
             if (!sess->gy.final_unit) {
112
-                smf_gy_send_ccr(sess, pfcp_xact,
113
+                smf_gy_send_ccr(
114
+                        sess, pfcp_xact->id,
115
                         OGS_DIAM_GY_CC_REQUEST_TYPE_UPDATE_REQUEST);
116
             } else {
117
                 ogs_debug("%s:%s Rx PFCP report after Gy Final Unit Indication",
118
@@ -1376,7 +1387,7 @@
119
                 smf_ue->imsi_bcd, sess->session.name);
120
             ogs_assert(OGS_OK ==
121
                 smf_epc_pfcp_send_session_deletion_request(
122
-                    sess, NULL));
123
+                    sess, OGS_INVALID_POOL_ID));
124
         } else {
125
             ogs_warn("%s:%s Error Indication from gNB",
126
                 smf_ue->supi, sess->session.name);
127
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/namf-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/namf-build.c Changed
10
 
1
@@ -44,7 +44,7 @@
2
     OpenAPI_ref_to_binary_data_t ngapData;
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(smf_ue->supi);
9
 
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/namf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/namf-handler.c Changed
10
 
1
@@ -29,7 +29,7 @@
2
     OpenAPI_n1_n2_message_transfer_rsp_data_t *N1N2MessageTransferRspData;
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(state);
9
     ogs_assert(recvmsg);
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/nas-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/nas-path.c Changed
21
 
1
@@ -30,9 +30,17 @@
2
 
3
     e = smf_event_new(SMF_EVT_5GSM_MESSAGE);
4
     ogs_assert(e);
5
-    e->sess = sess;
6
-    e->h.sbi.data = stream;
7
+
8
+    e->sess_id = sess->id;
9
     e->pkbuf = pkbuf;
10
+
11
+    if (stream) {
12
+        ogs_pool_id_t stream_id = ogs_sbi_id_from_stream(stream);
13
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
14
+                stream_id <= OGS_MAX_POOL_ID);
15
+        e->h.sbi.data = OGS_UINT_TO_POINTER(stream_id);;
16
+    }
17
+
18
     rv = ogs_queue_push(ogs_app()->queue, e);
19
     if (rv != OGS_OK) {
20
         ogs_error("ogs_queue_push() failed:%d", (int)rv);
21
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/ngap-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/ngap-handler.c Changed
55
 
1
@@ -46,7 +46,7 @@
2
     ogs_assert(stream);
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
 
9
     ogs_debug("PDUSessionResourceSetupResponseTransfer");
10
@@ -185,7 +185,7 @@
11
     ogs_assert(stream);
12
 
13
     ogs_assert(sess);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
 
18
     ogs_debug("PDUSessionResourceSetupUnsuccessfulTransfer");
19
@@ -285,7 +285,7 @@
20
     ogs_assert(stream);
21
 
22
     ogs_assert(sess);
23
-    smf_ue = sess->smf_ue;
24
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
25
     ogs_assert(smf_ue);
26
 
27
     ogs_debug("PDUSessionResourceModifyResponseTransfer");
28
@@ -390,7 +390,7 @@
29
     ogs_assert(stream);
30
 
31
     ogs_assert(sess);
32
-    smf_ue = sess->smf_ue;
33
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
34
     ogs_assert(smf_ue);
35
 
36
     ogs_debug("PathSwitchRequestTransfer");
37
@@ -517,7 +517,7 @@
38
     ogs_assert(stream);
39
 
40
     ogs_assert(sess);
41
-    smf_ue = sess->smf_ue;
42
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
43
     ogs_assert(smf_ue);
44
 
45
     ogs_debug("HandoverRequiredTransfer");
46
@@ -569,7 +569,7 @@
47
     ogs_assert(stream);
48
 
49
     ogs_assert(sess);
50
-    smf_ue = sess->smf_ue;
51
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
52
     ogs_assert(smf_ue);
53
 
54
     ogs_debug("HandoverRequestAcknowledgeTransfer");
55
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/ngap-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/ngap-path.c Changed
21
 
1
@@ -30,10 +30,17 @@
2
 
3
     e = smf_event_new(SMF_EVT_NGAP_MESSAGE);
4
     ogs_assert(e);
5
-    e->sess = sess;
6
-    e->h.sbi.data = stream;
7
+    e->sess_id = sess->id;
8
     e->pkbuf = pkbuf;
9
     e->ngap.type = type;
10
+
11
+    if (stream) {
12
+        ogs_pool_id_t stream_id = ogs_sbi_id_from_stream(stream);
13
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
14
+                stream_id <= OGS_MAX_POOL_ID);
15
+        e->h.sbi.data = OGS_UINT_TO_POINTER(stream_id);;
16
+    }
17
+
18
     rv = ogs_queue_push(ogs_app()->queue, e);
19
     if (rv != OGS_OK) {
20
         ogs_error("ogs_queue_push() failed:%d", (int)rv);
21
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/npcf-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/npcf-build.c Changed
19
 
1
@@ -38,7 +38,7 @@
2
     ogs_assert(sess);
3
     ogs_assert(sess->sm_context_ref);
4
     ogs_assert(sess->session.name);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
 
9
     memset(&message, 0, sizeof(message));
10
@@ -301,7 +301,7 @@
11
 
12
     ogs_assert(sess);
13
     ogs_assert(sess->sm_context_ref);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
     ogs_assert(sess->policy_association.resource_uri);
18
 
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/npcf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/npcf-handler.c Changed
28
 
1
@@ -304,7 +304,7 @@
2
     ogs_sockaddr_t *addr = NULL, *addr6 = NULL;
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
 
9
     ogs_assert(recvmsg);
10
@@ -699,7 +699,7 @@
11
 
12
     ogs_assert(sess);
13
     ogs_assert(stream);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
 
18
     ogs_assert(recvmsg);
19
@@ -748,7 +748,7 @@
20
 
21
     ogs_assert(sess);
22
     ogs_assert(stream);
23
-    smf_ue = sess->smf_ue;
24
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
25
     ogs_assert(smf_ue);
26
 
27
     ogs_assert(recvmsg);
28
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/nsmf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/nsmf-handler.c Changed
28
 
1
@@ -49,7 +49,7 @@
2
     ogs_assert(message);
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
 
9
     SmContextCreateData = message->SmContextCreateData;
10
@@ -398,7 +398,7 @@
11
     ogs_assert(message);
12
 
13
     ogs_assert(sess);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
 
18
     SmContextUpdateData = message->SmContextUpdateData;
19
@@ -818,7 +818,7 @@
20
     ogs_assert(stream);
21
     ogs_assert(message);
22
     ogs_assert(sess);
23
-    smf_ue = sess->smf_ue;
24
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
25
     ogs_assert(smf_ue);
26
 
27
     memset(&param, 0, sizeof(param));
28
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/nudm-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/nudm-build.c Changed
28
 
1
@@ -26,7 +26,7 @@
2
     ogs_sbi_request_t *request = NULL;
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(smf_ue->supi);
9
 
10
@@ -62,7 +62,7 @@
11
 
12
     ogs_assert(sess);
13
     ogs_assert(sess->psi);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
     ogs_assert(smf_ue->supi);
18
 
19
@@ -123,7 +123,7 @@
20
 
21
     ogs_assert(sess);
22
     ogs_assert(sess->psi);
23
-    smf_ue = sess->smf_ue;
24
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
25
     ogs_assert(smf_ue);
26
     ogs_assert(smf_ue->supi);
27
 
28
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/nudm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/nudm-handler.c Changed
10
 
1
@@ -53,7 +53,7 @@
2
 
3
     ogs_assert(sess);
4
     ogs_assert(stream);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     server = ogs_sbi_server_from_stream(stream);
9
     ogs_assert(server);
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/pfcp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/pfcp-path.c Changed
201
 
1
@@ -210,6 +210,7 @@
2
 
3
 static void sess_5gc_timeout(ogs_pfcp_xact_t *xact, void *data)
4
 {
5
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
6
     smf_ue_t *smf_ue = NULL;
7
     smf_sess_t *sess = NULL;
8
     ogs_sbi_stream_t *stream = NULL;
9
@@ -222,24 +223,30 @@
10
     ogs_assert(xact);
11
     ogs_assert(data);
12
 
13
-    sess = smf_sess_cycle(data);
14
+    if (xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
15
+            xact->assoc_stream_id <= OGS_MAX_POOL_ID)
16
+        stream = ogs_sbi_stream_find_by_id(xact->assoc_stream_id);
17
+
18
+    type = xact->seq0.type;
19
+
20
+    sess_id = OGS_POINTER_TO_UINT(data);
21
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
22
+
23
+    sess = smf_sess_find_by_id(sess_id);
24
     if (!sess) {
25
-        ogs_warn("Session has already been removed");
26
+        ogs_error("Session has already been removed %d", type);
27
         return;
28
     }
29
-    smf_ue = sess->smf_ue;
30
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
31
     ogs_assert(smf_ue);
32
 
33
-    stream = xact->assoc_stream;
34
-    type = xact->seq0.type;
35
-
36
     switch (type) {
37
     case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
38
         ogs_warn("No PFCP session establishment response");
39
 
40
         e = smf_event_new(SMF_EVT_N4_TIMER);
41
         ogs_assert(e);
42
-        e->sess = sess;
43
+        e->sess_id = sess->id;
44
         e->h.timer_id = SMF_TIMER_PFCP_NO_ESTABLISHMENT_RESPONSE;
45
         e->pfcp_node = sess->pfcp_node;
46
 
47
@@ -298,7 +305,7 @@
48
            removal from pfcp-sm state machine. */
49
         e = smf_event_new(SMF_EVT_N4_TIMER);
50
         ogs_assert(e);
51
-        e->sess = sess;
52
+        e->sess_id = sess->id;
53
         e->h.timer_id = SMF_TIMER_PFCP_NO_DELETION_RESPONSE;
54
         e->pfcp_node = sess->pfcp_node;
55
 
56
@@ -316,11 +323,23 @@
57
 
58
 static void sess_epc_timeout(ogs_pfcp_xact_t *xact, void *data)
59
 {
60
+    smf_sess_t *sess = NULL;
61
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
62
     uint8_t type;
63
 
64
     ogs_assert(xact);
65
     type = xact->seq0.type;
66
 
67
+    ogs_assert(data);
68
+    sess_id = OGS_POINTER_TO_UINT(data);
69
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
70
+
71
+    sess = smf_sess_find_by_id(sess_id);
72
+    if (!sess) {
73
+        ogs_error("Session has already been removed %d", type);
74
+        return;
75
+    }
76
+
77
     switch (type) {
78
     case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
79
         ogs_warn("No PFCP session establishment response");
80
@@ -339,11 +358,23 @@
81
 
82
 static void bearer_epc_timeout(ogs_pfcp_xact_t *xact, void *data)
83
 {
84
+    smf_bearer_t *bearer = NULL;
85
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
86
     uint8_t type;
87
 
88
     ogs_assert(xact);
89
     type = xact->seq0.type;
90
 
91
+    ogs_assert(data);
92
+    bearer_id = OGS_POINTER_TO_UINT(data);
93
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
94
+
95
+    bearer = smf_bearer_find_by_id(bearer_id);
96
+    if (!bearer) {
97
+        ogs_error("Bearer has already been removed %d", type);
98
+        return;
99
+    }
100
+
101
     switch (type) {
102
     case OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE:
103
         ogs_error("No PFCP session modification response");
104
@@ -407,7 +438,8 @@
105
 
106
     ogs_assert(sess);
107
 
108
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_5gc_timeout, sess);
109
+    xact = ogs_pfcp_xact_local_create(
110
+            sess->pfcp_node, sess_5gc_timeout, OGS_UINT_TO_POINTER(sess->id));
111
     if (!xact) {
112
         ogs_error("ogs_pfcp_xact_local_create() failed");
113
         return OGS_ERROR;
114
@@ -480,13 +512,19 @@
115
     if ((flags & OGS_PFCP_MODIFY_ERROR_INDICATION) == 0)
116
         ogs_assert(stream);
117
 
118
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_5gc_timeout, sess);
119
+    xact = ogs_pfcp_xact_local_create(
120
+            sess->pfcp_node, sess_5gc_timeout, OGS_UINT_TO_POINTER(sess->id));
121
     if (!xact) {
122
         ogs_error("ogs_pfcp_xact_local_create() failed");
123
         return OGS_ERROR;
124
     }
125
 
126
-    xact->assoc_stream = stream;
127
+    if (stream) {
128
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
129
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
130
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
131
+    }
132
+
133
     xact->local_seid = sess->smf_n4_seid;
134
     xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION;
135
 
136
@@ -510,13 +548,19 @@
137
 
138
     ogs_assert(sess);
139
 
140
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_5gc_timeout, sess);
141
+    xact = ogs_pfcp_xact_local_create(
142
+            sess->pfcp_node, sess_5gc_timeout, OGS_UINT_TO_POINTER(sess->id));
143
     if (!xact) {
144
         ogs_error("ogs_pfcp_xact_local_create() failed");
145
         return OGS_ERROR;
146
     }
147
 
148
-    xact->assoc_stream = stream;
149
+    if (stream) {
150
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
151
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
152
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
153
+    }
154
+
155
     xact->local_seid = sess->smf_n4_seid;
156
     xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION;
157
 
158
@@ -538,13 +582,19 @@
159
     ogs_assert(sess);
160
     ogs_assert(trigger);
161
 
162
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_5gc_timeout, sess);
163
+    xact = ogs_pfcp_xact_local_create(
164
+            sess->pfcp_node, sess_5gc_timeout, OGS_UINT_TO_POINTER(sess->id));
165
     if (!xact) {
166
         ogs_error("ogs_pfcp_xact_local_create() failed");
167
         return OGS_ERROR;
168
     }
169
 
170
-    xact->assoc_stream = stream;
171
+    if (stream) {
172
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
173
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
174
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
175
+    }
176
+
177
     xact->delete_trigger = trigger;
178
     xact->local_seid = sess->smf_n4_seid;
179
 
180
@@ -571,7 +621,7 @@
181
 }
182
 
183
 int smf_epc_pfcp_send_session_establishment_request(
184
-        smf_sess_t *sess, void *gtp_xact, uint64_t flags)
185
+        smf_sess_t *sess, ogs_pool_id_t gtp_xact_id, uint64_t flags)
186
 {
187
     int rv;
188
     ogs_pkbuf_t *n4buf = NULL;
189
@@ -580,14 +630,15 @@
190
 
191
     ogs_assert(sess);
192
 
193
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_epc_timeout, sess);
194
+    xact = ogs_pfcp_xact_local_create(
195
+            sess->pfcp_node, sess_epc_timeout, OGS_UINT_TO_POINTER(sess->id));
196
     if (!xact) {
197
         ogs_error("ogs_pfcp_xact_local_create() failed");
198
         return OGS_ERROR;
199
     }
200
 
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/pfcp-path.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/pfcp-path.h Changed
21
 
1
@@ -47,15 +47,15 @@
2
         smf_sess_t *sess, ogs_sbi_stream_t *stream, int trigger);
3
 
4
 int smf_epc_pfcp_send_session_establishment_request(
5
-        smf_sess_t *sess, void *gtp_xact, uint64_t flags);
6
+        smf_sess_t *sess, ogs_pool_id_t gtp_xact_id, uint64_t flags);
7
 int smf_epc_pfcp_send_all_pdr_modification_request(
8
-        smf_sess_t *sess, void *gtp_xact, ogs_pkbuf_t *gtpbuf,
9
+        smf_sess_t *sess, ogs_pool_id_t gtp_xact_id, ogs_pkbuf_t *gtpbuf,
10
         uint64_t flags, uint8_t gtp_pti, uint8_t gtp_cause);
11
 int smf_epc_pfcp_send_one_bearer_modification_request(
12
-        smf_bearer_t *bearer, void *gtp_xact,
13
+        smf_bearer_t *bearer, ogs_pool_id_t gtp_xact_id,
14
         uint64_t flags, uint8_t gtp_pti, uint8_t gtp_cause);
15
 int smf_epc_pfcp_send_session_deletion_request(
16
-        smf_sess_t *sess, void *gtp_xact);
17
+        smf_sess_t *sess, ogs_pool_id_t gtp_xact_id);
18
 
19
 int smf_epc_pfcp_send_deactivation(smf_sess_t *sess, uint8_t gtp_cause);
20
 
21
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/pfcp-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/pfcp-sm.c Changed
93
 
1
@@ -117,7 +117,7 @@
2
             ogs_pfcp_cp_send_association_setup_request(node, node_timeout);
3
             break;
4
         case SMF_TIMER_PFCP_NO_ESTABLISHMENT_RESPONSE:
5
-            sess = smf_sess_cycle(e->sess);
6
+            sess = smf_sess_find_by_id(e->sess_id);
7
             if (!sess) {
8
                 ogs_warn("Session has already been removed");
9
                 break;
10
@@ -125,7 +125,7 @@
11
             ogs_fsm_dispatch(&sess->sm, e);
12
             break;
13
         case SMF_TIMER_PFCP_NO_DELETION_RESPONSE:
14
-            sess = smf_sess_cycle(e->sess);
15
+            sess = smf_sess_find_by_id(e->sess_id);
16
             if (!sess) {
17
                 ogs_warn("Session has already been removed");
18
                 break;
19
@@ -141,7 +141,7 @@
20
     case SMF_EVT_N4_MESSAGE:
21
         message = e->pfcp_message;
22
         ogs_assert(message);
23
-        xact = e->pfcp_xact;
24
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
25
         ogs_assert(xact);
26
 
27
         switch (message->h.type) {
28
@@ -223,7 +223,7 @@
29
     case SMF_EVT_N4_MESSAGE:
30
         message = e->pfcp_message;
31
         ogs_assert(message);
32
-        xact = e->pfcp_xact;
33
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
34
         ogs_assert(xact);
35
 
36
         if (message->h.seid_presence && message->h.seid != 0) {
37
@@ -237,7 +237,7 @@
38
             sess = smf_sess_find_by_seid(xact->local_seid);
39
         }
40
         if (sess)
41
-            e->sess = sess;
42
+            e->sess_id = sess->id;
43
 
44
         switch (message->h.type) {
45
         case OGS_PFCP_HEARTBEAT_REQUEST_TYPE:
46
@@ -313,7 +313,8 @@
47
             if (!message->h.seid_presence) ogs_error("No SEID");
48
 
49
             if (!sess) {
50
-                ogs_gtp_xact_t *gtp_xact = xact->assoc_xact;
51
+                ogs_gtp_xact_t *gtp_xact =
52
+                    ogs_gtp_xact_find_by_id(xact->assoc_xact_id);
53
                 ogs_error("No Session");
54
                 if (!gtp_xact) {
55
                     ogs_error("No associated GTP transaction");
56
@@ -348,7 +349,8 @@
57
             if (!message->h.seid_presence) ogs_error("No SEID");
58
 
59
             if (!sess) {
60
-                ogs_gtp_xact_t *gtp_xact = xact->assoc_xact;
61
+                ogs_gtp_xact_t *gtp_xact =
62
+                    ogs_gtp_xact_find_by_id(xact->assoc_xact_id);
63
                 ogs_error("No Session");
64
                 if (!gtp_xact) {
65
                     ogs_error("No associated GTP transaction");
66
@@ -397,7 +399,7 @@
67
                 ogs_pfcp_send_heartbeat_request(node, node_timeout));
68
             break;
69
         case SMF_TIMER_PFCP_NO_ESTABLISHMENT_RESPONSE:
70
-            sess = smf_sess_cycle(e->sess);
71
+            sess = smf_sess_find_by_id(e->sess_id);
72
             if (!sess) {
73
                 ogs_warn("Session has already been removed");
74
                 break;
75
@@ -405,7 +407,7 @@
76
             ogs_fsm_dispatch(&sess->sm, e);
77
             break;
78
         case SMF_TIMER_PFCP_NO_DELETION_RESPONSE:
79
-            sess = smf_sess_cycle(e->sess);
80
+            sess = smf_sess_find_by_id(e->sess_id);
81
             if (!sess) {
82
                 ogs_warn("Session has already been removed");
83
                 break;
84
@@ -482,7 +484,7 @@
85
                             OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : "");
86
                     ogs_assert(OGS_OK ==
87
                         smf_epc_pfcp_send_session_establishment_request(
88
-                            sess, NULL,
89
+                            sess, OGS_INVALID_POOL_ID,
90
                             OGS_PFCP_CREATE_RESTORATION_INDICATION));
91
                 } else {
92
                     ogs_info("UE SUPI%s DNN%s IPv4%s IPv6%s",
93
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/s5c-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/s5c-build.c Changed
37
 
1
@@ -337,7 +337,7 @@
2
     smf_bearer_t *bearer = NULL;
3
 
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(req);
9
 
10
@@ -410,7 +410,7 @@
11
     char tft_bufOGS_GTP2_MAX_TRAFFIC_FLOW_TEMPLATE;
12
 
13
     ogs_assert(bearer);
14
-    sess = bearer->sess;
15
+    sess = smf_sess_find_by_id(bearer->sess_id);
16
     ogs_assert(sess);
17
     linked_bearer = smf_default_bearer_in_sess(sess);
18
     ogs_assert(linked_bearer);
19
@@ -489,7 +489,7 @@
20
     char tft_bufOGS_GTP2_MAX_TRAFFIC_FLOW_TEMPLATE;
21
 
22
     ogs_assert(bearer);
23
-    sess = bearer->sess;
24
+    sess = smf_sess_find_by_id(bearer->sess_id);
25
     ogs_assert(sess);
26
 
27
     ogs_debug("SMF Update Bearer Request");
28
@@ -567,7 +567,7 @@
29
     ogs_gtp2_cause_t cause;
30
 
31
     ogs_assert(bearer);
32
-    sess = bearer->sess;
33
+    sess = smf_sess_find_by_id(bearer->sess_id);
34
     ogs_assert(sess);
35
     linked_bearer = smf_default_bearer_in_sess(sess);
36
     ogs_assert(linked_bearer);
37
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/s5c-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/s5c-handler.c Changed
201
 
1
@@ -29,11 +29,23 @@
2
 
3
 static void pfcp_sess_timeout(ogs_pfcp_xact_t *xact, void *data)
4
 {
5
+    smf_sess_t *sess = NULL;
6
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
7
     uint8_t type;
8
 
9
     ogs_assert(xact);
10
     type = xact->seq0.type;
11
 
12
+    ogs_assert(data);
13
+    sess_id = OGS_POINTER_TO_UINT(data);
14
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
15
+
16
+    sess = smf_sess_find_by_id(sess_id);
17
+    if (!sess) {
18
+        ogs_error("Session has already been removed %d", type);
19
+        return;
20
+    }
21
+
22
     switch (type) {
23
     case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
24
         ogs_error("No PFCP session establishment response");
25
@@ -178,7 +190,7 @@
26
     if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED)
27
         return cause_value;
28
 
29
-    smf_ue = sess->smf_ue;
30
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
31
     ogs_assert(smf_ue);
32
 
33
     /* Set MSISDN: */
34
@@ -532,7 +544,7 @@
35
      * Check ALL Context
36
      ********************/
37
     ogs_assert(sess);
38
-    smf_ue = sess->smf_ue;
39
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
40
     ogs_assert(smf_ue);
41
 
42
     /* Control Plane(DL) : SGW-S5C */
43
@@ -630,7 +642,7 @@
44
         ogs_assert(pfcp_xact);
45
 
46
         pfcp_xact->epc = true; /* EPC PFCP transaction */
47
-        pfcp_xact->assoc_xact = gtp_xact;
48
+        pfcp_xact->assoc_xact_id = gtp_xact->id;
49
         pfcp_xact->modify_flags =
50
             flags|OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_ACTIVATE;
51
 
52
@@ -674,6 +686,7 @@
53
     ogs_gtp2_cause_t *cause = NULL;
54
     ogs_gtp2_f_teid_t *sgw_s5u_teid = NULL, *pgw_s5u_teid = NULL;
55
     smf_bearer_t *bearer = NULL;
56
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
57
     ogs_pfcp_far_t *dl_far = NULL;
58
 
59
     ogs_assert(sess);
60
@@ -685,12 +698,22 @@
61
      * Check Transaction
62
      ********************/
63
     ogs_assert(xact);
64
-    bearer = xact->data;
65
-    ogs_assert(bearer);
66
+
67
+    bearer_id = OGS_POINTER_TO_UINT(xact->data);
68
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
69
 
70
     rv = ogs_gtp_xact_commit(xact);
71
     ogs_expect(rv == OGS_OK);
72
 
73
+    /********************
74
+     * Check ALL Context
75
+     ********************/
76
+    bearer = smf_bearer_find_by_id(bearer_id);
77
+    if (!bearer) {
78
+        ogs_error("Bearer has already been removed");
79
+        return;
80
+    }
81
+
82
     /************************
83
      * Check Session Context
84
      ************************/
85
@@ -699,7 +722,7 @@
86
     if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
87
         ogs_assert(OGS_OK ==
88
             smf_epc_pfcp_send_one_bearer_modification_request(
89
-                bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
90
+                bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
91
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
92
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
93
         return;
94
@@ -756,7 +779,7 @@
95
     if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
96
         ogs_assert(OGS_OK ==
97
             smf_epc_pfcp_send_one_bearer_modification_request(
98
-                bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
99
+                bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
100
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
101
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
102
         return;
103
@@ -774,7 +797,7 @@
104
         ogs_error("GTP Bearer Cause VALUE:%d", cause_value);
105
         ogs_assert(OGS_OK ==
106
             smf_epc_pfcp_send_one_bearer_modification_request(
107
-                bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
108
+                bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
109
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
110
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
111
         return;
112
@@ -787,7 +810,7 @@
113
         ogs_error("GTP Cause Value:%d", cause_value);
114
         ogs_assert(OGS_OK ==
115
             smf_epc_pfcp_send_one_bearer_modification_request(
116
-                bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
117
+                bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
118
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
119
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
120
         return;
121
@@ -834,7 +857,7 @@
122
 
123
     ogs_assert(OGS_OK ==
124
         smf_epc_pfcp_send_one_bearer_modification_request(
125
-            bearer, NULL, OGS_PFCP_MODIFY_ACTIVATE,
126
+            bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_ACTIVATE,
127
             OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
128
             OGS_GTP2_CAUSE_UNDEFINED_VALUE));
129
 }
130
@@ -849,6 +872,7 @@
131
     uint64_t gtp_flags = 0;
132
     uint64_t pfcp_flags = 0;
133
     smf_bearer_t *bearer = NULL;
134
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
135
 
136
     ogs_assert(sess);
137
     ogs_assert(rsp);
138
@@ -861,8 +885,9 @@
139
     ogs_assert(xact);
140
     gtp_flags = xact->update_flags;
141
     ogs_assert(gtp_flags);
142
-    bearer = xact->data;
143
-    ogs_assert(bearer);
144
+
145
+    bearer_id = OGS_POINTER_TO_UINT(xact->data);
146
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
147
 
148
     rv = ogs_gtp_xact_commit(xact);
149
     ogs_expect(rv == OGS_OK);
150
@@ -918,8 +943,11 @@
151
     /********************
152
      * Check ALL Context
153
      ********************/
154
-    ogs_assert(sess);
155
-    ogs_assert(bearer);
156
+    bearer = smf_bearer_find_by_id(bearer_id);
157
+    if (!bearer) {
158
+        ogs_error("Bearer has already been removed");
159
+        return;
160
+    }
161
 
162
     ogs_debug("    SGW_S5C_TEID0x%x SMF_N4_TEID0x%x",
163
             sess->sgw_s5c_teid, sess->smf_n4_teid);
164
@@ -940,7 +968,7 @@
165
     if (pfcp_flags)
166
         ogs_assert(OGS_OK ==
167
             smf_epc_pfcp_send_one_bearer_modification_request(
168
-                bearer, NULL, pfcp_flags,
169
+                bearer, OGS_INVALID_POOL_ID, pfcp_flags,
170
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
171
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
172
 }
173
@@ -953,6 +981,7 @@
174
     int rv;
175
     uint8_t cause_value;
176
     smf_bearer_t *bearer = NULL;
177
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
178
 
179
     ogs_assert(sess);
180
     ogs_assert(rsp);
181
@@ -963,16 +992,19 @@
182
      * Check Transaction
183
      ********************/
184
     ogs_assert(xact);
185
-    bearer = xact->data;
186
-    ogs_assert(bearer);
187
+
188
+    bearer_id = OGS_POINTER_TO_UINT(xact->data);
189
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID && bearer_id <= OGS_MAX_POOL_ID);
190
 
191
     rv = ogs_gtp_xact_commit(xact);
192
     ogs_expect(rv == OGS_OK);
193
 
194
-    /********************
195
-     * Check ALL Context
196
-     ********************/
197
-    ogs_assert(bearer);
198
+    bearer = smf_bearer_find_by_id(bearer_id);
199
+    if (!bearer) {
200
+        ogs_error("Bearer has already been removed");
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/s6b-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/s6b-path.c Changed
93
 
1
@@ -26,7 +26,7 @@
2
     smf_sess_t *sess;
3
     os0_t       s6b_sid;             /* S6B Session-Id */
4
 
5
-    ogs_gtp_xact_t *xact;
6
+    ogs_pool_id_t xact_id;
7
 
8
     struct timespec ts; /* Time of sending the message */
9
 };
10
@@ -102,7 +102,7 @@
11
 
12
     ogs_assert(xact);
13
     ogs_assert(sess);
14
-    smf_ue = sess->smf_ue;
15
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
16
     ogs_assert(smf_ue);
17
 
18
     ogs_debug("AA-Request");
19
@@ -165,7 +165,7 @@
20
 
21
     /* Update session state */
22
     sess_data->sess = sess;
23
-    sess_data->xact = xact;
24
+    sess_data->xact_id = xact ? xact->id : OGS_INVALID_POOL_ID;
25
 
26
     /* Set Origin-Host & Origin-Realm */
27
     ret = fd_msg_add_origin(req, 0);
28
@@ -346,7 +346,6 @@
29
     int new;
30
 
31
     smf_sess_t *sess = NULL;
32
-    ogs_gtp_xact_t *xact = NULL;
33
     smf_event_t *e = NULL;
34
     ogs_diam_s6b_message_t *s6b_message = NULL;
35
 
36
@@ -371,8 +370,6 @@
37
 
38
     sess = sess_data->sess;
39
     ogs_assert(sess);
40
-    xact = sess_data->xact;
41
-    ogs_assert(xact);
42
 
43
     s6b_message = ogs_calloc(1, sizeof(ogs_diam_s6b_message_t));
44
     ogs_assert(s6b_message);
45
@@ -442,8 +439,8 @@
46
     if (error && s6b_message->result_code == ER_DIAMETER_SUCCESS)
47
             s6b_message->result_code = error;
48
 
49
-    e->sess = sess;
50
-    e->gtp_xact = xact;
51
+    e->sess_id = sess->id;
52
+    e->gtp_xact_id = sess_data->xact_id;
53
     e->s6b_message = s6b_message;
54
     ret = ogs_queue_push(ogs_app()->queue, e);
55
     if (ret != OGS_OK) {
56
@@ -516,9 +513,8 @@
57
     smf_ue_t *smf_ue = NULL;
58
     char *user_name = NULL;
59
 
60
-    //ogs_assert(xact);
61
     ogs_assert(sess);
62
-    smf_ue = sess->smf_ue;
63
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
64
     ogs_assert(smf_ue);
65
 
66
     ogs_debug("Session-Termination-Request");
67
@@ -557,7 +553,7 @@
68
 
69
     /* Update session state */
70
     sess_data->sess = sess;
71
-    sess_data->xact = xact;
72
+    sess_data->xact_id = xact ? xact->id : OGS_INVALID_POOL_ID;
73
 
74
     /* Set Origin-Host & Origin-Realm */
75
     ret = fd_msg_add_origin(req, 0);
76
@@ -666,6 +662,7 @@
77
     ogs_debug("    Retrieve its data: %s", sess_data->s6b_sid);
78
 
79
     sess = sess_data->sess;
80
+    ogs_assert(sess);
81
 
82
     s6b_message = ogs_calloc(1, sizeof(ogs_diam_s6b_message_t));
83
     ogs_assert(s6b_message);
84
@@ -736,7 +733,7 @@
85
         e = smf_event_new(SMF_EVT_S6B_MESSAGE);
86
         ogs_assert(e);
87
 
88
-        e->sess = sess;
89
+        e->sess_id = sess->id;
90
         e->s6b_message = s6b_message;
91
         rv = ogs_queue_push(ogs_app()->queue, e);
92
         if (rv != OGS_OK) {
93
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/sbi-path.c Changed
52
 
1
@@ -106,7 +106,7 @@
2
     target_nf_type = ogs_sbi_service_type_to_nf_type(service_type);
3
     ogs_assert(target_nf_type);
4
     ogs_assert(sess);
5
-    smf_ue = sess->smf_ue;
6
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
7
     ogs_assert(smf_ue);
8
     ogs_assert(build);
9
 
10
@@ -198,7 +198,7 @@
11
     }
12
 
13
     xact = ogs_sbi_xact_add(
14
-            &sess->sbi, service_type, discovery_option,
15
+            sess->id, &sess->sbi, service_type, discovery_option,
16
             (ogs_sbi_build_f)build, sess, data);
17
     if (!xact) {
18
         ogs_error("smf_sbi_discover_and_send() failed");
19
@@ -211,7 +211,12 @@
20
     }
21
 
22
     xact->state = state;
23
-    xact->assoc_stream = stream;
24
+
25
+    if (stream) {
26
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
27
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
28
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
29
+    }
30
 
31
     r = ogs_sbi_discover_and_send(xact);
32
     if (r != OGS_OK) {
33
@@ -238,7 +243,7 @@
34
     int r;
35
 
36
     ogs_assert(sess);
37
-    smf_ue = sess->smf_ue;
38
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
39
     ogs_assert(smf_ue);
40
 
41
     ogs_assert(param);
42
@@ -251,7 +256,8 @@
43
             discovery_option, sess->serving_nf_id);
44
 
45
     xact = ogs_sbi_xact_add(
46
-            &sess->sbi, OGS_SBI_SERVICE_TYPE_NAMF_COMM, discovery_option,
47
+            sess->id, &sess->sbi, OGS_SBI_SERVICE_TYPE_NAMF_COMM,
48
+            discovery_option,
49
             (ogs_sbi_build_f)smf_namf_comm_build_n1_n2_message_transfer,
50
             sess, param);
51
     if (!xact) {
52
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/smf/smf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/smf/smf-sm.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -70,6 +70,7 @@
9
     ogs_pfcp_message_t *pfcp_message = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *sbi_request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -77,6 +78,8 @@
17
     ogs_sbi_response_t *sbi_response = NULL;
18
     ogs_sbi_message_t sbi_message;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
21
+    ogs_pool_id_t sbi_object_id = OGS_INVALID_POOL_ID;
22
 
23
     ogs_nas_5gs_message_t nas_message;
24
     ogs_pkbuf_t *pkbuf = NULL;
25
@@ -116,7 +119,7 @@
26
             ogs_pkbuf_free(recvbuf);
27
             break;
28
         }
29
-        e->gtp_xact = gtp_xact;
30
+        e->gtp_xact_id = gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID;
31
 
32
         if (gtp2_message.h.teid_presence && gtp2_message.h.teid != 0) {
33
             sess = smf_sess_find_by_teid(gtp2_message.h.teid);
34
@@ -162,7 +165,7 @@
35
                     sess->sgw_s5c_teid,
36
                     gtp2_sender_f_teid.teid_presence, gtp2_sender_f_teid.teid);
37
 
38
-            e->sess = sess;
39
+            e->sess_id = sess->id;
40
             ogs_fsm_dispatch(&sess->sm, e);
41
             break;
42
         case OGS_GTP2_DELETE_SESSION_REQUEST_TYPE:
43
@@ -190,7 +193,7 @@
44
                     break;
45
                 }
46
             }
47
-            e->sess = sess;
48
+            e->sess_id = sess->id;
49
             ogs_fsm_dispatch(&sess->sm, e);
50
             break;
51
         case OGS_GTP2_MODIFY_BEARER_REQUEST_TYPE:
52
@@ -216,7 +219,7 @@
53
                 ogs_error("TODO: NACK the message");
54
                 break;
55
             }
56
-            e->sess = sess;
57
+            e->sess_id = sess->id;
58
             ogs_fsm_dispatch(&sess->sm, e);
59
             break;
60
         case OGS_GTP2_BEARER_RESOURCE_COMMAND_TYPE:
61
@@ -258,7 +261,7 @@
62
             ogs_pkbuf_free(recvbuf);
63
             break;
64
         }
65
-        e->gtp_xact = gtp_xact;
66
+        e->gtp_xact_id = gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID;
67
 
68
         switch(gtp1_message.h.type) {
69
         case OGS_GTP1_ECHO_REQUEST_TYPE:
70
@@ -282,7 +285,7 @@
71
                         OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND);
72
                 break;
73
             }
74
-            e->sess = sess;
75
+            e->sess_id = sess->id;
76
             ogs_fsm_dispatch(&sess->sm, e);
77
             break;
78
         case OGS_GTP1_DELETE_PDP_CONTEXT_REQUEST_TYPE:
79
@@ -294,7 +297,7 @@
80
                         OGS_GTP1_CAUSE_NON_EXISTENT);
81
                 break;
82
             }
83
-            e->sess = sess;
84
+            e->sess_id = sess->id;
85
             ogs_fsm_dispatch(&sess->sm, e);
86
             break;
87
         case OGS_GTP1_UPDATE_PDP_CONTEXT_REQUEST_TYPE:
88
@@ -317,7 +320,7 @@
89
         gx_message = e->gx_message;
90
         ogs_assert(gx_message);
91
 
92
-        sess = e->sess;
93
+        sess = smf_sess_find_by_id(e->sess_id);
94
         ogs_assert(sess);
95
 
96
         switch(gx_message->cmd_code) {
97
@@ -352,7 +355,7 @@
98
         gy_message = e->gy_message;
99
         ogs_assert(gy_message);
100
 
101
-        sess = e->sess;
102
+        sess = smf_sess_find_by_id(e->sess_id);
103
         ogs_assert(sess);
104
 
105
         switch(gy_message->cmd_code) {
106
@@ -374,7 +377,7 @@
107
         ogs_assert(e);
108
         s6b_message = e->s6b_message;
109
         ogs_assert(s6b_message);
110
-        sess = e->sess;
111
+        sess = smf_sess_find_by_id(e->sess_id);
112
         ogs_assert(sess);
113
 
114
         switch(s6b_message->cmd_code) {
115
@@ -419,7 +422,7 @@
116
         }
117
 
118
         e->pfcp_message = pfcp_message;
119
-        e->pfcp_xact = pfcp_xact;
120
+        e->pfcp_xact_id = pfcp_xact ? pfcp_xact->id : OGS_INVALID_POOL_ID;
121
 
122
         e->gtp2_message = NULL;
123
         if (pfcp_xact->gtpbuf) {
124
@@ -448,8 +451,16 @@
125
     case OGS_EVENT_SBI_SERVER:
126
         sbi_request = e->h.sbi.request;
127
         ogs_assert(sbi_request);
128
-        stream = e->h.sbi.data;
129
-        ogs_assert(stream);
130
+
131
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
132
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
133
+                stream_id <= OGS_MAX_POOL_ID);
134
+
135
+        stream = ogs_sbi_stream_find_by_id(stream_id);
136
+        if (!stream) {
137
+            ogs_error("STREAM has already been removed %d", stream_id);
138
+            break;
139
+        }
140
 
141
         rv = ogs_sbi_parse_request(&sbi_message, sbi_request);
142
         if (rv != OGS_OK) {
143
@@ -569,11 +580,11 @@
144
                 END
145
 
146
                 if (sess) {
147
-                    smf_ue = sess->smf_ue;
148
+                    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
149
                     ogs_assert(smf_ue);
150
                     ogs_assert(OGS_FSM_STATE(&sess->sm));
151
 
152
-                    e->sess = sess;
153
+                    e->sess_id = sess->id;
154
                     e->h.sbi.message = &sbi_message;
155
                     ogs_fsm_dispatch(&sess->sm, e);
156
                 }
157
@@ -763,8 +774,18 @@
158
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
159
             SWITCH(sbi_message.h.resource.component0)
160
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
161
-                sbi_xact = e->h.sbi.data;
162
-                ogs_assert(sbi_xact);
163
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
164
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
165
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
166
+
167
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
168
+                if (!sbi_xact) {
169
+                    /* CLIENT_WAIT timer could remove SBI transaction
170
+                     * before receiving SBI message */
171
+                    ogs_error("SBI transaction has already been removed %d",
172
+                            sbi_xact_id);
173
+                    break;
174
+                }
175
 
176
                 SWITCH(sbi_message.h.method)
177
                 CASE(OGS_SBI_HTTP_METHOD_GET)
178
@@ -791,35 +812,41 @@
179
         CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM)
180
         CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)
181
         CASE(OGS_SBI_SERVICE_NAME_NAMF_COMM)
182
-            sbi_xact = e->h.sbi.data;
183
-            ogs_assert(sbi_xact);
184
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
185
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
186
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
187
 
188
-            sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
189
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
190
             if (!sbi_xact) {
191
                 /* CLIENT_WAIT timer could remove SBI transaction
192
                  * before receiving SBI message */
193
-                ogs_error("SBI transaction has already been removed");
194
+                ogs_error("SBI transaction has already been removed %d",
195
+                        sbi_xact_id);
196
                 break;
197
             }
198
 
199
-            sess = (smf_sess_t *)sbi_xact->sbi_object;
200
-            ogs_assert(sess);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/context.c Changed
139
 
1
@@ -151,12 +151,11 @@
2
 
3
     ogs_assert(suci);
4
 
5
-    ogs_pool_alloc(&udm_ue_pool, &udm_ue);
6
+    ogs_pool_id_calloc(&udm_ue_pool, &udm_ue);
7
     if (!udm_ue) {
8
         ogs_error("No memory pool %s", suci);
9
         return NULL;
10
     }
11
-    memset(udm_ue, 0, sizeof *udm_ue);
12
 
13
     /* SBI Type */
14
     udm_ue->sbi.type = OGS_SBI_OBJ_UE_TYPE;
15
@@ -165,7 +164,7 @@
16
             (int)ogs_pool_index(&udm_ue_pool, udm_ue));
17
     if (!udm_ue->ctx_id) {
18
         ogs_error("No memory for udm_ue->ctx_id %s", suci);
19
-        ogs_pool_free(&udm_ue_pool, udm_ue);
20
+        ogs_pool_id_free(&udm_ue_pool, udm_ue);
21
         return NULL;
22
     }
23
 
24
@@ -173,7 +172,7 @@
25
     if (!udm_ue->suci) {
26
         ogs_error("No memory for udm_ue->suci %s", suci);
27
         ogs_free(udm_ue->ctx_id);
28
-        ogs_pool_free(&udm_ue_pool, udm_ue);
29
+        ogs_pool_id_free(&udm_ue_pool, udm_ue);
30
         return NULL;
31
     }
32
 
33
@@ -182,7 +181,7 @@
34
         ogs_error("No memory for udm_ue->supi %s", suci);
35
         ogs_free(udm_ue->suci);
36
         ogs_free(udm_ue->ctx_id);
37
-        ogs_pool_free(&udm_ue_pool, udm_ue);
38
+        ogs_pool_id_free(&udm_ue_pool, udm_ue);
39
         return NULL;
40
     }
41
 
42
@@ -190,7 +189,7 @@
43
     ogs_hash_set(self.supi_hash, udm_ue->supi, strlen(udm_ue->supi), udm_ue);
44
 
45
     memset(&e, 0, sizeof(e));
46
-    e.udm_ue = udm_ue;
47
+    e.udm_ue_id = udm_ue->id;
48
     ogs_fsm_init(&udm_ue->sm, udm_ue_state_initial, udm_ue_state_final, &e);
49
 
50
     ogs_list_add(&self.udm_ue_list, udm_ue);
51
@@ -207,7 +206,7 @@
52
     ogs_list_remove(&self.udm_ue_list, udm_ue);
53
 
54
     memset(&e, 0, sizeof(e));
55
-    e.udm_ue = udm_ue;
56
+    e.udm_ue_id = udm_ue->id;
57
     ogs_fsm_fini(&udm_ue->sm, &e);
58
 
59
     /* Free SBI object memory */
60
@@ -240,7 +239,7 @@
61
     if (udm_ue->dereg_callback_uri)
62
         ogs_free(udm_ue->dereg_callback_uri);
63
 
64
-    ogs_pool_free(&udm_ue_pool, udm_ue);
65
+    ogs_pool_id_free(&udm_ue_pool, udm_ue);
66
 }
67
 
68
 void udm_ue_remove_all(void)
69
@@ -286,18 +285,17 @@
70
     ogs_assert(udm_ue);
71
     ogs_assert(psi != OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED);
72
 
73
-    ogs_pool_alloc(&udm_sess_pool, &sess);
74
+    ogs_pool_id_calloc(&udm_sess_pool, &sess);
75
     ogs_assert(sess);
76
-    memset(sess, 0, sizeof *sess);
77
 
78
     /* SBI Type */
79
     sess->sbi.type = OGS_SBI_OBJ_SESS_TYPE;
80
 
81
-    sess->udm_ue = udm_ue;
82
+    sess->udm_ue_id = udm_ue->id;
83
     sess->psi = psi;
84
 
85
     memset(&e, 0, sizeof(e));
86
-    e.sess = sess;
87
+    e.sess_id = sess->id;
88
     ogs_fsm_init(&sess->sm, udm_sess_state_initial, udm_sess_state_final, &e);
89
 
90
     ogs_list_add(&udm_ue->sess_list, sess);
91
@@ -308,14 +306,16 @@
92
 void udm_sess_remove(udm_sess_t *sess)
93
 {
94
     udm_event_t e;
95
+    udm_ue_t *udm_ue = NULL;
96
 
97
     ogs_assert(sess);
98
-    ogs_assert(sess->udm_ue);
99
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
100
+    ogs_assert(udm_ue);
101
 
102
-    ogs_list_remove(&sess->udm_ue->sess_list, sess);
103
+    ogs_list_remove(&udm_ue->sess_list, sess);
104
 
105
     memset(&e, 0, sizeof(e));
106
-    e.sess = sess;
107
+    e.sess_id = sess->id;
108
     ogs_fsm_fini(&sess->sm, &e);
109
 
110
     /* Free SBI object memory */
111
@@ -329,7 +329,7 @@
112
     if (sess->smf_instance_id)
113
         ogs_free(sess->smf_instance_id);
114
 
115
-    ogs_pool_free(&udm_sess_pool, sess);
116
+    ogs_pool_id_free(&udm_sess_pool, sess);
117
 }
118
 
119
 void udm_sess_remove_all(udm_ue_t *udm_ue)
120
@@ -352,14 +352,14 @@
121
     return NULL;
122
 }
123
 
124
-udm_ue_t *udm_ue_cycle(udm_ue_t *udm_ue)
125
+udm_ue_t *udm_ue_find_by_id(ogs_pool_id_t id)
126
 {
127
-    return ogs_pool_cycle(&udm_ue_pool, udm_ue);
128
+    return ogs_pool_find_by_id(&udm_ue_pool, id);
129
 }
130
 
131
-udm_sess_t *udm_sess_cycle(udm_sess_t *sess)
132
+udm_sess_t *udm_sess_find_by_id(ogs_pool_id_t id)
133
 {
134
-    return ogs_pool_cycle(&udm_sess_pool, sess);
135
+    return ogs_pool_find_by_id(&udm_sess_pool, id);
136
 }
137
 
138
 udm_sdm_subscription_t *udm_sdm_subscription_add(udm_ue_t *udm_ue)
139
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/context.h Changed
37
 
1
@@ -46,6 +46,7 @@
2
 
3
 struct udm_ue_s {
4
     ogs_sbi_object_t sbi;
5
+    ogs_pool_id_t id;
6
     ogs_fsm_t sm;
7
 
8
     OpenAPI_auth_event_t *auth_event;
9
@@ -78,6 +79,7 @@
10
 
11
 struct udm_sess_s {
12
     ogs_sbi_object_t sbi;
13
+    ogs_pool_id_t id;
14
     ogs_fsm_t sm;
15
 
16
     uint8_t psi; /* PDU Session Identity */
17
@@ -87,7 +89,7 @@
18
     char *smf_instance_id;
19
 
20
     /* Related Context */
21
-    udm_ue_t *udm_ue;
22
+    ogs_pool_id_t udm_ue_id;
23
 };
24
 
25
 typedef struct udm_sdm_subscription_s {
26
@@ -118,8 +120,8 @@
27
 void udm_sess_remove_all(udm_ue_t *udm_ue);
28
 udm_sess_t *udm_sess_find_by_psi(udm_ue_t *udm_ue, uint8_t psi);
29
 
30
-udm_ue_t *udm_ue_cycle(udm_ue_t *udm_ue);
31
-udm_sess_t *udm_sess_cycle(udm_sess_t *sess);
32
+udm_ue_t *udm_ue_find_by_id(ogs_pool_id_t id);
33
+udm_sess_t *udm_sess_find_by_id(ogs_pool_id_t id);
34
 
35
 udm_sdm_subscription_t *udm_sdm_subscription_add(udm_ue_t *udm_ue);
36
 void udm_sdm_subscription_remove(udm_sdm_subscription_t *subscription);
37
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/event.h Changed
12
 
1
@@ -32,8 +32,8 @@
2
 typedef struct udm_event_s {
3
     ogs_event_t h;
4
 
5
-    udm_ue_t *udm_ue;
6
-    udm_sess_t *sess;
7
+    ogs_pool_id_t udm_ue_id;
8
+    ogs_pool_id_t sess_id;
9
 } udm_event_t;
10
 
11
 OGS_STATIC_ASSERT(OGS_EVENT_SIZE >= sizeof(udm_event_t));
12
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/nnrf-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/nnrf-handler.c Changed
36
 
1
@@ -25,6 +25,7 @@
2
 {
3
     ogs_sbi_nf_instance_t *nf_instance = NULL;
4
     ogs_sbi_object_t *sbi_object = NULL;
5
+    ogs_pool_id_t sbi_object_id = OGS_INVALID_POOL_ID;
6
     ogs_sbi_service_type_e service_type = OGS_SBI_SERVICE_TYPE_NULL;
7
     ogs_sbi_discovery_option_t *discovery_option = NULL;
8
 
9
@@ -46,6 +47,10 @@
10
     requester_nf_type = xact->requester_nf_type;
11
     ogs_assert(requester_nf_type);
12
 
13
+    sbi_object_id = xact->sbi_object_id;
14
+    ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
15
+            sbi_object_id <= OGS_MAX_POOL_ID);
16
+
17
     discovery_option = xact->discovery_option;
18
 
19
     SearchResult = recvmsg->SearchResult;
20
@@ -55,12 +60,12 @@
21
     }
22
 
23
     if (sbi_object->type == OGS_SBI_OBJ_UE_TYPE) {
24
-        udm_ue = (udm_ue_t *)sbi_object;
25
+        udm_ue = udm_ue_find_by_id(sbi_object_id);
26
         ogs_assert(udm_ue);
27
     } else if (sbi_object->type == OGS_SBI_OBJ_SESS_TYPE) {
28
-        sess = (udm_sess_t *)sbi_object;
29
+        sess = udm_sess_find_by_id(sbi_object_id);
30
         ogs_assert(sess);
31
-        udm_ue = sess->udm_ue;
32
+        udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
33
         ogs_assert(udm_ue);
34
     } else {
35
         ogs_fatal("(NF discover) Not implemented %s:%d",
36
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/nudm-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/nudm-handler.c Changed
19
 
1
@@ -530,7 +530,7 @@
2
     ogs_assert(message);
3
 
4
     ogs_assert(sess);
5
-    udm_ue = sess->udm_ue;
6
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
7
     ogs_assert(udm_ue);
8
 
9
     SmfRegistration = message->SmfRegistration;
10
@@ -604,7 +604,7 @@
11
     ogs_assert(message);
12
 
13
     ogs_assert(sess);
14
-    udm_ue = sess->udm_ue;
15
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
16
     ogs_assert(udm_ue);
17
 
18
     r = udm_sess_sbi_discover_and_send(OGS_SBI_SERVICE_TYPE_NUDR_DR, NULL,
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/nudr-build.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/nudr-build.c Changed
19
 
1
@@ -256,7 +256,7 @@
2
     ogs_sbi_request_t *request = NULL;
3
 
4
     ogs_assert(sess);
5
-    udm_ue = sess->udm_ue;
6
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
7
     ogs_assert(udm_ue);
8
 
9
     memset(&message, 0, sizeof(message));
10
@@ -301,7 +301,7 @@
11
     ogs_sbi_request_t *request = NULL;
12
 
13
     ogs_assert(sess);
14
-    udm_ue = sess->udm_ue;
15
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
16
     ogs_assert(udm_ue);
17
 
18
     memset(&message, 0, sizeof(message));
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/nudr-handler.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/nudr-handler.c Changed
10
 
1
@@ -754,7 +754,7 @@
2
     int status;
3
 
4
     ogs_assert(sess);
5
-    udm_ue = sess->udm_ue;
6
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
7
     ogs_assert(udm_ue);
8
     ogs_assert(stream);
9
     server = ogs_sbi_server_from_stream(stream);
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/sbi-path.c Changed
62
 
1
@@ -97,6 +97,7 @@
2
 }
3
 
4
 static int udm_sbi_discover_and_send(
5
+        ogs_pool_id_t sbi_object_id,
6
         ogs_sbi_object_t *sbi_object,
7
         ogs_sbi_service_type_e service_type,
8
         ogs_sbi_discovery_option_t *discovery_option,
9
@@ -111,15 +112,22 @@
10
     ogs_assert(stream);
11
     ogs_assert(build);
12
 
13
+    ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
14
+            sbi_object_id <= OGS_MAX_POOL_ID);
15
+
16
     xact = ogs_sbi_xact_add(
17
-            sbi_object, service_type, discovery_option,
18
+            sbi_object_id, sbi_object, service_type, discovery_option,
19
             (ogs_sbi_build_f)build, context, data);
20
     if (!xact) {
21
         ogs_error("udm_sbi_discover_and_send() failed");
22
         return OGS_ERROR;
23
     }
24
 
25
-    xact->assoc_stream = stream;
26
+    if (stream) {
27
+        xact->assoc_stream_id = ogs_sbi_id_from_stream(stream);
28
+        ogs_assert(xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
29
+                xact->assoc_stream_id <= OGS_MAX_POOL_ID);
30
+    }
31
 
32
     r = ogs_sbi_discover_and_send(xact);
33
     if (r != OGS_OK) {
34
@@ -139,9 +147,11 @@
35
 {
36
     int r;
37
 
38
+    ogs_assert(udm_ue->id >= OGS_MIN_POOL_ID && udm_ue->id <= OGS_MAX_POOL_ID);
39
+
40
     r = udm_sbi_discover_and_send(
41
-                &udm_ue->sbi, service_type, discovery_option,
42
-                (ogs_sbi_build_f)build, udm_ue, stream, data);
43
+            udm_ue->id, &udm_ue->sbi, service_type, discovery_option,
44
+            (ogs_sbi_build_f)build, udm_ue, stream, data);
45
     if (r != OGS_OK) {
46
         ogs_error("udm_ue_sbi_discover_and_send() failed");
47
         ogs_assert(true ==
48
@@ -162,9 +172,11 @@
49
 {
50
     int r;
51
 
52
+    ogs_assert(sess->id >= OGS_MIN_POOL_ID && sess->id <= OGS_MAX_POOL_ID);
53
+
54
     r = udm_sbi_discover_and_send(
55
-                &sess->sbi, service_type, discovery_option,
56
-                (ogs_sbi_build_f)build, sess, stream, data);
57
+            sess->id, &sess->sbi, service_type, discovery_option,
58
+            (ogs_sbi_build_f)build, sess, stream, data);
59
     if (r != OGS_OK) {
60
         ogs_error("udm_sess_sbi_discover_and_send() failed");
61
         ogs_assert(true ==
62
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/sess-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/sess-sm.c Changed
71
 
1
@@ -40,6 +40,7 @@
2
     udm_sess_t *sess = NULL;
3
 
4
     ogs_sbi_stream_t *stream = NULL;
5
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
6
     ogs_sbi_message_t *message = NULL;
7
 
8
     ogs_assert(s);
9
@@ -47,9 +48,9 @@
10
 
11
     udm_sm_debug(e);
12
 
13
-    sess = e->sess;
14
+    sess = udm_sess_find_by_id(e->sess_id);
15
     ogs_assert(sess);
16
-    udm_ue = sess->udm_ue;
17
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
18
     ogs_assert(udm_ue);
19
 
20
     switch (e->h.id) {
21
@@ -62,8 +63,16 @@
22
     case OGS_EVENT_SBI_SERVER:
23
         message = e->h.sbi.message;
24
         ogs_assert(message);
25
-        stream = e->h.sbi.data;
26
-        ogs_assert(stream);
27
+
28
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
29
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
30
+                stream_id <= OGS_MAX_POOL_ID);
31
+
32
+        stream = ogs_sbi_stream_find_by_id(stream_id);
33
+        if (!stream) {
34
+            ogs_error("STREAM has already been removed %d", stream_id);
35
+            break;
36
+        }
37
 
38
         SWITCH(message->h.service.name)
39
         CASE(OGS_SBI_SERVICE_NAME_NUDM_UECM)
40
@@ -112,8 +121,16 @@
41
     case OGS_EVENT_SBI_CLIENT:
42
         message = e->h.sbi.message;
43
         ogs_assert(message);
44
-        stream = e->h.sbi.data;
45
-        ogs_assert(stream);
46
+
47
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
48
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
49
+                stream_id <= OGS_MAX_POOL_ID);
50
+
51
+        stream = ogs_sbi_stream_find_by_id(stream_id);
52
+        if (!stream) {
53
+            ogs_error("STREAM has already been removed %d", stream_id);
54
+            break;
55
+        }
56
 
57
         SWITCH(message->h.service.name)
58
         CASE(OGS_SBI_SERVICE_NAME_NUDR_DR)
59
@@ -162,9 +179,9 @@
60
 
61
     udm_sm_debug(e);
62
 
63
-    sess = e->sess;
64
+    sess = udm_sess_find_by_id(e->sess_id);
65
     ogs_assert(sess);
66
-    udm_ue = sess->udm_ue;
67
+    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
68
     ogs_assert(udm_ue);
69
 
70
     switch (e->h.id) {
71
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/udm-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/udm-sm.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -40,6 +40,7 @@
9
     const char *api_version = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -47,9 +48,12 @@
17
     ogs_sbi_response_t *response = NULL;
18
     ogs_sbi_message_t message;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
21
 
22
     udm_ue_t *udm_ue = NULL;
23
+    ogs_pool_id_t udm_ue_id = OGS_INVALID_POOL_ID;
24
     udm_sess_t *sess = NULL;
25
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
26
 
27
     udm_sm_debug(e);
28
 
29
@@ -65,8 +69,16 @@
30
     case OGS_EVENT_SBI_SERVER:
31
         request = e->h.sbi.request;
32
         ogs_assert(request);
33
-        stream = e->h.sbi.data;
34
-        ogs_assert(stream);
35
+
36
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
37
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
38
+                stream_id <= OGS_MAX_POOL_ID);
39
+
40
+        stream = ogs_sbi_stream_find_by_id(stream_id);
41
+        if (!stream) {
42
+            ogs_error("STREAM has already been removed %d", stream_id);
43
+            break;
44
+        }
45
 
46
         rv = ogs_sbi_parse_request(&message, request);
47
         if (rv != OGS_OK) {
48
@@ -203,7 +215,7 @@
49
                 ogs_assert(sess);
50
                 ogs_assert(OGS_FSM_STATE(&sess->sm));
51
 
52
-                e->sess = sess;
53
+                e->sess_id = sess->id;
54
                 e->h.sbi.message = &message;
55
                 ogs_fsm_dispatch(&sess->sm, e);
56
                 if (OGS_FSM_CHECK(&sess->sm, udm_sess_state_exception)) {
57
@@ -216,7 +228,7 @@
58
             DEFAULT
59
                 ogs_assert(OGS_FSM_STATE(&udm_ue->sm));
60
 
61
-                e->udm_ue = udm_ue;
62
+                e->udm_ue_id = udm_ue->id;
63
                 e->h.sbi.message = &message;
64
                 ogs_fsm_dispatch(&udm_ue->sm, e);
65
                 if (OGS_FSM_CHECK(&udm_ue->sm, udm_ue_state_exception)) {
66
@@ -337,8 +349,18 @@
67
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
68
             SWITCH(message.h.resource.component0)
69
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
70
-                sbi_xact = e->h.sbi.data;
71
-                ogs_assert(sbi_xact);
72
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
73
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
74
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
75
+
76
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
77
+                if (!sbi_xact) {
78
+                    /* CLIENT_WAIT timer could remove SBI transaction
79
+                     * before receiving SBI message */
80
+                    ogs_error("SBI transaction has already been removed %d",
81
+                            sbi_xact_id);
82
+                    break;
83
+                }
84
 
85
                 SWITCH(message.h.method)
86
                 CASE(OGS_SBI_HTTP_METHOD_GET)
87
@@ -367,37 +389,44 @@
88
             CASE(OGS_SBI_RESOURCE_NAME_SUBSCRIPTION_DATA)
89
                 SWITCH(message.h.resource.component3)
90
                 CASE(OGS_SBI_RESOURCE_NAME_SMF_REGISTRATIONS)
91
-                    sbi_xact = e->h.sbi.data;
92
-                    ogs_assert(sbi_xact);
93
+                    sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
94
+                    ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
95
+                            sbi_xact_id <= OGS_MAX_POOL_ID);
96
 
97
-                    sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
98
+                    sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
99
                     if (!sbi_xact) {
100
                         /* CLIENT_WAIT timer could remove SBI transaction
101
                          * before receiving SBI message */
102
-                        ogs_error("SBI transaction has already been removed");
103
+                        ogs_error(
104
+                                "SBI transaction has already been removed %d",
105
+                                sbi_xact_id);
106
                         break;
107
                     }
108
 
109
-                    sess = (udm_sess_t *)sbi_xact->sbi_object;
110
-                    ogs_assert(sess);
111
-
112
-                    e->h.sbi.data = sbi_xact->assoc_stream;
113
+                    sess_id = sbi_xact->sbi_object_id;
114
+                    ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
115
+                            sess_id <= OGS_MAX_POOL_ID);
116
+
117
+                    if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
118
+                        sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
119
+                        e->h.sbi.data =
120
+                            OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
121
 
122
                     ogs_sbi_xact_remove(sbi_xact);
123
 
124
-                    sess = udm_sess_cycle(sess);
125
+                    sess = udm_sess_find_by_id(sess_id);
126
                     if (!sess) {
127
                         ogs_error("SESS Context has already been removed");
128
                         break;
129
                     }
130
 
131
-                    udm_ue = udm_ue_cycle(sess->udm_ue);
132
+                    udm_ue = udm_ue_find_by_id(sess->udm_ue_id);
133
                     if (!udm_ue) {
134
                         ogs_error("UE Context has already been removed");
135
                         break;
136
                     }
137
 
138
-                    e->sess = sess;
139
+                    e->sess_id = sess->id;
140
                     e->h.sbi.message = &message;
141
 
142
                     ogs_fsm_dispatch(&sess->sm, e);
143
@@ -409,31 +438,38 @@
144
                     break;
145
 
146
                 DEFAULT
147
-                    sbi_xact = e->h.sbi.data;
148
-                    ogs_assert(sbi_xact);
149
+                    sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
150
+                    ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
151
+                            sbi_xact_id <= OGS_MAX_POOL_ID);
152
 
153
-                    sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
154
+                    sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
155
                     if (!sbi_xact) {
156
                         /* CLIENT_WAIT timer could remove SBI transaction
157
                          * before receiving SBI message */
158
-                        ogs_error("SBI transaction has already been removed");
159
+                        ogs_error(
160
+                                "SBI transaction has already been removed %d",
161
+                                sbi_xact_id);
162
                         break;
163
                     }
164
 
165
-                    udm_ue = (udm_ue_t *)sbi_xact->sbi_object;
166
-                    ogs_assert(udm_ue);
167
-
168
-                    e->h.sbi.data = sbi_xact->assoc_stream;
169
+                    udm_ue_id = sbi_xact->sbi_object_id;
170
+                    ogs_assert(udm_ue_id >= OGS_MIN_POOL_ID &&
171
+                            udm_ue_id <= OGS_MAX_POOL_ID);
172
+
173
+                    if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
174
+                        sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
175
+                        e->h.sbi.data =
176
+                            OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
177
 
178
                     ogs_sbi_xact_remove(sbi_xact);
179
 
180
-                    udm_ue = udm_ue_cycle(udm_ue);
181
+                    udm_ue = udm_ue_find_by_id(udm_ue_id);
182
                     if (!udm_ue) {
183
                         ogs_error("UE Context has already been removed");
184
                         break;
185
                     }
186
 
187
-                    e->udm_ue = udm_ue;
188
+                    e->udm_ue_id = udm_ue->id;
189
                     e->h.sbi.message = &message;
190
 
191
                     ogs_fsm_dispatch(&udm_ue->sm, e);
192
@@ -534,20 +570,32 @@
193
              * 4. timer expiration event is processed. (double-free SBI xact)
194
              *
195
              * To avoid double-free SBI xact,
196
-             * we need to check ogs_sbi_xact_cycle()
197
+             * we need to check ogs_sbi_xact_find_by_id()
198
              */
199
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
200
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
201
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udm/ue-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udm/ue-sm.c Changed
75
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -38,6 +38,7 @@
9
     udm_ue_t *udm_ue = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_message_t *message = NULL;
14
     int r;
15
 
16
@@ -46,7 +47,7 @@
17
 
18
     udm_sm_debug(e);
19
 
20
-    udm_ue = e->udm_ue;
21
+    udm_ue = udm_ue_find_by_id(e->udm_ue_id);
22
     ogs_assert(udm_ue);
23
 
24
     switch (e->h.id) {
25
@@ -59,8 +60,16 @@
26
     case OGS_EVENT_SBI_SERVER:
27
         message = e->h.sbi.message;
28
         ogs_assert(message);
29
-        stream = e->h.sbi.data;
30
-        ogs_assert(stream);
31
+
32
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
33
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
34
+                stream_id <= OGS_MAX_POOL_ID);
35
+
36
+        stream = ogs_sbi_stream_find_by_id(stream_id);
37
+        if (!stream) {
38
+            ogs_error("STREAM has already been removed %d", stream_id);
39
+            break;
40
+        }
41
 
42
         SWITCH(message->h.service.name)
43
         CASE(OGS_SBI_SERVICE_NAME_NUDM_UEAU)
44
@@ -264,10 +273,18 @@
45
         message = e->h.sbi.message;
46
         ogs_assert(message);
47
 
48
-        udm_ue = e->udm_ue;
49
+        udm_ue = udm_ue_find_by_id(e->udm_ue_id);
50
         ogs_assert(udm_ue);
51
-        stream = e->h.sbi.data;
52
-        ogs_assert(stream);
53
+
54
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
55
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
56
+                stream_id <= OGS_MAX_POOL_ID);
57
+
58
+        stream = ogs_sbi_stream_find_by_id(stream_id);
59
+        if (!stream) {
60
+            ogs_error("STREAM has already been removed %d", stream_id);
61
+            break;
62
+        }
63
 
64
         SWITCH(message->h.service.name)
65
         CASE(OGS_SBI_SERVICE_NAME_NUDR_DR)
66
@@ -329,7 +346,7 @@
67
 
68
     udm_sm_debug(e);
69
 
70
-    udm_ue = e->udm_ue;
71
+    udm_ue = udm_ue_find_by_id(e->udm_ue_id);
72
     ogs_assert(udm_ue);
73
 
74
     switch (e->h.id) {
75
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/udr/udr-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/udr/udr-sm.c Changed
35
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -41,6 +41,7 @@
9
     int rv;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -62,8 +63,16 @@
17
     case OGS_EVENT_SBI_SERVER:
18
         request = e->h.sbi.request;
19
         ogs_assert(request);
20
-        stream = e->h.sbi.data;
21
-        ogs_assert(stream);
22
+
23
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
24
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
25
+                stream_id <= OGS_MAX_POOL_ID);
26
+
27
+        stream = ogs_sbi_stream_find_by_id(stream_id);
28
+        if (!stream) {
29
+            ogs_error("STREAM has already been removed %d", stream_id);
30
+            break;
31
+        }
32
 
33
         rv = ogs_sbi_parse_request(&message, request);
34
         if (rv != OGS_OK) {
35
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/upf/context.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/upf/context.c Changed
33
 
1
@@ -175,9 +175,8 @@
2
 
3
     ogs_assert(cp_f_seid);
4
 
5
-    ogs_pool_alloc(&upf_sess_pool, &sess);
6
+    ogs_pool_id_calloc(&upf_sess_pool, &sess);
7
     ogs_assert(sess);
8
-    memset(sess, 0, sizeof *sess);
9
 
10
     ogs_pfcp_pool_init(&sess->pfcp);
11
 
12
@@ -244,7 +243,7 @@
13
     ogs_pfcp_pool_final(&sess->pfcp);
14
 
15
     ogs_pool_free(&upf_n4_seid_pool, sess->upf_n4_seid_node);
16
-    ogs_pool_free(&upf_sess_pool, sess);
17
+    ogs_pool_id_free(&upf_sess_pool, sess);
18
     if (sess->apn_dnn)
19
         ogs_free(sess->apn_dnn);
20
     upf_metrics_inst_global_dec(UPF_METR_GLOB_GAUGE_UPF_SESSIONNBR);
21
@@ -352,6 +351,11 @@
22
     return ret;
23
 }
24
 
25
+upf_sess_t *upf_sess_find_by_id(ogs_pool_id_t id)
26
+{
27
+    return ogs_pool_find_by_id(&upf_sess_pool, id);
28
+}
29
+
30
 upf_sess_t *upf_sess_add_by_message(ogs_pfcp_message_t *message)
31
 {
32
     upf_sess_t *sess = NULL;
33
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/upf/context.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/upf/context.h Changed
17
 
1
@@ -100,6 +100,7 @@
2
 #define UPF_SESS(pfcp_sess) ogs_container_of(pfcp_sess, upf_sess_t, pfcp)
3
 typedef struct upf_sess_s {
4
     ogs_lnode_t     lnode;
5
+    ogs_pool_id_t   id;
6
     ogs_pool_id_t   *upf_n4_seid_node;  /* A node of UPF-N4-SEID */
7
 
8
     ogs_pfcp_sess_t pfcp;
9
@@ -141,6 +142,7 @@
10
 upf_sess_t *upf_sess_find_by_upf_n4_seid(uint64_t seid);
11
 upf_sess_t *upf_sess_find_by_ipv4(uint32_t addr);
12
 upf_sess_t *upf_sess_find_by_ipv6(uint32_t *addr6);
13
+upf_sess_t *upf_sess_find_by_id(ogs_pool_id_t id);
14
 
15
 uint8_t upf_sess_set_ue_ip(upf_sess_t *sess,
16
         uint8_t session_type, ogs_pfcp_pdr_t *pdr);
17
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/upf/event.h -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/upf/event.h Changed
10
 
1
@@ -49,7 +49,7 @@
2
     ogs_pkbuf_t *pkbuf;
3
 
4
     ogs_pfcp_node_t *pfcp_node;
5
-    ogs_pfcp_xact_t *pfcp_xact;
6
+    ogs_pool_id_t pfcp_xact_id;
7
     ogs_pfcp_message_t *pfcp_message;
8
 } upf_event_t;
9
 
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/upf/pfcp-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/upf/pfcp-path.c Changed
35
 
1
@@ -270,11 +270,23 @@
2
 
3
 static void sess_timeout(ogs_pfcp_xact_t *xact, void *data)
4
 {
5
+    upf_sess_t *sess = NULL;
6
+    ogs_pool_id_t sess_id = OGS_INVALID_POOL_ID;
7
     uint8_t type;
8
 
9
     ogs_assert(xact);
10
     type = xact->seq0.type;
11
 
12
+    ogs_assert(data);
13
+    sess_id = OGS_POINTER_TO_UINT(data);
14
+    ogs_assert(sess_id >= OGS_MIN_POOL_ID && sess_id <= OGS_MAX_POOL_ID);
15
+
16
+    sess = upf_sess_find_by_id(sess_id);
17
+    if (!sess) {
18
+        ogs_error("Session has already been removed %d", type);
19
+        return;
20
+    }
21
+
22
     switch (type) {
23
     case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
24
         ogs_error("No PFCP session report response");
25
@@ -302,7 +314,8 @@
26
     h.type = OGS_PFCP_SESSION_REPORT_REQUEST_TYPE;
27
     h.seid = sess->smf_n4_f_seid.seid;
28
 
29
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_timeout, sess);
30
+    xact = ogs_pfcp_xact_local_create(
31
+            sess->pfcp_node, sess_timeout, OGS_UINT_TO_POINTER(sess->id));
32
     if (!xact) {
33
         ogs_error("ogs_pfcp_xact_local_create() failed");
34
         return OGS_ERROR;
35
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/upf/pfcp-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/upf/pfcp-sm.c Changed
19
 
1
@@ -122,7 +122,7 @@
2
     case UPF_EVT_N4_MESSAGE:
3
         message = e->pfcp_message;
4
         ogs_assert(message);
5
-        xact = e->pfcp_xact;
6
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
7
         ogs_assert(xact);
8
 
9
         switch (message->h.type) {
10
@@ -204,7 +204,7 @@
11
     case UPF_EVT_N4_MESSAGE:
12
         message = e->pfcp_message;
13
         ogs_assert(message);
14
-        xact = e->pfcp_xact;
15
+        xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
16
         ogs_assert(xact);
17
 
18
         if (message->h.seid_presence && message->h.seid != 0)
19
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/src/upf/upf-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/src/upf/upf-sm.c Changed
10
 
1
@@ -87,7 +87,7 @@
2
         }
3
 
4
         e->pfcp_message = pfcp_message;
5
-        e->pfcp_xact = xact;
6
+        e->pfcp_xact_id = xact ? xact->id : OGS_INVALID_POOL_ID;
7
         ogs_fsm_dispatch(&node->sm, e);
8
         if (OGS_FSM_CHECK(&node->sm, upf_pfcp_state_exception)) {
9
             ogs_error("PFCP state machine exception");
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/tests/af/af-sm.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/tests/af/af-sm.c Changed
103
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2024 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -45,6 +45,7 @@
9
     af_sess_t *sess = NULL;
10
 
11
     ogs_sbi_stream_t *stream = NULL;
12
+    ogs_pool_id_t stream_id = 0;
13
     ogs_sbi_request_t *request = NULL;
14
 
15
     ogs_sbi_nf_instance_t *nf_instance = NULL;
16
@@ -52,6 +53,7 @@
17
     ogs_sbi_response_t *response = NULL;
18
     ogs_sbi_message_t message;
19
     ogs_sbi_xact_t *sbi_xact = NULL;
20
+    ogs_pool_id_t sbi_xact_id = 0;
21
 
22
     af_sm_debug(e);
23
 
24
@@ -67,8 +69,16 @@
25
     case OGS_EVENT_SBI_SERVER:
26
         request = e->h.sbi.request;
27
         ogs_assert(request);
28
-        stream = e->h.sbi.data;
29
-        ogs_assert(stream);
30
+
31
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
32
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
33
+                stream_id <= OGS_MAX_POOL_ID);
34
+
35
+        stream = ogs_sbi_stream_find_by_id(stream_id);
36
+        if (!stream) {
37
+            ogs_error("STREAM has already been removed %d", stream_id);
38
+            break;
39
+        }
40
 
41
         rv = ogs_sbi_parse_request(&message, request);
42
         if (rv != OGS_OK) {
43
@@ -278,8 +288,17 @@
44
         CASE(OGS_SBI_SERVICE_NAME_NNRF_DISC)
45
             SWITCH(message.h.resource.component0)
46
             CASE(OGS_SBI_RESOURCE_NAME_NF_INSTANCES)
47
-                sbi_xact = e->h.sbi.data;
48
-                ogs_assert(sbi_xact);
49
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
50
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
51
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
52
+
53
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
54
+                if (!sbi_xact) {
55
+                    /* CLIENT_WAIT timer could remove SBI transaction
56
+                     * before receiving SBI message */
57
+                    ogs_error("SBI transaction has already been removed");
58
+                    break;
59
+                }
60
 
61
                 SWITCH(message.h.method)
62
                 CASE(OGS_SBI_HTTP_METHOD_GET)
63
@@ -306,10 +325,11 @@
64
         CASE(OGS_SBI_SERVICE_NAME_NBSF_MANAGEMENT)
65
             SWITCH(message.h.resource.component0)
66
             CASE(OGS_SBI_RESOURCE_NAME_PCF_BINDINGS)
67
-                sbi_xact = e->h.sbi.data;
68
-                ogs_assert(sbi_xact);
69
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
70
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
71
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
72
 
73
-                sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
74
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
75
                 if (!sbi_xact) {
76
                     /* CLIENT_WAIT timer could remove SBI transaction
77
                      * before receiving SBI message */
78
@@ -478,15 +498,21 @@
79
              * 4. timer expiration event is processed. (double-free SBI xact)
80
              *
81
              * To avoid double-free SBI xact,
82
-             * we need to check ogs_sbi_xact_cycle()
83
+             * we need to check ogs_sbi_xact_find_by_id()
84
              */
85
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
86
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
87
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
88
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
89
+
90
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
91
             if (!sbi_xact) {
92
                 ogs_error("SBI transaction has already been removed");
93
                 break;
94
             }
95
 
96
-            stream = sbi_xact->assoc_stream;
97
+            if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
98
+                sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
99
+                stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
100
             /* Here, we should not use ogs_assert(stream)
101
              * since 'namf-comm' service has no an associated stream. */
102
 
103
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/tests/af/sbi-path.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/tests/af/sbi-path.c Changed
10
 
1
@@ -74,7 +74,7 @@
2
     ogs_assert(build);
3
 
4
     xact = ogs_sbi_xact_add(
5
-            &sess->sbi, service_type, discovery_option,
6
+            0, &sess->sbi, service_type, discovery_option,
7
             (ogs_sbi_build_f)build, sess, data);
8
     if (!xact) {
9
         ogs_error("af_sbi_discover_and_send() failed");
10
open5gs_2.7.1.39.dc2e1.202406292026.tar.xz/tests/sctp/abts-main.c -> open5gs_2.7.1.48.555c2.202406302026.tar.xz/tests/sctp/abts-main.c Changed
11
 
1
@@ -33,6 +33,9 @@
2
 {
3
     ogs_sctp_final();
4
 
5
+    ogs_app_config_final();
6
+    ogs_app_context_final();
7
+
8
     ogs_pkbuf_default_destroy();
9
     ogs_core_terminate();
10
 }
11