Changes of Revision 473

commit_555c20c4c54f3825420551744511af21da9607c0.txt Added
commit_dc2e167a8f74d95829c87242063e8824de84f5b4.txt Deleted
open5gs_2.7.1.39.dc2e1.dsc -> open5gs_2.7.1.48.555c2.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
6
+Version: 2.7.1.48.555c2
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
- 28d058b5e35934942578dde05587cefe5f62b204 14496208 open5gs_2.7.1.39.dc2e1.tar.xz
15
+ 97373dfd288a1532628759e586b794b8f57468e4 14495712 open5gs_2.7.1.48.555c2.tar.xz
16
 Checksums-Sha256:
17
- fad371995b749ebbeb5950105335c9481a81930ea19a2e4306edaeb39404297b 14496208 open5gs_2.7.1.39.dc2e1.tar.xz
18
+ 8f4bdb382651beb1f8eeab0bb16f1b4403868a2164bf47611c72bb7c8afbe7d0 14495712 open5gs_2.7.1.48.555c2.tar.xz
19
 Files:
20
- 6a0ee0b3611b7de5527347347a7f7867 14496208 open5gs_2.7.1.39.dc2e1.tar.xz
21
+ 948b6b2c4f4bffd70fb656a67b899a50 14495712 open5gs_2.7.1.48.555c2.tar.xz
22
open5gs_2.7.1.39.dc2e1.tar.xz/.tarball-version -> open5gs_2.7.1.48.555c2.tar.xz/.tarball-version Changed
4
 
1
@@ -1 +1 @@
2
-2.7.1.39-dc2e1
3
+2.7.1.48-555c2
4
open5gs_2.7.1.39.dc2e1.tar.xz/debian/changelog -> open5gs_2.7.1.48.555c2.tar.xz/debian/changelog Changed
12
 
1
@@ -1,8 +1,8 @@
2
-open5gs (2.7.1.39.dc2e1) unstable; urgency=medium
3
+open5gs (2.7.1.48.555c2) unstable; urgency=medium
4
 
5
   * Automatically generated changelog entry for building the Osmocom master feed
6
 
7
- -- Osmocom OBS scripts <info@osmocom.org>  Fri, 28 Jun 2024 13:49:38 +0000
8
+ -- Osmocom OBS scripts <info@osmocom.org>  Sun, 30 Jun 2024 13:49:26 +0000
9
 
10
 open5gs (2.7.1) unstable; urgency=medium
11
 
12
open5gs_2.7.1.39.dc2e1.tar.xz/lib/core/ogs-macros.h -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/core/ogs-pool.h -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/core/ogs-timer.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/gtp/xact.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/gtp/xact.h -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/pfcp/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/pfcp/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/pfcp/xact.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/pfcp/xact.h -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/mhd-server.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/nghttp2-server.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/server.c -> open5gs_2.7.1.48.555c2.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.tar.xz/lib/sbi/server.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/amf-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/amf-sm.c Changed
396
 
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
             }
202
 
203
-            amf_ue = sess->amf_ue;
204
-            ogs_assert(amf_ue);
205
-            amf_ue = amf_ue_cycle(amf_ue);
206
-            ogs_assert(amf_ue);
207
+            amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
208
+            if (!amf_ue) {
209
+                ogs_error("UE(amf-ue) context has already been removed");
210
+                break;
211
+            }
212
 
213
             ogs_assert(OGS_FSM_STATE(&amf_ue->sm));
214
 
215
-            e->amf_ue = amf_ue;
216
-            e->sess = sess;
217
+            e->amf_ue_id = amf_ue->id;
218
+            e->sess_id = sess->id;
219
             e->h.sbi.message = &sbi_message;;
220
             e->h.sbi.state = state;
221
 
222
@@ -667,17 +699,26 @@
223
              * 4. timer expiration event is processed. (double-free SBI xact)
224
              *
225
              * To avoid double-free SBI xact,
226
-             * we need to check ogs_sbi_xact_cycle()
227
+             * we need to check ogs_sbi_xact_find_by_id()
228
              */
229
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
230
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
231
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
232
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
233
+
234
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
235
             if (!sbi_xact) {
236
-                ogs_error("SBI transaction has already been removed");
237
+                ogs_error("SBI transaction has already been removed %d",
238
+                        sbi_xact_id);
239
                 break;
240
             }
241
 
242
             sbi_object = sbi_xact->sbi_object;
243
             ogs_assert(sbi_object);
244
 
245
+            sbi_object_id = sbi_xact->sbi_object_id;
246
+            ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
247
+                    sbi_object_id <= OGS_MAX_POOL_ID);
248
+
249
             service_type = sbi_xact->service_type;
250
 
251
             ogs_sbi_xact_remove(sbi_xact);
252
@@ -687,9 +728,7 @@
253
 
254
             switch(sbi_object->type) {
255
             case OGS_SBI_OBJ_UE_TYPE:
256
-                amf_ue = (amf_ue_t *)sbi_object;
257
-                ogs_assert(amf_ue);
258
-                amf_ue = amf_ue_cycle(amf_ue);
259
+                amf_ue = amf_ue_find_by_id(sbi_object_id);
260
                 if (!amf_ue) {
261
                     ogs_error("UE(amf_ue) Context has already been removed");
262
                     break;
263
@@ -703,15 +742,13 @@
264
                 break;
265
 
266
             case OGS_SBI_OBJ_SESS_TYPE:
267
-                sess = (amf_sess_t *)sbi_object;
268
-                ogs_assert(sess);
269
-                sess = amf_sess_cycle(sess);
270
+                sess = amf_sess_find_by_id(sbi_object_id);
271
                 if (!sess) {
272
                     ogs_error("Session has already been removed");
273
                     break;
274
                 }
275
 
276
-                amf_ue = amf_ue_cycle(sess->amf_ue);
277
+                amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
278
                 if (!amf_ue) {
279
                     ogs_error("UE(amf_ue) Context has already been removed");
280
                     break;
281
@@ -720,13 +757,15 @@
282
                 ogs_error("%d:%d Cannot receive SBI message",
283
                         sess->psi, sess->pti);
284
                 if (sess->payload_container_type) {
285
-                    r = nas_5gs_send_back_gsm_message(sess->ran_ue, sess,
286
+                    r = nas_5gs_send_back_gsm_message(
287
+                            ran_ue_find_by_id(sess->ran_ue_id), sess,
288
                             OGS_5GMM_CAUSE_PAYLOAD_WAS_NOT_FORWARDED,
289
                             AMF_NAS_BACKOFF_TIME);
290
                     ogs_expect(r == OGS_OK);
291
                     ogs_assert(r != OGS_ERROR);
292
                 } else {
293
-                    r = ngap_send_error_indication2(sess->ran_ue,
294
+                    r = ngap_send_error_indication2(
295
+                            ran_ue_find_by_id(sess->ran_ue_id),
296
                             NGAP_Cause_PR_transport,
297
                             NGAP_CauseTransport_transport_resource_unavailable);
298
                     ogs_expect(r == OGS_OK);
299
@@ -760,7 +799,11 @@
300
         gnb = amf_gnb_find_by_addr(addr);
301
         if (!gnb) {
302
             gnb = amf_gnb_add(sock, addr);
303
-            ogs_assert(gnb);
304
+            if (!gnb) {
305
+                ogs_error("amf_gnb_add() failed");
306
+                ogs_sock_destroy(sock);
307
+                ogs_free(addr);
308
+            }
309
         } else {
310
             ogs_warn("gNB context duplicated with IP-address %s!!!",
311
                     OGS_ADDR(addr, buf));
312
@@ -782,7 +825,10 @@
313
         gnb = amf_gnb_find_by_addr(addr);
314
         if (!gnb) {
315
             gnb = amf_gnb_add(sock, addr);
316
-            ogs_assert(gnb);
317
+            if (!gnb) {
318
+                ogs_error("amf_gnb_add() failed");
319
+                ogs_free(addr);
320
+            }
321
         } else {
322
             ogs_free(addr);
323
         }
324
@@ -833,7 +879,7 @@
325
 
326
         rc = ogs_ngap_decode(&ngap_message, pkbuf);
327
         if (rc == OGS_OK) {
328
-            e->gnb = gnb;
329
+            e->gnb_id = gnb->id;
330
             e->ngap.message = &ngap_message;
331
             ogs_fsm_dispatch(&gnb->sm, e);
332
         } else {
333
@@ -850,13 +896,14 @@
334
         break;
335
 
336
     case AMF_EVENT_NGAP_TIMER:
337
-        ran_ue = e->ran_ue;
338
-        ogs_assert(ran_ue);
339
+        ran_ue = ran_ue_find_by_id(e->ran_ue_id);
340
+        if (!ran_ue) {
341
+            ogs_error("NG Context has already been removed");
342
+            break;
343
+        }
344
 
345
         switch (e->h.timer_id) {
346
         case AMF_TIMER_NG_DELAYED_SEND:
347
-            gnb = e->gnb;
348
-            ogs_assert(gnb);
349
             pkbuf = e->pkbuf;
350
             ogs_assert(pkbuf);
351
 
352
@@ -880,18 +927,22 @@
353
         break;
354
 
355
     case AMF_EVENT_5GMM_MESSAGE:
356
-        ran_ue = e->ran_ue;
357
-        ogs_assert(ran_ue);
358
         pkbuf = e->pkbuf;
359
         ogs_assert(pkbuf);
360
 
361
+        ran_ue = ran_ue_find_by_id(e->ran_ue_id);
362
+        if (!ran_ue) {
363
+            ogs_error("NG Context has already been removed");
364
+            break;
365
+        }
366
+
367
         if (ogs_nas_5gmm_decode(&nas_message, pkbuf) != OGS_OK) {
368
             ogs_error("ogs_nas_5gmm_decode() failed");
369
             ogs_pkbuf_free(pkbuf);
370
             break;
371
         }
372
 
373
-        amf_ue = ran_ue->amf_ue;
374
+        amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
375
         if (!amf_ue) {
376
             amf_ue = amf_ue_find_by_message(&nas_message);
377
             if (!amf_ue) {
378
@@ -986,7 +1037,7 @@
379
         ogs_assert(amf_ue);
380
         ogs_assert(OGS_FSM_STATE(&amf_ue->sm));
381
 
382
-        e->amf_ue = amf_ue;
383
+        e->amf_ue_id = amf_ue->id;
384
         e->nas.message = &nas_message;
385
 
386
         ogs_fsm_dispatch(&amf_ue->sm, e);
387
@@ -995,7 +1046,7 @@
388
         break;
389
 
390
     case AMF_EVENT_5GMM_TIMER:
391
-        amf_ue = amf_ue_cycle(e->amf_ue);
392
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
393
         if (!amf_ue) {
394
             ogs_error("UE(amf_ue) Context has already been removed");
395
             break;
396
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/context.c -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/context.c Changed
515
 
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
     }
202
     amf_ue->t3550.pkbuf = NULL;
203
@@ -1560,39 +1573,43 @@
204
             ogs_app()->timer_mgr, amf_timer_t3555_expire, amf_ue);
205
     if (!amf_ue->t3555.timer) {
206
         ogs_error("ogs_timer_add() failed");
207
-        ogs_pool_free(&amf_ue_pool, amf_ue);
208
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
209
         return NULL;
210
     }
211
     amf_ue->t3555.pkbuf = NULL;
212
     amf_ue->t3560.timer = ogs_timer_add(
213
-            ogs_app()->timer_mgr, amf_timer_t3560_expire, amf_ue);
214
+            ogs_app()->timer_mgr, amf_timer_t3560_expire,
215
+            OGS_UINT_TO_POINTER(amf_ue->id));
216
     if (!amf_ue->t3560.timer) {
217
         ogs_error("ogs_timer_add() failed");
218
-        ogs_pool_free(&amf_ue_pool, amf_ue);
219
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
220
         return NULL;
221
     }
222
     amf_ue->t3560.pkbuf = NULL;
223
     amf_ue->t3570.timer = ogs_timer_add(
224
-            ogs_app()->timer_mgr, amf_timer_t3570_expire, amf_ue);
225
+            ogs_app()->timer_mgr, amf_timer_t3570_expire,
226
+            OGS_UINT_TO_POINTER(amf_ue->id));
227
     if (!amf_ue->t3570.timer) {
228
         ogs_error("ogs_timer_add() failed");
229
-        ogs_pool_free(&amf_ue_pool, amf_ue);
230
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
231
         return NULL;
232
     }
233
     amf_ue->t3570.pkbuf = NULL;
234
     amf_ue->mobile_reachable.timer = ogs_timer_add(
235
-            ogs_app()->timer_mgr, amf_timer_mobile_reachable_expire, amf_ue);
236
+            ogs_app()->timer_mgr, amf_timer_mobile_reachable_expire,
237
+            OGS_UINT_TO_POINTER(amf_ue->id));
238
     if (!amf_ue->mobile_reachable.timer) {
239
         ogs_error("ogs_timer_add() failed");
240
-        ogs_pool_free(&amf_ue_pool, amf_ue);
241
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
242
         return NULL;
243
     }
244
     amf_ue->mobile_reachable.pkbuf = NULL;
245
     amf_ue->implicit_deregistration.timer = ogs_timer_add(
246
-            ogs_app()->timer_mgr, amf_timer_implicit_deregistration_expire, amf_ue);
247
+            ogs_app()->timer_mgr, amf_timer_implicit_deregistration_expire,
248
+            OGS_UINT_TO_POINTER(amf_ue->id));
249
     if (!amf_ue->implicit_deregistration.timer) {
250
         ogs_error("ogs_timer_add() failed");
251
-        ogs_pool_free(&amf_ue_pool, amf_ue);
252
+        ogs_pool_id_free(&amf_ue_pool, amf_ue);
253
         return NULL;
254
     }
255
     amf_ue->implicit_deregistration.pkbuf = NULL;
256
@@ -1713,7 +1730,7 @@
257
 
258
     amf_ue_deassociate(amf_ue);
259
 
260
-    ogs_pool_free(&amf_ue_pool, amf_ue);
261
+    ogs_pool_id_free(&amf_ue_pool, amf_ue);
262
 
263
     ogs_info("Removed Number of AMF-UEs is now %d",
264
             ogs_list_count(&self.amf_ue_list));
265
@@ -1724,7 +1741,7 @@
266
     amf_ue_t *amf_ue = NULL, *next = NULL;;
267
 
268
     ogs_list_for_each_safe(&self.amf_ue_list, next, amf_ue) {
269
-        ran_ue_t *ran_ue = ran_ue_cycle(amf_ue->ran_ue);
270
+        ran_ue_t *ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
271
 
272
         if (ran_ue) ran_ue_remove(ran_ue);
273
 
274
@@ -1739,7 +1756,7 @@
275
     ogs_assert(amf_ue);
276
 
277
     memset(&e, 0, sizeof(e));
278
-    e.amf_ue = amf_ue;
279
+    e.amf_ue_id = amf_ue->id;
280
     ogs_fsm_init(&amf_ue->sm, gmm_state_initial, gmm_state_final, &e);
281
 }
282
 
283
@@ -1750,7 +1767,7 @@
284
     ogs_assert(amf_ue);
285
 
286
     memset(&e, 0, sizeof(e));
287
-    e.amf_ue = amf_ue;
288
+    e.amf_ue_id = amf_ue->id;
289
     ogs_fsm_fini(&amf_ue->sm, &e);
290
 }
291
 
292
@@ -2075,13 +2092,20 @@
293
             ogs_pool_index(&amf_ue_pool, old_amf_ue)) {
294
             ogs_warn("%s OLD UE Context Release", suci);
295
             if (CM_CONNECTED(old_amf_ue)) {
296
+                ran_ue_t *ran_ue = ran_ue_find_by_id(old_amf_ue->ran_ue_id);
297
                 /* Implcit NG release */
298
                 ogs_warn("%s Implicit NG release", suci);
299
-                ogs_warn("%s    RAN_UE_NGAP_ID%lld AMF_UE_NGAP_ID%lld",
300
-                        old_amf_ue->suci,
301
-                        (long long)old_amf_ue->ran_ue->ran_ue_ngap_id,
302
-                        (long long)old_amf_ue->ran_ue->amf_ue_ngap_id);
303
-                ran_ue_remove(old_amf_ue->ran_ue);
304
+                if (ran_ue) {
305
+                    ogs_warn("%s    RAN_UE_NGAP_ID%lld "
306
+                            "AMF_UE_NGAP_ID%lld",
307
+                            old_amf_ue->suci,
308
+                            (long long)ran_ue->ran_ue_ngap_id,
309
+                            (long long)ran_ue->amf_ue_ngap_id);
310
+                    ran_ue_remove(ran_ue);
311
+                } else {
312
+                    ogs_error("%s RAN-NG Context has already been removed",
313
+                                old_amf_ue->suci);
314
+                }
315
             }
316
 
317
     /*
318
@@ -2099,7 +2123,7 @@
319
 
320
             /* Phase-1 : Change AMF-UE Context in Session Context */
321
             ogs_list_for_each(&old_amf_ue->sess_list, old_sess)
322
-                old_sess->amf_ue = amf_ue;
323
+                old_sess->amf_ue_id = amf_ue->id;
324
 
325
             /* Phase-2 : Move Session Context from OLD to NEW AMF-UE Context */
326
             memcpy(&amf_ue->sess_list,
327
@@ -2138,10 +2162,17 @@
328
     amf_gnb_t *gnb = NULL;
329
     ran_ue_t *ran_ue = NULL;
330
 
331
-    ran_ue = amf_ue->ran_ue;
332
-    ogs_assert(ran_ue);
333
-    gnb = ran_ue->gnb;
334
-    ogs_assert(gnb);
335
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
336
+    if (!ran_ue) {
337
+        ogs_error("%s RAN-NG Context has already been removed", amf_ue->suci);
338
+        return OpenAPI_rat_type_NULL;
339
+    }
340
+
341
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
342
+    if (!gnb) {
343
+        ogs_error("%d gNB has already been removed", ran_ue->gnb_id);
344
+        return OpenAPI_rat_type_NULL;
345
+    }
346
 
347
     return gnb->rat_type;
348
 }
349
@@ -2151,35 +2182,31 @@
350
     ogs_assert(amf_ue);
351
     ogs_assert(ran_ue);
352
 
353
-    amf_ue->ran_ue = ran_ue;
354
-    ran_ue->amf_ue = amf_ue;
355
+    amf_ue->ran_ue_id = ran_ue->id;
356
+    ran_ue->amf_ue_id = amf_ue->id;
357
 }
358
 
359
 void ran_ue_deassociate(ran_ue_t *ran_ue)
360
 {
361
     ogs_assert(ran_ue);
362
-    ran_ue->amf_ue = NULL;
363
+    ran_ue->amf_ue_id = OGS_INVALID_POOL_ID;
364
 }
365
 
366
 void amf_ue_deassociate(amf_ue_t *amf_ue)
367
 {
368
     ogs_assert(amf_ue);
369
-    amf_ue->ran_ue = NULL;
370
+    amf_ue->ran_ue_id = OGS_INVALID_POOL_ID;
371
 }
372
 
373
 void source_ue_associate_target_ue(
374
         ran_ue_t *source_ue, ran_ue_t *target_ue)
375
 {
376
-    amf_ue_t *amf_ue = NULL;
377
-
378
     ogs_assert(source_ue);
379
     ogs_assert(target_ue);
380
-    amf_ue = source_ue->amf_ue;
381
-    ogs_assert(amf_ue);
382
 
383
-    target_ue->amf_ue = amf_ue;
384
-    target_ue->source_ue = source_ue;
385
-    source_ue->target_ue = target_ue;
386
+    target_ue->amf_ue_id = source_ue->amf_ue_id;
387
+    target_ue->source_ue_id = source_ue->id;
388
+    source_ue->target_ue_id = target_ue->id;
389
 }
390
 
391
 void source_ue_deassociate_target_ue(ran_ue_t *ran_ue)
392
@@ -2188,22 +2215,28 @@
393
     ran_ue_t *target_ue = NULL;
394
     ogs_assert(ran_ue);
395
 
396
-    if (ran_ue->target_ue) {
397
+    if (ran_ue->target_ue_id >= OGS_MIN_POOL_ID &&
398
+        ran_ue->target_ue_id <= OGS_MAX_POOL_ID) {
399
         source_ue = ran_ue;
400
-        target_ue = ran_ue->target_ue;
401
+        target_ue = ran_ue_find_by_id(ran_ue->target_ue_id);
402
 
403
-        ogs_assert(source_ue->target_ue);
404
-        ogs_assert(target_ue->source_ue);
405
-        source_ue->target_ue = NULL;
406
-        target_ue->source_ue = NULL;
407
-    } else if (ran_ue->source_ue) {
408
+        ogs_assert(source_ue->target_ue_id >= OGS_MIN_POOL_ID &&
409
+                source_ue->target_ue_id <= OGS_MAX_POOL_ID);
410
+        ogs_assert(target_ue->source_ue_id >= OGS_MIN_POOL_ID &&
411
+                target_ue->source_ue_id <= OGS_MAX_POOL_ID);
412
+        source_ue->target_ue_id = OGS_INVALID_POOL_ID;
413
+        target_ue->source_ue_id = OGS_INVALID_POOL_ID;
414
+    } else if (ran_ue->source_ue_id >= OGS_MIN_POOL_ID &&
415
+                ran_ue->source_ue_id <= OGS_MAX_POOL_ID) {
416
         target_ue = ran_ue;
417
-        source_ue = ran_ue->source_ue;
418
+        source_ue = ran_ue_find_by_id(ran_ue->source_ue_id);
419
 
420
-        ogs_assert(source_ue->target_ue);
421
-        ogs_assert(target_ue->source_ue);
422
-        source_ue->target_ue = NULL;
423
-        target_ue->source_ue = NULL;
424
+        ogs_assert(source_ue->target_ue_id >= OGS_MIN_POOL_ID &&
425
+                source_ue->target_ue_id <= OGS_MAX_POOL_ID);
426
+        ogs_assert(target_ue->source_ue_id >= OGS_MIN_POOL_ID &&
427
+                target_ue->source_ue_id <= OGS_MAX_POOL_ID);
428
+        source_ue->target_ue_id = OGS_INVALID_POOL_ID;
429
+        target_ue->source_ue_id = OGS_INVALID_POOL_ID;
430
     }
431
 }
432
 
433
@@ -2214,13 +2247,12 @@
434
     ogs_assert(amf_ue);
435
     ogs_assert(psi != OGS_NAS_PDU_SESSION_IDENTITY_UNASSIGNED);
436
 
437
-    ogs_pool_alloc(&amf_sess_pool, &sess);
438
+    ogs_pool_id_calloc(&amf_sess_pool, &sess);
439
     ogs_assert(sess);
440
-    memset(sess, 0, sizeof *sess);
441
 
442
     sess->sbi.type = OGS_SBI_OBJ_SESS_TYPE;
443
 
444
-    sess->amf_ue = amf_ue;
445
+    sess->amf_ue_id = amf_ue->id;
446
     sess->psi = psi;
447
 
448
     sess->s_nssai.sst = 0;
449
@@ -2237,10 +2269,15 @@
450
 
451
 void amf_sess_remove(amf_sess_t *sess)
452
 {
453
+    amf_ue_t *amf_ue = NULL;
454
+
455
     ogs_assert(sess);
456
-    ogs_assert(sess->amf_ue);
457
 
458
-    ogs_list_remove(&sess->amf_ue->sess_list, sess);
459
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
460
+    if (amf_ue)
461
+        ogs_list_remove(&amf_ue->sess_list, sess);
462
+    else
463
+        ogs_error("UE(amf-ue) context has already been removed");
464
 
465
     /* Free SBI object memory */
466
     if (ogs_list_count(&sess->sbi.xact_list))
467
@@ -2277,7 +2314,7 @@
468
     if (sess->nssf.nrf.client)
469
         ogs_sbi_client_remove(sess->nssf.nrf.client);
470
 
471
-    ogs_pool_free(&amf_sess_pool, sess);
472
+    ogs_pool_id_free(&amf_sess_pool, sess);
473
 
474
     stats_remove_amf_session();
475
 }
476
@@ -2302,14 +2339,14 @@
477
     return NULL;
478
 }
479
 
480
-amf_ue_t *amf_ue_cycle(amf_ue_t *amf_ue)
481
+amf_ue_t *amf_ue_find_by_id(ogs_pool_id_t id)
482
 {
483
-    return ogs_pool_cycle(&amf_ue_pool, amf_ue);
484
+    return ogs_pool_find_by_id(&amf_ue_pool, id);
485
 }
486
 
487
-amf_sess_t *amf_sess_cycle(amf_sess_t *sess)
488
+amf_sess_t *amf_sess_find_by_id(ogs_pool_id_t id)
489
 {
490
-    return ogs_pool_cycle(&amf_sess_pool, sess);
491
+    return ogs_pool_find_by_id(&amf_sess_pool, id);
492
 }
493
 
494
 void amf_sbi_select_nf(
495
@@ -2748,15 +2785,16 @@
496
     ran_ue_t *ran_ue = NULL;
497
 
498
     ogs_assert(amf_ue);
499
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
500
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
501
     if (!ran_ue) {
502
         ogs_error("%s RAN-NG Context has already been removed",
503
                     amf_ue->supi);
504
         return false;
505
     }
506
-    gnb = amf_gnb_cycle(ran_ue->gnb);
507
+
508
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
509
     if (!gnb) {
510
-        ogs_error("gNB has already been removed");
511
+        ogs_error("%d gNB has already been removed", ran_ue->gnb_id);
512
         return false;
513
     }
514
 
515
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/context.h -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/context.h Changed
228
 
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
 int amf_gnb_set_gnb_id(amf_gnb_t *gnb, uint32_t gnb_id);
202
 int amf_gnb_sock_type(ogs_sock_t *sock);
203
-amf_gnb_t *amf_gnb_cycle(amf_gnb_t *gnb);
204
+amf_gnb_t *amf_gnb_find_by_id(ogs_pool_id_t id);
205
 
206
 ran_ue_t *ran_ue_add(amf_gnb_t *gnb, uint64_t ran_ue_ngap_id);
207
 void ran_ue_remove(ran_ue_t *ran_ue);
208
@@ -821,7 +847,7 @@
209
         amf_gnb_t *gnb, uint64_t ran_ue_ngap_id);
210
 ran_ue_t *ran_ue_find(uint32_t index);
211
 ran_ue_t *ran_ue_find_by_amf_ue_ngap_id(uint64_t amf_ue_ngap_id);
212
-ran_ue_t *ran_ue_cycle(ran_ue_t *ran_ue);
213
+ran_ue_t *ran_ue_find_by_id(ogs_pool_id_t id);
214
 
215
 void amf_ue_new_guti(amf_ue_t *amf_ue);
216
 void amf_ue_confirm_guti(amf_ue_t *amf_ue);
217
@@ -924,8 +950,8 @@
218
 amf_sess_t *amf_sess_find_by_psi(amf_ue_t *amf_ue, uint8_t psi);
219
 amf_sess_t *amf_sess_find_by_dnn(amf_ue_t *amf_ue, char *dnn);
220
 
221
-amf_ue_t *amf_ue_cycle(amf_ue_t *amf_ue);
222
-amf_sess_t *amf_sess_cycle(amf_sess_t *sess);
223
+amf_ue_t *amf_ue_find_by_id(ogs_pool_id_t id);
224
+amf_sess_t *amf_sess_find_by_id(ogs_pool_id_t id);
225
 
226
 void amf_sbi_select_nf(
227
         ogs_sbi_object_t *sbi_object,
228
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/gmm-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/gmm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/gmm-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/gmm-sm.c Changed
230
 
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
+    sess = amf_sess_find_by_id(e->sess_id);
202
+    if (sess) {
203
+        amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
204
         ogs_assert(amf_ue);
205
     } else {
206
-        amf_ue = e->amf_ue;
207
+        amf_ue = amf_ue_find_by_id(e->amf_ue_id);
208
         ogs_assert(amf_ue);
209
     }
210
 
211
@@ -2516,7 +2517,8 @@
212
         xact_count = amf_sess_xact_count(amf_ue);
213
 
214
         amf_sbi_send_release_all_sessions(
215
-                amf_ue->ran_ue, amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE);
216
+                ran_ue_find_by_id(amf_ue->ran_ue_id), amf_ue,
217
+                AMF_RELEASE_SM_CONTEXT_NO_STATE);
218
 
219
         if (!AMF_SESSION_RELEASE_PENDING(amf_ue) &&
220
             amf_sess_xact_count(amf_ue) == xact_count) {
221
@@ -2534,7 +2536,7 @@
222
         nas_message = e->nas.message;
223
         ogs_assert(nas_message);
224
 
225
-        ran_ue = ran_ue_cycle(amf_ue->ran_ue);
226
+        ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
227
         ogs_assert(ran_ue);
228
 
229
         h.type = e->nas.type;
230
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/namf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/nas-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/nas-path.c Changed
496
 
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
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
202
+    if (!ran_ue) {
203
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
204
         return OGS_NOTFOUND;
205
     }
206
 
207
@@ -493,7 +503,7 @@
208
 
209
     amf_metrics_inst_global_inc(AMF_METR_GLOB_CTR_AMF_AUTH_REQ);
210
 
211
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
212
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
213
     ogs_expect(rv == OGS_OK);
214
 
215
     return rv;
216
@@ -502,15 +512,17 @@
217
 int nas_5gs_send_authentication_reject(amf_ue_t *amf_ue)
218
 {
219
     int rv;
220
+    ran_ue_t *ran_ue = NULL;
221
     ogs_pkbuf_t *gmmbuf = NULL;
222
 
223
-    if (!amf_ue_cycle(amf_ue)) {
224
+    if (!amf_ue) {
225
         ogs_error("UE(amf-ue) context has already been removed");
226
         return OGS_NOTFOUND;
227
     }
228
 
229
-    if (!ran_ue_cycle(amf_ue->ran_ue)) {
230
-        ogs_error("NG context has already been removed");
231
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
232
+    if (!ran_ue) {
233
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
234
         return OGS_NOTFOUND;
235
     }
236
 
237
@@ -524,7 +536,7 @@
238
 
239
     amf_metrics_inst_global_inc(AMF_METR_GLOB_CTR_AMF_AUTH_REJECT);
240
 
241
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
242
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
243
     ogs_expect(rv == OGS_OK);
244
 
245
     return rv;
246
@@ -533,15 +545,17 @@
247
 int nas_5gs_send_security_mode_command(amf_ue_t *amf_ue)
248
 {
249
     int rv;
250
+    ran_ue_t *ran_ue = NULL;
251
     ogs_pkbuf_t *gmmbuf = NULL;
252
 
253
-    if (!amf_ue_cycle(amf_ue)) {
254
+    if (!amf_ue) {
255
         ogs_error("UE(amf-ue) context has already been removed");
256
         return OGS_NOTFOUND;
257
     }
258
 
259
-    if (!ran_ue_cycle(amf_ue->ran_ue)) {
260
-        ogs_error("NG context has already been removed");
261
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
262
+    if (!ran_ue) {
263
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
264
         return OGS_NOTFOUND;
265
     }
266
 
267
@@ -566,7 +580,7 @@
268
     ogs_timer_start(amf_ue->t3560.timer,
269
             amf_timer_cfg(AMF_TIMER_T3560)->duration);
270
 
271
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
272
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
273
     ogs_expect(rv == OGS_OK);
274
 
275
     return rv;
276
@@ -576,15 +590,17 @@
277
         amf_ue_t *amf_ue, gmm_configuration_update_command_param_t *param)
278
 {
279
     int rv;
280
+    ran_ue_t *ran_ue = NULL;
281
     ogs_pkbuf_t *gmmbuf = NULL;
282
 
283
-    if (!amf_ue_cycle(amf_ue)) {
284
+    if (!amf_ue) {
285
         ogs_error("UE(amf-ue) context has already been removed");
286
         return OGS_NOTFOUND;
287
     }
288
 
289
-    if (!ran_ue_cycle(amf_ue->ran_ue)) {
290
-        ogs_error("NG context has already been removed");
291
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
292
+    if (!ran_ue) {
293
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
294
         return OGS_NOTFOUND;
295
     }
296
 
297
@@ -627,7 +643,7 @@
298
 
299
     amf_metrics_inst_global_inc(AMF_METR_GLOB_CTR_MM_CONF_UPDATE);
300
 
301
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
302
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
303
     ogs_expect(rv == OGS_OK);
304
 
305
     return rv;
306
@@ -645,16 +661,16 @@
307
     ogs_pkbuf_t *ngapbuf = NULL;
308
 
309
     ogs_assert(sess);
310
-    amf_ue = amf_ue_cycle(sess->amf_ue);
311
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
312
     if (!amf_ue) {
313
         ogs_error("UE(amf-ue) context has already been removed");
314
         if (n1smbuf) ogs_pkbuf_free(n1smbuf);
315
         ogs_pkbuf_free(n2smbuf);
316
         return OGS_NOTFOUND;
317
     }
318
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
319
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
320
     if (!ran_ue) {
321
-        ogs_warn("NG context has already been removed");
322
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
323
         if (n1smbuf) ogs_pkbuf_free(n1smbuf);
324
         ogs_pkbuf_free(n2smbuf);
325
         return OGS_NOTFOUND;
326
@@ -709,16 +725,16 @@
327
     ogs_pkbuf_t *ngapbuf = NULL;
328
 
329
     ogs_assert(sess);
330
-    amf_ue = amf_ue_cycle(sess->amf_ue);
331
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
332
     if (!amf_ue) {
333
         ogs_error("UE(amf-ue) context has already been removed");
334
         if (n1smbuf) ogs_pkbuf_free(n1smbuf);
335
         ogs_pkbuf_free(n2smbuf);
336
         return OGS_NOTFOUND;
337
     }
338
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
339
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
340
     if (!ran_ue) {
341
-        ogs_warn("%s NG context has already been removed", amf_ue->supi);
342
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
343
         if (n1smbuf) ogs_pkbuf_free(n1smbuf);
344
         ogs_pkbuf_free(n2smbuf);
345
         return OGS_NOTFOUND;
346
@@ -770,16 +786,16 @@
347
 
348
     ogs_assert(n2smbuf);
349
     ogs_assert(sess);
350
-    amf_ue = amf_ue_cycle(sess->amf_ue);
351
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
352
     if (!amf_ue) {
353
         ogs_error("UE(amf-ue) context has already been removed");
354
         if (n1smbuf) ogs_pkbuf_free(n1smbuf);
355
         ogs_pkbuf_free(n2smbuf);
356
         return OGS_NOTFOUND;
357
     }
358
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
359
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
360
     if (!ran_ue) {
361
-        ogs_warn("NG context has already been removed");
362
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
363
         if (n1smbuf) ogs_pkbuf_free(n1smbuf);
364
         ogs_pkbuf_free(n2smbuf);
365
         return OGS_NOTFOUND;
366
@@ -862,15 +878,17 @@
367
 int nas_5gs_send_gmm_status(amf_ue_t *amf_ue, ogs_nas_5gmm_cause_t cause)
368
 {
369
     int rv;
370
+    ran_ue_t *ran_ue = NULL;
371
     ogs_pkbuf_t *gmmbuf = NULL;
372
 
373
-    if (!amf_ue_cycle(amf_ue)) {
374
+    if (!amf_ue) {
375
         ogs_error("UE(amf-ue) context has already been removed");
376
         return OGS_NOTFOUND;
377
     }
378
 
379
-    if (!ran_ue_cycle(amf_ue->ran_ue)) {
380
-        ogs_error("NG context has already been removed");
381
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
382
+    if (!ran_ue) {
383
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
384
         return OGS_NOTFOUND;
385
     }
386
 
387
@@ -882,7 +900,7 @@
388
         return OGS_ERROR;
389
     }
390
 
391
-    rv = nas_5gs_send_to_downlink_nas_transport(amf_ue->ran_ue, gmmbuf);
392
+    rv = nas_5gs_send_to_downlink_nas_transport(ran_ue, gmmbuf);
393
     ogs_expect(rv == OGS_OK);
394
 
395
     return rv;
396
@@ -893,13 +911,11 @@
397
 {
398
     int rv;
399
 
400
-    amf_ue = amf_ue_cycle(amf_ue);
401
     if (!amf_ue) {
402
         ogs_error("UE(amf-ue) context has already been removed");
403
         return OGS_NOTFOUND;
404
     }
405
 
406
-    ran_ue = ran_ue_cycle(ran_ue);
407
     if (!ran_ue) {
408
         ogs_error("%s NG context has already been removed", amf_ue->supi);
409
         return OGS_NOTFOUND;
410
@@ -950,11 +966,17 @@
411
 int nas_5gs_send_gmm_reject_from_sbi(amf_ue_t *amf_ue, int status)
412
 {
413
     int rv;
414
+    ran_ue_t *ran_ue = NULL;
415
 
416
     ogs_assert(amf_ue);
417
 
418
-    rv = nas_5gs_send_gmm_reject(
419
-            amf_ue->ran_ue, amf_ue, gmm_cause_from_sbi(status));
420
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
421
+    if (!ran_ue) {
422
+        ogs_error("%s NG context has already been removed", amf_ue->supi);
423
+        return OGS_NOTFOUND;
424
+    }
425
+
426
+    rv = nas_5gs_send_gmm_reject(ran_ue, amf_ue, gmm_cause_from_sbi(status));
427
     ogs_expect(rv == OGS_OK);
428
 
429
     return rv;
430
@@ -969,20 +991,17 @@
431
     ogs_pkbuf_t *gmmbuf = NULL;
432
     amf_ue_t *amf_ue = NULL;
433
 
434
-    ogs_assert(sess);
435
-    sess = amf_sess_cycle(sess);
436
     if (!sess) {
437
         ogs_error("Session has already been removed");
438
         return OGS_NOTFOUND;
439
     }
440
 
441
-    amf_ue = amf_ue_cycle(sess->amf_ue);
442
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
443
     if (!amf_ue) {
444
         ogs_error("UE(amf-ue) context has already been removed");
445
         return OGS_NOTFOUND;
446
     }
447
 
448
-    ran_ue = ran_ue_cycle(ran_ue);
449
     if (!ran_ue) {
450
         ogs_error("%s NG context has already been removed", amf_ue->supi);
451
         return OGS_NOTFOUND;
452
@@ -1025,19 +1044,18 @@
453
     amf_ue_t *amf_ue = NULL;
454
 
455
     ogs_assert(sess);
456
-    sess = amf_sess_cycle(sess);
457
+
458
     if (!sess) {
459
         ogs_error("Session has already been removed");
460
         return OGS_NOTFOUND;
461
     }
462
 
463
-    amf_ue = amf_ue_cycle(sess->amf_ue);
464
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
465
     if (!amf_ue) {
466
         ogs_error("UE(amf-ue) context has already been removed");
467
         return OGS_NOTFOUND;
468
     }
469
 
470
-    ran_ue = ran_ue_cycle(ran_ue);
471
     if (!ran_ue) {
472
         ogs_error("%s NG context has already been removed", amf_ue->supi);
473
         return OGS_NOTFOUND;
474
@@ -1061,20 +1079,17 @@
475
     ogs_pkbuf_t *pbuf = NULL;
476
     amf_ue_t *amf_ue = NULL;
477
 
478
-    ogs_assert(sess);
479
-    sess = amf_sess_cycle(sess);
480
     if (!sess) {
481
         ogs_error("Session has already been removed");
482
         return OGS_NOTFOUND;
483
     }
484
 
485
-    amf_ue = amf_ue_cycle(sess->amf_ue);
486
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
487
     if (!amf_ue) {
488
         ogs_error("UE(amf-ue) context has already been removed");
489
         return OGS_NOTFOUND;
490
     }
491
 
492
-    ran_ue = ran_ue_cycle(ran_ue);
493
     if (!ran_ue) {
494
         ogs_error("%s NG context has already been removed", amf_ue->supi);
495
         return OGS_NOTFOUND;
496
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/ngap-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/ngap-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/ngap-handler.c Changed
233
 
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
-    amf_ue = source_ue->amf_ue;
202
+    amf_ue = amf_ue_find_by_id(source_ue->amf_ue_id);
203
     if (!amf_ue) {
204
         ogs_error("Cannot find AMF-UE Context %lld",
205
                 (long long)amf_ue_ngap_id);
206
@@ -4127,7 +4125,7 @@
207
         return;
208
     }
209
 
210
-    source_ue = target_ue->source_ue;
211
+    source_ue = ran_ue_find_by_id(target_ue->source_ue_id);
212
     if (!source_ue) {
213
         ogs_error("Cannot find Source-UE Context %lld",
214
                 (long long)amf_ue_ngap_id);
215
@@ -4139,7 +4137,7 @@
216
         ogs_assert(r != OGS_ERROR);
217
         return;
218
     }
219
-    amf_ue = target_ue->amf_ue;
220
+    amf_ue = amf_ue_find_by_id(target_ue->amf_ue_id);
221
     if (!amf_ue) {
222
         ogs_error("Cannot find AMF-UE Context %lld",
223
                 (long long)amf_ue_ngap_id);
224
@@ -4663,7 +4661,7 @@
225
             /* RAN_UE Context where PartOfNG_interface was requested */
226
             ran_ue->part_of_ng_reset_requested = true;
227
 
228
-            amf_ue = ran_ue->amf_ue;
229
+            amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
230
             /*
231
              * Issues #1928
232
              *
233
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/ngap-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/amf/ngap-path.c Changed
349
 
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
     }
202
@@ -503,10 +498,7 @@
203
     int rv;
204
     ogs_pkbuf_t *ngapbuf = NULL;
205
 
206
-    if (!amf_gnb_cycle(target_gnb)) {
207
-        ogs_error("gNB has already been removed");
208
-        return OGS_NOTFOUND;
209
-    }
210
+    ogs_assert(target_gnb);
211
     ogs_assert(transfer);
212
 
213
     ngapbuf = ngap_build_downlink_ran_configuration_transfer(transfer);
214
@@ -529,20 +521,18 @@
215
     ran_ue_t *ran_ue = NULL;
216
     ogs_pkbuf_t *ngapbuf = NULL;
217
 
218
-    ogs_assert(sess);
219
-    sess = amf_sess_cycle(sess);
220
     if (!sess) {
221
         ogs_error("Session has already been removed");
222
         return OGS_NOTFOUND;
223
     }
224
 
225
-    amf_ue = amf_ue_cycle(sess->amf_ue);
226
+    amf_ue = amf_ue_find_by_id(sess->amf_ue_id);
227
     if (!amf_ue) {
228
         ogs_error("UE(amf-ue) context has already been removed");
229
         return OGS_NOTFOUND;
230
     }
231
 
232
-    ran_ue = ran_ue_cycle(amf_ue->ran_ue);
233
+    ran_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
234
     if (!ran_ue) {
235
         ogs_error("%s NG context has already been removed", amf_ue->supi);
236
         return OGS_NOTFOUND;
237
@@ -567,18 +557,18 @@
238
     ran_ue_t *source_ue = NULL, *target_ue = NULL;
239
     ogs_pkbuf_t *ngapbuf = NULL;
240
 
241
-    if (!amf_ue_cycle(amf_ue)) {
242
+    if (!amf_ue) {
243
         ogs_error("UE(amf-ue) context has already been removed");
244
         return OGS_NOTFOUND;
245
     }
246
 
247
-    source_ue = ran_ue_cycle(amf_ue->ran_ue);
248
+    source_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
249
     if (!source_ue) {
250
         ogs_error("NG context has already been removed");
251
         return OGS_NOTFOUND;
252
     }
253
 
254
-    target_ue = ran_ue_cycle(source_ue->target_ue);
255
+    target_ue = ran_ue_find_by_id(source_ue->target_ue_id);
256
     if (!target_ue) {
257
         ogs_error("NG context has already been removed");
258
         return OGS_NOTFOUND;
259
@@ -602,7 +592,7 @@
260
     int rv;
261
     ogs_pkbuf_t *ngapbuf = NULL;
262
 
263
-    if (!ran_ue_cycle(source_ue)) {
264
+    if (!source_ue) {
265
         ogs_error("NG context has already been removed");
266
         return OGS_NOTFOUND;
267
     }
268
@@ -628,12 +618,12 @@
269
     ran_ue_t *source_ue = NULL;
270
     ogs_pkbuf_t *ngapbuf = NULL;
271
 
272
-    if (!amf_ue_cycle(amf_ue)) {
273
+    if (!amf_ue) {
274
         ogs_error("UE(amf-ue) context has already been removed");
275
         return OGS_NOTFOUND;
276
     }
277
 
278
-    source_ue = ran_ue_cycle(amf_ue->ran_ue);
279
+    source_ue = ran_ue_find_by_id(amf_ue->ran_ue_id);
280
     if (!source_ue) {
281
         ogs_error("NG context has already been removed");
282
         return OGS_NOTFOUND;
283
@@ -656,7 +646,7 @@
284
     int rv;
285
     ogs_pkbuf_t *ngapbuf = NULL;
286
 
287
-    if (!ran_ue_cycle(source_ue)) {
288
+    if (!source_ue) {
289
         ogs_error("NG context has already been removed");
290
         return OGS_NOTFOUND;
291
     }
292
@@ -680,7 +670,7 @@
293
     int rv;
294
     ogs_pkbuf_t *ngapbuf = NULL;
295
 
296
-    if (!ran_ue_cycle(target_ue)) {
297
+    if (!target_ue) {
298
         ogs_error("NG context has already been removed");
299
         return OGS_NOTFOUND;
300
     }
301
@@ -707,10 +697,7 @@
302
     int rv;
303
     ogs_pkbuf_t *ngapbuf = NULL;
304
 
305
-    if (!amf_gnb_cycle(gnb)) {
306
-        ogs_error("gNB has already been removed");
307
-        return OGS_NOTFOUND;
308
-    }
309
+    ogs_assert(gnb);
310
 
311
     ngapbuf = ogs_ngap_build_error_indication(
312
             ran_ue_ngap_id, amf_ue_ngap_id, group, cause);
313
@@ -729,15 +716,21 @@
314
         ran_ue_t *ran_ue, NGAP_Cause_PR group, long cause)
315
 {
316
     int rv;
317
+    amf_gnb_t *gnb = NULL;
318
 
319
-    ran_ue = ran_ue_cycle(ran_ue);
320
     if (!ran_ue) {
321
         ogs_error("NG context has already been removed");
322
         return OGS_NOTFOUND;
323
     }
324
 
325
+    gnb = amf_gnb_find_by_id(ran_ue->gnb_id);
326
+    if (!gnb) {
327
+        ogs_error("%d gNB has already been removed", ran_ue->gnb_id);
328
+        return OGS_NOTFOUND;
329
+    }
330
+
331
     rv = ngap_send_error_indication(
332
-        ran_ue->gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id,
333
+        gnb, &ran_ue->ran_ue_ngap_id, &ran_ue->amf_ue_ngap_id,
334
         group, cause);
335
     ogs_expect(rv == OGS_OK);
336
 
337
@@ -751,10 +744,7 @@
338
     int rv;
339
     ogs_pkbuf_t *ngapbuf = NULL;
340
 
341
-    if (!amf_gnb_cycle(gnb)) {
342
-        ogs_error("gNB has already been removed");
343
-        return OGS_NOTFOUND;
344
-    }
345
+    ogs_assert(gnb);
346
 
347
     ngapbuf = ogs_ngap_build_ng_reset_ack(partOfNG_Interface);
348
     if (!ngapbuf) {
349
open5gs_2.7.1.39.dc2e1.tar.xz/src/amf/ngap-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/nnrf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/nnssf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/npcf-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/nsmf-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/nsmf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/nudm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/amf/timer.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/ausf/ausf-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/ausf/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/ausf/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/ausf/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/ausf/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/ausf/ue-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/bsf/bsf-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/bsf/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/emm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/emm-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/esm-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/esm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/esm-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-context.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/mme-context.c Changed
904
 
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
+    source_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
202
     ogs_assert(source_ue);
203
 
204
     current = source_ue->sgw;
205
@@ -3114,13 +3117,13 @@
206
     if (!changed) return SGW_WITHOUT_RELOCATION;
207
 
208
     /* Check if Old Source UE */
209
-    old_source_ue = sgw_ue_cycle(source_ue->source_ue);
210
+    old_source_ue = sgw_ue_find_by_id(source_ue->source_ue_id);
211
     if (old_source_ue) {
212
         sgw_ue_source_deassociate_target(old_source_ue);
213
         sgw_ue_remove(old_source_ue);
214
     }
215
 
216
-    target_ue = sgw_ue_cycle(source_ue->target_ue);
217
+    target_ue = sgw_ue_find_by_id(source_ue->target_ue_id);
218
     if (target_ue) {
219
         ogs_error("SGW-UE source has already been associated with target");
220
         return SGW_HAS_ALREADY_BEEN_RELOCATED;
221
@@ -3254,80 +3257,90 @@
222
     char bufOGS_ADDRSTRLEN;
223
 
224
     ogs_assert(enb_ue);
225
-    enb = enb_ue->enb;
226
-    ogs_assert(enb);
227
 
228
-    ogs_pool_alloc(&mme_ue_pool, &mme_ue);
229
+    enb = mme_enb_find_by_id(enb_ue->enb_id);
230
+    if (!enb) {
231
+        ogs_error("%d eNB has already been removed", enb_ue->enb_id);
232
+        return NULL;
233
+    }
234
+
235
+    ogs_pool_id_calloc(&mme_ue_pool, &mme_ue);
236
     if (mme_ue == NULL) {
237
         ogs_error("Could not allocate mme_ue context from pool");
238
         return NULL;
239
     }
240
 
241
-    memset(mme_ue, 0, sizeof *mme_ue);
242
-
243
     /* Add All Timers */
244
     mme_ue->t3413.timer = ogs_timer_add(
245
-            ogs_app()->timer_mgr, mme_timer_t3413_expire, mme_ue);
246
+            ogs_app()->timer_mgr, mme_timer_t3413_expire,
247
+            OGS_UINT_TO_POINTER(mme_ue->id));
248
     if (!mme_ue->t3413.timer) {
249
         ogs_error("ogs_timer_add() failed");
250
-        ogs_pool_free(&mme_ue_pool, mme_ue);
251
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
252
         return NULL;
253
     }
254
     mme_ue->t3413.pkbuf = NULL;
255
     mme_ue->t3422.timer = ogs_timer_add(
256
-            ogs_app()->timer_mgr, mme_timer_t3422_expire, mme_ue);
257
+            ogs_app()->timer_mgr, mme_timer_t3422_expire,
258
+            OGS_UINT_TO_POINTER(mme_ue->id));
259
     if (!mme_ue->t3422.timer) {
260
         ogs_error("ogs_timer_add() failed");
261
-        ogs_pool_free(&mme_ue_pool, mme_ue);
262
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
263
         return NULL;
264
     }
265
     mme_ue->t3422.pkbuf = NULL;
266
     mme_ue->t3450.timer = ogs_timer_add(
267
-            ogs_app()->timer_mgr, mme_timer_t3450_expire, mme_ue);
268
+            ogs_app()->timer_mgr, mme_timer_t3450_expire,
269
+            OGS_UINT_TO_POINTER(mme_ue->id));
270
     if (!mme_ue->t3450.timer) {
271
         ogs_error("ogs_timer_add() failed");
272
-        ogs_pool_free(&mme_ue_pool, mme_ue);
273
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
274
         return NULL;
275
     }
276
     mme_ue->t3450.pkbuf = NULL;
277
     mme_ue->t3460.timer = ogs_timer_add(
278
-            ogs_app()->timer_mgr, mme_timer_t3460_expire, mme_ue);
279
+            ogs_app()->timer_mgr, mme_timer_t3460_expire,
280
+            OGS_UINT_TO_POINTER(mme_ue->id));
281
     if (!mme_ue->t3460.timer) {
282
         ogs_error("ogs_timer_add() failed");
283
-        ogs_pool_free(&mme_ue_pool, mme_ue);
284
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
285
         return NULL;
286
     }
287
     mme_ue->t3460.pkbuf = NULL;
288
     mme_ue->t3470.timer = ogs_timer_add(
289
-            ogs_app()->timer_mgr, mme_timer_t3470_expire, mme_ue);
290
+            ogs_app()->timer_mgr, mme_timer_t3470_expire,
291
+            OGS_UINT_TO_POINTER(mme_ue->id));
292
     if (!mme_ue->t3470.timer) {
293
         ogs_error("ogs_timer_add() failed");
294
-        ogs_pool_free(&mme_ue_pool, mme_ue);
295
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
296
         return NULL;
297
     }
298
     mme_ue->t3470.pkbuf = NULL;
299
     mme_ue->t_mobile_reachable.timer = ogs_timer_add(
300
-            ogs_app()->timer_mgr, mme_timer_mobile_reachable_expire, mme_ue);
301
+            ogs_app()->timer_mgr, mme_timer_mobile_reachable_expire,
302
+            OGS_UINT_TO_POINTER(mme_ue->id));
303
     if (!mme_ue->t_mobile_reachable.timer) {
304
         ogs_error("ogs_timer_add() failed");
305
-        ogs_pool_free(&mme_ue_pool, mme_ue);
306
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
307
         return NULL;
308
     }
309
     mme_ue->t_mobile_reachable.pkbuf = NULL;
310
     mme_ue->t_implicit_detach.timer = ogs_timer_add(
311
-            ogs_app()->timer_mgr, mme_timer_implicit_detach_expire, mme_ue);
312
+            ogs_app()->timer_mgr, mme_timer_implicit_detach_expire,
313
+            OGS_UINT_TO_POINTER(mme_ue->id));
314
     if (!mme_ue->t_implicit_detach.timer) {
315
         ogs_error("ogs_timer_add() failed");
316
-        ogs_pool_free(&mme_ue_pool, mme_ue);
317
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
318
         return NULL;
319
     }
320
     mme_ue->t_implicit_detach.pkbuf = NULL;
321
 
322
     mme_ue->gn.t_gn_holding = ogs_timer_add(
323
-            ogs_app()->timer_mgr, mme_timer_gn_holding_timer_expire, mme_ue);
324
+            ogs_app()->timer_mgr, mme_timer_gn_holding_timer_expire,
325
+            OGS_UINT_TO_POINTER(mme_ue->id));
326
     if (! mme_ue->gn.t_gn_holding) {
327
         ogs_error("ogs_timer_add() failed");
328
-        ogs_pool_free(&mme_ue_pool, mme_ue);
329
+        ogs_pool_id_free(&mme_ue_pool, mme_ue);
330
         return NULL;
331
     }
332
 
333
@@ -3384,6 +3397,7 @@
334
 
335
 void mme_ue_remove(mme_ue_t *mme_ue)
336
 {
337
+    sgw_ue_t *sgw_ue = NULL;
338
     ogs_assert(mme_ue);
339
 
340
     ogs_list_remove(&self.mme_ue_list, mme_ue);
341
@@ -3395,8 +3409,8 @@
342
     ogs_hash_set(self.mme_gn_teid_hash,
343
             &mme_ue->gn.mme_gn_teid, sizeof(mme_ue->gn.mme_gn_teid), NULL);
344
 
345
-    ogs_assert(mme_ue->sgw_ue);
346
-    sgw_ue_remove(mme_ue->sgw_ue);
347
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
348
+    if (sgw_ue) sgw_ue_remove(sgw_ue);
349
 
350
     if (mme_ue->imsi_len != 0)
351
         ogs_hash_set(mme_self()->imsi_ue_hash,
352
@@ -3443,7 +3457,7 @@
353
 
354
     ogs_pool_free(&mme_s11_teid_pool, mme_ue->mme_s11_teid_node);
355
     ogs_pool_free(&mme_gn_teid_pool, mme_ue->gn.mme_gn_teid_node);
356
-    ogs_pool_free(&mme_ue_pool, mme_ue);
357
+    ogs_pool_id_free(&mme_ue_pool, mme_ue);
358
 
359
     ogs_info("Removed Number of MME-UEs is now %d",
360
             ogs_list_count(&self.mme_ue_list));
361
@@ -3454,7 +3468,7 @@
362
     mme_ue_t *mme_ue = NULL, *next = NULL;;
363
 
364
     ogs_list_for_each_safe(&self.mme_ue_list, next, mme_ue) {
365
-        enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue);
366
+        enb_ue_t *enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
367
 
368
         if (enb_ue) enb_ue_remove(enb_ue);
369
 
370
@@ -3462,9 +3476,9 @@
371
     }
372
 }
373
 
374
-mme_ue_t *mme_ue_cycle(mme_ue_t *mme_ue)
375
+mme_ue_t *mme_ue_find_by_id(ogs_pool_id_t id)
376
 {
377
-    return ogs_pool_cycle(&mme_ue_pool, mme_ue);
378
+    return ogs_pool_find_by_id(&mme_ue_pool, id);
379
 }
380
 
381
 void mme_ue_fsm_init(mme_ue_t *mme_ue)
382
@@ -3474,7 +3488,7 @@
383
     ogs_assert(mme_ue);
384
 
385
     memset(&e, 0, sizeof(e));
386
-    e.mme_ue = mme_ue;
387
+    e.mme_ue_id = mme_ue->id;
388
     ogs_fsm_init(&mme_ue->sm, emm_state_initial, emm_state_final, &e);
389
 }
390
 
391
@@ -3485,7 +3499,7 @@
392
     ogs_assert(mme_ue);
393
 
394
     memset(&e, 0, sizeof(e));
395
-    e.mme_ue = mme_ue;
396
+    e.mme_ue_id = mme_ue->id;
397
     ogs_fsm_fini(&mme_ue->sm, &e);
398
 }
399
 
400
@@ -3705,6 +3719,7 @@
401
     mme_ue_t *old_mme_ue = NULL;
402
     mme_sess_t *old_sess = NULL;
403
     mme_bearer_t *old_bearer = NULL;
404
+    sgw_ue_t *sgw_ue = NULL, *old_sgw_ue = NULL;
405
     ogs_assert(mme_ue && imsi_bcd);
406
 
407
     ogs_cpystrn(mme_ue->imsi_bcd, imsi_bcd, OGS_MAX_IMSI_BCD_LEN+1);
408
@@ -3718,13 +3733,19 @@
409
             ogs_pool_index(&mme_ue_pool, old_mme_ue)) {
410
             ogs_warn("%s OLD UE Context Release", mme_ue->imsi_bcd);
411
             if (ECM_CONNECTED(old_mme_ue)) {
412
+                enb_ue_t *enb_ue = enb_ue_find_by_id(old_mme_ue->enb_ue_id);
413
                 /* Implcit S1 release */
414
                 ogs_warn("%s Implicit S1 release", mme_ue->imsi_bcd);
415
-                ogs_warn("%s    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
416
-                        old_mme_ue->imsi_bcd,
417
-                        old_mme_ue->enb_ue->enb_ue_s1ap_id,
418
-                        old_mme_ue->enb_ue->mme_ue_s1ap_id);
419
-                enb_ue_remove(old_mme_ue->enb_ue);
420
+                if (enb_ue) {
421
+                    ogs_warn("%s    ENB_UE_S1AP_ID%d MME_UE_S1AP_ID%d",
422
+                            old_mme_ue->imsi_bcd,
423
+                            enb_ue->enb_ue_s1ap_id,
424
+                            enb_ue->mme_ue_s1ap_id);
425
+                    enb_ue_remove(enb_ue);
426
+                } else {
427
+                    ogs_error("%s S1 Context has already been removed",
428
+                                old_mme_ue->imsi_bcd);
429
+                }
430
             }
431
 
432
     /*
433
@@ -3742,14 +3763,14 @@
434
             /* Phase-1 : Change MME-UE Context in Session Context */
435
             ogs_list_for_each(&old_mme_ue->sess_list, old_sess) {
436
                 ogs_list_for_each(&old_sess->bearer_list, old_bearer) {
437
-                    old_bearer->mme_ue = mme_ue;
438
+                    old_bearer->mme_ue_id = mme_ue->id;
439
 
440
                     if (old_bearer->ebi_node)
441
                         ogs_pool_free(
442
                                 &old_mme_ue->ebi_pool, old_bearer->ebi_node);
443
                     old_bearer->ebi_node = NULL;
444
                 }
445
-                old_sess->mme_ue = mme_ue;
446
+                old_sess->mme_ue_id = mme_ue->id;
447
             }
448
 
449
             /* Phase-2 : Move Session Context from OLD to NEW MME-UE Context */
450
@@ -3760,11 +3781,12 @@
451
             memset(&old_mme_ue->sess_list, 0, sizeof(old_mme_ue->sess_list));
452
 
453
             /* Phase-4 : Move sgw_ue->sgw_s11_teid */
454
-            ogs_assert(old_mme_ue->sgw_ue);
455
-            ogs_assert(mme_ue->sgw_ue);
456
-            mme_ue->sgw_ue->sgw_s11_teid = old_mme_ue->sgw_ue->sgw_s11_teid;
457
+            sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
458
+            ogs_assert(sgw_ue);
459
+            old_sgw_ue = sgw_ue_find_by_id(old_mme_ue->sgw_ue_id);
460
+            ogs_assert(old_sgw_ue);
461
+            sgw_ue->sgw_s11_teid = old_sgw_ue->sgw_s11_teid;
462
 
463
-            MME_UE_CHECK(OGS_LOG_WARN, old_mme_ue);
464
             mme_ue_remove(old_mme_ue);
465
         }
466
     }
467
@@ -3875,7 +3897,7 @@
468
     ogs_assert(org == OGS_GTP_LOCAL_ORIGINATOR ||
469
                 org == OGS_GTP_REMOTE_ORIGINATOR);
470
 
471
-    sgw_ue = mme_ue->sgw_ue;
472
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
473
     if (!sgw_ue) return 0;
474
 
475
     gnode = sgw_ue->gnode;
476
@@ -3891,34 +3913,30 @@
477
     ogs_assert(mme_ue);
478
     ogs_assert(enb_ue);
479
 
480
-    mme_ue->enb_ue = enb_ue;
481
-    enb_ue->mme_ue = mme_ue;
482
+    mme_ue->enb_ue_id = enb_ue->id;
483
+    enb_ue->mme_ue_id = mme_ue->id;
484
 }
485
 
486
 void enb_ue_deassociate(enb_ue_t *enb_ue)
487
 {
488
     ogs_assert(enb_ue);
489
-    enb_ue->mme_ue = NULL;
490
+    enb_ue->mme_ue_id = OGS_INVALID_POOL_ID;
491
 }
492
 
493
 void enb_ue_unlink(mme_ue_t *mme_ue)
494
 {
495
     ogs_assert(mme_ue);
496
-    mme_ue->enb_ue = NULL;
497
+    mme_ue->enb_ue_id = OGS_INVALID_POOL_ID;
498
 }
499
 
500
 void enb_ue_source_associate_target(enb_ue_t *source_ue, enb_ue_t *target_ue)
501
 {
502
-    mme_ue_t *mme_ue = NULL;
503
-
504
     ogs_assert(source_ue);
505
     ogs_assert(target_ue);
506
-    mme_ue = source_ue->mme_ue;
507
-    ogs_assert(mme_ue);
508
 
509
-    target_ue->mme_ue = mme_ue;
510
-    target_ue->source_ue = source_ue;
511
-    source_ue->target_ue = target_ue;
512
+    target_ue->mme_ue_id = source_ue->mme_ue_id;
513
+    target_ue->source_ue_id = source_ue->id;
514
+    source_ue->target_ue_id = target_ue->id;
515
 }
516
 
517
 void enb_ue_source_deassociate_target(enb_ue_t *enb_ue)
518
@@ -3927,22 +3945,28 @@
519
     enb_ue_t *target_ue = NULL;
520
     ogs_assert(enb_ue);
521
 
522
-    if (enb_ue->target_ue) {
523
+    if (enb_ue->target_ue_id >= OGS_MIN_POOL_ID &&
524
+        enb_ue->target_ue_id <= OGS_MAX_POOL_ID) {
525
         source_ue = enb_ue;
526
-        target_ue = enb_ue->target_ue;
527
+        target_ue = enb_ue_find_by_id(enb_ue->target_ue_id);
528
 
529
-        ogs_assert(source_ue->target_ue);
530
-        ogs_assert(target_ue->source_ue);
531
-        source_ue->target_ue = NULL;
532
-        target_ue->source_ue = NULL;
533
-    } else if (enb_ue->source_ue) {
534
+        ogs_assert(source_ue->target_ue_id >= OGS_MIN_POOL_ID &&
535
+                source_ue->target_ue_id <= OGS_MAX_POOL_ID);
536
+        ogs_assert(target_ue->source_ue_id >= OGS_MIN_POOL_ID &&
537
+                target_ue->source_ue_id <= OGS_MAX_POOL_ID);
538
+        source_ue->target_ue_id = OGS_INVALID_POOL_ID;
539
+        target_ue->source_ue_id = OGS_INVALID_POOL_ID;
540
+    } else if (enb_ue->source_ue_id >= OGS_MIN_POOL_ID &&
541
+                enb_ue->source_ue_id <= OGS_MAX_POOL_ID) {
542
         target_ue = enb_ue;
543
-        source_ue = enb_ue->source_ue;
544
+        source_ue = enb_ue_find_by_id(enb_ue->source_ue_id);
545
 
546
-        ogs_assert(source_ue->target_ue);
547
-        ogs_assert(target_ue->source_ue);
548
-        source_ue->target_ue = NULL;
549
-        target_ue->source_ue = NULL;
550
+        ogs_assert(source_ue->target_ue_id >= OGS_MIN_POOL_ID &&
551
+                source_ue->target_ue_id <= OGS_MAX_POOL_ID);
552
+        ogs_assert(target_ue->source_ue_id >= OGS_MIN_POOL_ID &&
553
+                target_ue->source_ue_id <= OGS_MAX_POOL_ID);
554
+        source_ue->target_ue_id = OGS_INVALID_POOL_ID;
555
+        target_ue->source_ue_id = OGS_INVALID_POOL_ID;
556
     }
557
 }
558
 
559
@@ -3951,34 +3975,30 @@
560
     ogs_assert(mme_ue);
561
     ogs_assert(sgw_ue);
562
 
563
-    mme_ue->sgw_ue = sgw_ue;
564
-    sgw_ue->mme_ue = mme_ue;
565
+    mme_ue->sgw_ue_id = sgw_ue->id;
566
+    sgw_ue->mme_ue_id = mme_ue->id;
567
 }
568
 
569
 void sgw_ue_deassociate(sgw_ue_t *sgw_ue)
570
 {
571
     ogs_assert(sgw_ue);
572
-    sgw_ue->mme_ue = NULL;
573
+    sgw_ue->mme_ue_id = OGS_INVALID_POOL_ID;
574
 }
575
 
576
 void sgw_ue_unlink(mme_ue_t *mme_ue)
577
 {
578
     ogs_assert(mme_ue);
579
-    mme_ue->sgw_ue = NULL;
580
+    mme_ue->sgw_ue_id = OGS_INVALID_POOL_ID;
581
 }
582
 
583
 void sgw_ue_source_associate_target(sgw_ue_t *source_ue, sgw_ue_t *target_ue)
584
 {
585
-    mme_ue_t *mme_ue = NULL;
586
-
587
     ogs_assert(source_ue);
588
     ogs_assert(target_ue);
589
-    mme_ue = source_ue->mme_ue;
590
-    ogs_assert(mme_ue);
591
 
592
-    target_ue->mme_ue = mme_ue;
593
-    target_ue->source_ue = source_ue;
594
-    source_ue->target_ue = target_ue;
595
+    target_ue->mme_ue_id = source_ue->mme_ue_id;
596
+    target_ue->source_ue_id = source_ue->id;
597
+    source_ue->target_ue_id = target_ue->id;
598
 }
599
 
600
 void sgw_ue_source_deassociate_target(sgw_ue_t *sgw_ue)
601
@@ -3987,22 +4007,28 @@
602
     sgw_ue_t *target_ue = NULL;
603
     ogs_assert(sgw_ue);
604
 
605
-    if (sgw_ue->target_ue) {
606
+    if (sgw_ue->target_ue_id >= OGS_MIN_POOL_ID &&
607
+        sgw_ue->target_ue_id <= OGS_MAX_POOL_ID) {
608
         source_ue = sgw_ue;
609
-        target_ue = sgw_ue->target_ue;
610
+        target_ue = sgw_ue_find_by_id(sgw_ue->target_ue_id);
611
 
612
-        ogs_assert(source_ue->target_ue);
613
-        ogs_assert(target_ue->source_ue);
614
-        source_ue->target_ue = NULL;
615
-        target_ue->source_ue = NULL;
616
-    } else if (sgw_ue->source_ue) {
617
+        ogs_assert(source_ue->target_ue_id >= OGS_MIN_POOL_ID &&
618
+                source_ue->target_ue_id <= OGS_MAX_POOL_ID);
619
+        ogs_assert(target_ue->source_ue_id >= OGS_MIN_POOL_ID &&
620
+                target_ue->source_ue_id <= OGS_MAX_POOL_ID);
621
+        source_ue->target_ue_id = OGS_INVALID_POOL_ID;
622
+        target_ue->source_ue_id = OGS_INVALID_POOL_ID;
623
+    } else if (sgw_ue->source_ue_id >= OGS_MIN_POOL_ID &&
624
+                sgw_ue->source_ue_id <= OGS_MAX_POOL_ID) {
625
         target_ue = sgw_ue;
626
-        source_ue = sgw_ue->source_ue;
627
+        source_ue = sgw_ue_find_by_id(sgw_ue->source_ue_id);
628
 
629
-        ogs_assert(source_ue->target_ue);
630
-        ogs_assert(target_ue->source_ue);
631
-        source_ue->target_ue = NULL;
632
-        target_ue->source_ue = NULL;
633
+        ogs_assert(source_ue->target_ue_id >= OGS_MIN_POOL_ID &&
634
+                source_ue->target_ue_id <= OGS_MAX_POOL_ID);
635
+        ogs_assert(target_ue->source_ue_id >= OGS_MIN_POOL_ID &&
636
+                target_ue->source_ue_id <= OGS_MAX_POOL_ID);
637
+        source_ue->target_ue_id = OGS_INVALID_POOL_ID;
638
+        target_ue->source_ue_id = OGS_INVALID_POOL_ID;
639
     }
640
 }
641
 
642
@@ -4014,13 +4040,12 @@
643
     ogs_assert(mme_ue);
644
     ogs_assert(pti != OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED);
645
 
646
-    ogs_pool_alloc(&mme_sess_pool, &sess);
647
+    ogs_pool_id_calloc(&mme_sess_pool, &sess);
648
     ogs_assert(sess);
649
-    memset(sess, 0, sizeof *sess);
650
 
651
     ogs_list_init(&sess->bearer_list);
652
 
653
-    sess->mme_ue = mme_ue;
654
+    sess->mme_ue_id = mme_ue->id;
655
     sess->pti = pti;
656
 
657
     bearer = mme_bearer_add(sess);
658
@@ -4038,7 +4063,7 @@
659
     mme_ue_t *mme_ue = NULL;
660
 
661
     ogs_assert(sess);
662
-    mme_ue = sess->mme_ue;
663
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
664
     ogs_assert(mme_ue);
665
 
666
     ogs_list_remove(&mme_ue->sess_list, sess);
667
@@ -4050,7 +4075,7 @@
668
     OGS_TLV_CLEAR_DATA(&sess->pgw_pco);
669
     OGS_TLV_CLEAR_DATA(&sess->pgw_epco);
670
 
671
-    ogs_pool_free(&mme_sess_pool, sess);
672
+    ogs_pool_id_free(&mme_sess_pool, sess);
673
 
674
     stats_remove_mme_session();
675
 }
676
@@ -4090,7 +4115,7 @@
677
 
678
     bearer = mme_bearer_find_by_ue_ebi(mme_ue, ebi);
679
     if (bearer)
680
-        return bearer->sess;
681
+        return mme_sess_find_by_id(bearer->sess_id);
682
 
683
     return NULL;
684
 }
685
@@ -4112,6 +4137,11 @@
686
     return NULL;
687
 }
688
 
689
+mme_sess_t *mme_sess_find_by_id(ogs_pool_id_t id)
690
+{
691
+    return ogs_pool_find_by_id(&mme_sess_pool, id);
692
+}
693
+
694
 mme_sess_t *mme_sess_first(const mme_ue_t *mme_ue)
695
 {
696
     return ogs_list_first(&mme_ue->sess_list);
697
@@ -4142,12 +4172,11 @@
698
     mme_ue_t *mme_ue = NULL;
699
 
700
     ogs_assert(sess);
701
-    mme_ue = sess->mme_ue;
702
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
703
     ogs_assert(mme_ue);
704
 
705
-    ogs_pool_alloc(&mme_bearer_pool, &bearer);
706
+    ogs_pool_id_calloc(&mme_bearer_pool, &bearer);
707
     ogs_assert(bearer);
708
-    memset(bearer, 0, sizeof *bearer);
709
 
710
     ogs_list_init(&bearer->update.xact_list);
711
 
712
@@ -4159,17 +4188,18 @@
713
     ogs_assert(bearer->ebi >= MIN_EPS_BEARER_ID &&
714
                 bearer->ebi <= MAX_EPS_BEARER_ID);
715
 
716
-    bearer->mme_ue = mme_ue;
717
-    bearer->sess = sess;
718
+    bearer->mme_ue_id = mme_ue->id;
719
+    bearer->sess_id = sess->id;
720
 
721
     ogs_list_add(&sess->bearer_list, bearer);
722
 
723
     bearer->t3489.timer = ogs_timer_add(
724
-            ogs_app()->timer_mgr, mme_timer_t3489_expire, bearer);
725
+            ogs_app()->timer_mgr, mme_timer_t3489_expire,
726
+            OGS_UINT_TO_POINTER(bearer->id));
727
     bearer->t3489.pkbuf = NULL;
728
 
729
     memset(&e, 0, sizeof(e));
730
-    e.bearer = bearer;
731
+    e.bearer_id = bearer->id;
732
     ogs_fsm_init(&bearer->sm, esm_state_initial, esm_state_final, &e);
733
 
734
     return bearer;
735
@@ -4178,32 +4208,36 @@
736
 void mme_bearer_remove(mme_bearer_t *bearer)
737
 {
738
     mme_event_t e;
739
+    mme_ue_t *mme_ue = NULL;
740
+    mme_sess_t *sess = NULL;
741
     ogs_gtp_xact_t *xact = NULL, *next_xact = NULL;
742
 
743
     ogs_assert(bearer);
744
-    ogs_assert(bearer->mme_ue);
745
-    ogs_assert(bearer->sess);
746
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
747
+    ogs_assert(mme_ue);
748
+    sess = mme_sess_find_by_id(bearer->sess_id);
749
+    ogs_assert(sess);
750
 
751
     memset(&e, 0, sizeof(e));
752
-    e.bearer = bearer;
753
+    e.bearer_id = bearer->id;
754
     ogs_fsm_fini(&bearer->sm, &e);
755
 
756
     CLEAR_BEARER_ALL_TIMERS(bearer);
757
     ogs_timer_delete(bearer->t3489.timer);
758
 
759
-    ogs_list_remove(&bearer->sess->bearer_list, bearer);
760
+    ogs_list_remove(&sess->bearer_list, bearer);
761
 
762
     OGS_TLV_CLEAR_DATA(&bearer->tft);
763
 
764
     if (bearer->ebi_node)
765
-        ogs_pool_free(&bearer->mme_ue->ebi_pool, bearer->ebi_node);
766
+        ogs_pool_free(&mme_ue->ebi_pool, bearer->ebi_node);
767
 
768
     ogs_list_for_each_entry_safe(&bearer->update.xact_list,
769
             next_xact, xact, to_update_node) {
770
         ogs_list_remove(&bearer->update.xact_list, &xact->to_update_node);
771
     }
772
 
773
-    ogs_pool_free(&mme_bearer_pool, bearer);
774
+    ogs_pool_id_free(&mme_bearer_pool, bearer);
775
 }
776
 
777
 void mme_bearer_remove_all(mme_sess_t *sess)
778
@@ -4268,10 +4302,14 @@
779
 
780
     mme_bearer_t *bearer = NULL;
781
     mme_sess_t *sess = NULL;
782
+    mme_ue_t *sess_mme_ue = NULL;
783
+    enb_ue_t *enb_ue = NULL;
784
 
785
     ogs_assert(mme_ue);
786
     ogs_assert(message);
787
 
788
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
789
+
790
     pti = message->esm.h.procedure_transaction_identity;
791
     ebi = message->esm.h.eps_bearer_identity;
792
 
793
@@ -4283,7 +4321,7 @@
794
         bearer = mme_bearer_find_by_ue_ebi(mme_ue, ebi);
795
         if (!bearer) {
796
             ogs_error("No Bearer : EBI%d", ebi);
797
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
798
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
799
                     OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,
800
                     OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
801
             ogs_expect(r == OGS_OK);
802
@@ -4297,7 +4335,7 @@
803
     if (pti == OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED) {
804
         ogs_error("ESM message type: %d, Both PTI%d and EBI%d are 0",
805
                 message->esm.h.message_type, pti, ebi);
806
-        r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
807
+        r = nas_eps_send_attach_reject(enb_ue, mme_ue,
808
                 OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,
809
                 OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
810
         ogs_expect(r == OGS_OK);
811
@@ -4316,7 +4354,7 @@
812
         if (!bearer) {
813
             ogs_error("No Bearer : Linked-EBI%d",
814
                     linked_eps_bearer_identity->eps_bearer_identity);
815
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
816
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
817
                     OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,
818
                     OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
819
             ogs_expect(r == OGS_OK);
820
@@ -4367,7 +4405,7 @@
821
     }
822
 
823
     if (bearer) {
824
-        sess = bearer->sess;
825
+        sess = mme_sess_find_by_id(bearer->sess_id);
826
         ogs_assert(sess);
827
         sess->pti = pti;
828
 
829
@@ -4402,11 +4440,12 @@
830
                 ogs_debug("%s:%d:%d:%p",
831
                     sess->session ? sess->session->name : "Unknown",
832
                     sess->pti, pti, sess);
833
+
834
+                sess_mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
835
                 ogs_debug("%s:%p",
836
-                    sess->mme_ue ? sess->mme_ue->imsi_bcd : "Unknown",
837
-                    sess->mme_ue);
838
+                    sess_mme_ue ? sess_mme_ue->imsi_bcd : "Unknown",
839
+                    sess_mme_ue);
840
             }
841
-            MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
842
         }
843
 
844
         if (!sess) {
845
@@ -4417,20 +4456,22 @@
846
             ogs_debug("%s:%d:%d:%p",
847
                 sess->session ? sess->session->name : "Unknown",
848
                 sess->pti, pti, sess);
849
+
850
+            sess_mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
851
             ogs_debug("%s:%p",
852
-                sess->mme_ue ? sess->mme_ue->imsi_bcd : "Unknown",
853
-                sess->mme_ue);
854
-            MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
855
+                sess_mme_ue ? sess_mme_ue->imsi_bcd : "Unknown",
856
+                sess_mme_ue);
857
         } else {
858
             sess->pti = pti;
859
             ogs_debug("%s:%p", mme_ue->imsi_bcd, mme_ue);
860
             ogs_debug("%s:%d:%d:%p",
861
                 sess->session ? sess->session->name : "Unknown",
862
                 sess->pti, pti, sess);
863
+
864
+            sess_mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
865
             ogs_debug("%s:%p",
866
-                sess->mme_ue ? sess->mme_ue->imsi_bcd : "Unknown",
867
-                sess->mme_ue);
868
-            MME_UE_CHECK(OGS_LOG_DEBUG, mme_ue);
869
+                sess_mme_ue ? sess_mme_ue->imsi_bcd : "Unknown",
870
+                sess_mme_ue);
871
         }
872
 
873
     } else {
874
@@ -4438,7 +4479,7 @@
875
         if (!sess) {
876
             ogs_error("No Session : ESM message type%d, PTI%d",
877
                     message->esm.h.message_type, pti);
878
-            r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
879
+            r = nas_eps_send_attach_reject(enb_ue, mme_ue,
880
                     OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,
881
                     OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
882
             ogs_expect(r == OGS_OK);
883
@@ -4468,7 +4509,7 @@
884
     mme_sess_t *sess = NULL;
885
 
886
     ogs_assert(bearer);
887
-    sess = bearer->sess;
888
+    sess = mme_sess_find_by_id(bearer->sess_id);
889
     ogs_assert(sess);
890
 
891
     return mme_default_bearer_in_sess(sess);
892
@@ -4487,9 +4528,9 @@
893
     return ogs_list_next(bearer);
894
 }
895
 
896
-mme_bearer_t *mme_bearer_cycle(mme_bearer_t *bearer)
897
+mme_bearer_t *mme_bearer_find_by_id(ogs_pool_id_t id)
898
 {
899
-    return ogs_pool_cycle(&mme_bearer_pool, bearer);
900
+    return ogs_pool_find_by_id(&mme_bearer_pool, id);
901
 }
902
 
903
 void mme_session_remove_all(mme_ue_t *mme_ue)
904
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/mme-context.h -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/mme-context.h Changed
335
 
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
@@ -614,7 +595,7 @@
202
     } paging;
203
 
204
     /* SGW UE context */
205
-    sgw_ue_t        *sgw_ue;
206
+    ogs_pool_id_t sgw_ue_id;
207
 
208
     /* Save PDN Connectivity Request */
209
     ogs_nas_esm_message_container_t pdn_connectivity_request;
210
@@ -715,19 +696,25 @@
211
 };
212
 
213
 #define SESSION_CONTEXT_IS_AVAILABLE(__mME) \
214
-     ((__mME) && ((__mME)->sgw_ue) && (((__mME)->sgw_ue)->sgw_s11_teid))
215
+    ((__mME) && \
216
+     ((__mME)->sgw_ue_id >= OGS_MIN_POOL_ID) && \
217
+     ((__mME)->sgw_ue_id <= OGS_MAX_POOL_ID) && \
218
+     (sgw_ue_find_by_id((__mME)->sgw_ue_id)) && \
219
+     (sgw_ue_find_by_id((__mME)->sgw_ue_id)->sgw_s11_teid))
220
 
221
 #define CLEAR_SESSION_CONTEXT(__mME) \
222
     do { \
223
+        sgw_ue_t *sgw_ue = NULL; \
224
         ogs_assert((__mME)); \
225
-        ((__mME)->sgw_ue)->sgw_s11_teid = 0; \
226
+        sgw_ue = sgw_ue_find_by_id((__mME)->sgw_ue_id); \
227
+        if (sgw_ue) sgw_ue->sgw_s11_teid = 0; \
228
     } while(0)
229
 
230
 #define MME_SESS_CLEAR(__sESS) \
231
     do { \
232
         mme_ue_t *mme_ue = NULL; \
233
         ogs_assert(__sESS); \
234
-        mme_ue = (__sESS)->mme_ue; \
235
+        mme_ue = mme_ue_find_by_id((__sESS)->mme_ue_id); \
236
         ogs_assert(mme_ue); \
237
         ogs_info("Removed Session: UE IMSI:%s APN:%s", \
238
                 mme_ue->imsi_bcd, \
239
@@ -743,6 +730,7 @@
240
     (mme_ue_have_session_release_pending(__mME))
241
 typedef struct mme_sess_s {
242
     ogs_lnode_t     lnode;
243
+    ogs_pool_id_t   id;
244
 
245
     uint8_t         pti;        /* Procedure Trasaction Identity */
246
 
247
@@ -756,7 +744,7 @@
248
     ogs_list_t      bearer_list;
249
 
250
     /* Related Context */
251
-    mme_ue_t        *mme_ue;
252
+    ogs_pool_id_t   mme_ue_id;
253
 
254
     ogs_session_t   *session;
255
 
256
@@ -821,6 +809,8 @@
257
     ogs_lnode_t     lnode;
258
     ogs_lnode_t     to_modify_node;
259
 
260
+    ogs_pool_id_t   id;
261
+
262
     ogs_fsm_t       sm;             /* State Machine */
263
 
264
     uint8_t         *ebi_node;      /* Pool-Node for EPS Bearer ID */
265
@@ -870,8 +860,8 @@
266
     } t3489;
267
 
268
     /* Related Context */
269
-    mme_ue_t        *mme_ue;
270
-    mme_sess_t      *sess;
271
+    ogs_pool_id_t   mme_ue_id;
272
+    ogs_pool_id_t   sess_id;
273
 
274
     /*
275
      * Issues #3240
276
@@ -889,7 +879,7 @@
277
      * as a list so that we can manage multiple of them.
278
      */
279
     struct {
280
-        ogs_gtp_xact_t  *xact;
281
+        ogs_pool_id_t  xact_id;
282
     } create, delete, notify;
283
     struct {
284
         ogs_list_t  xact_list;
285
@@ -940,7 +930,7 @@
286
 mme_enb_t *mme_enb_find_by_enb_id(uint32_t enb_id);
287
 int mme_enb_set_enb_id(mme_enb_t *enb, uint32_t enb_id);
288
 int mme_enb_sock_type(ogs_sock_t *sock);
289
-mme_enb_t *mme_enb_cycle(mme_enb_t *enb);
290
+mme_enb_t *mme_enb_find_by_id(ogs_pool_id_t id);
291
 
292
 enb_ue_t *enb_ue_add(mme_enb_t *enb, uint32_t enb_ue_s1ap_id);
293
 void enb_ue_remove(enb_ue_t *enb_ue);
294
@@ -949,12 +939,12 @@
295
         const mme_enb_t *enb, uint32_t enb_ue_s1ap_id);
296
 enb_ue_t *enb_ue_find(uint32_t index);
297
 enb_ue_t *enb_ue_find_by_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id);
298
-enb_ue_t *enb_ue_cycle(enb_ue_t *enb_ue);
299
+enb_ue_t *enb_ue_find_by_id(ogs_pool_id_t id);
300
 
301
 sgw_ue_t *sgw_ue_add(mme_sgw_t *sgw);
302
 void sgw_ue_remove(sgw_ue_t *sgw_ue);
303
 void sgw_ue_switch_to_sgw(sgw_ue_t *sgw_ue, mme_sgw_t *new_sgw);
304
-sgw_ue_t *sgw_ue_cycle(sgw_ue_t *sgw_ue);
305
+sgw_ue_t *sgw_ue_find_by_id(ogs_pool_id_t id);
306
 
307
 typedef enum {
308
     SGW_WITHOUT_RELOCATION = 1,
309
@@ -969,7 +959,7 @@
310
 mme_ue_t *mme_ue_add(enb_ue_t *enb_ue);
311
 void mme_ue_remove(mme_ue_t *mme_ue);
312
 void mme_ue_remove_all(void);
313
-mme_ue_t *mme_ue_cycle(mme_ue_t *mme_ue);
314
+mme_ue_t *mme_ue_find_by_id(ogs_pool_id_t id);
315
 
316
 void mme_ue_fsm_init(mme_ue_t *mme_ue);
317
 void mme_ue_fsm_fini(mme_ue_t *mme_ue);
318
@@ -1059,6 +1049,7 @@
319
 mme_sess_t *mme_sess_find_by_pti(const mme_ue_t *mme_ue, uint8_t pti);
320
 mme_sess_t *mme_sess_find_by_ebi(const mme_ue_t *mme_ue, uint8_t ebi);
321
 mme_sess_t *mme_sess_find_by_apn(const mme_ue_t *mme_ue, const char *apn);
322
+mme_sess_t *mme_sess_find_by_id(ogs_pool_id_t id);
323
 
324
 mme_sess_t *mme_sess_first(const mme_ue_t *mme_ue);
325
 mme_sess_t *mme_sess_next(mme_sess_t *sess);
326
@@ -1075,7 +1066,7 @@
327
 mme_bearer_t *mme_linked_bearer(mme_bearer_t *bearer);
328
 mme_bearer_t *mme_bearer_first(const mme_sess_t *sess);
329
 mme_bearer_t *mme_bearer_next(mme_bearer_t *bearer);
330
-mme_bearer_t *mme_bearer_cycle(mme_bearer_t *bearer);
331
+mme_bearer_t *mme_bearer_find_by_id(ogs_pool_id_t id);
332
 
333
 void mme_session_remove_all(mme_ue_t *mme_ue);
334
 ogs_session_t *mme_session_find_by_apn(mme_ue_t *mme_ue, const char *apn);
335
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/mme-event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-fd-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-gn-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-gn-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-gtp-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/mme-gtp-path.c Changed
319
 
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
+
202
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
203
     h.type = OGS_GTP2_DELETE_BEARER_RESPONSE_TYPE;
204
     h.teid = sgw_ue->sgw_s11_teid;
205
@@ -542,7 +564,7 @@
206
 
207
     ogs_assert(action);
208
     ogs_assert(mme_ue);
209
-    sgw_ue = mme_ue->sgw_ue;
210
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
211
     ogs_assert(sgw_ue);
212
 
213
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
214
@@ -555,7 +577,9 @@
215
         return OGS_ERROR;
216
     }
217
 
218
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, pkbuf, timeout, mme_ue);
219
+    xact = ogs_gtp_xact_local_create(
220
+            sgw_ue->gnode, &h, pkbuf, timeout,
221
+            OGS_UINT_TO_POINTER(mme_ue->id));
222
     if (!xact) {
223
         ogs_error("ogs_gtp_xact_local_create() failed");
224
         return OGS_ERROR;
225
@@ -575,7 +599,7 @@
226
     enb_ue_t *enb_ue = NULL, *next = NULL;
227
 
228
     ogs_list_for_each_safe(&enb->enb_ue_list, next, enb_ue) {
229
-        mme_ue = enb_ue->mme_ue;
230
+        mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
231
 
232
         if (mme_ue) {
233
             if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED) {
234
@@ -631,14 +655,17 @@
235
     ogs_pkbuf_t *s11buf = NULL;
236
 
237
     ogs_assert(bearer);
238
-    xact = ogs_gtp_xact_cycle(bearer->notify.xact);
239
+    ogs_assert(bearer->notify.xact_id >= OGS_MIN_POOL_ID &&
240
+            bearer->notify.xact_id <= OGS_MAX_POOL_ID);
241
+    xact = ogs_gtp_xact_find_by_id(bearer->notify.xact_id);
242
     if (!xact) {
243
-        ogs_warn("GTP transaction(NOTIFY) has already been removed");
244
+        ogs_error("GTP transaction(NOTIFY) has already been removed");
245
         return OGS_OK;
246
     }
247
-    mme_ue = bearer->mme_ue;
248
+
249
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
250
     ogs_assert(mme_ue);
251
-    sgw_ue = mme_ue->sgw_ue;
252
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
253
     ogs_assert(sgw_ue);
254
 
255
     /* Build Downlink data notification ack */
256
@@ -674,7 +701,7 @@
257
     sgw_ue_t *sgw_ue = NULL;
258
 
259
     ogs_assert(mme_ue);
260
-    sgw_ue = mme_ue->sgw_ue;
261
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
262
     ogs_assert(sgw_ue);
263
 
264
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
265
@@ -689,7 +716,9 @@
266
         return OGS_ERROR;
267
     }
268
 
269
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, pkbuf, timeout, mme_ue);
270
+    xact = ogs_gtp_xact_local_create(
271
+            sgw_ue->gnode, &h, pkbuf, timeout,
272
+            OGS_UINT_TO_POINTER(mme_ue->id));
273
     if (!xact) {
274
         ogs_error("ogs_gtp_xact_local_create() failed");
275
         return OGS_ERROR;
276
@@ -713,7 +742,7 @@
277
 
278
     ogs_assert(action);
279
     ogs_assert(mme_ue);
280
-    sgw_ue = mme_ue->sgw_ue;
281
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
282
     ogs_assert(sgw_ue);
283
 
284
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
285
@@ -727,7 +756,9 @@
286
     }
287
     ogs_pkbuf_reserve(pkbuf, OGS_TLV_MAX_HEADROOM);
288
 
289
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, pkbuf, timeout, mme_ue);
290
+    xact = ogs_gtp_xact_local_create(
291
+            sgw_ue->gnode, &h, pkbuf, timeout,
292
+            OGS_UINT_TO_POINTER(mme_ue->id));
293
     if (!xact) {
294
         ogs_error("ogs_gtp_xact_local_create() failed");
295
         return OGS_ERROR;
296
@@ -753,9 +784,9 @@
297
     sgw_ue_t *sgw_ue = NULL;
298
 
299
     ogs_assert(bearer);
300
-    mme_ue = bearer->mme_ue;
301
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
302
     ogs_assert(mme_ue);
303
-    sgw_ue = mme_ue->sgw_ue;
304
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
305
     ogs_assert(sgw_ue);
306
 
307
     memset(&h, 0, sizeof(ogs_gtp2_header_t));
308
@@ -768,7 +799,9 @@
309
         return OGS_ERROR;
310
     }
311
 
312
-    xact = ogs_gtp_xact_local_create(sgw_ue->gnode, &h, pkbuf, timeout, bearer);
313
+    xact = ogs_gtp_xact_local_create(
314
+            sgw_ue->gnode, &h, pkbuf, timeout,
315
+            OGS_UINT_TO_POINTER(bearer->id));
316
     if (!xact) {
317
         ogs_error("ogs_gtp_xact_local_create() failed");
318
         return OGS_ERROR;
319
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/mme-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-s11-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-s11-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/mme-s11-handler.c Changed
566
 
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
         if (mme_sess_count(mme_ue) == 1) /* Last Session */ {
202
             if (ECM_IDLE(mme_ue)) {
203
-                MME_UE_CHECK(OGS_LOG_ERROR, mme_ue);
204
                 mme_ue_remove(mme_ue);
205
             } else {
206
-                ogs_assert(mme_ue->enb_ue);
207
-                r = s1ap_send_ue_context_release_command(mme_ue->enb_ue,
208
+                r = s1ap_send_ue_context_release_command(enb_ue,
209
                     S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
210
                     S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
211
                 ogs_expect(r == OGS_OK);
212
@@ -806,17 +810,11 @@
213
     } else if (action ==
214
             OGS_GTP_DELETE_SEND_RELEASE_WITH_S1_REMOVE_AND_UNLINK) {
215
         if (mme_sess_count(mme_ue) == 1) /* Last Session */ {
216
-            enb_ue_t *enb_ue = NULL;
217
-
218
-            enb_ue = enb_ue_cycle(mme_ue->enb_ue);
219
-            if (enb_ue) {
220
-                r = s1ap_send_ue_context_release_command(enb_ue,
221
-                        S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
222
-                        S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0);
223
-                ogs_expect(r == OGS_OK);
224
-                ogs_assert(r != OGS_ERROR);
225
-            } else
226
-                ogs_error("ENB-S1 Context has already been removed");
227
+            r = s1ap_send_ue_context_release_command(enb_ue,
228
+                    S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
229
+                    S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0);
230
+            ogs_expect(r == OGS_OK);
231
+            ogs_assert(r != OGS_ERROR);
232
         }
233
 
234
     } else if (action == OGS_GTP_DELETE_HANDLE_PDN_CONNECTIVITY_REQUEST) {
235
@@ -825,7 +823,7 @@
236
                     &mme_ue->pdn_connectivity_request);
237
             if (rv != OGS_OK) {
238
                 ogs_error("nas_eps_send_emm_to_esm() failed");
239
-                r = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
240
+                r = nas_eps_send_attach_reject(enb_ue, mme_ue,
241
                         OGS_NAS_EMM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED,
242
                         OGS_NAS_ESM_CAUSE_PROTOCOL_ERROR_UNSPECIFIED);
243
                 ogs_expect(r == OGS_OK);
244
@@ -883,7 +881,7 @@
245
         ogs_error("No Context in TEID");
246
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
247
     } else {
248
-        sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
249
+        sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
250
         ogs_assert(sgw_ue);
251
 
252
         if (req->linked_eps_bearer_id.presence == 0) {
253
@@ -1028,7 +1026,8 @@
254
      * If GTP-xact Holding timer is expired,
255
      * OLD bearer->xact memory will be automatically removed.
256
      */
257
-    bearer->create.xact = xact;
258
+    ogs_assert(xact->id >= OGS_MIN_POOL_ID && xact->id <= OGS_MAX_POOL_ID);
259
+    bearer->create.xact_id = xact->id;
260
 
261
     /* Before Activate DEDICATED bearer, check DEFAULT bearer status */
262
     default_bearer = mme_default_bearer_in_sess(sess);
263
@@ -1040,7 +1039,7 @@
264
     if (OGS_FSM_CHECK(&default_bearer->sm, esm_state_active)) {
265
         if (ECM_IDLE(mme_ue)) {
266
             MME_STORE_PAGING_INFO(mme_ue,
267
-                MME_PAGING_TYPE_CREATE_BEARER, bearer);
268
+                MME_PAGING_TYPE_CREATE_BEARER, bearer->id);
269
             r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps);
270
             ogs_expect(r == OGS_OK);
271
             ogs_assert(r != OGS_ERROR);
272
@@ -1084,7 +1083,7 @@
273
         ogs_error("No Context in TEID");
274
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
275
     } else {
276
-        sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
277
+        sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
278
         ogs_assert(sgw_ue);
279
 
280
         if (req->bearer_contexts.presence == 0) {
281
@@ -1119,7 +1118,7 @@
282
     ogs_assert(sgw_ue);
283
 
284
     ogs_assert(bearer);
285
-    sess = bearer->sess;
286
+    sess = mme_sess_find_by_id(bearer->sess_id);
287
     ogs_assert(sess);
288
 
289
     ogs_debug("    MME_S11_TEID%d SGW_S11_TEID%d",
290
@@ -1155,7 +1154,7 @@
291
      */
292
 
293
     xact->cb = gtp_remote_holding_timeout;
294
-    xact->data = bearer;
295
+    xact->data = OGS_UINT_TO_POINTER(bearer->id);
296
 
297
     ogs_list_add(&bearer->update.xact_list, &xact->to_update_node);
298
 
299
@@ -1192,7 +1191,7 @@
300
         req->bearer_contexts.tft.presence == 1) {
301
         if (ECM_IDLE(mme_ue)) {
302
             MME_STORE_PAGING_INFO(mme_ue,
303
-                MME_PAGING_TYPE_UPDATE_BEARER, bearer);
304
+                MME_PAGING_TYPE_UPDATE_BEARER, bearer->id);
305
             r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps);
306
             ogs_expect(r == OGS_OK);
307
             ogs_assert(r != OGS_ERROR);
308
@@ -1249,7 +1248,7 @@
309
         ogs_error("No Context in TEID");
310
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
311
     } else {
312
-        sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
313
+        sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
314
         ogs_assert(sgw_ue);
315
 
316
         if (req->linked_eps_bearer_id.presence == 1) {
317
@@ -1309,7 +1308,7 @@
318
     ogs_assert(sgw_ue);
319
 
320
     ogs_assert(bearer);
321
-    sess = bearer->sess;
322
+    sess = mme_sess_find_by_id(bearer->sess_id);
323
     ogs_assert(sess);
324
 
325
     ogs_debug("    MME_S11_TEID%d SGW_S11_TEID%d",
326
@@ -1329,11 +1328,12 @@
327
      * If GTP-xact Holding timer is expired,
328
      * OLD bearer->xact memory will be automatically removed.
329
      */
330
-    bearer->delete.xact = xact;
331
+    ogs_assert(xact->id >= OGS_MIN_POOL_ID && xact->id <= OGS_MAX_POOL_ID);
332
+    bearer->delete.xact_id = xact->id;
333
 
334
     if (ECM_IDLE(mme_ue)) {
335
         MME_STORE_PAGING_INFO(mme_ue,
336
-            MME_PAGING_TYPE_DELETE_BEARER, bearer);
337
+            MME_PAGING_TYPE_DELETE_BEARER, bearer->id);
338
         r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps);
339
         ogs_expect(r == OGS_OK);
340
         ogs_assert(r != OGS_ERROR);
341
@@ -1370,8 +1370,7 @@
342
     action = xact->release_action;
343
     ogs_assert(action);
344
 
345
-    MME_UE_CHECK(OGS_LOG_DEBUG, xact->data);
346
-    mme_ue = mme_ue_cycle(xact->data);
347
+    mme_ue = mme_ue_find_by_id(OGS_POINTER_TO_UINT(xact->data));
348
 
349
     rv = ogs_gtp_xact_commit(xact);
350
     if (rv != OGS_OK) {
351
@@ -1383,7 +1382,7 @@
352
         ogs_error("MME-UE Context has already been removed");
353
         return;
354
     }
355
-    sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
356
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
357
     ogs_assert(sgw_ue);
358
 
359
     /***********************
360
@@ -1421,7 +1420,7 @@
361
     }
362
 
363
     if (action == OGS_GTP_RELEASE_SEND_UE_CONTEXT_RELEASE_COMMAND) {
364
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
365
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
366
         if (enb_ue) {
367
             r = s1ap_send_ue_context_release_command(enb_ue,
368
                     S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
369
@@ -1449,17 +1448,18 @@
370
      * for new UE-associated logical S1-connections over the S1 interface,
371
      * the MME shall respond with the RESET ACKNOWLEDGE message.
372
      */
373
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
374
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
375
 
376
         enb_ue_unlink(mme_ue);
377
 
378
         if (enb_ue) {
379
-            mme_enb_t *enb = enb_ue->enb;
380
-            ogs_assert(enb);
381
+            mme_enb_t *enb = NULL;
382
+
383
+            enb = mme_enb_find_by_id(enb_ue->enb_id);
384
 
385
             enb_ue_remove(enb_ue);
386
 
387
-            if (ogs_list_count(&enb->enb_ue_list) == 0) {
388
+            if (enb && ogs_list_count(&enb->enb_ue_list) == 0) {
389
                 r = s1ap_send_s1_reset_ack(enb, NULL);
390
                 ogs_expect(r == OGS_OK);
391
                 ogs_assert(r != OGS_ERROR);
392
@@ -1471,35 +1471,39 @@
393
     } else if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_PARTIAL) {
394
         enb_ue_t *iter = NULL;
395
 
396
-        enb_ue = enb_ue_cycle(mme_ue->enb_ue);
397
+        enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
398
 
399
         enb_ue_unlink(mme_ue);
400
 
401
         if (enb_ue) {
402
-            mme_enb_t *enb = enb_ue->enb;
403
-            ogs_assert(enb);
404
+            mme_enb_t *enb = NULL;
405
+
406
+            enb = mme_enb_find_by_id(enb_ue->enb_id);
407
 
408
             enb_ue_remove(enb_ue);
409
 
410
-            ogs_list_for_each(&enb->enb_ue_list, iter) {
411
-                if (iter->part_of_s1_reset_requested == true) {
412
-                    /* The ENB_UE context
413
-                     * where PartOfS1_interface was requested
414
-                     * still remains */
415
-                    return;
416
+            if (enb) {
417
+                ogs_list_for_each(&enb->enb_ue_list, iter) {
418
+                    if (iter->part_of_s1_reset_requested == true) {
419
+                        /* The ENB_UE context
420
+                         * where PartOfS1_interface was requested
421
+                         * still remains */
422
+                        return;
423
+                    }
424
                 }
425
-            }
426
 
427
-            /* All ENB_UE context
428
-             * where PartOfS1_interface was requested
429
-             * REMOVED */
430
-            ogs_assert(enb->s1_reset_ack);
431
-            r = s1ap_send_to_enb(enb, enb->s1_reset_ack, S1AP_NON_UE_SIGNALLING);
432
-            ogs_expect(r == OGS_OK);
433
-            ogs_assert(r != OGS_ERROR);
434
+                /* All ENB_UE context
435
+                 * where PartOfS1_interface was requested
436
+                 * REMOVED */
437
+                ogs_assert(enb->s1_reset_ack);
438
+                r = s1ap_send_to_enb(
439
+                        enb, enb->s1_reset_ack, S1AP_NON_UE_SIGNALLING);
440
+                ogs_expect(r == OGS_OK);
441
+                ogs_assert(r != OGS_ERROR);
442
 
443
-            /* Clear S1-Reset Ack Buffer */
444
-            enb->s1_reset_ack = NULL;
445
+                /* Clear S1-Reset Ack Buffer */
446
+                enb->s1_reset_ack = NULL;
447
+            }
448
         } else {
449
             ogs_error("ENB-S1 Context has already been removed");
450
         }
451
@@ -1534,7 +1538,7 @@
452
         ogs_error("No UE Context");
453
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
454
     } else {
455
-        sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
456
+        sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
457
         ogs_assert(sgw_ue);
458
 
459
         if (noti->eps_bearer_id.presence == 0) {
460
@@ -1577,7 +1581,8 @@
461
      * If GTP-xact Holding timer is expired,
462
      * OLD bearer->xact memory will be automatically removed.
463
      */
464
-    bearer->notify.xact = xact;
465
+    ogs_assert(xact->id >= OGS_MIN_POOL_ID && xact->id <= OGS_MAX_POOL_ID);
466
+    bearer->notify.xact_id = xact->id;
467
 
468
     if (noti->cause.presence) {
469
         ogs_gtp2_cause_t *cause = noti->cause.data;
470
@@ -1601,7 +1606,7 @@
471
  */
472
     if (ECM_IDLE(mme_ue)) {
473
         MME_STORE_PAGING_INFO(mme_ue,
474
-            MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION, bearer);
475
+            MME_PAGING_TYPE_DOWNLINK_DATA_NOTIFICATION, bearer->id);
476
         r = s1ap_send_paging(mme_ue, S1AP_CNDomain_ps);
477
         ogs_expect(r == OGS_OK);
478
         ogs_assert(r != OGS_ERROR);
479
@@ -1637,7 +1642,7 @@
480
  *   included in Downlink Data Notification is "Error Indication received
481
  *   from RNC/eNodeB/S4-SGSN"
482
  */
483
-            enb_ue_t *enb_ue = enb_ue_cycle(mme_ue->enb_ue);
484
+            enb_ue_t *enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
485
             ogs_assert(enb_ue);
486
 
487
             r = s1ap_send_ue_context_release_command(enb_ue,
488
@@ -1675,7 +1680,7 @@
489
      * Check Transaction
490
      ********************/
491
     ogs_assert(xact);
492
-    mme_ue = mme_ue_cycle(xact->data);
493
+    mme_ue = mme_ue_find_by_id(OGS_POINTER_TO_UINT(xact->data));
494
 
495
     rv = ogs_gtp_xact_commit(xact);
496
     if (rv != OGS_OK) {
497
@@ -1687,7 +1692,7 @@
498
         ogs_error("MME-UE Context has already been removed");
499
         return;
500
     }
501
-    sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
502
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
503
     ogs_assert(sgw_ue);
504
 
505
     /************************
506
@@ -1781,7 +1786,7 @@
507
         }
508
     }
509
 
510
-    source_ue = enb_ue_cycle(mme_ue->enb_ue);
511
+    source_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
512
     ogs_assert(source_ue);
513
 
514
     r = s1ap_send_handover_command(source_ue);
515
@@ -1810,7 +1815,7 @@
516
     ogs_assert(xact);
517
     action = xact->delete_indirect_action;
518
     ogs_assert(action);
519
-    mme_ue = mme_ue_cycle(xact->data);
520
+    mme_ue = mme_ue_find_by_id(OGS_POINTER_TO_UINT(xact->data));
521
 
522
     rv = ogs_gtp_xact_commit(xact);
523
     if (rv != OGS_OK) {
524
@@ -1822,7 +1827,7 @@
525
         ogs_error("MME-UE Context has already been removed");
526
         return;
527
     }
528
-    sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
529
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
530
     ogs_assert(sgw_ue);
531
 
532
     /************************
533
@@ -1890,7 +1895,7 @@
534
     if (action == OGS_GTP_DELETE_INDIRECT_HANDOVER_COMPLETE) {
535
         /* Nothing to do */
536
     } else if (action == OGS_GTP_DELETE_INDIRECT_HANDOVER_CANCEL) {
537
-        r = s1ap_send_handover_cancel_ack(mme_ue->enb_ue);
538
+        r = s1ap_send_handover_cancel_ack(enb_ue_find_by_id(mme_ue->enb_ue_id));
539
         ogs_expect(r == OGS_OK);
540
         ogs_assert(r != OGS_ERROR);
541
     } else {
542
@@ -1917,11 +1922,11 @@
543
      * Check Transaction
544
      ********************/
545
     ogs_assert(xact);
546
-    bearer = xact->data;
547
+    bearer = mme_bearer_find_by_id(OGS_POINTER_TO_UINT(xact->data));
548
     ogs_assert(ind);
549
-    sess = bearer->sess;
550
+    sess = mme_sess_find_by_id(bearer->sess_id);
551
     ogs_assert(sess);
552
-    mme_ue = mme_ue_cycle(sess->mme_ue);
553
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
554
 
555
     rv = ogs_gtp_xact_commit(xact);
556
     if (rv != OGS_OK) {
557
@@ -1933,7 +1938,7 @@
558
         ogs_error("MME-UE Context has already been removed");
559
         return;
560
     }
561
-    sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
562
+    sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
563
     ogs_assert(sgw_ue);
564
 
565
     if (!mme_ue_from_teid)
566
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/mme-s6a-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/mme-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/mme-sm.c Changed
229
 
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
-        ogs_assert(sgw_ue);
202
-        mme_ue = sgw_ue->mme_ue;
203
-        ogs_assert(mme_ue);
204
+        sgw_ue = sgw_ue_find_by_id(e->sgw_ue_id);
205
+        if (!sgw_ue) {
206
+            ogs_error("SGW-UE Context has already been removed");
207
+            break;
208
+        }
209
+        mme_ue = mme_ue_find_by_id(sgw_ue->mme_ue_id);
210
+        if (!mme_ue) {
211
+            ogs_error("MME-UE Context has already been removed");
212
+            break;
213
+        }
214
 
215
         switch (e->timer_id) {
216
         case MME_TIMER_S11_HOLDING:
217
@@ -867,9 +878,9 @@
218
         break;
219
 
220
     case MME_EVENT_GN_TIMER:
221
-        mme_ue = e->mme_ue;
222
+        mme_ue = mme_ue_find_by_id(e->mme_ue_id);
223
         ogs_assert(mme_ue);
224
-        sgw_ue = mme_ue->sgw_ue;
225
+        sgw_ue = sgw_ue_find_by_id(mme_ue->sgw_ue_id);
226
         ogs_assert(sgw_ue);
227
 
228
         switch (e->timer_id) {
229
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/mme-timer.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/nas-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/nas-path.c Changed
612
 
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
-    if (!mme_ue_cycle(mme_ue)) {
202
+    if (!mme_ue) {
203
         ogs_error("UE(mme-ue) context has already been removed");
204
         return OGS_NOTFOUND;
205
     }
206
 
207
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
208
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
209
+    if (!enb_ue) {
210
         ogs_error("S1 context has already been removed");
211
         return OGS_NOTFOUND;
212
     }
213
@@ -409,7 +429,7 @@
214
     ogs_timer_start(mme_ue->t3422.timer, 
215
             mme_timer_cfg(MME_TIMER_T3422)->duration);    
216
 
217
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
218
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
219
     ogs_expect(rv == OGS_OK);
220
 
221
     return rv;
222
@@ -418,15 +438,16 @@
223
 int nas_eps_send_detach_accept(mme_ue_t *mme_ue)
224
 {
225
     int rv;
226
- 
227
+    enb_ue_t *enb_ue = NULL;
228
     ogs_pkbuf_t *emmbuf = NULL;
229
 
230
-    if (!mme_ue_cycle(mme_ue)) {
231
+    if (!mme_ue) {
232
         ogs_error("UE(mme-ue) context has already been removed");
233
         return OGS_NOTFOUND;
234
     }
235
 
236
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
237
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
238
+    if (!enb_ue) {
239
         ogs_error("S1 context has already been removed");
240
         return OGS_NOTFOUND;
241
     }
242
@@ -441,14 +462,14 @@
243
             return OGS_ERROR;
244
         }
245
 
246
-        rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
247
+        rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
248
         if (rv != OGS_OK) {
249
             ogs_error("nas_eps_send_to_downlink_nas_transport() failed");
250
             return rv;
251
         }
252
     }
253
 
254
-    rv = s1ap_send_ue_context_release_command(mme_ue->enb_ue,
255
+    rv = s1ap_send_ue_context_release_command(enb_ue,
256
             S1AP_Cause_PR_nas, S1AP_CauseNas_detach,
257
             S1AP_UE_CTX_REL_S1_REMOVE_AND_UNLINK, 0);
258
     ogs_expect(rv == OGS_OK);
259
@@ -460,18 +481,20 @@
260
     mme_sess_t *sess, ogs_nas_esm_cause_t esm_cause, int create_action)
261
 {
262
     int rv;
263
-    mme_ue_t *mme_ue;
264
+    mme_ue_t *mme_ue = NULL;
265
+    enb_ue_t *enb_ue = NULL;
266
     ogs_pkbuf_t *esmbuf = NULL;
267
 
268
     ogs_assert(sess);
269
 
270
-    mme_ue = sess->mme_ue;
271
-    if (!mme_ue_cycle(mme_ue)) {
272
+    mme_ue = mme_ue_find_by_id(sess->mme_ue_id);
273
+    if (!mme_ue) {
274
         ogs_error("UE(mme-ue) context has already been removed");
275
         return OGS_NOTFOUND;
276
     }
277
 
278
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
279
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
280
+    if (!enb_ue) {
281
         ogs_error("S1 context has already been removed");
282
         return OGS_NOTFOUND;
283
     }
284
@@ -479,14 +502,14 @@
285
     if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) {
286
         /* During the UE-attach process, we'll send Attach-Reject
287
          * with pyggybacking PDN-connectivity-Reject */
288
-        rv = nas_eps_send_attach_reject(mme_ue->enb_ue, mme_ue,
289
+        rv = nas_eps_send_attach_reject(enb_ue, mme_ue,
290
             OGS_NAS_EMM_CAUSE_ESM_FAILURE, esm_cause);
291
         if (rv != OGS_OK) {
292
             ogs_error("nas_eps_send_attach_reject() failed");
293
             return rv;
294
         }
295
 
296
-        rv = s1ap_send_ue_context_release_command(mme_ue->enb_ue,
297
+        rv = s1ap_send_ue_context_release_command(enb_ue,
298
                 S1AP_Cause_PR_nas, S1AP_CauseNas_normal_release,
299
                 S1AP_UE_CTX_REL_UE_CONTEXT_REMOVE, 0);
300
         ogs_expect(rv == OGS_OK);
301
@@ -498,7 +521,7 @@
302
             return OGS_ERROR;
303
         }
304
 
305
-        rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, esmbuf);
306
+        rv = nas_eps_send_to_downlink_nas_transport(enb_ue, esmbuf);
307
         ogs_expect(rv == OGS_OK);
308
     }
309
 
310
@@ -509,17 +532,19 @@
311
 {
312
     int rv;
313
     mme_ue_t *mme_ue = NULL;
314
+    enb_ue_t *enb_ue = NULL;
315
     ogs_pkbuf_t *esmbuf = NULL;
316
 
317
     ogs_assert(bearer);
318
 
319
-    mme_ue = bearer->mme_ue;
320
-    if (!mme_ue_cycle(mme_ue)) {
321
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
322
+    if (!mme_ue) {
323
         ogs_error("UE(mme-ue) context has already been removed");
324
         return OGS_NOTFOUND;
325
     }
326
 
327
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
328
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
329
+    if (!enb_ue) {
330
         ogs_error("S1 context has already been removed");
331
         return OGS_NOTFOUND;
332
     }
333
@@ -543,7 +568,7 @@
334
     ogs_timer_start(bearer->t3489.timer, 
335
             mme_timer_cfg(MME_TIMER_T3489)->duration);
336
 
337
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, esmbuf);
338
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, esmbuf);
339
     ogs_expect(rv == OGS_OK);
340
 
341
     return rv;
342
@@ -557,18 +582,20 @@
343
     ogs_pkbuf_t *esmbuf = NULL;
344
     mme_sess_t *sess = NULL;
345
     mme_ue_t *mme_ue = NULL;
346
+    enb_ue_t *enb_ue = NULL;
347
 
348
     ogs_assert(bearer);
349
-    sess = bearer->sess;
350
+    sess = mme_sess_find_by_id(bearer->sess_id);
351
     ogs_assert(sess);
352
 
353
-    mme_ue = bearer->mme_ue;
354
-    if (!mme_ue_cycle(mme_ue)) {
355
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
356
+    if (!mme_ue) {
357
         ogs_error("UE(mme-ue) context has already been removed");
358
         return OGS_NOTFOUND;
359
     }
360
 
361
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
362
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
363
+    if (!enb_ue) {
364
         ogs_error("S1 context has already been removed");
365
         return OGS_NOTFOUND;
366
     }
367
@@ -599,16 +626,18 @@
368
     ogs_pkbuf_t *s1apbuf = NULL;
369
     ogs_pkbuf_t *esmbuf = NULL;
370
     mme_ue_t *mme_ue = NULL;
371
+    enb_ue_t *enb_ue = NULL;
372
 
373
     ogs_assert(bearer);
374
 
375
-    mme_ue = bearer->mme_ue;
376
-    if (!mme_ue_cycle(mme_ue)) {
377
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
378
+    if (!mme_ue) {
379
         ogs_error("UE(mme-ue) context has already been removed");
380
         return OGS_NOTFOUND;
381
     }
382
 
383
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
384
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
385
+    if (!enb_ue) {
386
         ogs_error("S1 context has already been removed");
387
         return OGS_NOTFOUND;
388
     }
389
@@ -654,16 +683,18 @@
390
     ogs_pkbuf_t *s1apbuf = NULL;
391
     ogs_pkbuf_t *esmbuf = NULL;
392
     mme_ue_t *mme_ue = NULL;
393
+    enb_ue_t *enb_ue = NULL;
394
 
395
     ogs_assert(bearer);
396
 
397
-    mme_ue = bearer->mme_ue;
398
-    if (!mme_ue_cycle(mme_ue)) {
399
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
400
+    if (!mme_ue) {
401
         ogs_error("UE(mme-ue) context has already been removed");
402
         return OGS_NOTFOUND;
403
     }
404
 
405
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
406
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
407
+    if (!enb_ue) {
408
         ogs_error("S1 context has already been removed");
409
         return OGS_NOTFOUND;
410
     }
411
@@ -685,7 +716,7 @@
412
         rv = nas_eps_send_to_enb(mme_ue, s1apbuf);
413
         ogs_expect(rv == OGS_OK);
414
     } else {
415
-        rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, esmbuf);
416
+        rv = nas_eps_send_to_downlink_nas_transport(enb_ue, esmbuf);
417
         ogs_expect(rv == OGS_OK);
418
     }
419
 
420
@@ -698,16 +729,18 @@
421
     ogs_pkbuf_t *s1apbuf = NULL;
422
     ogs_pkbuf_t *esmbuf = NULL;
423
     mme_ue_t *mme_ue = NULL;
424
+    enb_ue_t *enb_ue = NULL;
425
 
426
     ogs_assert(bearer);
427
 
428
-    mme_ue = bearer->mme_ue;
429
-    if (!mme_ue_cycle(mme_ue)) {
430
+    mme_ue = mme_ue_find_by_id(bearer->mme_ue_id);
431
+    if (!mme_ue) {
432
         ogs_error("UE(mme-ue) context has already been removed");
433
         return OGS_NOTFOUND;
434
     }
435
 
436
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
437
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
438
+    if (!enb_ue) {
439
         ogs_error("S1 context has already been removed");
440
         return OGS_NOTFOUND;
441
     }
442
@@ -736,14 +769,16 @@
443
         mme_ue_t *mme_ue, uint8_t pti, ogs_nas_esm_cause_t esm_cause)
444
 {
445
     int rv;
446
+    enb_ue_t *enb_ue = NULL;
447
     ogs_pkbuf_t *esmbuf = NULL;
448
 
449
-    if (!mme_ue_cycle(mme_ue)) {
450
+    if (!mme_ue) {
451
         ogs_error("UE(mme-ue) context has already been removed");
452
         return OGS_NOTFOUND;
453
     }
454
 
455
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
456
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
457
+    if (!enb_ue) {
458
         ogs_error("S1 context has already been removed");
459
         return OGS_NOTFOUND;
460
     }
461
@@ -757,7 +792,7 @@
462
         return OGS_ERROR;
463
     }
464
 
465
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, esmbuf);
466
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, esmbuf);
467
     ogs_expect(rv == OGS_OK);
468
 
469
     return rv;
470
@@ -767,14 +802,16 @@
471
         mme_ue_t *mme_ue, uint8_t pti, ogs_nas_esm_cause_t esm_cause)
472
 {
473
     int rv;
474
+    enb_ue_t *enb_ue = NULL;
475
     ogs_pkbuf_t *esmbuf = NULL;
476
 
477
-    if (!mme_ue_cycle(mme_ue)) {
478
+    if (!mme_ue) {
479
         ogs_error("UE(mme-ue) context has already been removed");
480
         return OGS_NOTFOUND;
481
     }
482
 
483
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
484
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
485
+    if (!enb_ue) {
486
         ogs_error("S1 context has already been removed");
487
         return OGS_NOTFOUND;
488
     }
489
@@ -788,7 +825,7 @@
490
         return OGS_ERROR;
491
     }
492
 
493
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, esmbuf);
494
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, esmbuf);
495
     ogs_expect(rv == OGS_OK);
496
 
497
     return rv;
498
@@ -798,14 +835,16 @@
499
         mme_ue_t *mme_ue, S1AP_ProcedureCode_t procedureCode)
500
 {
501
     int rv;
502
+    enb_ue_t *enb_ue = NULL;
503
     ogs_pkbuf_t *emmbuf = NULL;
504
 
505
-    if (!mme_ue_cycle(mme_ue)) {
506
+    if (!mme_ue) {
507
         ogs_error("UE(mme-ue) context has already been removed");
508
         return OGS_NOTFOUND;
509
     }
510
 
511
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
512
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
513
+    if (!enb_ue) {
514
         ogs_error("S1 context has already been removed");
515
         return OGS_NOTFOUND;
516
     }
517
@@ -841,7 +880,7 @@
518
         rv = nas_eps_send_to_enb(mme_ue, s1apbuf);
519
         ogs_expect(rv == OGS_OK);
520
     } else if (procedureCode == S1AP_ProcedureCode_id_downlinkNASTransport) {
521
-        rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
522
+        rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
523
         ogs_expect(rv == OGS_OK);
524
     } else
525
         ogs_assert_if_reached();
526
@@ -855,12 +894,12 @@
527
     int rv;
528
     ogs_pkbuf_t *emmbuf = NULL;
529
 
530
-    if (!mme_ue_cycle(mme_ue)) {
531
+    if (!mme_ue) {
532
         ogs_error("UE(mme-ue) context has already been removed");
533
         return OGS_NOTFOUND;
534
     }
535
 
536
-    if (!enb_ue_cycle(enb_ue)) {
537
+    if (!enb_ue) {
538
         ogs_error("S1 context has already been removed");
539
         return OGS_NOTFOUND;
540
     }
541
@@ -886,12 +925,12 @@
542
     int rv;
543
     ogs_pkbuf_t *emmbuf = NULL;
544
 
545
-    if (!mme_ue_cycle(mme_ue)) {
546
+    if (!mme_ue) {
547
         ogs_error("UE(mme-ue) context has already been removed");
548
         return OGS_NOTFOUND;
549
     }
550
 
551
-    if (!enb_ue_cycle(enb_ue)) {
552
+    if (!enb_ue) {
553
         ogs_error("S1 context has already been removed");
554
         return OGS_NOTFOUND;
555
     }
556
@@ -914,14 +953,16 @@
557
 int nas_eps_send_cs_service_notification(mme_ue_t *mme_ue)
558
 {
559
     int rv;
560
+    enb_ue_t *enb_ue = NULL;
561
     ogs_pkbuf_t *emmbuf = NULL;
562
 
563
-    if (!mme_ue_cycle(mme_ue)) {
564
+    if (!mme_ue) {
565
         ogs_error("UE(mme-ue) context has already been removed");
566
         return OGS_NOTFOUND;
567
     }
568
 
569
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
570
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
571
+    if (!enb_ue) {
572
         ogs_error("S1 context has already been removed");
573
         return OGS_NOTFOUND;
574
     }
575
@@ -934,7 +975,7 @@
576
         return OGS_ERROR;
577
     }
578
 
579
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
580
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
581
     ogs_expect(rv == OGS_OK);
582
 
583
     return rv;
584
@@ -944,14 +985,16 @@
585
         mme_ue_t *mme_ue, uint8_t *buffer, uint8_t length)
586
 {
587
     int rv;
588
+    enb_ue_t *enb_ue = NULL;
589
     ogs_pkbuf_t *emmbuf = NULL;
590
 
591
-    if (!mme_ue_cycle(mme_ue)) {
592
+    if (!mme_ue) {
593
         ogs_error("UE(mme-ue) context has already been removed");
594
         return OGS_NOTFOUND;
595
     }
596
 
597
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
598
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
599
+    if (!enb_ue) {
600
         ogs_error("S1 context has already been removed");
601
         return OGS_NOTFOUND;
602
     }
603
@@ -967,7 +1010,7 @@
604
         return OGS_ERROR;
605
     }
606
 
607
-    rv = nas_eps_send_to_downlink_nas_transport(mme_ue->enb_ue, emmbuf);
608
+    rv = nas_eps_send_to_downlink_nas_transport(enb_ue, emmbuf);
609
     ogs_expect(rv == OGS_OK);
610
 
611
     return rv;
612
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/s1ap-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/s1ap-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/s1ap-handler.c Changed
276
 
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
     if (!mme_ue) {
202
         ogs_error("No UE(mme-ue) context");
203
         return;
204
@@ -3112,7 +3105,7 @@
205
         return;
206
     }
207
 
208
-    source_ue = target_ue->source_ue;
209
+    source_ue = enb_ue_find_by_id(target_ue->source_ue_id);
210
     if (!source_ue) {
211
         ogs_error("No Source UE");
212
         r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID,
213
@@ -3122,7 +3115,7 @@
214
         return;
215
     }
216
 
217
-    mme_ue = source_ue->mme_ue;
218
+    mme_ue = mme_ue_find_by_id(source_ue->mme_ue_id);
219
     if (!mme_ue) {
220
         ogs_error("No UE(mme-ue) context");
221
         return;
222
@@ -3315,7 +3308,7 @@
223
         return;
224
     }
225
 
226
-    source_ue = target_ue->source_ue;
227
+    source_ue = enb_ue_find_by_id(target_ue->source_ue_id);
228
     if (!source_ue) {
229
         ogs_error("No Source UE");
230
         r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, NULL,
231
@@ -3437,7 +3430,7 @@
232
         return;
233
     }
234
 
235
-    target_ue = source_ue->target_ue;
236
+    target_ue = enb_ue_find_by_id(source_ue->target_ue_id);
237
     if (!target_ue) {
238
         ogs_error("No Target UE");
239
         r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID,
240
@@ -3565,7 +3558,7 @@
241
         return;
242
     }
243
 
244
-    target_ue = source_ue->target_ue;
245
+    target_ue = enb_ue_find_by_id(source_ue->target_ue_id);
246
     if (!target_ue) {
247
         ogs_error("No Target UE");
248
         r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID,
249
@@ -3711,7 +3704,7 @@
250
     tAC = &TAI->tAC;
251
     ogs_assert(tAC && tAC->size == sizeof(uint16_t));
252
 
253
-    source_ue = target_ue->source_ue;
254
+    source_ue = enb_ue_find_by_id(target_ue->source_ue_id);
255
     if (!source_ue) {
256
         ogs_error("No Source UE");
257
         r = s1ap_send_error_indication(enb, MME_UE_S1AP_ID, ENB_UE_S1AP_ID,
258
@@ -3721,7 +3714,7 @@
259
         return;
260
     }
261
 
262
-    mme_ue = source_ue->mme_ue;
263
+    mme_ue = mme_ue_find_by_id(source_ue->mme_ue_id);
264
     if (!mme_ue) {
265
         ogs_error("No UE(mme-ue) context");
266
         return;
267
@@ -3944,7 +3937,7 @@
268
             /* ENB_UE Context where PartOfS1_interface was requested */
269
             enb_ue->part_of_s1_reset_requested = true;
270
 
271
-            mme_ue = enb_ue->mme_ue;
272
+            mme_ue = mme_ue_find_by_id(enb_ue->mme_ue_id);
273
             if (mme_ue) {
274
                 ogs_assert(OGS_OK ==
275
                     mme_gtp_send_release_access_bearers_request(mme_ue,
276
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/s1ap-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/mme/s1ap-path.c Changed
401
 
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
 
202
-    if (!enb_ue_cycle(enb_ue)) {
203
+    if (!enb_ue) {
204
         ogs_error("S1 context has already been removed");
205
         return OGS_NOTFOUND;
206
     }
207
@@ -498,7 +493,7 @@
208
 
209
     ogs_debug("S1-Paging");
210
 
211
-    if (!mme_ue_cycle(mme_ue)) {
212
+    if (!mme_ue) {
213
         ogs_error("UE(mme-ue) context has already been removed");
214
         return OGS_NOTFOUND;
215
     }
216
@@ -550,15 +545,11 @@
217
     int rv;
218
     ogs_pkbuf_t *s1apbuf = NULL;
219
 
220
-    ogs_debug("MMEConfigurationTransfer");
221
-
222
-    if (!mme_enb_cycle(target_enb)) {
223
-        ogs_error("eNB has already been removed");
224
-        return OGS_NOTFOUND;
225
-    }
226
-
227
+    ogs_assert(target_enb);
228
     ogs_assert(SONConfigurationTransfer);
229
 
230
+    ogs_debug("MMEConfigurationTransfer");
231
+
232
     s1apbuf = s1ap_build_mme_configuration_transfer(SONConfigurationTransfer);
233
     if (!s1apbuf) {
234
         ogs_error("s1ap_build_mme_configuration_transfer() failed");
235
@@ -577,12 +568,9 @@
236
     int rv;
237
     ogs_pkbuf_t *s1apbuf = NULL;
238
 
239
-    ogs_debug("Tx MME Direct Information Transfer");
240
+    ogs_assert(target_enb);
241
 
242
-    if (!mme_enb_cycle(target_enb)) {
243
-        ogs_error("eNB has already been removed");
244
-        return OGS_NOTFOUND;
245
-    }
246
+    ogs_debug("Tx MME Direct Information Transfer");
247
 
248
     s1apbuf = s1ap_build_direct_information_transfer(buf, buf_len);
249
     if (!s1apbuf) {
250
@@ -603,12 +591,12 @@
251
 
252
     ogs_debug("E-RABModificationConfirm");
253
 
254
-    if (!mme_ue_cycle(mme_ue)) {
255
+    if (!mme_ue) {
256
         ogs_error("UE(mme-ue) context has already been removed");
257
         return OGS_NOTFOUND;
258
     }
259
 
260
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
261
+    if (!enb_ue_find_by_id(mme_ue->enb_ue_id)) {
262
         ogs_error("S1 context has already been removed");
263
         return OGS_NOTFOUND;
264
     }
265
@@ -633,12 +621,12 @@
266
 
267
     ogs_debug("PathSwitchAcknowledge");
268
 
269
-    if (!mme_ue_cycle(mme_ue)) {
270
+    if (!mme_ue) {
271
         ogs_error("UE(mme-ue) context has already been removed");
272
         return OGS_NOTFOUND;
273
     }
274
 
275
-    if (!enb_ue_cycle(mme_ue->enb_ue)) {
276
+    if (!enb_ue_find_by_id(mme_ue->enb_ue_id)) {
277
         ogs_error("S1 context has already been removed");
278
         return OGS_NOTFOUND;
279
     }
280
@@ -663,12 +651,12 @@
281
 
282
     ogs_debug("HandoverCommand");
283
 
284
-    if (!enb_ue_cycle(source_ue)) {
285
+    if (!source_ue) {
286
         ogs_error("S1 context has already been removed");
287
         return OGS_NOTFOUND;
288
     }
289
 
290
-    if (!mme_ue_cycle(source_ue->mme_ue)) {
291
+    if (!mme_ue_find_by_id(source_ue->mme_ue_id)) {
292
         ogs_error("UE(mme-ue) context has already been removed");
293
         return OGS_NOTFOUND;
294
     }
295
@@ -693,7 +681,7 @@
296
 
297
     ogs_debug("HandoverPreparationFailure");
298
 
299
-    if (!enb_ue_cycle(source_ue)) {
300
+    if (!source_ue) {
301
         ogs_error("S1 context has already been removed");
302
         return OGS_NOTFOUND;
303
     }
304
@@ -719,7 +707,7 @@
305
 
306
     ogs_debug("HandoverCancelAcknowledge");
307
 
308
-    if (!enb_ue_cycle(source_ue)) {
309
+    if (!source_ue) {
310
         ogs_error("S1 context has already been removed");
311
         return OGS_NOTFOUND;
312
     }
313
@@ -748,24 +736,21 @@
314
 
315
     enb_ue_t *target_ue = NULL;
316
 
317
+    ogs_assert(target_enb);
318
+
319
     ogs_info("HandoverRequest");
320
 
321
-    if (!enb_ue_cycle(source_ue)) {
322
+    if (!source_ue) {
323
         ogs_error("S1 context has already been removed");
324
         return OGS_NOTFOUND;
325
     }
326
 
327
-    if (!mme_ue_cycle(source_ue->mme_ue)) {
328
+    if (!mme_ue_find_by_id(source_ue->mme_ue_id)) {
329
         ogs_error("UE(mme-ue) context has already been removed");
330
         return OGS_NOTFOUND;
331
     }
332
 
333
-    if (!mme_enb_cycle(target_enb)) {
334
-        ogs_error("eNB has already been removed");
335
-        return OGS_NOTFOUND;
336
-    }
337
-
338
-    target_ue = enb_ue_cycle(source_ue->target_ue);
339
+    target_ue = enb_ue_find_by_id(source_ue->target_ue_id);
340
     if (target_ue) {
341
     /*
342
      * Issue #3014
343
@@ -844,7 +829,7 @@
344
 
345
     ogs_info("MMEStatusTransfer");
346
 
347
-    if (!enb_ue_cycle(target_ue)) {
348
+    if (!target_ue) {
349
         ogs_error("S1 context has already been removed");
350
         return OGS_NOTFOUND;
351
     }
352
@@ -871,12 +856,9 @@
353
     int rv;
354
     ogs_pkbuf_t *s1apbuf = NULL;
355
 
356
-    ogs_info("ErrorIndication");
357
+    ogs_assert(enb);
358
 
359
-    if (!mme_enb_cycle(enb)) {
360
-        ogs_error("eNB has already been removed");
361
-        return OGS_NOTFOUND;
362
-    }
363
+    ogs_info("ErrorIndication");
364
 
365
     s1apbuf = ogs_s1ap_build_error_indication(
366
             mme_ue_s1ap_id, enb_ue_s1ap_id, group, cause);
367
@@ -901,18 +883,18 @@
368
     S1AP_MME_UE_S1AP_ID_t mme_ue_s1ap_id;
369
     S1AP_ENB_UE_S1AP_ID_t enb_ue_s1ap_id;
370
 
371
-    if (!mme_ue_cycle(mme_ue)) {
372
+    if (!mme_ue) {
373
         ogs_error("UE(mme-ue) context has already been removed");
374
         return OGS_NOTFOUND;
375
     }
376
 
377
-    enb_ue = enb_ue_cycle(mme_ue->enb_ue);
378
+    enb_ue = enb_ue_find_by_id(mme_ue->enb_ue_id);
379
     if (!enb_ue) {
380
         ogs_error("S1 context has already been removed");
381
         return OGS_NOTFOUND;
382
     }
383
 
384
-    enb = mme_enb_cycle(enb_ue->enb);
385
+    enb = mme_enb_find_by_id(enb_ue->enb_id);
386
     if (!enb) {
387
         ogs_error("eNB has already been removed");
388
         return OGS_NOTFOUND;
389
@@ -935,10 +917,7 @@
390
     int rv;
391
     ogs_pkbuf_t *s1apbuf = NULL;
392
 
393
-    if (!mme_enb_cycle(enb)) {
394
-        ogs_error("eNB has already been removed");
395
-        return OGS_NOTFOUND;
396
-    }
397
+    ogs_assert(enb);
398
 
399
     ogs_info("S1-Reset Acknowledge");
400
     s1apbuf = ogs_s1ap_build_s1_reset_ack(partOfS1_Interface);
401
open5gs_2.7.1.39.dc2e1.tar.xz/src/mme/s1ap-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/mme/sgsap-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/nrf/nf-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/nrf/nrf-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/nssf/nssf-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/am-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/nbsf-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/nbsf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/nnrf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/npcf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/nudr-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/nudr-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/pcf-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/pcf/pcf-sm.c Changed
331
 
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
 
202
                     ogs_fsm_dispatch(&sess->sm, e);
203
@@ -552,37 +586,39 @@
204
 
205
             SWITCH(message.h.resource.component0)
206
             CASE(OGS_SBI_RESOURCE_NAME_PCF_BINDINGS)
207
+                sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
208
+                ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
209
+                        sbi_xact_id <= OGS_MAX_POOL_ID);
210
 
211
-                sbi_xact = e->h.sbi.data;
212
-                ogs_assert(sbi_xact);
213
-
214
-                sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
215
+                sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
216
                 if (!sbi_xact) {
217
                     /* CLIENT_WAIT timer could remove SBI transaction
218
                      * before receiving SBI message */
219
-                    ogs_error("SBI transaction has already been removed");
220
+                    ogs_error("SBI transaction has already been removed %d",
221
+                            sbi_xact_id);
222
                     break;
223
                 }
224
 
225
-                sess = (pcf_sess_t *)sbi_xact->sbi_object;
226
-                ogs_assert(sess);
227
-
228
-                e->h.sbi.data = sbi_xact->assoc_stream;
229
+                sess_id = sbi_xact->sbi_object_id;
230
+                ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
231
+                        sess_id <= OGS_MAX_POOL_ID);
232
+
233
+                if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
234
+                    sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
235
+                    e->h.sbi.data = OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
236
 
237
                 ogs_sbi_xact_remove(sbi_xact);
238
 
239
-                sess = pcf_sess_cycle(sess);
240
+                sess = pcf_sess_find_by_id(sess_id);
241
                 if (!sess) {
242
                     ogs_error("Session has already been removed");
243
                     break;
244
                 }
245
 
246
-                pcf_ue = sess->pcf_ue;
247
-                ogs_assert(pcf_ue);
248
-                pcf_ue = pcf_ue_cycle(pcf_ue);
249
+                pcf_ue = pcf_ue_find_by_id(sess->pcf_ue_id);
250
                 ogs_assert(pcf_ue);
251
 
252
-                e->sess = sess;
253
+                e->sess_id = sess->id;
254
                 e->h.sbi.message = &message;
255
 
256
                 ogs_fsm_dispatch(&sess->sm, e);
257
@@ -687,19 +723,25 @@
258
              * 4. timer expiration event is processed. (double-free SBI xact)
259
              *
260
              * To avoid double-free SBI xact,
261
-             * we need to check ogs_sbi_xact_cycle()
262
+             * we need to check ogs_sbi_xact_find_by_id()
263
              */
264
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
265
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
266
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
267
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
268
+
269
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
270
             if (!sbi_xact) {
271
-                ogs_error("SBI transaction has already been removed");
272
+                ogs_error("SBI transaction has already been removed %d",
273
+                        sbi_xact_id);
274
                 break;
275
             }
276
 
277
             sbi_object = sbi_xact->sbi_object;
278
             ogs_assert(sbi_object);
279
 
280
-            stream = sbi_xact->assoc_stream;
281
-            ogs_assert(stream);
282
+            ogs_assert(sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
283
+                    sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID);
284
+            stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
285
 
286
             service_type = sbi_xact->service_type;
287
 
288
@@ -710,9 +752,11 @@
289
 
290
             switch(sbi_object->type) {
291
             case OGS_SBI_OBJ_UE_TYPE:
292
-                pcf_ue = (pcf_ue_t *)sbi_object;
293
-                ogs_assert(pcf_ue);
294
-                pcf_ue = pcf_ue_cycle(pcf_ue);
295
+                pcf_ue_id = sbi_xact->sbi_object_id;
296
+                ogs_assert(pcf_ue_id >= OGS_MIN_POOL_ID &&
297
+                        pcf_ue_id <= OGS_MAX_POOL_ID);
298
+
299
+                pcf_ue = pcf_ue_find_by_id(pcf_ue_id);
300
                 if (!pcf_ue) {
301
                     ogs_error("UE(pcf_ue) has already been removed");
302
                     break;
303
@@ -721,9 +765,11 @@
304
                 break;
305
 
306
             case OGS_SBI_OBJ_SESS_TYPE:
307
-                sess = (pcf_sess_t *)sbi_object;
308
-                ogs_assert(sess);
309
-                sess = pcf_sess_cycle(sess);
310
+                sess_id = sbi_xact->sbi_object_id;
311
+                ogs_assert(sess_id >= OGS_MIN_POOL_ID &&
312
+                        sess_id <= OGS_MAX_POOL_ID);
313
+
314
+                sess = pcf_sess_find_by_id(sess_id);
315
                 if (!sess) {
316
                     ogs_error("Session has already been removed");
317
                     break;
318
@@ -739,6 +785,12 @@
319
             }
320
 
321
             ogs_error("Cannot receive SBI message");
322
+
323
+            if (!stream) {
324
+                ogs_error("STREAM has alreadt been removed %d",
325
+                        sbi_xact->assoc_stream_id);
326
+                break;
327
+            }
328
             ogs_assert(true ==
329
                 ogs_sbi_server_send_error(stream,
330
                     OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL,
331
open5gs_2.7.1.39.dc2e1.tar.xz/src/pcf/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/pcf/sm-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/scp/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/scp/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/scp/sbi-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/scp/sbi-path.c Changed
236
 
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
     }
202
 
203
@@ -869,6 +907,10 @@
204
         goto cleanup;
205
     }
206
 
207
+    ogs_assert(assoc->target_apiroot);
208
+    request = assoc->request;
209
+    ogs_assert(request);
210
+
211
     if (false == send_request(
212
                 sepp_client, response_handler, request, false, assoc)) {
213
         strerror = ogs_msprintf("send_request() failed");
214
@@ -884,6 +926,12 @@
215
     ogs_assert(strerror);
216
     ogs_error("%s", strerror);
217
 
218
+    scp_assoc_remove(assoc);
219
+
220
+    if (!stream) {
221
+        ogs_error("STREAM has already been removed %d", stream_id);
222
+        return OGS_ERROR;
223
+    }
224
     ogs_assert(true ==
225
         ogs_sbi_server_send_error(
226
             stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST, NULL, strerror, NULL,
227
@@ -891,8 +939,6 @@
228
 
229
     ogs_free(strerror);
230
 
231
-    scp_assoc_remove(assoc);
232
-
233
     ogs_sbi_response_free(response);
234
     ogs_sbi_message_free(&message);
235
 
236
open5gs_2.7.1.39.dc2e1.tar.xz/src/scp/scp-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sepp/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sepp/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sepp/handshake-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sepp/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sepp/sepp-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/context.c -> open5gs_2.7.1.48.555c2.tar.xz/src/sgwc/context.c Changed
247
 
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
@@ -751,7 +765,7 @@
202
     tunnel->pdr = pdr;
203
     tunnel->far = far;
204
 
205
-    tunnel->bearer = bearer;
206
+    tunnel->bearer_id = bearer->id;
207
 
208
     ogs_list_add(&bearer->tunnel_list, tunnel);
209
 
210
@@ -760,10 +774,13 @@
211
 
212
 int sgwc_tunnel_remove(sgwc_tunnel_t *tunnel)
213
 {
214
+    sgwc_bearer_t *bearer = NULL;
215
+
216
     ogs_assert(tunnel);
217
-    ogs_assert(tunnel->bearer);
218
+    bearer = sgwc_bearer_find_by_id(tunnel->bearer_id);
219
+    ogs_assert(bearer);
220
 
221
-    ogs_list_remove(&tunnel->bearer->tunnel_list, tunnel);
222
+    ogs_list_remove(&bearer->tunnel_list, tunnel);
223
 
224
     ogs_pfcp_pdr_remove(tunnel->pdr);
225
     ogs_pfcp_far_remove(tunnel->far);
226
@@ -773,7 +790,7 @@
227
     if (tunnel->local_addr6)
228
         ogs_freeaddrinfo(tunnel->local_addr6);
229
 
230
-    ogs_pool_free(&sgwc_tunnel_pool, tunnel);
231
+    ogs_pool_id_free(&sgwc_tunnel_pool, tunnel);
232
 
233
     return OGS_OK;
234
 }
235
@@ -863,6 +880,11 @@
236
     return NULL;
237
 }
238
 
239
+sgwc_tunnel_t *sgwc_tunnel_find_by_id(ogs_pool_id_t id)
240
+{
241
+    return ogs_pool_find_by_id(&sgwc_tunnel_pool, id);
242
+}
243
+
244
 sgwc_tunnel_t *sgwc_dl_tunnel_in_bearer(sgwc_bearer_t *bearer)
245
 {
246
     ogs_assert(bearer);
247
open5gs_2.7.1.39.dc2e1.tar.xz/src/sgwc/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/gtp-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/pfcp-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/pfcp-path.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/pfcp-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/s11-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/s11-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/sgwc/s11-handler.c Changed
445
 
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
@@ -715,17 +764,29 @@
202
      * Check Transaction
203
      ********************/
204
     ogs_assert(s11_xact);
205
-    s5c_xact = s11_xact->assoc_xact;
206
+    s5c_xact = ogs_gtp_xact_find_by_id(s11_xact->assoc_xact_id);
207
     ogs_assert(s5c_xact);
208
 
209
-    if (s11_xact->xid & OGS_GTP_CMD_XACT_ID)
210
+    if (s11_xact->xid & OGS_GTP_CMD_XACT_ID) {
211
         /* MME received Bearer Resource Modification Request */
212
-        bearer = s5c_xact->data;
213
-    else
214
-        bearer = s11_xact->data;
215
+        ogs_assert(s5c_xact->data);
216
+        bearer_id = OGS_POINTER_TO_UINT(s5c_xact->data);
217
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
218
+                bearer_id <= OGS_MAX_POOL_ID);
219
 
220
-    ogs_assert(bearer);
221
-    sess = bearer->sess;
222
+        bearer = sgwc_bearer_find_by_id(bearer_id);
223
+        ogs_assert(bearer);
224
+    } else {
225
+        ogs_assert(s11_xact->data);
226
+        bearer_id = OGS_POINTER_TO_UINT(s11_xact->data);
227
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
228
+                bearer_id <= OGS_MAX_POOL_ID);
229
+
230
+        bearer = sgwc_bearer_find_by_id(bearer_id);
231
+        ogs_assert(bearer);
232
+    }
233
+
234
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
235
     ogs_assert(sess);
236
 
237
     rv = ogs_gtp_xact_commit(s11_xact);
238
@@ -765,7 +826,7 @@
239
     if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
240
         ogs_assert(OGS_OK ==
241
             sgwc_pfcp_send_bearer_modification_request(
242
-                bearer, NULL, NULL,
243
+                bearer, OGS_INVALID_POOL_ID, NULL,
244
                 OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE));
245
         ogs_gtp_send_error_message(s5c_xact, sess ? sess->pgw_s5c_teid : 0,
246
                 OGS_GTP2_CREATE_BEARER_RESPONSE_TYPE, cause_value);
247
@@ -784,7 +845,7 @@
248
         ogs_error("GTP Cause Value:%d", cause_value);
249
         ogs_assert(OGS_OK ==
250
             sgwc_pfcp_send_bearer_modification_request(
251
-                bearer, NULL, NULL,
252
+                bearer, OGS_INVALID_POOL_ID, NULL,
253
                 OGS_PFCP_MODIFY_UL_ONLY|OGS_PFCP_MODIFY_REMOVE));
254
         ogs_gtp_send_error_message(s5c_xact, sess ? sess->pgw_s5c_teid : 0,
255
                 OGS_GTP2_CREATE_BEARER_RESPONSE_TYPE, cause_value);
256
@@ -867,7 +928,7 @@
257
 
258
     ogs_assert(OGS_OK ==
259
         sgwc_pfcp_send_bearer_modification_request(
260
-            bearer, s5c_xact, gtpbuf,
261
+            bearer, s5c_xact->id, gtpbuf,
262
             OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_CREATE));
263
 }
264
 
265
@@ -882,6 +943,7 @@
266
     ogs_gtp_xact_t *s5c_xact = NULL;
267
     sgwc_sess_t *sess = NULL;
268
     sgwc_bearer_t *bearer = NULL;
269
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
270
     ogs_gtp2_update_bearer_response_t *rsp = NULL;
271
 
272
     ogs_assert(sgwc_ue);
273
@@ -895,17 +957,29 @@
274
      * Check Transaction
275
      ********************/
276
     ogs_assert(s11_xact);
277
-    s5c_xact = s11_xact->assoc_xact;
278
+    s5c_xact = ogs_gtp_xact_find_by_id(s11_xact->assoc_xact_id);
279
     ogs_assert(s5c_xact);
280
 
281
-    if (s11_xact->xid & OGS_GTP_CMD_XACT_ID)
282
+    if (s11_xact->xid & OGS_GTP_CMD_XACT_ID) {
283
         /* MME received Bearer Resource Modification Request */
284
-        bearer = s5c_xact->data;
285
-    else
286
-        bearer = s11_xact->data;
287
+        ogs_assert(s5c_xact->data);
288
+        bearer_id = OGS_POINTER_TO_UINT(s5c_xact->data);
289
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
290
+                bearer_id <= OGS_MAX_POOL_ID);
291
 
292
-    ogs_assert(bearer);
293
-    sess = bearer->sess;
294
+        bearer = sgwc_bearer_find_by_id(bearer_id);
295
+        ogs_assert(bearer);
296
+    } else {
297
+        ogs_assert(s11_xact->data);
298
+        bearer_id = OGS_POINTER_TO_UINT(s11_xact->data);
299
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
300
+                bearer_id <= OGS_MAX_POOL_ID);
301
+
302
+        bearer = sgwc_bearer_find_by_id(bearer_id);
303
+        ogs_assert(bearer);
304
+    }
305
+
306
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
307
     ogs_assert(sess);
308
 
309
     rv = ogs_gtp_xact_commit(s11_xact);
310
@@ -1005,6 +1079,7 @@
311
 
312
     sgwc_sess_t *sess = NULL;
313
     sgwc_bearer_t *bearer = NULL;
314
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
315
     ogs_gtp2_delete_bearer_response_t *rsp = NULL;
316
 
317
     ogs_assert(sgwc_ue);
318
@@ -1018,17 +1093,29 @@
319
      * Check Transaction
320
      ********************/
321
     ogs_assert(s11_xact);
322
-    s5c_xact = s11_xact->assoc_xact;
323
+    s5c_xact = ogs_gtp_xact_find_by_id(s11_xact->assoc_xact_id);
324
     ogs_assert(s5c_xact);
325
 
326
-    if (s11_xact->xid & OGS_GTP_CMD_XACT_ID)
327
+    if (s11_xact->xid & OGS_GTP_CMD_XACT_ID) {
328
         /* MME received Bearer Resource Modification Request */
329
-        bearer = s5c_xact->data;
330
-    else
331
-        bearer = s11_xact->data;
332
+        ogs_assert(s5c_xact->data);
333
+        bearer_id = OGS_POINTER_TO_UINT(s5c_xact->data);
334
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
335
+                bearer_id <= OGS_MAX_POOL_ID);
336
 
337
-    ogs_assert(bearer);
338
-    sess = bearer->sess;
339
+        bearer = sgwc_bearer_find_by_id(bearer_id);
340
+        ogs_assert(bearer);
341
+    } else {
342
+        ogs_assert(s11_xact->data);
343
+        bearer_id = OGS_POINTER_TO_UINT(s11_xact->data);
344
+        ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
345
+                bearer_id <= OGS_MAX_POOL_ID);
346
+
347
+        bearer = sgwc_bearer_find_by_id(bearer_id);
348
+        ogs_assert(bearer);
349
+    }
350
+
351
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
352
     ogs_assert(sess);
353
 
354
     rv = ogs_gtp_xact_commit(s11_xact);
355
@@ -1065,7 +1152,8 @@
356
         }
357
 
358
         ogs_assert(OGS_OK ==
359
-            sgwc_pfcp_send_session_deletion_request(sess, s5c_xact, gtpbuf));
360
+            sgwc_pfcp_send_session_deletion_request(
361
+                sess, s5c_xact->id, gtpbuf));
362
     } else {
363
        /*
364
         * << EPS Bearer IDs >>
365
@@ -1117,7 +1205,7 @@
366
 
367
         ogs_assert(OGS_OK ==
368
             sgwc_pfcp_send_bearer_modification_request(
369
-                bearer, s5c_xact, gtpbuf, OGS_PFCP_MODIFY_REMOVE));
370
+                bearer, s5c_xact->id, gtpbuf, OGS_PFCP_MODIFY_REMOVE));
371
     }
372
 }
373
 
374
@@ -1166,7 +1254,7 @@
375
 
376
         ogs_assert(OGS_OK ==
377
             sgwc_pfcp_send_session_modification_request(
378
-                sess, s11_xact, gtpbuf,
379
+                sess, s11_xact->id, gtpbuf,
380
                 OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE));
381
     }
382
 }
383
@@ -1179,6 +1267,7 @@
384
     uint8_t cause_value;
385
 
386
     sgwc_bearer_t *bearer = NULL;
387
+    ogs_pool_id_t bearer_id = OGS_INVALID_POOL_ID;
388
     sgwc_sess_t *sess = NULL;
389
 
390
     ogs_gtp2_downlink_data_notification_acknowledge_t *ack = NULL;
391
@@ -1191,9 +1280,14 @@
392
      * Check Transaction
393
      ********************/
394
     ogs_assert(s11_xact);
395
-    bearer = s11_xact->data;
396
+    ogs_assert(s11_xact->data);
397
+    bearer_id = OGS_POINTER_TO_UINT(s11_xact->data);
398
+    ogs_assert(bearer_id >= OGS_MIN_POOL_ID &&
399
+            bearer_id <= OGS_MAX_POOL_ID);
400
+
401
+    bearer = sgwc_bearer_find_by_id(bearer_id);
402
     ogs_assert(bearer);
403
-    sess = bearer->sess;
404
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
405
     ogs_assert(sess);
406
 
407
     rv = ogs_gtp_xact_commit(s11_xact);
408
@@ -1359,7 +1453,7 @@
409
 
410
         ogs_assert(OGS_OK ==
411
             sgwc_pfcp_send_session_modification_request(
412
-                sess, s11_xact, gtpbuf,
413
+                sess, s11_xact->id, gtpbuf,
414
                 OGS_PFCP_MODIFY_INDIRECT|OGS_PFCP_MODIFY_CREATE));
415
     }
416
 }
417
@@ -1405,7 +1499,7 @@
418
 
419
         ogs_assert(OGS_OK ==
420
             sgwc_pfcp_send_session_modification_request(
421
-                sess, s11_xact, gtpbuf,
422
+                sess, s11_xact->id, gtpbuf,
423
                 OGS_PFCP_MODIFY_INDIRECT| OGS_PFCP_MODIFY_REMOVE));
424
     }
425
 }
426
@@ -1492,7 +1586,7 @@
427
      * Check ALL Context
428
      ********************/
429
     ogs_assert(bearer);
430
-    sess = bearer->sess;
431
+    sess = sgwc_sess_find_by_id(bearer->sess_id);
432
     ogs_assert(sess);
433
     ogs_assert(sess->gnode);
434
     ogs_assert(sgwc_ue);
435
@@ -1512,7 +1606,8 @@
436
     }
437
 
438
     s5c_xact = ogs_gtp_xact_local_create(
439
-            sess->gnode, &message->h, pkbuf, gtp_bearer_timeout, bearer);
440
+            sess->gnode, &message->h, pkbuf, gtp_bearer_timeout,
441
+            OGS_UINT_TO_POINTER(bearer->id));
442
     if (!s5c_xact) {
443
         ogs_error("ogs_gtp_xact_local_create() failed");
444
         return;
445
open5gs_2.7.1.39.dc2e1.tar.xz/src/sgwc/s5c-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/sgwc/s5c-handler.c Changed
212
 
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
 
202
     /************************
203
@@ -941,7 +948,7 @@
204
         ogs_error("No Context in TEID");
205
         cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
206
     } else {
207
-        sgwc_ue = sess->sgwc_ue;
208
+        sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
209
         ogs_assert(sgwc_ue);
210
     }
211
 
212
open5gs_2.7.1.39.dc2e1.tar.xz/src/sgwc/sgwc-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwc/sxa-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/sgwc/sxa-handler.c Changed
398
 
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
-                s11_xact = pfcp_xact->assoc_xact;
202
+                s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
203
                 ogs_assert(s11_xact);
204
 
205
                 ogs_gtp_send_error_message(
206
@@ -606,7 +632,7 @@
207
                         OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE, cause_value);
208
 
209
             } else if (flags & OGS_PFCP_MODIFY_DL_ONLY) {
210
-                s11_xact = pfcp_xact->assoc_xact;
211
+                s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
212
                 ogs_assert(s11_xact);
213
 
214
                 ogs_gtp_send_error_message(
215
@@ -617,7 +643,7 @@
216
                 ogs_assert_if_reached();
217
             }
218
         } else if (flags & OGS_PFCP_MODIFY_DEACTIVATE) {
219
-            s11_xact = pfcp_xact->assoc_xact;
220
+            s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
221
             ogs_assert(s11_xact);
222
 
223
             ogs_gtp_send_error_message(
224
@@ -652,7 +678,7 @@
225
      */
226
     if (flags & OGS_PFCP_MODIFY_REMOVE) {
227
         if (flags & OGS_PFCP_MODIFY_INDIRECT) {
228
-            s11_xact = pfcp_xact->assoc_xact;
229
+            s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
230
             ogs_assert(s11_xact);
231
 
232
             ogs_pfcp_xact_commit(pfcp_xact);
233
@@ -713,7 +739,7 @@
234
             }
235
 
236
         } else {
237
-            s5c_xact = pfcp_xact->assoc_xact;
238
+            s5c_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
239
 
240
             ogs_pfcp_xact_commit(pfcp_xact);
241
 
242
@@ -746,7 +772,7 @@
243
             ogs_gtp2_create_bearer_request_t *gtp_req = NULL;
244
             ogs_gtp2_f_teid_t sgw_s1u_teid;
245
 
246
-            s5c_xact = pfcp_xact->assoc_xact;
247
+            s5c_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
248
             ogs_assert(s5c_xact);
249
 
250
             ogs_pfcp_xact_commit(pfcp_xact);
251
@@ -780,7 +806,8 @@
252
             ogs_assert(sgwc_ue->gnode);
253
             ogs_assert(bearer);
254
             s11_xact = ogs_gtp_xact_local_create(sgwc_ue->gnode,
255
-                    &recv_message->h, pkbuf, bearer_timeout, bearer);
256
+                    &recv_message->h, pkbuf, bearer_timeout,
257
+                    OGS_UINT_TO_POINTER(bearer->id));
258
             if (!s11_xact) {
259
                 ogs_error("ogs_gtp_xact_local_create() failed");
260
                 return;
261
@@ -796,7 +823,7 @@
262
             ogs_gtp2_create_bearer_response_t *gtp_rsp = NULL;
263
             ogs_gtp2_f_teid_t sgw_s5u_teid, pgw_s5u_teid;
264
 
265
-            s5c_xact = pfcp_xact->assoc_xact;
266
+            s5c_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
267
             ogs_assert(s5c_xact);
268
 
269
             ogs_pfcp_xact_commit(pfcp_xact);
270
@@ -854,7 +881,7 @@
271
             ogs_expect(rv == OGS_OK);
272
 
273
         } else if (flags & OGS_PFCP_MODIFY_INDIRECT) {
274
-            s11_xact = pfcp_xact->assoc_xact;
275
+            s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
276
             ogs_assert(s11_xact);
277
 
278
             ogs_pfcp_xact_commit(pfcp_xact);
279
@@ -987,7 +1014,7 @@
280
     } else if (flags & OGS_PFCP_MODIFY_ACTIVATE) {
281
         OGS_LIST(bearer_to_modify_list);
282
 
283
-        s11_xact = pfcp_xact->assoc_xact;
284
+        s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
285
         ogs_assert(s11_xact);
286
 
287
         ogs_list_copy(&bearer_to_modify_list,
288
@@ -1094,7 +1121,7 @@
289
                     ogs_assert(sess->gnode);
290
                     s5c_xact = ogs_gtp_xact_local_create(
291
                             sess->gnode, &recv_message->h, pkbuf,
292
-                            sess_timeout, sess);
293
+                            sess_timeout, OGS_UINT_TO_POINTER(sess->id));
294
                     if (!s5c_xact) {
295
                         ogs_error("ogs_gtp_xact_local_create() failed");
296
                         return;
297
@@ -1194,7 +1221,7 @@
298
     } else if (flags & OGS_PFCP_MODIFY_DEACTIVATE) {
299
         if (flags & OGS_PFCP_MODIFY_ERROR_INDICATION) {
300
             /* It's faked method for receiving `bearer` context */
301
-            bearer = pfcp_xact->assoc_xact;
302
+            bearer = sgwc_bearer_find_by_id(pfcp_xact->assoc_xact_id);
303
             ogs_assert(bearer);
304
 
305
             ogs_pfcp_xact_commit(pfcp_xact);
306
@@ -1208,7 +1235,7 @@
307
             }
308
 
309
         } else {
310
-            s11_xact = pfcp_xact->assoc_xact;
311
+            s11_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
312
             ogs_assert(s11_xact);
313
 
314
             ogs_pfcp_xact_commit(pfcp_xact);
315
@@ -1293,7 +1320,7 @@
316
         cause_value = OGS_GTP2_CAUSE_MANDATORY_IE_MISSING;
317
     }
318
 
319
-    gtp_xact = pfcp_xact->assoc_xact;
320
+    gtp_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
321
 
322
     ogs_pfcp_xact_commit(pfcp_xact);
323
 
324
@@ -1314,7 +1341,7 @@
325
          * 1. MME sends Delete Session Request to SGW/SMF.
326
          * 2. SMF sends Delete Session Response to SGW/MME.
327
          */
328
-        if (sess) sgwc_ue = sess->sgwc_ue;
329
+        if (sess) sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
330
         teid = sgwc_ue ? sgwc_ue->mme_s11_teid : 0;
331
         break;
332
     case OGS_GTP2_DELETE_BEARER_RESPONSE_TYPE:
333
@@ -1347,7 +1374,7 @@
334
     }
335
 
336
     ogs_assert(sess);
337
-    sgwc_ue = sess->sgwc_ue;
338
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
339
     ogs_assert(sgwc_ue);
340
 
341
     if (gtp_xact) {
342
@@ -1377,10 +1404,7 @@
343
     }
344
 
345
 cleanup:
346
-    if (sgwc_sess_cycle(sess))
347
-        sgwc_sess_remove(sess);
348
-    else
349
-        ogs_error("Session has already been removed");
350
+    sgwc_sess_remove(sess);
351
 }
352
 
353
 void sgwc_sxa_handle_session_report_request(
354
@@ -1426,7 +1450,7 @@
355
     }
356
 
357
     ogs_assert(sess);
358
-    sgwc_ue = sess->sgwc_ue;
359
+    sgwc_ue = sgwc_ue_find_by_id(sess->sgwc_ue_id);
360
     ogs_assert(sgwc_ue);
361
 
362
     if (!sgwc_ue->gnode) {
363
@@ -1476,7 +1500,7 @@
364
         if (far) {
365
             tunnel = sgwc_tunnel_find_by_far_id(sess, far->id);
366
             ogs_assert(tunnel);
367
-            bearer = tunnel->bearer;
368
+            bearer = sgwc_bearer_find_by_id(tunnel->bearer_id);
369
             ogs_assert(bearer);
370
             if (far->dst_if == OGS_PFCP_INTERFACE_ACCESS) {
371
                 ogs_warn("%s Error Indication from eNB", sgwc_ue->imsi_bcd);
372
@@ -1485,7 +1509,7 @@
373
                         sgwc_pfcp_send_session_modification_request(sess,
374
                     /* We only use the `assoc_xact` parameter temporarily here
375
                      * to pass the `bearer` context. */
376
-                            (ogs_gtp_xact_t *)bearer,
377
+                            bearer->id,
378
                             NULL,
379
                             OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE|
380
                             OGS_PFCP_MODIFY_ERROR_INDICATION));
381
@@ -1496,13 +1520,14 @@
382
                                 sgwc_ue->imsi_bcd);
383
                     ogs_assert(OGS_OK ==
384
                         sgwc_pfcp_send_session_deletion_request(
385
-                            sess, NULL, NULL));
386
+                            sess, OGS_INVALID_POOL_ID, NULL));
387
                 } else {
388
                     ogs_error("%s Error Indication(Dedicated Bearer) "
389
                             "from SMF", sgwc_ue->imsi_bcd);
390
                     ogs_assert(OGS_OK ==
391
                         sgwc_pfcp_send_bearer_modification_request(
392
-                            bearer, NULL, NULL, OGS_PFCP_MODIFY_REMOVE));
393
+                            bearer, OGS_INVALID_POOL_ID, NULL,
394
+                            OGS_PFCP_MODIFY_REMOVE));
395
                 }
396
             } else {
397
                 ogs_error("Error Indication Ignored for Indirect Tunnel");
398
open5gs_2.7.1.39.dc2e1.tar.xz/src/sgwu/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwu/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwu/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwu/pfcp-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwu/pfcp-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/sgwu/sgwu-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/binding.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/context.c -> open5gs_2.7.1.48.555c2.tar.xz/src/smf/context.c Changed
319
 
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
+}
202
+
203
+smf_sess_t *smf_sess_find_by_id(ogs_pool_id_t id)
204
 {
205
-    return ogs_pool_cycle(&smf_ue_pool, smf_ue);
206
+    return ogs_pool_find_by_id(&smf_sess_pool, id);
207
 }
208
 
209
-smf_sess_t *smf_sess_cycle(smf_sess_t *sess)
210
+smf_bearer_t *smf_bearer_find_by_id(ogs_pool_id_t id)
211
 {
212
-    return ogs_pool_cycle(&smf_sess_pool, sess);
213
+    return ogs_pool_find_by_id(&smf_bearer_pool, id);
214
 }
215
 
216
-smf_bearer_t *smf_bearer_cycle(smf_bearer_t *bearer)
217
+smf_bearer_t *smf_qos_flow_find_by_id(ogs_pool_id_t id)
218
 {
219
-    return ogs_pool_cycle(&smf_bearer_pool, bearer);
220
+    return ogs_pool_find_by_id(&smf_bearer_pool, id);
221
 }
222
 
223
-smf_bearer_t *smf_qos_flow_cycle(smf_bearer_t *qos_flow)
224
+smf_pf_t *smf_pf_find_by_id(ogs_pool_id_t id)
225
 {
226
-    return ogs_pool_cycle(&smf_bearer_pool, qos_flow);
227
+    return ogs_pool_find_by_id(&smf_pf_pool, id);
228
 }
229
 
230
 smf_pf_t *smf_pf_add(smf_bearer_t *bearer)
231
@@ -2670,17 +2672,16 @@
232
     smf_pf_t *pf = NULL;
233
 
234
     ogs_assert(bearer);
235
-    sess = bearer->sess;
236
+    sess = smf_sess_find_by_id(bearer->sess_id);
237
     ogs_assert(sess);
238
 
239
-    ogs_pool_alloc(&smf_pf_pool, &pf);
240
+    ogs_pool_id_calloc(&smf_pf_pool, &pf);
241
     ogs_assert(pf);
242
-    memset(pf, 0, sizeof *pf);
243
 
244
     ogs_pool_alloc(&bearer->pf_identifier_pool, &pf->identifier_node);
245
     if (!pf->identifier_node) {
246
         ogs_error("smf_pf_add: Expectation `pf->identifier_node' failed");
247
-        ogs_pool_free(&smf_pf_pool, pf);
248
+        ogs_pool_id_free(&smf_pf_pool, pf);
249
         return NULL;
250
     }
251
 
252
@@ -2692,7 +2693,7 @@
253
     if (!pf->precedence_node) {
254
         ogs_error("smf_pf_add: Expectation `pf->precedence_node' failed");
255
         ogs_pool_free(&bearer->pf_identifier_pool, pf->identifier_node);
256
-        ogs_pool_free(&smf_pf_pool, pf);
257
+        ogs_pool_id_free(&smf_pf_pool, pf);
258
         return NULL;
259
     }
260
 
261
@@ -2703,7 +2704,7 @@
262
     /* Re-use 'pf_precedence_pool' to generate SDF Filter ID */
263
     pf->sdf_filter_id = *(pf->precedence_node);
264
 
265
-    pf->bearer = bearer;
266
+    pf->bearer_id = bearer->id;
267
 
268
     ogs_list_add(&bearer->pf_list, pf);
269
 
270
@@ -2712,21 +2713,26 @@
271
 
272
 int smf_pf_remove(smf_pf_t *pf)
273
 {
274
+    smf_sess_t *sess = NULL;
275
+    smf_bearer_t *bearer = NULL;
276
+
277
     ogs_assert(pf);
278
-    ogs_assert(pf->bearer);
279
-    ogs_assert(pf->bearer->sess);
280
+    bearer = smf_bearer_find_by_id(pf->bearer_id);
281
+    ogs_assert(bearer);
282
+    sess = smf_sess_find_by_id(bearer->sess_id);
283
+    ogs_assert(sess);
284
 
285
-    ogs_list_remove(&pf->bearer->pf_list, pf);
286
+    ogs_list_remove(&bearer->pf_list, pf);
287
     if (pf->flow_description)
288
         ogs_free(pf->flow_description);
289
 
290
     if (pf->identifier_node)
291
-        ogs_pool_free(&pf->bearer->pf_identifier_pool, pf->identifier_node);
292
+        ogs_pool_free(&bearer->pf_identifier_pool, pf->identifier_node);
293
     if (pf->precedence_node)
294
         ogs_pool_free(
295
-                &pf->bearer->sess->pf_precedence_pool, pf->precedence_node);
296
+                &sess->pf_precedence_pool, pf->precedence_node);
297
 
298
-    ogs_pool_free(&smf_pf_pool, pf);
299
+    ogs_pool_id_free(&smf_pf_pool, pf);
300
 
301
     return OGS_OK;
302
 }
303
@@ -2740,12 +2746,13 @@
304
         smf_pf_remove(pf);
305
 }
306
 
307
-smf_pf_t *smf_pf_find_by_id(smf_bearer_t *bearer, uint8_t id)
308
+smf_pf_t *smf_pf_find_by_identifier(
309
+        smf_bearer_t *bearer, uint8_t identifier)
310
 {
311
     smf_pf_t *pf = NULL;
312
 
313
     ogs_list_for_each(&bearer->pf_list, pf) {
314
-        if (pf->identifier == id) return pf;
315
+        if (pf->identifier == identifier) return pf;
316
     }
317
 
318
     return NULL;
319
open5gs_2.7.1.39.dc2e1.tar.xz/src/smf/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/fd-path.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/gn-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/gsm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/gsm-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/smf/gsm-sm.c Changed
989
 
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
+
202
+        stream = ogs_sbi_stream_find_by_id(stream_id);
203
+        if (!stream) {
204
+            ogs_error("STREAM has already been removed %d", stream_id);
205
+            break;
206
+        }
207
+
208
         switch (nas_message->gsm.h.message_type) {
209
         case OGS_NAS_5GS_PDU_SESSION_ESTABLISHMENT_REQUEST:
210
             rv = gsm_handle_pdu_session_establishment_request(sess, stream,
211
@@ -339,25 +363,28 @@
212
     uint32_t diam_err;
213
     bool need_gy_terminate = false;
214
 
215
+    ogs_gtp_xact_t *gtp_xact = NULL;
216
+
217
     ogs_assert(s);
218
     ogs_assert(e);
219
 
220
     smf_sm_debug(e);
221
 
222
-    sess = e->sess;
223
+    sess = smf_sess_find_by_id(e->sess_id);
224
     ogs_assert(sess);
225
 
226
     switch (e->h.id) {
227
     case SMF_EVT_S6B_MESSAGE:
228
         s6b_message = e->s6b_message;
229
         ogs_assert(s6b_message);
230
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
231
 
232
         switch(s6b_message->cmd_code) {
233
         case OGS_DIAM_S6B_CMD_AUTHENTICATION_AUTHORIZATION:
234
             sess->sm_data.s6b_aar_in_flight = false;
235
             sess->sm_data.s6b_aaa_err = s6b_message->result_code;
236
             if (s6b_message->result_code == ER_DIAMETER_SUCCESS) {
237
-                send_ccr_init_req_gx_gy(sess, e);
238
+                send_ccr_init_req_gx_gy(sess, gtp_xact);
239
                 return;
240
             }
241
             goto test_can_proceed;
242
@@ -367,14 +394,15 @@
243
     case SMF_EVT_GX_MESSAGE:
244
         gx_message = e->gx_message;
245
         ogs_assert(gx_message);
246
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
247
 
248
         switch(gx_message->cmd_code) {
249
         case OGS_DIAM_GX_CMD_CODE_CREDIT_CONTROL:
250
             switch(gx_message->cc_request_type) {
251
             case OGS_DIAM_GX_CC_REQUEST_TYPE_INITIAL_REQUEST:
252
-                ogs_assert(e->gtp_xact);
253
+                ogs_assert(gtp_xact);
254
                 diam_err = smf_gx_handle_cca_initial_request(sess,
255
-                                gx_message, e->gtp_xact);
256
+                                gx_message, gtp_xact);
257
                 sess->sm_data.gx_ccr_init_in_flight = false;
258
                 sess->sm_data.gx_cca_init_err = diam_err;
259
                 goto test_can_proceed;
260
@@ -386,14 +414,15 @@
261
     case SMF_EVT_GY_MESSAGE:
262
         gy_message = e->gy_message;
263
         ogs_assert(gy_message);
264
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
265
 
266
         switch(gy_message->cmd_code) {
267
         case OGS_DIAM_GY_CMD_CODE_CREDIT_CONTROL:
268
             switch(gy_message->cc_request_type) {
269
             case OGS_DIAM_GY_CC_REQUEST_TYPE_INITIAL_REQUEST:
270
-                ogs_assert(e->gtp_xact);
271
+                ogs_assert(gtp_xact);
272
                 diam_err = smf_gy_handle_cca_initial_request(sess,
273
-                                gy_message, e->gtp_xact, &need_gy_terminate);
274
+                                gy_message, gtp_xact, &need_gy_terminate);
275
                 sess->sm_data.gy_ccr_init_in_flight = false;
276
                 sess->sm_data.gy_cca_init_err = diam_err;
277
                 goto test_can_proceed;
278
@@ -419,23 +448,29 @@
279
 
280
         if (diam_err == ER_DIAMETER_SUCCESS) {
281
             OGS_FSM_TRAN(s, smf_gsm_state_wait_pfcp_establishment);
282
+            ogs_assert(gtp_xact);
283
             ogs_assert(OGS_OK ==
284
                 smf_epc_pfcp_send_session_establishment_request(
285
-                    sess, e->gtp_xact, 0));
286
+                    sess,
287
+                    gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID, 0));
288
         } else {
289
             /* Tear down Gx/Gy session if its sm_data.*init_err == ER_DIAMETER_SUCCESS */
290
             if (sess->sm_data.gx_cca_init_err == ER_DIAMETER_SUCCESS) {
291
                 sess->sm_data.gx_ccr_term_in_flight = true;
292
-                smf_gx_send_ccr(sess, e->gtp_xact, OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST);
293
+                smf_gx_send_ccr(
294
+                    sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID,
295
+                    OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST);
296
             }
297
             if (smf_use_gy_iface() == 1 &&
298
                 (sess->sm_data.gy_cca_init_err == ER_DIAMETER_SUCCESS || need_gy_terminate)) {
299
                 sess->sm_data.gy_ccr_term_in_flight = true;
300
-                smf_gy_send_ccr(sess, e->gtp_xact, OGS_DIAM_GY_CC_REQUEST_TYPE_TERMINATION_REQUEST);
301
+                smf_gy_send_ccr(
302
+                    sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID,
303
+                    OGS_DIAM_GY_CC_REQUEST_TYPE_TERMINATION_REQUEST);
304
             }
305
             uint8_t gtp_cause = gtp_cause_from_diameter(
306
-                                    e->gtp_xact->gtp_version, diam_err, NULL);
307
-            send_gtp_create_err_msg(sess, e->gtp_xact, gtp_cause);
308
+                                    gtp_xact->gtp_version, diam_err, NULL);
309
+            send_gtp_create_err_msg(sess, gtp_xact, gtp_cause);
310
         }
311
     }
312
 }
313
@@ -447,6 +482,7 @@
314
     smf_sess_t *sess = NULL;
315
 
316
     ogs_sbi_stream_t *stream = NULL;
317
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
318
     ogs_sbi_message_t *sbi_message = NULL;
319
 
320
     int state = 0;
321
@@ -456,7 +492,7 @@
322
 
323
     smf_sm_debug(e);
324
 
325
-    sess = e->sess;
326
+    sess = smf_sess_find_by_id(e->sess_id);
327
     ogs_assert(sess);
328
 
329
     switch (e->h.id) {
330
@@ -469,13 +505,20 @@
331
         sbi_message = e->h.sbi.message;
332
         ogs_assert(sbi_message);
333
 
334
-        smf_ue = sess->smf_ue;
335
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
336
         ogs_assert(smf_ue);
337
 
338
         SWITCH(sbi_message->h.service.name)
339
         CASE(OGS_SBI_SERVICE_NAME_NUDM_SDM)
340
-            stream = e->h.sbi.data;
341
-            ogs_assert(stream);
342
+            stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
343
+            ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
344
+                    stream_id <= OGS_MAX_POOL_ID);
345
+
346
+            stream = ogs_sbi_stream_find_by_id(stream_id);
347
+            if (!stream) {
348
+                ogs_error("STREAM has already been removed %d", stream_id);
349
+                break;
350
+            }
351
 
352
             SWITCH(sbi_message->h.resource.component1)
353
             CASE(OGS_SBI_RESOURCE_NAME_SM_DATA)
354
@@ -601,7 +644,7 @@
355
 
356
     smf_sm_debug(e);
357
 
358
-    sess = e->sess;
359
+    sess = smf_sess_find_by_id(e->sess_id);
360
     ogs_assert(sess);
361
 
362
     switch (e->h.id) {
363
@@ -609,7 +652,7 @@
364
         break;
365
 
366
     case SMF_EVT_N4_MESSAGE:
367
-        pfcp_xact = e->pfcp_xact;
368
+        pfcp_xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
369
         ogs_assert(pfcp_xact);
370
         pfcp_message = e->pfcp_message;
371
         ogs_assert(pfcp_message);
372
@@ -617,7 +660,8 @@
373
         switch (pfcp_message->h.type) {
374
         case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
375
             if (pfcp_xact->epc) {
376
-                ogs_gtp_xact_t *gtp_xact = pfcp_xact->assoc_xact;
377
+                ogs_gtp_xact_t *gtp_xact =
378
+                    ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
379
                 ogs_assert(gtp_xact);
380
 
381
                 pfcp_cause = smf_epc_n4_handle_session_establishment_response(
382
@@ -627,31 +671,28 @@
383
                     /* FIXME: tear down Gy and Gx */
384
                     gtp_cause = gtp_cause_from_pfcp(
385
                                     pfcp_cause, gtp_xact->gtp_version);
386
-                    send_gtp_create_err_msg(sess, e->gtp_xact, gtp_cause);
387
+                    send_gtp_create_err_msg(sess, gtp_xact, gtp_cause);
388
                     return;
389
                 }
390
 
391
-                gtp_xact = pfcp_xact->assoc_xact;
392
-                if (gtp_xact) {
393
-                    switch (gtp_xact->gtp_version) {
394
-                    case 1:
395
-                        rv = smf_gtp1_send_create_pdp_context_response(
396
-                                sess, gtp_xact);
397
-                        break;
398
-                    case 2:
399
-                        rv = smf_gtp2_send_create_session_response(
400
-                                sess, gtp_xact);
401
-                        break;
402
-                    default:
403
-                        rv = OGS_ERROR;
404
-                        break;
405
-                    }
406
-                    /* If no CreatePDPCtxResp can be sent,
407
-                     * then tear down the session: */
408
-                    if (rv != OGS_OK) {
409
-                        OGS_FSM_TRAN(s, smf_gsm_state_wait_pfcp_deletion);
410
-                        return;
411
-                    }
412
+                switch (gtp_xact->gtp_version) {
413
+                case 1:
414
+                    rv = smf_gtp1_send_create_pdp_context_response(
415
+                            sess, gtp_xact);
416
+                    break;
417
+                case 2:
418
+                    rv = smf_gtp2_send_create_session_response(
419
+                            sess, gtp_xact);
420
+                    break;
421
+                default:
422
+                    rv = OGS_ERROR;
423
+                    break;
424
+                }
425
+                /* If no CreatePDPCtxResp can be sent,
426
+                 * then tear down the session: */
427
+                if (rv != OGS_OK) {
428
+                    OGS_FSM_TRAN(s, smf_gsm_state_wait_pfcp_deletion);
429
+                    return;
430
                 }
431
 
432
                 if (sess->gtp_rat_type == OGS_GTP2_RAT_TYPE_WLAN) {
433
@@ -735,8 +776,10 @@
434
     ogs_nas_5gs_message_t *nas_message = NULL;
435
 
436
     ogs_sbi_stream_t *stream = NULL;
437
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
438
     ogs_sbi_message_t *sbi_message = NULL;
439
 
440
+    ogs_gtp_xact_t *gtp_xact = NULL;
441
     ogs_gtp1_message_t *gtp1_message = NULL;
442
     ogs_gtp2_message_t *gtp2_message = NULL;
443
     uint8_t gtp1_cause, gtp2_cause;
444
@@ -750,7 +793,7 @@
445
 
446
     smf_sm_debug(e);
447
 
448
-    sess = e->sess;
449
+    sess = smf_sess_find_by_id(e->sess_id);
450
     ogs_assert(sess);
451
 
452
     switch (e->h.id) {
453
@@ -763,14 +806,15 @@
454
     case SMF_EVT_GN_MESSAGE:
455
         gtp1_message = e->gtp1_message;
456
         ogs_assert(gtp1_message);
457
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
458
 
459
         switch(gtp1_message->h.type) {
460
         case OGS_GTP1_DELETE_PDP_CONTEXT_REQUEST_TYPE:
461
             gtp1_cause = smf_gn_handle_delete_pdp_context_request(sess,
462
-                            e->gtp_xact,
463
+                            gtp_xact,
464
                             &gtp1_message->delete_pdp_context_request);
465
             if (gtp1_cause != OGS_GTP1_CAUSE_REQUEST_ACCEPTED) {
466
-                ogs_gtp1_send_error_message(e->gtp_xact, sess->sgw_s5c_teid,
467
+                ogs_gtp1_send_error_message(gtp_xact, sess->sgw_s5c_teid,
468
                         OGS_GTP1_DELETE_PDP_CONTEXT_RESPONSE_TYPE, gtp1_cause);
469
                 return;
470
             }
471
@@ -781,14 +825,15 @@
472
     case SMF_EVT_S5C_MESSAGE:
473
         gtp2_message = e->gtp2_message;
474
         ogs_assert(gtp2_message);
475
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
476
 
477
         switch(gtp2_message->h.type) {
478
         case OGS_GTP2_DELETE_SESSION_REQUEST_TYPE:
479
             gtp2_cause = smf_s5c_handle_delete_session_request(
480
-                            sess, e->gtp_xact,
481
+                            sess, gtp_xact,
482
                             &gtp2_message->delete_session_request);
483
             if (gtp2_cause != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
484
-                ogs_gtp2_send_error_message(e->gtp_xact, sess->sgw_s5c_teid,
485
+                ogs_gtp2_send_error_message(gtp_xact, sess->sgw_s5c_teid,
486
                         OGS_GTP2_DELETE_SESSION_RESPONSE_TYPE, gtp2_cause);
487
                 return;
488
             }
489
@@ -796,9 +841,8 @@
490
             break;
491
         case OGS_GTP2_DELETE_BEARER_RESPONSE_TYPE:
492
             release = smf_s5c_handle_delete_bearer_response(
493
-                sess, e->gtp_xact, &e->gtp2_message->delete_bearer_response);
494
+                sess, gtp_xact, &e->gtp2_message->delete_bearer_response);
495
             if (release) {
496
-                e->gtp_xact = NULL;
497
                 OGS_FSM_TRAN(s, smf_gsm_state_wait_pfcp_deletion);
498
             }
499
             break;
500
@@ -809,7 +853,7 @@
501
         break;
502
 
503
     case SMF_EVT_N4_MESSAGE:
504
-        pfcp_xact = e->pfcp_xact;
505
+        pfcp_xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
506
         ogs_assert(pfcp_xact);
507
         pfcp_message = e->pfcp_message;
508
         ogs_assert(pfcp_message);
509
@@ -856,13 +900,15 @@
510
     case SMF_EVT_GY_MESSAGE:
511
         gy_message = e->gy_message;
512
         ogs_assert(gy_message);
513
+        pfcp_xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
514
 
515
         switch(gy_message->cmd_code) {
516
         case OGS_DIAM_GY_CMD_CODE_CREDIT_CONTROL:
517
             switch (gy_message->cc_request_type) {
518
             case OGS_DIAM_GY_CC_REQUEST_TYPE_UPDATE_REQUEST:
519
-                ogs_assert(e->pfcp_xact);
520
-                diam_err = smf_gy_handle_cca_update_request(sess, gy_message, e->pfcp_xact);
521
+                ogs_assert(pfcp_xact);
522
+                diam_err = smf_gy_handle_cca_update_request(
523
+                        sess, gy_message, pfcp_xact);
524
                 if (diam_err != ER_DIAMETER_SUCCESS)
525
                     OGS_FSM_TRAN(s, smf_gsm_state_wait_pfcp_deletion);
526
                 break;
527
@@ -874,8 +920,16 @@
528
     case OGS_EVENT_SBI_SERVER:
529
         sbi_message = e->h.sbi.message;
530
         ogs_assert(sbi_message);
531
-        stream = e->h.sbi.data;
532
-        ogs_assert(stream);
533
+
534
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
535
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
536
+                stream_id <= OGS_MAX_POOL_ID);
537
+
538
+        stream = ogs_sbi_stream_find_by_id(stream_id);
539
+        if (!stream) {
540
+            ogs_error("STREAM has already been removed %d", stream_id);
541
+            break;
542
+        }
543
 
544
         SWITCH(sbi_message->h.service.name)
545
         CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)
546
@@ -913,12 +967,15 @@
547
         sbi_message = e->h.sbi.message;
548
         ogs_assert(sbi_message);
549
 
550
-        smf_ue = sess->smf_ue;
551
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
552
         ogs_assert(smf_ue);
553
 
554
         SWITCH(sbi_message->h.service.name)
555
         CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)
556
-            stream = e->h.sbi.data;
557
+            stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
558
+            if (stream_id >= OGS_MIN_POOL_ID && stream_id <= OGS_MAX_POOL_ID)
559
+                stream = ogs_sbi_stream_find_by_id(stream_id);
560
+
561
             state = e->h.sbi.state;
562
 
563
             SWITCH(sbi_message->h.resource.component0)
564
@@ -1062,11 +1119,19 @@
565
     case SMF_EVT_5GSM_MESSAGE:
566
         nas_message = e->nas.message;
567
         ogs_assert(nas_message);
568
-        stream = e->h.sbi.data;
569
-        ogs_assert(stream);
570
-        smf_ue = sess->smf_ue;
571
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
572
         ogs_assert(smf_ue);
573
 
574
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
575
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
576
+                stream_id <= OGS_MAX_POOL_ID);
577
+
578
+        stream = ogs_sbi_stream_find_by_id(stream_id);
579
+        if (!stream) {
580
+            ogs_error("STREAM has already been removed %d", stream_id);
581
+            break;
582
+        }
583
+
584
         switch (nas_message->gsm.h.message_type) {
585
         case OGS_NAS_5GS_PDU_SESSION_MODIFICATION_REQUEST:
586
             rv = gsm_handle_pdu_session_modification_request(sess, stream,
587
@@ -1128,14 +1193,22 @@
588
         break;
589
 
590
     case SMF_EVT_NGAP_MESSAGE:
591
-        stream = e->h.sbi.data;
592
-        ogs_assert(stream);
593
-        smf_ue = sess->smf_ue;
594
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
595
         ogs_assert(smf_ue);
596
         pkbuf = e->pkbuf;
597
         ogs_assert(pkbuf);
598
         ogs_assert(e->ngap.type);
599
 
600
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
601
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
602
+                stream_id <= OGS_MAX_POOL_ID);
603
+
604
+        stream = ogs_sbi_stream_find_by_id(stream_id);
605
+        if (!stream) {
606
+            ogs_error("STREAM has already been removed %d", stream_id);
607
+            break;
608
+        }
609
+
610
         switch (e->ngap.type) {
611
         case OpenAPI_n2_sm_info_type_PDU_RES_SETUP_RSP:
612
             rv = ngap_handle_pdu_session_resource_setup_response_transfer(
613
@@ -1263,6 +1336,7 @@
614
     smf_sess_t *sess = NULL;
615
 
616
     ogs_sbi_stream_t *stream = NULL;
617
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
618
     ogs_sbi_message_t *sbi_message = NULL;
619
 
620
     ogs_pfcp_xact_t *pfcp_xact = NULL;
621
@@ -1276,7 +1350,7 @@
622
 
623
     smf_sm_debug(e);
624
 
625
-    sess = e->sess;
626
+    sess = smf_sess_find_by_id(e->sess_id);
627
     ogs_assert(sess);
628
 
629
     switch (e->h.id) {
630
@@ -1285,12 +1359,21 @@
631
          * we'll use `sess->epc` */
632
         if (sess->epc) {
633
             /* EPC */
634
+            gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
635
             ogs_assert(OGS_OK ==
636
-                smf_epc_pfcp_send_session_deletion_request(sess, e->gtp_xact));
637
+                smf_epc_pfcp_send_session_deletion_request(
638
+                    sess, gtp_xact ? gtp_xact->id : OGS_INVALID_POOL_ID));
639
         } else {
640
             /* 5GC */
641
-            stream = e->h.sbi.data;
642
-            ogs_assert(stream);
643
+            stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
644
+            ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
645
+                    stream_id <= OGS_MAX_POOL_ID);
646
+
647
+            stream = ogs_sbi_stream_find_by_id(stream_id);
648
+            if (!stream) {
649
+                ogs_error("STREAM has already been removed %d", stream_id);
650
+                break;
651
+            }
652
 
653
             ogs_assert(OGS_OK ==
654
                 smf_5gc_pfcp_send_session_deletion_request(
655
@@ -1306,7 +1389,7 @@
656
         break; /* ignore */
657
 
658
     case SMF_EVT_N4_MESSAGE:
659
-        pfcp_xact = e->pfcp_xact;
660
+        pfcp_xact = ogs_pfcp_xact_find_by_id(e->pfcp_xact_id);
661
         ogs_assert(pfcp_xact);
662
         pfcp_message = e->pfcp_message;
663
         ogs_assert(pfcp_message);
664
@@ -1314,7 +1397,7 @@
665
         switch (pfcp_message->h.type) {
666
         case OGS_PFCP_SESSION_DELETION_RESPONSE_TYPE:
667
             if (pfcp_xact->epc) {
668
-                gtp_xact = pfcp_xact->assoc_xact;
669
+                gtp_xact = ogs_gtp_xact_find_by_id(pfcp_xact->assoc_xact_id);
670
 
671
                 pfcp_cause = smf_epc_n4_handle_session_deletion_response(
672
                             sess, pfcp_xact,
673
@@ -1327,14 +1410,18 @@
674
                     send_gtp_delete_err_msg(sess, gtp_xact, gtp_cause);
675
                     break;
676
                 }
677
-                e->gtp_xact = gtp_xact;
678
-                if (send_ccr_termination_req_gx_gy_s6b(sess, e) == true)
679
+                if (send_ccr_termination_req_gx_gy_s6b(
680
+                            sess, gtp_xact) == true)
681
                     OGS_FSM_TRAN(s, smf_gsm_state_wait_epc_auth_release);
682
                 /* else: free session? */
683
             } else {
684
                 int trigger;
685
 
686
-                stream = pfcp_xact->assoc_stream;
687
+                if (pfcp_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
688
+                        pfcp_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
689
+                    stream = ogs_sbi_stream_find_by_id(
690
+                            pfcp_xact->assoc_stream_id);
691
+
692
                 trigger = pfcp_xact->delete_trigger;
693
                 ogs_assert(trigger);
694
 
695
@@ -1422,15 +1509,22 @@
696
         sbi_message = e->h.sbi.message;
697
         ogs_assert(sbi_message);
698
 
699
-        smf_ue = sess->smf_ue;
700
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
701
         ogs_assert(smf_ue);
702
 
703
         SWITCH(sbi_message->h.service.name)
704
         CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)
705
             ogs_pkbuf_t *n1smbuf = NULL;
706
 
707
-            stream = e->h.sbi.data;
708
-            ogs_assert(stream);
709
+            stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
710
+            ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
711
+                    stream_id <= OGS_MAX_POOL_ID);
712
+
713
+            stream = ogs_sbi_stream_find_by_id(stream_id);
714
+            if (!stream) {
715
+                ogs_error("STREAM has already been removed %d", stream_id);
716
+                break;
717
+            }
718
 
719
             ogs_error("%s:%d state %d res_status %d",
720
                 smf_ue->supi, sess->psi,
721
@@ -1462,12 +1556,14 @@
722
     ogs_diam_s6b_message_t *s6b_message = NULL;
723
     uint32_t diam_err;
724
 
725
+    ogs_gtp_xact_t *gtp_xact = NULL;
726
+
727
     ogs_assert(s);
728
     ogs_assert(e);
729
 
730
     smf_sm_debug(e);
731
 
732
-    sess = e->sess;
733
+    sess = smf_sess_find_by_id(e->sess_id);
734
     ogs_assert(sess);
735
 
736
     switch (e->h.id) {
737
@@ -1486,13 +1582,14 @@
738
     case SMF_EVT_GX_MESSAGE:
739
         gx_message = e->gx_message;
740
         ogs_assert(gx_message);
741
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
742
 
743
         switch(gx_message->cmd_code) {
744
         case OGS_DIAM_GX_CMD_CODE_CREDIT_CONTROL:
745
             switch(gx_message->cc_request_type) {
746
             case OGS_DIAM_GX_CC_REQUEST_TYPE_TERMINATION_REQUEST:
747
                 diam_err = smf_gx_handle_cca_termination_request(sess,
748
-                                gx_message, e->gtp_xact);
749
+                                gx_message, gtp_xact);
750
                 sess->sm_data.gx_ccr_term_in_flight = false;
751
                 sess->sm_data.gx_cca_term_err = diam_err;
752
                 goto test_can_proceed;
753
@@ -1504,13 +1601,14 @@
754
     case SMF_EVT_GY_MESSAGE:
755
         gy_message = e->gy_message;
756
         ogs_assert(gy_message);
757
+        gtp_xact = ogs_gtp_xact_find_by_id(e->gtp_xact_id);
758
 
759
         switch(gy_message->cmd_code) {
760
         case OGS_DIAM_GY_CMD_CODE_CREDIT_CONTROL:
761
             switch(gy_message->cc_request_type) {
762
             case OGS_DIAM_GY_CC_REQUEST_TYPE_TERMINATION_REQUEST:
763
                 diam_err = smf_gy_handle_cca_termination_request(sess,
764
-                                gy_message, e->gtp_xact);
765
+                                gy_message, gtp_xact);
766
                 sess->sm_data.gy_ccr_term_in_flight = false;
767
                 sess->sm_data.gy_cca_term_err = diam_err;
768
                 goto test_can_proceed;
769
@@ -1548,26 +1646,26 @@
770
             diam_err = sess->sm_data.s6b_sta_err;
771
 
772
         /* Initiated by peer request, let's answer: */
773
-        if (e->gtp_xact) {
774
+        if (gtp_xact) {
775
             if (diam_err == ER_DIAMETER_SUCCESS) {
776
                 /*
777
                  * 1. MME sends Delete Session Request to SGW/SMF.
778
                  * 2. SMF sends Delete Session Response to SGW/MME.
779
                  */
780
-                switch (e->gtp_xact->gtp_version) {
781
+                switch (gtp_xact->gtp_version) {
782
                 case 1:
783
                     smf_gtp1_send_delete_pdp_context_response(
784
-                                sess, e->gtp_xact);
785
+                                sess, gtp_xact);
786
                     break;
787
                 case 2:
788
                     smf_gtp2_send_delete_session_response(
789
-                                sess, e->gtp_xact);
790
+                                sess, gtp_xact);
791
                     break;
792
                 }
793
             } else {
794
                 uint8_t gtp_cause = gtp_cause_from_diameter(
795
-                                    e->gtp_xact->gtp_version, diam_err, NULL);
796
-                send_gtp_delete_err_msg(sess, e->gtp_xact, gtp_cause);
797
+                                    gtp_xact->gtp_version, diam_err, NULL);
798
+                send_gtp_delete_err_msg(sess, gtp_xact, gtp_cause);
799
             }
800
         }
801
         OGS_FSM_TRAN(s, smf_gsm_state_epc_session_will_release);
802
@@ -1586,6 +1684,7 @@
803
     ogs_nas_5gs_message_t *nas_message = NULL;
804
 
805
     ogs_sbi_stream_t *stream = NULL;
806
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
807
     ogs_sbi_message_t *sbi_message = NULL;
808
 
809
     ogs_assert(s);
810
@@ -1593,7 +1692,7 @@
811
 
812
     smf_sm_debug(e);
813
 
814
-    sess = e->sess;
815
+    sess = smf_sess_find_by_id(e->sess_id);
816
     ogs_assert(sess);
817
 
818
     switch (e->h.id) {
819
@@ -1605,8 +1704,16 @@
820
     case OGS_EVENT_SBI_SERVER:
821
         sbi_message = e->h.sbi.message;
822
         ogs_assert(sbi_message);
823
-        stream = e->h.sbi.data;
824
-        ogs_assert(stream);
825
+
826
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
827
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
828
+                stream_id <= OGS_MAX_POOL_ID);
829
+
830
+        stream = ogs_sbi_stream_find_by_id(stream_id);
831
+        if (!stream) {
832
+            ogs_error("STREAM has already been removed %d", stream_id);
833
+            break;
834
+        }
835
 
836
         SWITCH(sbi_message->h.service.name)
837
         CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)
838
@@ -1644,7 +1751,7 @@
839
         sbi_message = e->h.sbi.message;
840
         ogs_assert(sbi_message);
841
 
842
-        smf_ue = sess->smf_ue;
843
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
844
         ogs_assert(smf_ue);
845
 
846
         SWITCH(sbi_message->h.service.name)
847
@@ -1669,8 +1776,15 @@
848
         CASE(OGS_SBI_SERVICE_NAME_NPCF_SMPOLICYCONTROL)
849
             ogs_pkbuf_t *n1smbuf = NULL;
850
 
851
-            stream = e->h.sbi.data;
852
-            ogs_assert(stream);
853
+            stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
854
+            ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
855
+                    stream_id <= OGS_MAX_POOL_ID);
856
+
857
+            stream = ogs_sbi_stream_find_by_id(stream_id);
858
+            if (!stream) {
859
+                ogs_error("STREAM has already been removed %d", stream_id);
860
+                break;
861
+            }
862
 
863
             ogs_error("%s:%d state %d res_status %d",
864
                 smf_ue->supi, sess->psi,
865
@@ -1692,14 +1806,22 @@
866
         break;
867
 
868
     case SMF_EVT_NGAP_MESSAGE:
869
-        stream = e->h.sbi.data;
870
-        ogs_assert(stream);
871
-        smf_ue = sess->smf_ue;
872
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
873
         ogs_assert(smf_ue);
874
         pkbuf = e->pkbuf;
875
         ogs_assert(pkbuf);
876
         ogs_assert(e->ngap.type);
877
 
878
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
879
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
880
+                stream_id <= OGS_MAX_POOL_ID);
881
+
882
+        stream = ogs_sbi_stream_find_by_id(stream_id);
883
+        if (!stream) {
884
+            ogs_error("STREAM has already been removed %d", stream_id);
885
+            break;
886
+        }
887
+
888
         switch (e->ngap.type) {
889
         case OpenAPI_n2_sm_info_type_PDU_RES_SETUP_RSP:
890
             /*
891
@@ -1766,11 +1888,19 @@
892
     case SMF_EVT_5GSM_MESSAGE:
893
         nas_message = e->nas.message;
894
         ogs_assert(nas_message);
895
-        stream = e->h.sbi.data;
896
-        ogs_assert(stream);
897
-        smf_ue = sess->smf_ue;
898
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
899
         ogs_assert(smf_ue);
900
 
901
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
902
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
903
+                stream_id <= OGS_MAX_POOL_ID);
904
+
905
+        stream = ogs_sbi_stream_find_by_id(stream_id);
906
+        if (!stream) {
907
+            ogs_error("STREAM has already been removed %d", stream_id);
908
+            break;
909
+        }
910
+
911
         switch (nas_message->gsm.h.message_type) {
912
         case OGS_NAS_5GS_PDU_SESSION_RELEASE_COMPLETE:
913
             ogs_assert(true == ogs_sbi_send_http_status_no_content(stream));
914
@@ -1815,7 +1945,7 @@
915
 
916
     smf_sm_debug(e);
917
 
918
-    sess = e->sess;
919
+    sess = smf_sess_find_by_id(e->sess_id);
920
     ogs_assert(sess);
921
 
922
     switch (e->h.id) {
923
@@ -1846,7 +1976,7 @@
924
         sbi_message = e->h.sbi.message;
925
         ogs_assert(sbi_message);
926
 
927
-        smf_ue = sess->smf_ue;
928
+        smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
929
         ogs_assert(smf_ue);
930
 
931
         SWITCH(sbi_message->h.service.name)
932
@@ -1925,6 +2055,7 @@
933
     smf_sess_t *sess = NULL;
934
 
935
     ogs_sbi_stream_t *stream = NULL;
936
+    ogs_pool_id_t stream_id = OGS_INVALID_POOL_ID;
937
     ogs_sbi_message_t *sbi_message = NULL;
938
 
939
     ogs_assert(s);
940
@@ -1932,7 +2063,7 @@
941
 
942
     smf_sm_debug(e);
943
 
944
-    sess = e->sess;
945
+    sess = smf_sess_find_by_id(e->sess_id);
946
     ogs_assert(sess);
947
 
948
     switch (e->h.id) {
949
@@ -1945,8 +2076,16 @@
950
     case OGS_EVENT_SBI_SERVER:
951
         sbi_message = e->h.sbi.message;
952
         ogs_assert(sbi_message);
953
-        stream = e->h.sbi.data;
954
-        ogs_assert(stream);
955
+
956
+        stream_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
957
+        ogs_assert(stream_id >= OGS_MIN_POOL_ID &&
958
+                stream_id <= OGS_MAX_POOL_ID);
959
+
960
+        stream = ogs_sbi_stream_find_by_id(stream_id);
961
+        if (!stream) {
962
+            ogs_error("STREAM has already been removed %d", stream_id);
963
+            break;
964
+        }
965
 
966
         SWITCH(sbi_message->h.service.name)
967
         CASE(OGS_SBI_SERVICE_NAME_NSMF_PDUSESSION)
968
@@ -1992,7 +2131,7 @@
969
 
970
     smf_sm_debug(e);
971
 
972
-    sess = e->sess;
973
+    sess = smf_sess_find_by_id(e->sess_id);
974
     ogs_assert(sess);
975
 
976
     switch (e->h.id) {
977
@@ -2019,9 +2158,9 @@
978
 
979
     smf_sm_debug(e);
980
 
981
-    sess = e->sess;
982
+    sess = smf_sess_find_by_id(e->sess_id);
983
     ogs_assert(sess);
984
-    smf_ue = sess->smf_ue;
985
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
986
     ogs_assert(smf_ue);
987
 
988
     switch (e->h.id) {
989
open5gs_2.7.1.39.dc2e1.tar.xz/src/smf/gtp-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/gx-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/gy-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/gy-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/n4-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/n4-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/namf-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/namf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/nas-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/ngap-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/ngap-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/npcf-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/npcf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/nsmf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/nudm-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/nudm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/pfcp-path.c -> open5gs_2.7.1.48.555c2.tar.xz/src/smf/pfcp-path.c Changed
321
 
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
     xact->epc = true; /* EPC PFCP transaction */
202
-    xact->assoc_xact = gtp_xact;
203
+    xact->assoc_xact_id = gtp_xact_id;
204
     xact->local_seid = sess->smf_n4_seid;
205
     xact->create_flags = flags;
206
 
207
@@ -644,7 +695,7 @@
208
 }
209
 
210
 int smf_epc_pfcp_send_all_pdr_modification_request(
211
-        smf_sess_t *sess, void *gtp_xact, ogs_pkbuf_t *gtpbuf,
212
+        smf_sess_t *sess, ogs_pool_id_t gtp_xact_id, ogs_pkbuf_t *gtpbuf,
213
         uint64_t flags, uint8_t gtp_pti, uint8_t gtp_cause)
214
 {
215
     int rv;
216
@@ -653,14 +704,15 @@
217
 
218
     ogs_assert(sess);
219
 
220
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_epc_timeout, sess);
221
+    xact = ogs_pfcp_xact_local_create(
222
+            sess->pfcp_node, sess_epc_timeout, OGS_UINT_TO_POINTER(sess->id));
223
     if (!xact) {
224
         ogs_error("ogs_pfcp_xact_local_create() failed");
225
         return OGS_ERROR;
226
     }
227
 
228
     xact->epc = true; /* EPC PFCP transaction */
229
-    xact->assoc_xact = gtp_xact;
230
+    xact->assoc_xact_id = gtp_xact_id;
231
     xact->local_seid = sess->smf_n4_seid;
232
     xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION;
233
 
234
@@ -686,7 +738,7 @@
235
 }
236
 
237
 int smf_epc_pfcp_send_one_bearer_modification_request(
238
-        smf_bearer_t *bearer, void *gtp_xact,
239
+        smf_bearer_t *bearer, ogs_pool_id_t gtp_xact_id,
240
         uint64_t flags, uint8_t gtp_pti, uint8_t gtp_cause)
241
 {
242
     int rv;
243
@@ -694,18 +746,19 @@
244
     smf_sess_t *sess = NULL;
245
 
246
     ogs_assert(bearer);
247
-    sess = bearer->sess;
248
+    sess = smf_sess_find_by_id(bearer->sess_id);
249
     ogs_assert(sess);
250
 
251
     xact = ogs_pfcp_xact_local_create(
252
-            sess->pfcp_node, bearer_epc_timeout, bearer);
253
+            sess->pfcp_node, bearer_epc_timeout,
254
+            OGS_UINT_TO_POINTER(bearer->id));
255
     if (!xact) {
256
         ogs_error("ogs_pfcp_xact_local_create() failed");
257
         return OGS_ERROR;
258
     }
259
 
260
     xact->epc = true; /* EPC PFCP transaction */
261
-    xact->assoc_xact = gtp_xact;
262
+    xact->assoc_xact_id = gtp_xact_id;
263
     xact->local_seid = sess->smf_n4_seid;
264
     xact->modify_flags = flags;
265
 
266
@@ -723,7 +776,7 @@
267
 }
268
 
269
 int smf_epc_pfcp_send_session_deletion_request(
270
-        smf_sess_t *sess, void *gtp_xact)
271
+        smf_sess_t *sess, ogs_pool_id_t gtp_xact_id)
272
 {
273
     int rv;
274
     ogs_pkbuf_t *n4buf = NULL;
275
@@ -732,7 +785,8 @@
276
 
277
     ogs_assert(sess);
278
 
279
-    xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_epc_timeout, sess);
280
+    xact = ogs_pfcp_xact_local_create(
281
+            sess->pfcp_node, sess_epc_timeout, OGS_UINT_TO_POINTER(sess->id));
282
     if (!xact) {
283
         ogs_error("ogs_pfcp_xact_local_create() failed");
284
         return OGS_ERROR;
285
@@ -761,7 +815,7 @@
286
      * - Bearer Resource Command
287
      * - Delete Bearer Request/Response with DEDICATED BEARER.
288
      */
289
-    xact->assoc_xact = gtp_xact;
290
+    xact->assoc_xact_id = gtp_xact_id;
291
     xact->local_seid = sess->smf_n4_seid;
292
 
293
     memset(&h, 0, sizeof(ogs_pfcp_header_t));
294
@@ -793,7 +847,7 @@
295
     smf_sess_t *eutran_sess = NULL, *wlan_sess = NULL;
296
 
297
     ogs_assert(sess);
298
-    smf_ue = sess->smf_ue;
299
+    smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
300
     ogs_assert(smf_ue);
301
 
302
     switch (gtp_cause) {
303
@@ -812,7 +866,7 @@
304
 
305
         /* Deactivate WLAN Session */
306
         rv = smf_epc_pfcp_send_all_pdr_modification_request(
307
-                wlan_sess, NULL, NULL,
308
+                wlan_sess, OGS_INVALID_POOL_ID, NULL,
309
                 OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE,
310
                 OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
311
                 OGS_GTP2_CAUSE_ACCESS_CHANGED_FROM_NON_3GPP_TO_3GPP);
312
@@ -835,7 +889,7 @@
313
 
314
             /* Deactivate EUTRAN Session */
315
             rv = smf_epc_pfcp_send_all_pdr_modification_request(
316
-                    eutran_sess, NULL, NULL,
317
+                    eutran_sess, OGS_INVALID_POOL_ID, NULL,
318
                     OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE,
319
                     OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
320
                     OGS_GTP2_CAUSE_RAT_CHANGED_FROM_3GPP_TO_NON_3GPP);
321
open5gs_2.7.1.39.dc2e1.tar.xz/src/smf/pfcp-path.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/pfcp-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/s5c-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/s5c-handler.c -> open5gs_2.7.1.48.555c2.tar.xz/src/smf/s5c-handler.c Changed
261
 
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
+        /* Release entire session: */
202
+        return true;
203
+    }
204
 
205
     if (rsp->linked_eps_bearer_id.presence) {
206
         /*
207
@@ -1051,7 +1083,7 @@
208
 
209
     ogs_assert(OGS_OK ==
210
         smf_epc_pfcp_send_one_bearer_modification_request(
211
-            bearer, NULL, OGS_PFCP_MODIFY_REMOVE,
212
+            bearer, OGS_INVALID_POOL_ID, OGS_PFCP_MODIFY_REMOVE,
213
             OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED,
214
             OGS_GTP2_CAUSE_UNDEFINED_VALUE));
215
     return false;
216
@@ -1260,7 +1292,7 @@
217
             OGS_GTP2_TFT_CODE_REPLACE_PACKET_FILTERS_IN_EXISTING) {
218
         for (i = 0; i < tft.num_of_packet_filter &&
219
                     i < OGS_MAX_NUM_OF_FLOW_IN_GTP; i++) {
220
-            pf = smf_pf_find_by_id(bearer, tft.pfi.identifier+1);
221
+            pf = smf_pf_find_by_identifier(bearer, tft.pfi.identifier+1);
222
             if (pf) {
223
                 if (reconfigure_packet_filter(pf, &tft, i) < 0) {
224
                     ogs_gtp2_send_error_message(
225
@@ -1326,7 +1358,7 @@
226
 
227
         for (i = 0; i < tft.num_of_packet_filter &&
228
                     i < OGS_MAX_NUM_OF_FLOW_IN_GTP; i++) {
229
-            pf = smf_pf_find_by_id(bearer, tft.pfi.identifier+1);
230
+            pf = smf_pf_find_by_identifier(bearer, tft.pfi.identifier+1);
231
             if (!pf)
232
                 pf = smf_pf_add(bearer);
233
             ogs_assert(pf);
234
@@ -1391,7 +1423,7 @@
235
             OGS_GTP2_TFT_CODE_DELETE_PACKET_FILTERS_FROM_EXISTING) {
236
         for (i = 0; i < tft.num_of_packet_filter &&
237
                     i <= OGS_MAX_NUM_OF_FLOW_IN_GTP; i++) {
238
-            pf = smf_pf_find_by_id(bearer, tft.pfi.identifier+1);
239
+            pf = smf_pf_find_by_identifier(bearer, tft.pfi.identifier+1);
240
             if (pf)
241
                 smf_pf_remove(pf);
242
         }
243
@@ -1438,7 +1470,7 @@
244
          */
245
         ogs_assert(OGS_OK ==
246
             smf_epc_pfcp_send_one_bearer_modification_request(
247
-                bearer, xact,
248
+                bearer, xact->id,
249
                 OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE,
250
                 cmd->procedure_transaction_id.u8,
251
                 OGS_GTP2_CAUSE_UNDEFINED_VALUE));
252
@@ -1483,7 +1515,7 @@
253
          *
254
          * To do this, I saved Bearer Context in Transaction Context.
255
          */
256
-        xact->data = bearer;
257
+        xact->data = OGS_UINT_TO_POINTER(bearer->id);
258
 
259
         rv = ogs_gtp_xact_commit(xact);
260
         ogs_expect(rv == OGS_OK);
261
open5gs_2.7.1.39.dc2e1.tar.xz/src/smf/s6b-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/smf/smf-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/smf/smf-sm.c Changed
344
 
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
+            sbi_object_id = sbi_xact->sbi_object_id;
202
+            ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
203
+                    sbi_object_id <= OGS_MAX_POOL_ID);
204
+
205
+            if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
206
+                sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
207
+                e->h.sbi.data = OGS_UINT_TO_POINTER(sbi_xact->assoc_stream_id);
208
 
209
-            e->h.sbi.data = sbi_xact->assoc_stream;
210
             e->h.sbi.state = sbi_xact->state;
211
 
212
             ogs_sbi_xact_remove(sbi_xact);
213
 
214
-            sess = smf_sess_cycle(sess);
215
+            sess = smf_sess_find_by_id(sbi_object_id);
216
             if (!sess) {
217
                 ogs_error("Session has already been removed");
218
                 break;
219
             }
220
-            smf_ue = smf_ue_cycle(sess->smf_ue);
221
+            smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
222
             ogs_assert(smf_ue);
223
             ogs_assert(OGS_FSM_STATE(&sess->sm));
224
 
225
-            e->sess = sess;
226
+            e->sess_id = sess->id;
227
             e->h.sbi.message = &sbi_message;
228
 
229
             ogs_fsm_dispatch(&sess->sm, e);
230
@@ -829,32 +856,38 @@
231
             int state = 0;
232
             bool unknown_res_status = false;
233
 
234
-            sbi_xact = e->h.sbi.data;
235
-            ogs_assert(sbi_xact);
236
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
237
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
238
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
239
 
240
-            sbi_xact = ogs_sbi_xact_cycle(sbi_xact);
241
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
242
             if (!sbi_xact) {
243
                 /* CLIENT_WAIT timer could remove SBI transaction
244
                  * before receiving SBI message */
245
-                ogs_error("SBI transaction has already been removed");
246
+                ogs_error("SBI transaction has already been removed %d",
247
+                        sbi_xact_id);
248
                 break;
249
             }
250
 
251
-            sess = (smf_sess_t *)sbi_xact->sbi_object;
252
-            ogs_assert(sess);
253
+            sbi_object_id = sbi_xact->sbi_object_id;
254
+            ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
255
+                    sbi_object_id <= OGS_MAX_POOL_ID);
256
+
257
+            if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
258
+                sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
259
+                stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
260
 
261
-            stream = sbi_xact->assoc_stream;
262
             state = sbi_xact->state;
263
             ogs_assert(state);
264
 
265
             ogs_sbi_xact_remove(sbi_xact);
266
 
267
-            sess = smf_sess_cycle(sess);
268
+            sess = smf_sess_find_by_id(sbi_object_id);
269
             if (!sess) {
270
                 ogs_error("Session has already been removed");
271
                 break;
272
             }
273
-            smf_ue = smf_ue_cycle(sess->smf_ue);
274
+            smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
275
             ogs_assert(smf_ue);
276
 
277
             if (state == SMF_UECM_STATE_REGISTERED) {
278
@@ -988,15 +1021,22 @@
279
              * 4. timer expiration event is processed. (double-free SBI xact)
280
              *
281
              * To avoid double-free SBI xact,
282
-             * we need to check ogs_sbi_xact_cycle()
283
+             * we need to check ogs_sbi_xact_find_by_id()
284
              */
285
-            sbi_xact = ogs_sbi_xact_cycle(e->h.sbi.data);
286
+            sbi_xact_id = OGS_POINTER_TO_UINT(e->h.sbi.data);
287
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
288
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
289
+
290
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
291
             if (!sbi_xact) {
292
-                ogs_error("SBI transaction has already been removed");
293
+                ogs_error("SBI transaction has already been removed %d",
294
+                        sbi_xact_id);
295
                 break;
296
             }
297
 
298
-            stream = sbi_xact->assoc_stream;
299
+            if (sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
300
+                sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID)
301
+                stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
302
             /* Here, we should not use ogs_assert(stream)
303
              * since 'namf-comm' service has no an associated stream. */
304
 
305
@@ -1018,10 +1058,6 @@
306
         break;
307
 
308
     case SMF_EVT_5GSM_MESSAGE:
309
-        sess = e->sess;
310
-        ogs_assert(sess);
311
-        stream = e->h.sbi.data;
312
-        ogs_assert(stream);
313
         pkbuf = e->pkbuf;
314
         ogs_assert(pkbuf);
315
 
316
@@ -1031,8 +1067,7 @@
317
             return;
318
         }
319
 
320
-        ogs_assert(sess);
321
-        sess = smf_sess_cycle(sess);
322
+        sess = smf_sess_find_by_id(e->sess_id);
323
         if (!sess) {
324
             ogs_error("Session has already been removed");
325
             ogs_pkbuf_free(pkbuf);
326
@@ -1046,16 +1081,11 @@
327
         break;
328
 
329
     case SMF_EVT_NGAP_MESSAGE:
330
-        sess = e->sess;
331
-        ogs_assert(sess);
332
-        stream = e->h.sbi.data;
333
-        ogs_assert(stream);
334
         pkbuf = e->pkbuf;
335
         ogs_assert(pkbuf);
336
         ogs_assert(e->ngap.type);
337
 
338
-        ogs_assert(sess);
339
-        sess = smf_sess_cycle(sess);
340
+        sess = smf_sess_find_by_id(e->sess_id);
341
         if (!sess) {
342
             ogs_error("Session has already been removed");
343
             ogs_pkbuf_free(pkbuf);
344
open5gs_2.7.1.39.dc2e1.tar.xz/src/udm/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/nnrf-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/nudm-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/nudr-build.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/nudr-handler.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/sess-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udm/udm-sm.c -> open5gs_2.7.1.48.555c2.tar.xz/src/udm/udm-sm.c Changed
230
 
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
+            ogs_assert(sbi_xact_id >= OGS_MIN_POOL_ID &&
202
+                    sbi_xact_id <= OGS_MAX_POOL_ID);
203
+
204
+            sbi_xact = ogs_sbi_xact_find_by_id(sbi_xact_id);
205
             if (!sbi_xact) {
206
-                ogs_error("SBI transaction has already been removed");
207
+                ogs_error("SBI transaction has already been removed %d",
208
+                        sbi_xact_id);
209
                 break;
210
             }
211
 
212
-            stream = sbi_xact->assoc_stream;
213
-            ogs_assert(stream);
214
+            ogs_assert(sbi_xact->assoc_stream_id >= OGS_MIN_POOL_ID &&
215
+                    sbi_xact->assoc_stream_id <= OGS_MAX_POOL_ID);
216
+            stream = ogs_sbi_stream_find_by_id(sbi_xact->assoc_stream_id);
217
 
218
             ogs_sbi_xact_remove(sbi_xact);
219
 
220
             ogs_error("Cannot receive SBI message");
221
+
222
+            if (!stream) {
223
+                ogs_error("STREAM has alreadt been removed %d",
224
+                        sbi_xact->assoc_stream_id);
225
+                break;
226
+            }
227
             ogs_assert(true ==
228
                 ogs_sbi_server_send_error(stream,
229
                     OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL,
230
open5gs_2.7.1.39.dc2e1.tar.xz/src/udm/ue-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/udr/udr-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/upf/context.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/upf/context.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/upf/event.h -> open5gs_2.7.1.48.555c2.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.tar.xz/src/upf/pfcp-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/upf/pfcp-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/src/upf/upf-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/tests/af/af-sm.c -> open5gs_2.7.1.48.555c2.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.tar.xz/tests/af/sbi-path.c -> open5gs_2.7.1.48.555c2.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.tar.xz/tests/sctp/abts-main.c -> open5gs_2.7.1.48.555c2.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