Changes of Revision 16

open5gs_2.6.2.dsc -> open5gs_2.6.3.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-ausf, open5gs-udm, open5gs-pcf, open5gs-nssf, open5gs-bsf, open5gs-udr, open5gs, open5gs-dbg
4
 Architecture: any
5
-Version: 2.6.2
6
+Version: 2.6.3
7
 Maintainer: Harald Welte <laforge@gnumonks.org>
8
 Uploaders: Sukchan Lee <acetcom@gmail.com>
9
 Homepage: https://open5gs.org
10
@@ -31,8 +31,8 @@
11
  open5gs-udr deb net optional arch=any
12
  open5gs-upf deb net optional arch=any
13
 Checksums-Sha1:
14
- a370923fa23cc91f422b84f2ea46d7f52442979c 14113060 open5gs_2.6.2.tar.xz
15
+ 062b6374186956af41192a4b297ea3c7e85ad80c 14116892 open5gs_2.6.3.tar.xz
16
 Checksums-Sha256:
17
- 139b4785625ff07b6713ec57713438c288655c848b5285734f90088eec0bc769 14113060 open5gs_2.6.2.tar.xz
18
+ 7c07cabbe9cb5d0886993cddb16aaee7d97007a3fd1998e234cccd4dd69c2933 14116892 open5gs_2.6.3.tar.xz
19
 Files:
20
- f83b2666ecb6f0c8261292c4084904ad 14113060 open5gs_2.6.2.tar.xz
21
+ d931a2b8835315104148d14efb21adb0 14116892 open5gs_2.6.3.tar.xz
22
open5gs_2.6.2.tar.xz/.tarball-version -> open5gs_2.6.3.tar.xz/.tarball-version Changed
4
 
1
@@ -1 +1 @@
2
-2.6.2
3
+2.6.3
4
open5gs_2.6.2.tar.xz/debian/changelog -> open5gs_2.6.3.tar.xz/debian/changelog Changed
35
 
1
@@ -1,3 +1,33 @@
2
+open5gs (2.6.3) unstable; urgency=medium
3
+
4
+  * PFCP restoration
5
+
6
+ -- Sukchan Lee <acetcom@gmail.com>  Wed, 26 Apr 2023 10:45:45 +0900
7
+
8
+open5gs (2.6.3~kinetic) kinetic; urgency=medium
9
+
10
+  * PFCP restoration
11
+
12
+ -- Sukchan Lee <acetcom@gmail.com>  Wed, 26 Apr 2023 10:43:45 +0900
13
+
14
+open5gs (2.6.3~jammy) jammy; urgency=medium
15
+
16
+  * PFCP restoration
17
+
18
+ -- Sukchan Lee <acetcom@gmail.com>  Wed, 26 Apr 2023 10:41:51 +0900
19
+
20
+open5gs (2.6.3~focal) focal; urgency=medium
21
+
22
+  * PFCP restoration
23
+
24
+ -- Sukchan Lee <acetcom@gmail.com>  Wed, 26 Apr 2023 10:39:56 +0900
25
+
26
+open5gs (2.6.3~bionic) bionic; urgency=medium
27
+
28
+  * PFCP restoration
29
+
30
+ -- Sukchan Lee <acetcom@gmail.com>  Wed, 26 Apr 2023 10:37:04 +0900
31
+
32
 open5gs (2.6.2) unstable; urgency=medium
33
 
34
   * Bug Fixed
35
open5gs_2.6.2.tar.xz/docs/_docs/guide/01-quickstart.md -> open5gs_2.6.3.tar.xz/docs/_docs/guide/01-quickstart.md Changed
18
 
1
@@ -79,13 +79,14 @@
2
 ```bash
3
 $ sudo apt update
4
 $ sudo apt install wget gnupg
5
-$ wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
6
+$ wget -qO - https://pgp.mongodb.com/server-6.0.asc | sudo apt-key add -
7
 ```
8
 
9
 Create the list file /etc/apt/sources.list.d/mongodb-org-6.0.list for your version of Ubuntu.
10
 
11
+On ubuntu 22.04 (Jammy)
12
 ```bash
13
-$ echo "deb  arch=amd64,arm64  https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
14
+$ echo "deb  arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
15
 ```
16
 
17
 Install the MongoDB packages.
18
open5gs_2.6.2.tar.xz/docs/_docs/guide/02-building-open5gs-from-sources.md -> open5gs_2.6.3.tar.xz/docs/_docs/guide/02-building-open5gs-from-sources.md Changed
18
 
1
@@ -18,13 +18,14 @@
2
 ```bash
3
 $ sudo apt update
4
 $ sudo apt install wget gnupg
5
-$ wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
6
+$ wget -qO - https://pgp.mongodb.com/server-6.0.asc | sudo apt-key add -
7
 ```
8
 
9
 Create the list file /etc/apt/sources.list.d/mongodb-org-6.0.list for your version of Ubuntu.
10
 
11
+On ubuntu 22.04 (Jammy)
12
 ```bash
13
-$ echo "deb  arch=amd64,arm64  https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
14
+$ echo "deb  arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
15
 ```
16
 
17
 Install the MongoDB packages.
18
open5gs_2.6.2.tar.xz/docs/_docs/tutorial/01-your-first-lte.md -> open5gs_2.6.3.tar.xz/docs/_docs/tutorial/01-your-first-lte.md Changed
12
 
1
@@ -165,8 +165,8 @@
2
 The Open5GS package is available on the recent versions of *Ubuntu*.
3
 ```bash
4
 # Install the MongoDB Packages
5
-$ wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
6
-$ echo "deb  arch=amd64,arm64  https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
7
+$ wget -qO - https://pgp.mongodb.com/server-6.0.asc | sudo apt-key add -
8
+$ echo "deb  arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
9
 $ sudo apt update
10
 $ sudo apt install mongodb-org
11
 
12
open5gs_2.6.2.tar.xz/docs/_pages/docs.md -> open5gs_2.6.3.tar.xz/docs/_pages/docs.md Changed
9
 
1
@@ -40,6 +40,7 @@
2
 - @infinitydon
3
   - Open5GS on Amazon Elastic Kubernetes Service(https://aws.amazon.com/blogs/opensource/open-source-mobile-core-network-implementation-on-amazon-elastic-kubernetes-service/)
4
   - Kubernetes Open5GS Deployment(https://dev.to/infinitydon/virtual-4g-simulation-using-kubernetes-and-gns3-3b7k?fbclid=IwAR1p99h13a-mCfejanbBQe0H0-jp5grXkn5mWf1WrTHf47UtegB2-UHGGZQ)
5
+  - 5G Core SBI mTLS Using External Certificate PKI(https://futuredon.medium.com/5g-core-sbi-mtls-using-external-certificate-pki-4ffc02ac7728)
6
 
7
 - @nickvsnetworking
8
   - My first 5G Core : Open5GS and UERANSIM(http://nickvsnetworking.com/my-first-5g-core-open5gs-and-ueransim/)
9
open5gs_2.6.2.tar.xz/docs/_pages/support.md -> open5gs_2.6.3.tar.xz/docs/_pages/support.md Changed
10
 
1
@@ -21,7 +21,7 @@
2
 
3
 We work with leading partners in mobile communications to offer our customers complete solutions.
4
 
5
-**NextEPC(https://nextepc.com/)**: Established in U.S. in 2019, NextEPC Inc. provides the latest wireless telecommunications technologies and outstanding support to wireless solution providers and vendors around the world. Their solutions include scalable and versatile 4G/5G core network systems. They also offer professional development and customization services for Enterprise users.
6
+**NextEPC(https://nextepc.com/)**: Established in U.S. in 2019, NextEPC Inc. provides the latest wireless telecommunications technologies and outstanding support to wireless solution providers and vendors around the world. Their solutions include scalable and versatile 4G/5G core network systems, recently a commercial-grade DPDK-accelerated UPF is also available. They offer professional development and customization services for Enterprise users.
7
 
8
 Please contact sales@nextepc.com(mailto:sales@nextepc.com) for more informations.
9
 
10
open5gs_2.6.3.tar.xz/docs/_posts/2023-04-04-release-v2.6.2.md Added
17
 
1
@@ -0,0 +1,15 @@
2
+---
3
+title: "v2.6.2 - Bug Fixes"
4
+date: 2023-04-04 22:19:00 +0900
5
+categories:
6
+  - Release
7
+tags:
8
+  - News
9
+  - Release
10
+head_inline: "<style> ul { padding-bottom: 1em; } .blue { color: blue; }</style>"
11
+---
12
+
13
+See Release Note(https://github.com/open5gs/open5gs/releases/tag/v2.6.2)
14
+
15
+Download -- v2.6.2.tar.gz(https://github.com/open5gs/open5gs/archive/v2.6.2.tar.gz)
16
+{: .notice--info}
17
open5gs_2.6.3.tar.xz/docs/_posts/2023-04-26-release-v2.6.3.md Added
17
 
1
@@ -0,0 +1,15 @@
2
+---
3
+title: "v2.6.3 - PFCP Restoration"
4
+date: 2023-04-26 10:52:00 +0900
5
+categories:
6
+  - Release
7
+tags:
8
+  - News
9
+  - Release
10
+head_inline: "<style> ul { padding-bottom: 1em; } .blue { color: blue; }</style>"
11
+---
12
+
13
+See Release Note(https://github.com/open5gs/open5gs/releases/tag/v2.6.3)
14
+
15
+Download -- v2.6.3.tar.gz(https://github.com/open5gs/open5gs/archive/v2.6.3.tar.gz)
16
+{: .notice--info}
17
open5gs_2.6.2.tar.xz/docs/assets/webui/install -> open5gs_2.6.3.tar.xz/docs/assets/webui/install Changed
10
 
1
@@ -10,7 +10,7 @@
2
 #
3
 
4
 PACKAGE="open5gs"
5
-VERSION="2.6.1"
6
+VERSION="2.6.3"
7
 
8
 print_status() {
9
     echo
10
open5gs_2.6.2.tar.xz/lib/app/ogs-context.c -> open5gs_2.6.3.tar.xz/lib/app/ogs-context.c Changed
16
 
1
@@ -76,13 +76,13 @@
2
     self.pool.message = self.max.ue * POOL_NUM_PER_UE;
3
     self.pool.event = self.max.ue * POOL_NUM_PER_UE;
4
     self.pool.socket = self.max.ue * POOL_NUM_PER_UE;
5
-    self.pool.subscription = self.max.ue * POOL_NUM_PER_UE;
6
     self.pool.xact = self.max.ue * POOL_NUM_PER_UE;
7
     self.pool.stream = self.max.ue * POOL_NUM_PER_UE;
8
 
9
     self.pool.nf = self.max.peer;
10
 #define NF_SERVICE_PER_NF_INSTANCE 16
11
     self.pool.nf_service = self.pool.nf * NF_SERVICE_PER_NF_INSTANCE;
12
+    self.pool.subscription = self.pool.nf * NF_SERVICE_PER_NF_INSTANCE;
13
 
14
     self.pool.gtp_node = self.pool.nf;
15
     if (self.max.gtp_peer)
16
open5gs_2.6.2.tar.xz/lib/core/ogs-core.c -> open5gs_2.6.3.tar.xz/lib/core/ogs-core.c Changed
23
 
1
@@ -38,9 +38,9 @@
2
 
3
 void ogs_core_initialize(void)
4
 {
5
+    ogs_mem_init();
6
     ogs_log_init();
7
     ogs_pkbuf_init();
8
-    ogs_mem_init();
9
     ogs_socket_init();
10
     ogs_tlv_init();
11
 
12
@@ -56,9 +56,9 @@
13
 {
14
     ogs_tlv_final();
15
     ogs_socket_final();
16
-    ogs_mem_final();
17
     ogs_pkbuf_final();
18
     ogs_log_final();
19
+    ogs_mem_final();
20
 }
21
 
22
 ogs_core_context_t *ogs_core(void)
23
open5gs_2.6.2.tar.xz/lib/core/ogs-memory.h -> open5gs_2.6.3.tar.xz/lib/core/ogs-memory.h Changed
10
 
1
@@ -58,7 +58,7 @@
2
         void *ptr, size_t size, const char *file_line);
3
 int ogs_free_debug(void *ptr);
4
 
5
-#if OGS_USE_TALLOC
6
+#if OGS_USE_TALLOC == 1
7
 
8
 /*****************************************
9
  * Memory Pool - Use talloc library
10
open5gs_2.6.2.tar.xz/lib/core/ogs-pkbuf.c -> open5gs_2.6.3.tar.xz/lib/core/ogs-pkbuf.c Changed
45
 
1
@@ -99,6 +99,7 @@
2
 {
3
 #if OGS_USE_TALLOC == 0
4
     ogs_pool_init(&pkbuf_pool, ogs_core()->pkbuf.pool);
5
+
6
 #endif
7
 }
8
 
9
@@ -219,7 +220,7 @@
10
 ogs_pkbuf_t *ogs_pkbuf_alloc_debug(
11
         ogs_pkbuf_pool_t *pool, unsigned int size, const char *file_line)
12
 {
13
-#if OGS_USE_TALLOC
14
+#if OGS_USE_TALLOC == 1
15
     ogs_pkbuf_t *pkbuf = NULL;
16
 
17
     pkbuf = ogs_talloc_zero_size(pool, sizeof(*pkbuf) + size, file_line);
18
@@ -287,7 +288,7 @@
19
 
20
 void ogs_pkbuf_free(ogs_pkbuf_t *pkbuf)
21
 {
22
-#if OGS_USE_TALLOC
23
+#if OGS_USE_TALLOC == 1
24
     ogs_talloc_free(pkbuf, OGS_FILE_LINE);
25
 #else
26
     ogs_pkbuf_pool_t *pool = NULL;
27
@@ -315,7 +316,7 @@
28
 
29
 ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line)
30
 {
31
-#if OGS_USE_TALLOC
32
+#if OGS_USE_TALLOC == 1
33
     ogs_pkbuf_t *newbuf;
34
 #else
35
     ogs_pkbuf_pool_t *pool = NULL;
36
@@ -331,7 +332,7 @@
37
         return NULL;
38
     }
39
 
40
-#if OGS_USE_TALLOC
41
+#if OGS_USE_TALLOC == 1
42
     newbuf = ogs_pkbuf_alloc_debug(NULL, size, file_line);
43
     if (!newbuf) {
44
         ogs_error("ogs_pkbuf_alloc() failed size=%d", size);
45
open5gs_2.6.2.tar.xz/lib/core/ogs-pkbuf.h -> open5gs_2.6.3.tar.xz/lib/core/ogs-pkbuf.h Changed
10
 
1
@@ -35,7 +35,7 @@
2
     unsigned int reference_count;
3
 } ogs_cluster_t;
4
 
5
-#if OGS_USE_TALLOC
6
+#if OGS_USE_TALLOC == 1
7
 typedef void ogs_pkbuf_pool_t;
8
 #else
9
 typedef struct ogs_pkbuf_pool_s ogs_pkbuf_pool_t;
10
open5gs_2.6.2.tar.xz/lib/core/ogs-pool.h -> open5gs_2.6.3.tar.xz/lib/core/ogs-pool.h Changed
98
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -28,7 +28,15 @@
9
 extern "C" {
10
 #endif
11
 
12
-typedef unsigned int ogs_index_t;
13
+#if OGS_USE_TALLOC == 1
14
+#define ogs_pool_create ogs_malloc
15
+#define ogs_pool_destroy ogs_free
16
+#else
17
+#define ogs_pool_create malloc
18
+#define ogs_pool_destroy free
19
+#endif
20
+
21
+typedef uint32_t ogs_pool_id_t;
22
 
23
 #define OGS_POOL(pool, type) \
24
     struct { \
25
@@ -41,11 +49,11 @@
26
 #define ogs_pool_init(pool, _size) do { \
27
     int i; \
28
     (pool)->name = #pool; \
29
-    (pool)->free = malloc(sizeof(*(pool)->free) * _size); \
30
+    (pool)->free = ogs_pool_create(sizeof(*(pool)->free) * _size); \
31
     ogs_assert((pool)->free); \
32
-    (pool)->array = malloc(sizeof(*(pool)->array) * _size); \
33
+    (pool)->array = ogs_pool_create(sizeof(*(pool)->array) * _size); \
34
     ogs_assert((pool)->array); \
35
-    (pool)->index = malloc(sizeof(*(pool)->index) * _size); \
36
+    (pool)->index = ogs_pool_create(sizeof(*(pool)->index) * _size); \
37
     ogs_assert((pool)->index); \
38
     (pool)->size = (pool)->avail = _size; \
39
     (pool)->head = (pool)->tail = 0; \
40
@@ -59,9 +67,9 @@
41
     if (((pool)->size != (pool)->avail)) \
42
         ogs_error("%d in '%s%d' were not released.", \
43
                 (pool)->size - (pool)->avail, (pool)->name, (pool)->size); \
44
-    free((pool)->free); \
45
-    free((pool)->array); \
46
-    free((pool)->index); \
47
+    ogs_pool_destroy((pool)->free); \
48
+    ogs_pool_destroy((pool)->array); \
49
+    ogs_pool_destroy((pool)->index); \
50
 } while (0)
51
 
52
 #define ogs_pool_index(pool, node) (((node) - (pool)->array)+1)
53
@@ -93,30 +101,23 @@
54
 #define ogs_pool_size(pool) ((pool)->size)
55
 #define ogs_pool_avail(pool) ((pool)->avail)
56
 
57
-#define ogs_index_init(pool, _size) do { \
58
+#define ogs_pool_sequence_id_generate(pool) do { \
59
     int i; \
60
-    (pool)->name = #pool; \
61
-    (pool)->free = ogs_malloc(sizeof(*(pool)->free) * _size); \
62
-    ogs_assert((pool)->free); \
63
-    (pool)->array = ogs_malloc(sizeof(*(pool)->array) * _size); \
64
-    ogs_assert((pool)->array); \
65
-    (pool)->index = ogs_malloc(sizeof(*(pool)->index) * _size); \
66
-    ogs_assert((pool)->index); \
67
-    (pool)->size = (pool)->avail = _size; \
68
-    (pool)->head = (pool)->tail = 0; \
69
-    for (i = 0; i < _size; i++) { \
70
-        (pool)->freei = &((pool)->arrayi); \
71
-        (pool)->indexi = NULL; \
72
-    } \
73
+    for (i = 0; i < (pool)->size; i++) \
74
+        (pool)->arrayi = i+1; \
75
 } while (0)
76
 
77
-#define ogs_index_final(pool) do { \
78
-    if (((pool)->size != (pool)->avail)) \
79
-        ogs_error("%d in '%s%d' were not released.", \
80
-                (pool)->size - (pool)->avail, (pool)->name, (pool)->size); \
81
-    ogs_free((pool)->free); \
82
-    ogs_free((pool)->array); \
83
-    ogs_free((pool)->index); \
84
+#define ogs_pool_random_id_generate(pool) do { \
85
+    int i, j; \
86
+    ogs_pool_id_t temp; \
87
+    for (i = 0; i < (pool)->size; i++) \
88
+        (pool)->arrayi = i+1; \
89
+    for (i = (pool)->size - 1; i > 0; i--) { \
90
+       j = ogs_random32() % (i + 1); \
91
+       temp = (pool)->arrayi; \
92
+       (pool)->arrayi = (pool)->arrayj; \
93
+       (pool)->arrayj = temp; \
94
+    } \
95
 } while (0)
96
 
97
 #ifdef __cplusplus
98
open5gs_2.6.2.tar.xz/lib/core/ogs-strings.h -> open5gs_2.6.3.tar.xz/lib/core/ogs-strings.h Changed
10
 
1
@@ -110,7 +110,7 @@
2
     char *source, const char *file_line, const char *message, ...)
3
     OGS_GNUC_PRINTF(3, 4);
4
 
5
-#if OGS_USE_TALLOC
6
+#if OGS_USE_TALLOC == 1
7
 
8
 /*****************************************
9
  * Memory Pool - Use talloc library
10
open5gs_2.6.2.tar.xz/lib/gtp/v1/build.c -> open5gs_2.6.3.tar.xz/lib/gtp/v1/build.c Changed
9
 
1
@@ -1,6 +1,7 @@
2
 /*
3
  * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
  * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5
+ * Copyright (C) 2023 Sukchan Lee <acetcom@gmail.com>
6
  *
7
  * This file is part of Open5GS.
8
  *
9
open5gs_2.6.2.tar.xz/lib/gtp/v1/build.h -> open5gs_2.6.3.tar.xz/lib/gtp/v1/build.h Changed
17
 
1
@@ -1,6 +1,7 @@
2
 /*
3
  * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
  * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5
+ * Copyright (C) 2023 by Sukchan Lee <acetcom@gmail.com>
6
  *
7
  * This file is part of Open5GS.
8
  *
9
@@ -31,6 +32,7 @@
10
 
11
 ogs_pkbuf_t *ogs_gtp1_build_echo_request(uint8_t type);
12
 ogs_pkbuf_t *ogs_gtp1_build_echo_response(uint8_t type, uint8_t recovery);
13
+
14
 #ifdef __cplusplus
15
 }
16
 #endif
17
open5gs_2.6.2.tar.xz/lib/gtp/v1/path.c -> open5gs_2.6.3.tar.xz/lib/gtp/v1/path.c Changed
19
 
1
@@ -1,6 +1,7 @@
2
 /*
3
  * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
  * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5
+ * Copyright (C) 2023 by Sukchan Lee <acetcom@gmail.com>
6
  *
7
  * This file is part of Open5GS.
8
  *
9
@@ -143,8 +144,7 @@
10
     ogs_expect(rv == OGS_OK);
11
 }
12
 
13
-void ogs_gtp1_send_echo_request(
14
-        ogs_gtp_node_t *gnode)
15
+void ogs_gtp1_send_echo_request(ogs_gtp_node_t *gnode)
16
 {
17
     int rv;
18
     ogs_pkbuf_t *pkbuf = NULL;
19
open5gs_2.6.2.tar.xz/lib/gtp/v2/build.c -> open5gs_2.6.3.tar.xz/lib/gtp/v2/build.c Changed
109
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -57,7 +57,7 @@
9
     return ogs_gtp2_build_msg(&gtp_message);
10
 }
11
 
12
-ogs_pkbuf_t *ogs_gtp2_build_error_indication(
13
+ogs_pkbuf_t *ogs_gtp1_build_error_indication(
14
         uint32_t teid, ogs_sockaddr_t *addr)
15
 {
16
     ogs_pkbuf_t *pkbuf = NULL;
17
@@ -112,3 +112,91 @@
18
 
19
     return pkbuf;
20
 }
21
+
22
+void ogs_gtp2_fill_header(
23
+        ogs_gtp2_header_t *gtp_hdesc, ogs_gtp2_extension_header_t *ext_hdesc,
24
+        ogs_pkbuf_t *pkbuf)
25
+{
26
+    ogs_gtp2_header_t *gtp_h = NULL;
27
+    ogs_gtp2_extension_header_t *ext_h = NULL;
28
+    uint8_t flags;
29
+    uint8_t gtp_hlen = 0;
30
+
31
+    ogs_assert(gtp_hdesc);
32
+    ogs_assert(ext_hdesc);
33
+    ogs_assert(pkbuf);
34
+
35
+    /* Processing GTP Flags */
36
+    flags = gtp_hdesc->flags;
37
+    flags |= OGS_GTPU_FLAGS_V | OGS_GTPU_FLAGS_PT;
38
+    if (ext_hdesc->qos_flow_identifier) flags |= OGS_GTPU_FLAGS_E;
39
+
40
+    /* Define GTP Header Size */
41
+    if (flags & OGS_GTPU_FLAGS_E)
42
+        gtp_hlen = OGS_GTPV1U_HEADER_LEN+8;
43
+    else if (flags & (OGS_GTPU_FLAGS_S|OGS_GTPU_FLAGS_PN))
44
+        gtp_hlen = OGS_GTPV1U_HEADER_LEN+4;
45
+    else
46
+        gtp_hlen = OGS_GTPV1U_HEADER_LEN;
47
+
48
+    ogs_pkbuf_push(pkbuf, gtp_hlen);
49
+
50
+    /* Fill GTP Header */
51
+    gtp_h = (ogs_gtp2_header_t *)pkbuf->data;
52
+    ogs_assert(gtp_h);
53
+    memset(gtp_h, 0, gtp_hlen);
54
+
55
+    gtp_h->flags = flags;
56
+    gtp_h->type = gtp_hdesc->type;
57
+
58
+    if (gtp_h->type == OGS_GTPU_MSGTYPE_ECHO_REQ ||
59
+        gtp_h->type == OGS_GTPU_MSGTYPE_ECHO_RSP ||
60
+        gtp_h->type == OGS_GTPU_MSGTYPE_ERR_IND) {
61
+        /*
62
+         * TS29.281 5.1 General format in GTP-U header
63
+         *
64
+         * - The Echo Request/Response and Supported Extension Headers
65
+         *   notification messages, where the Tunnel Endpoint Identifier
66
+         *   shall be set to all zeroes.
67
+         * - The Error Indication message where the Tunnel Endpoint Identifier
68
+         *   shall be set to all zeros.
69
+         */
70
+        ogs_assert(gtp_hdesc->teid == 0);
71
+    }
72
+
73
+    gtp_h->teid = htobe32(gtp_hdesc->teid);
74
+
75
+    /*
76
+     * TS29.281 5.1 General format in GTP-U header
77
+     *
78
+     * Length: This field indicates the length in octets of the payload,
79
+     * i.e. the rest of the packet following the mandatory part of
80
+     * the GTP header (that is the first 8 octets). The Sequence Number,
81
+     * the N-PDU Number or any Extension headers shall be considered
82
+     * to be part of the payload, i.e. included in the length count.
83
+     */
84
+    gtp_h->length = htobe16(pkbuf->len - OGS_GTPV1U_HEADER_LEN);
85
+
86
+    /* Fill Extention Header */
87
+    if (gtp_h->flags & OGS_GTPU_FLAGS_E) {
88
+        ext_h = (ogs_gtp2_extension_header_t *)
89
+            (pkbuf->data + OGS_GTPV1U_HEADER_LEN);
90
+        ogs_assert(ext_h);
91
+
92
+        if (ext_hdesc->qos_flow_identifier) {
93
+            /* 5G Core */
94
+            ext_h->type = OGS_GTP2_EXTENSION_HEADER_TYPE_PDU_SESSION_CONTAINER;
95
+            ext_h->len = 1;
96
+            ext_h->pdu_type = ext_hdesc->pdu_type;
97
+            ext_h->qos_flow_identifier = ext_hdesc->qos_flow_identifier;
98
+            ext_h->next_type =
99
+                OGS_GTP2_EXTENSION_HEADER_TYPE_NO_MORE_EXTENSION_HEADERS;
100
+        } else {
101
+            /* EPC */
102
+            ext_h->type = ext_hdesc->type;
103
+            ext_h->len = 1;
104
+            ext_h->next_type =
105
+                OGS_GTP2_EXTENSION_HEADER_TYPE_NO_MORE_EXTENSION_HEADERS;
106
+        }
107
+    }
108
+}
109
open5gs_2.6.2.tar.xz/lib/gtp/v2/build.h -> open5gs_2.6.3.tar.xz/lib/gtp/v2/build.h Changed
23
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -33,9 +33,13 @@
9
 ogs_pkbuf_t *ogs_gtp2_build_echo_response(
10
         uint8_t type, uint8_t recovery, uint8_t features);
11
 
12
-ogs_pkbuf_t *ogs_gtp2_build_error_indication(
13
+ogs_pkbuf_t *ogs_gtp1_build_error_indication(
14
         uint32_t teid, ogs_sockaddr_t *addr);
15
 
16
+void ogs_gtp2_fill_header(
17
+        ogs_gtp2_header_t *gtp_hdesc, ogs_gtp2_extension_header_t *ext_hdesc,
18
+        ogs_pkbuf_t *pkbuf);
19
+
20
 #ifdef __cplusplus
21
 }
22
 #endif
23
open5gs_2.6.2.tar.xz/lib/gtp/v2/path.c -> open5gs_2.6.3.tar.xz/lib/gtp/v2/path.c Changed
143
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -27,92 +27,11 @@
9
     char bufOGS_ADDRSTRLEN;
10
     int rv;
11
 
12
-    ogs_gtp2_header_t *gtp_h = NULL;
13
-    ogs_gtp2_extension_header_t *ext_h = NULL;
14
-    uint8_t flags;
15
-    uint8_t gtp_hlen = 0;
16
-
17
-    ogs_assert(gnode);
18
-    ogs_assert(gtp_hdesc);
19
-    ogs_assert(ext_hdesc);
20
-    ogs_assert(pkbuf);
21
-
22
-    /* Processing GTP Flags */
23
-    flags = gtp_hdesc->flags;
24
-    flags |= OGS_GTPU_FLAGS_V | OGS_GTPU_FLAGS_PT;
25
-    if (ext_hdesc->qos_flow_identifier) flags |= OGS_GTPU_FLAGS_E;
26
-
27
-    /* Define GTP Header Size */
28
-    if (flags & OGS_GTPU_FLAGS_E)
29
-        gtp_hlen = OGS_GTPV1U_HEADER_LEN+8;
30
-    else if (flags & (OGS_GTPU_FLAGS_S|OGS_GTPU_FLAGS_PN))
31
-        gtp_hlen = OGS_GTPV1U_HEADER_LEN+4;
32
-    else
33
-        gtp_hlen = OGS_GTPV1U_HEADER_LEN;
34
-
35
-    ogs_pkbuf_push(pkbuf, gtp_hlen);
36
-
37
-    /* Fill GTP Header */
38
-    gtp_h = (ogs_gtp2_header_t *)pkbuf->data;
39
-    ogs_assert(gtp_h);
40
-    memset(gtp_h, 0, gtp_hlen);
41
-
42
-    gtp_h->flags = flags;
43
-    gtp_h->type = gtp_hdesc->type;
44
-
45
-    if (gtp_h->type == OGS_GTPU_MSGTYPE_ECHO_REQ ||
46
-        gtp_h->type == OGS_GTPU_MSGTYPE_ECHO_RSP ||
47
-        gtp_h->type == OGS_GTPU_MSGTYPE_ERR_IND) {
48
-        /*
49
-         * TS29.281 5.1 General format in GTP-U header
50
-         *
51
-         * - The Echo Request/Response and Supported Extension Headers
52
-         *   notification messages, where the Tunnel Endpoint Identifier
53
-         *   shall be set to all zeroes.
54
-         * - The Error Indication message where the Tunnel Endpoint Identifier
55
-         *   shall be set to all zeros.
56
-         */
57
-        ogs_assert(gtp_hdesc->teid == 0);
58
-    }
59
-
60
-    gtp_h->teid = htobe32(gtp_hdesc->teid);
61
-
62
-    /*
63
-     * TS29.281 5.1 General format in GTP-U header
64
-     *
65
-     * Length: This field indicates the length in octets of the payload,
66
-     * i.e. the rest of the packet following the mandatory part of
67
-     * the GTP header (that is the first 8 octets). The Sequence Number,
68
-     * the N-PDU Number or any Extension headers shall be considered
69
-     * to be part of the payload, i.e. included in the length count.
70
-     */
71
-    gtp_h->length = htobe16(pkbuf->len - OGS_GTPV1U_HEADER_LEN);
72
-
73
-    /* Fill Extention Header */
74
-    if (gtp_h->flags & OGS_GTPU_FLAGS_E) {
75
-        ext_h = (ogs_gtp2_extension_header_t *)
76
-            (pkbuf->data + OGS_GTPV1U_HEADER_LEN);
77
-        ogs_assert(ext_h);
78
-
79
-        if (ext_hdesc->qos_flow_identifier) {
80
-            /* 5G Core */
81
-            ext_h->type = OGS_GTP2_EXTENSION_HEADER_TYPE_PDU_SESSION_CONTAINER;
82
-            ext_h->len = 1;
83
-            ext_h->pdu_type = ext_hdesc->pdu_type;
84
-            ext_h->qos_flow_identifier = ext_hdesc->qos_flow_identifier;
85
-            ext_h->next_type =
86
-                OGS_GTP2_EXTENSION_HEADER_TYPE_NO_MORE_EXTENSION_HEADERS;
87
-        } else {
88
-            /* EPC */
89
-            ext_h->type = ext_hdesc->type;
90
-            ext_h->len = 1;
91
-            ext_h->next_type =
92
-                OGS_GTP2_EXTENSION_HEADER_TYPE_NO_MORE_EXTENSION_HEADERS;
93
-        }
94
-    }
95
+    ogs_gtp2_fill_header(gtp_hdesc, ext_hdesc, pkbuf);
96
 
97
     ogs_trace("SEND GTP-U%d to Peer%s : TEID0x%x",
98
             gtp_hdesc->type, OGS_ADDR(&gnode->addr, buf), gtp_hdesc->teid);
99
+
100
     rv = ogs_gtp_sendto(gnode, pkbuf);
101
     if (rv != OGS_OK) {
102
         if (ogs_socket_errno != OGS_EAGAIN) {
103
@@ -342,3 +261,39 @@
104
     rv = ogs_gtp_xact_commit(xact);
105
     ogs_expect(rv == OGS_OK);
106
 }
107
+
108
+void ogs_gtp1_send_error_indication(
109
+        ogs_sock_t *sock, uint32_t teid, uint8_t qfi, const ogs_sockaddr_t *to)
110
+{
111
+    ssize_t sent;
112
+    ogs_pkbuf_t *pkbuf = NULL;
113
+
114
+    ogs_gtp2_header_t gtp_hdesc;
115
+    ogs_gtp2_extension_header_t ext_hdesc;
116
+
117
+    ogs_assert(sock);
118
+    ogs_assert(to);
119
+
120
+    pkbuf = ogs_gtp1_build_error_indication(teid, &sock->local_addr);
121
+    if (!pkbuf) {
122
+        ogs_error("ogs_gtp1_build_error_indication() failed");
123
+        return;
124
+    }
125
+
126
+    memset(&gtp_hdesc, 0, sizeof(gtp_hdesc));
127
+    memset(&ext_hdesc, 0, sizeof(ext_hdesc));
128
+
129
+    gtp_hdesc.type = OGS_GTPU_MSGTYPE_ERR_IND;
130
+    gtp_hdesc.flags = OGS_GTPU_FLAGS_S|OGS_GTPU_FLAGS_E;
131
+    ext_hdesc.type = OGS_GTP2_EXTENSION_HEADER_TYPE_UDP_PORT;
132
+    ext_hdesc.qos_flow_identifier = qfi;
133
+
134
+    ogs_gtp2_fill_header(&gtp_hdesc, &ext_hdesc, pkbuf);
135
+
136
+    sent = ogs_sendto(sock->fd, pkbuf->data, pkbuf->len, 0, to);
137
+    if (sent < 0 || sent != pkbuf->len) {
138
+        ogs_log_message(OGS_LOG_ERROR, ogs_socket_errno,
139
+                "ogs_sendto() failed");
140
+    }
141
+    ogs_pkbuf_free(pkbuf);
142
+}
143
open5gs_2.6.2.tar.xz/lib/gtp/v2/path.h -> open5gs_2.6.3.tar.xz/lib/gtp/v2/path.h Changed
18
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -44,6 +44,9 @@
9
 void ogs_gtp2_send_echo_response(ogs_gtp_xact_t *xact,
10
         uint8_t recovery, uint8_t features);
11
 
12
+void ogs_gtp1_send_error_indication(
13
+        ogs_sock_t *sock, uint32_t teid, uint8_t qfi, const ogs_sockaddr_t *to);
14
+
15
 #ifdef __cplusplus
16
 }
17
 #endif
18
open5gs_2.6.2.tar.xz/lib/gtp/xact.h -> open5gs_2.6.3.tar.xz/lib/gtp/xact.h Changed
18
 
1
@@ -1,6 +1,7 @@
2
 /*
3
  * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
  * Copyright (C) 2022 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5
+ * Copyright (C) 2023 by Sukchan Lee <acetcom@gmail.com>
6
  *
7
  * This file is part of Open5GS.
8
  *
9
@@ -57,7 +58,7 @@
10
  */
11
 typedef struct ogs_gtp_xact_s {
12
     ogs_lnode_t     node;           /**< A node of list */
13
-    ogs_index_t     index;
14
+    ogs_pool_id_t   index;
15
 
16
     uint8_t gtp_version;            /**< 1 or 2 */
17
 
18
open5gs_2.6.2.tar.xz/lib/pfcp/build.c -> open5gs_2.6.3.tar.xz/lib/pfcp/build.c Changed
26
 
1
@@ -446,17 +446,15 @@
2
 
3
     ogs_assert(pdr);
4
 
5
-    if (ogs_pfcp_self()->up_function_features.ftup) {
6
-        if (pdr->f_teid_len) {
7
-            memcpy(&pdrbufi.f_teid, &pdr->f_teid, pdr->f_teid_len);
8
-            pdrbufi.f_teid.teid = htobe32(pdr->f_teid.teid);
9
+    if (pdr->f_teid_len) {
10
+        memcpy(&pdrbufi.f_teid, &pdr->f_teid, pdr->f_teid_len);
11
+        pdrbufi.f_teid.teid = htobe32(pdr->f_teid.teid);
12
 
13
-            message->local_f_teid.presence = 1;
14
-            message->local_f_teid.data = &pdrbufi.f_teid;
15
-            message->local_f_teid.len = pdr->f_teid_len;
16
+        message->local_f_teid.presence = 1;
17
+        message->local_f_teid.data = &pdrbufi.f_teid;
18
+        message->local_f_teid.len = pdr->f_teid_len;
19
 
20
-            pdr_presence = true;
21
-        }
22
+        pdr_presence = true;
23
     }
24
 
25
     if (pdr_presence == true) {
26
open5gs_2.6.2.tar.xz/lib/pfcp/context.c -> open5gs_2.6.3.tar.xz/lib/pfcp/context.c Changed
201
 
1
@@ -27,18 +27,23 @@
2
 static OGS_POOL(ogs_pfcp_node_pool, ogs_pfcp_node_t);
3
 
4
 static OGS_POOL(ogs_pfcp_sess_pool, ogs_pfcp_sess_t);
5
-static OGS_POOL(ogs_pfcp_pdr_pool, ogs_pfcp_pdr_t);
6
 static OGS_POOL(ogs_pfcp_far_pool, ogs_pfcp_far_t);
7
 static OGS_POOL(ogs_pfcp_urr_pool, ogs_pfcp_urr_t);
8
 static OGS_POOL(ogs_pfcp_qer_pool, ogs_pfcp_qer_t);
9
 static OGS_POOL(ogs_pfcp_bar_pool, ogs_pfcp_bar_t);
10
 
11
+static OGS_POOL(ogs_pfcp_pdr_pool, ogs_pfcp_pdr_t);
12
+static OGS_POOL(ogs_pfcp_pdr_teid_pool, ogs_pool_id_t);
13
+static ogs_pool_id_t *pdr_random_to_index;
14
+
15
+static OGS_POOL(ogs_pfcp_rule_pool, ogs_pfcp_rule_t);
16
+
17
 static OGS_POOL(ogs_pfcp_dev_pool, ogs_pfcp_dev_t);
18
 static OGS_POOL(ogs_pfcp_subnet_pool, ogs_pfcp_subnet_t);
19
-static OGS_POOL(ogs_pfcp_rule_pool, ogs_pfcp_rule_t);
20
 
21
 void ogs_pfcp_context_init(void)
22
 {
23
+    int i;
24
     ogs_assert(context_initialized == 0);
25
 
26
     /* Initialize SMF context */
27
@@ -52,8 +57,6 @@
28
 
29
     ogs_pool_init(&ogs_pfcp_sess_pool, ogs_app()->pool.sess);
30
 
31
-    ogs_pool_init(&ogs_pfcp_pdr_pool,
32
-            ogs_app()->pool.sess * OGS_MAX_NUM_OF_PDR);
33
     ogs_pool_init(&ogs_pfcp_far_pool,
34
             ogs_app()->pool.sess * OGS_MAX_NUM_OF_FAR);
35
     ogs_pool_init(&ogs_pfcp_urr_pool,
36
@@ -63,6 +66,17 @@
37
     ogs_pool_init(&ogs_pfcp_bar_pool,
38
             ogs_app()->pool.sess * OGS_MAX_NUM_OF_BAR);
39
 
40
+    ogs_pool_init(&ogs_pfcp_pdr_pool,
41
+            ogs_app()->pool.sess * OGS_MAX_NUM_OF_PDR);
42
+    ogs_pool_init(&ogs_pfcp_pdr_teid_pool, ogs_pfcp_pdr_pool.size);
43
+    ogs_pool_random_id_generate(&ogs_pfcp_pdr_teid_pool);
44
+
45
+    pdr_random_to_index = ogs_calloc(
46
+            sizeof(ogs_pool_id_t), ogs_pfcp_pdr_pool.size);
47
+    ogs_assert(pdr_random_to_index);
48
+    for (i = 0; i < ogs_pfcp_pdr_pool.size; i++)
49
+        pdr_random_to_indexogs_pfcp_pdr_teid_pool.arrayi = i;
50
+
51
     ogs_pool_init(&ogs_pfcp_rule_pool,
52
             ogs_app()->pool.sess *
53
             OGS_MAX_NUM_OF_PDR * OGS_MAX_NUM_OF_FLOW_IN_PDR);
54
@@ -98,8 +112,11 @@
55
     ogs_pool_final(&ogs_pfcp_subnet_pool);
56
     ogs_pool_final(&ogs_pfcp_rule_pool);
57
 
58
-    ogs_pool_final(&ogs_pfcp_sess_pool);
59
     ogs_pool_final(&ogs_pfcp_pdr_pool);
60
+    ogs_pool_final(&ogs_pfcp_pdr_teid_pool);
61
+    ogs_free(pdr_random_to_index);
62
+
63
+    ogs_pool_final(&ogs_pfcp_sess_pool);
64
     ogs_pool_final(&ogs_pfcp_far_pool);
65
     ogs_pool_final(&ogs_pfcp_urr_pool);
66
     ogs_pool_final(&ogs_pfcp_qer_pool);
67
@@ -894,6 +911,16 @@
68
     }
69
     memset(pdr, 0, sizeof *pdr);
70
 
71
+    pdr->obj.type = OGS_PFCP_OBJ_PDR_TYPE;
72
+    pdr->src_if = OGS_PFCP_INTERFACE_UNKNOWN;
73
+
74
+    /* Set TEID */
75
+    ogs_pool_alloc(&ogs_pfcp_pdr_teid_pool, &pdr->teid_node);
76
+    ogs_assert(pdr->teid_node);
77
+
78
+    pdr->teid = *(pdr->teid_node);
79
+
80
+    /* Set PDR-ID */
81
     ogs_pool_alloc(&sess->pdr_id_pool, &pdr->id_node);
82
     if (pdr->id_node == NULL) {
83
         ogs_error("pdr_id_pool() failed");
84
@@ -901,17 +928,9 @@
85
         return NULL;
86
     }
87
 
88
-    pdr->obj.type = OGS_PFCP_OBJ_PDR_TYPE;
89
-
90
-    pdr->index = ogs_pool_index(&ogs_pfcp_pdr_pool, pdr);
91
-    ogs_assert(pdr->index > 0 &&
92
-            pdr->index <= ogs_app()->pool.sess * OGS_MAX_NUM_OF_PDR);
93
-
94
     pdr->id = *(pdr->id_node);
95
     ogs_assert(pdr->id > 0 && pdr->id <= OGS_MAX_NUM_OF_PDR);
96
 
97
-    pdr->src_if = OGS_PFCP_INTERFACE_UNKNOWN;
98
-
99
     pdr->sess = sess;
100
     ogs_list_add(&sess->pdr_list, pdr);
101
 
102
@@ -948,12 +967,88 @@
103
     return pdr;
104
 }
105
 
106
+void ogs_pfcp_pdr_swap_teid(ogs_pfcp_pdr_t *pdr)
107
+{
108
+    int i = 0;
109
+
110
+    ogs_assert(pdr);
111
+    ogs_assert(pdr->f_teid.teid > 0 &&
112
+            pdr->f_teid.teid <= ogs_pfcp_pdr_teid_pool.size);
113
+
114
+    /* Find out the Array Index for the restored TEID. */
115
+    i = pdr_random_to_indexpdr->f_teid.teid;
116
+    ogs_assert(i < ogs_pfcp_pdr_teid_pool.size);
117
+
118
+    ogs_assert(pdr->teid_node);
119
+    /*
120
+     * If SWAP has already done this, it will not try this again.
121
+     * This situation can occur when multiple PDRs are restored
122
+     * with the same TEID.
123
+     */
124
+    if (pdr->f_teid.teid == ogs_pfcp_pdr_teid_pool.arrayi) {
125
+        ogs_pfcp_pdr_teid_pool.arrayi = *(pdr->teid_node);
126
+        *(pdr->teid_node) = pdr->f_teid.teid;
127
+    }
128
+}
129
+
130
 void ogs_pfcp_object_teid_hash_set(
131
-        ogs_pfcp_object_type_e type, ogs_pfcp_pdr_t *pdr)
132
+        ogs_pfcp_object_type_e type, ogs_pfcp_pdr_t *pdr,
133
+        bool restoration_indication)
134
 {
135
     ogs_assert(type);
136
     ogs_assert(pdr);
137
 
138
+    if (ogs_pfcp_self()->up_function_features.ftup && pdr->f_teid.ch) {
139
+
140
+        ogs_pfcp_pdr_t *choosed_pdr = NULL;
141
+
142
+        if (pdr->f_teid.chid) {
143
+            choosed_pdr = ogs_pfcp_pdr_find_by_choose_id(
144
+                    pdr->sess, pdr->f_teid.choose_id);
145
+            if (!choosed_pdr) {
146
+                pdr->chid = true;
147
+                pdr->choose_id = pdr->f_teid.choose_id;
148
+            }
149
+        }
150
+
151
+        if (choosed_pdr) {
152
+            pdr->f_teid_len = choosed_pdr->f_teid_len;
153
+            memcpy(&pdr->f_teid, &choosed_pdr->f_teid, pdr->f_teid_len);
154
+
155
+        } else {
156
+            ogs_gtpu_resource_t *resource = NULL;
157
+            resource = ogs_pfcp_find_gtpu_resource(
158
+                    &ogs_gtp_self()->gtpu_resource_list,
159
+                    pdr->dnn, OGS_PFCP_INTERFACE_ACCESS);
160
+            if (resource) {
161
+                ogs_assert(
162
+                    (resource->info.v4 && pdr->f_teid.ipv4) ||
163
+                    (resource->info.v6 && pdr->f_teid.ipv6));
164
+                ogs_assert(OGS_OK ==
165
+                    ogs_pfcp_user_plane_ip_resource_info_to_f_teid(
166
+                    &resource->info, &pdr->f_teid, &pdr->f_teid_len));
167
+                if (resource->info.teidri)
168
+                    pdr->f_teid.teid = OGS_PFCP_GTPU_INDEX_TO_TEID(
169
+                            pdr->teid, resource->info.teidri,
170
+                            resource->info.teid_range);
171
+                else
172
+                    pdr->f_teid.teid = pdr->teid;
173
+            } else {
174
+                ogs_assert(
175
+                    (ogs_gtp_self()->gtpu_addr && pdr->f_teid.ipv4) ||
176
+                    (ogs_gtp_self()->gtpu_addr6 && pdr->f_teid.ipv6));
177
+                ogs_assert(OGS_OK ==
178
+                    ogs_pfcp_sockaddr_to_f_teid(
179
+                        pdr->f_teid.ipv4 ?
180
+                            ogs_gtp_self()->gtpu_addr : NULL,
181
+                        pdr->f_teid.ipv6 ?
182
+                            ogs_gtp_self()->gtpu_addr6 : NULL,
183
+                        &pdr->f_teid, &pdr->f_teid_len));
184
+                pdr->f_teid.teid = pdr->teid;
185
+            }
186
+        }
187
+    }
188
+
189
     if (pdr->hash.teid.len)
190
         ogs_hash_set(self.object_teid_hash,
191
                 &pdr->hash.teid.key, pdr->hash.teid.len, NULL);
192
@@ -1107,6 +1202,7 @@
193
         ogs_free(pdr->ipv6_framed_routes);
194
     }
195
 
196
+    ogs_pool_free(&ogs_pfcp_pdr_teid_pool, pdr->teid_node);
197
     ogs_pool_free(&ogs_pfcp_pdr_pool, pdr);
198
 }
199
 
200
@@ -1220,7 +1316,7 @@
201
open5gs_2.6.2.tar.xz/lib/pfcp/context.h -> open5gs_2.6.3.tar.xz/lib/pfcp/context.h Changed
38
 
1
@@ -137,7 +137,9 @@
2
 
3
 typedef struct ogs_pfcp_pdr_s {
4
     ogs_pfcp_object_t       obj;
5
-    uint32_t                index;
6
+
7
+    ogs_pool_id_t           *teid_node;  /* A node of TEID */
8
+    ogs_pool_id_t           teid;
9
 
10
     ogs_lnode_t             to_create_node;
11
     ogs_lnode_t             to_modify_node;
12
@@ -399,8 +401,11 @@
13
 ogs_pfcp_pdr_t *ogs_pfcp_pdr_find_or_add(
14
         ogs_pfcp_sess_t *sess, ogs_pfcp_pdr_id_t id);
15
 
16
+void ogs_pfcp_pdr_swap_teid(ogs_pfcp_pdr_t *pdr);
17
+
18
 void ogs_pfcp_object_teid_hash_set(
19
-        ogs_pfcp_object_type_e type, ogs_pfcp_pdr_t *pdr);
20
+        ogs_pfcp_object_type_e type, ogs_pfcp_pdr_t *pdr,
21
+        bool restoration_indication);
22
 ogs_pfcp_object_t *ogs_pfcp_object_find_by_teid(uint32_t teid);
23
 int ogs_pfcp_object_count_by_teid(ogs_pfcp_sess_t *sess, uint32_t teid);
24
 
25
@@ -422,7 +427,11 @@
26
         ogs_pfcp_sess_t *sess, ogs_pfcp_far_id_t id);
27
 
28
 void ogs_pfcp_far_f_teid_hash_set(ogs_pfcp_far_t *far);
29
-ogs_pfcp_far_t *ogs_pfcp_far_find_by_error_indication(ogs_pkbuf_t *pkbuf);
30
+ogs_pfcp_far_t *ogs_pfcp_far_find_by_gtpu_error_indication(
31
+        ogs_pkbuf_t *pkbuf);
32
+ogs_pfcp_far_t *ogs_pfcp_far_find_by_pfcp_session_report(
33
+        ogs_pfcp_sess_t *sess,
34
+        ogs_pfcp_tlv_error_indication_report_t *error_indication_report);
35
 
36
 void ogs_pfcp_far_teid_hash_set(ogs_pfcp_far_t *far);
37
 ogs_pfcp_far_t *ogs_pfcp_far_find_by_teid(uint32_t teid);
38
open5gs_2.6.2.tar.xz/lib/pfcp/handler.c -> open5gs_2.6.3.tar.xz/lib/pfcp/handler.c Changed
36
 
1
@@ -320,6 +320,7 @@
2
 
3
 ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
4
         ogs_pfcp_tlv_create_pdr_t *message,
5
+        ogs_pfcp_sereq_flags_t *sereq_flags,
6
         uint8_t *cause_value, uint8_t *offending_ie_value)
7
 {
8
     ogs_pfcp_pdr_t *pdr = NULL;
9
@@ -376,6 +377,18 @@
10
             *offending_ie_value = OGS_PFCP_F_TEID_TYPE;
11
             return NULL;
12
         }
13
+
14
+        if (f_teid.ch == 0) {
15
+            if (sereq_flags && sereq_flags->restoration_indication == 1) {
16
+                f_teid.teid = be32toh(f_teid.teid);
17
+                if (ogs_pfcp_object_find_by_teid(f_teid.teid)) {
18
+                    ogs_error("TEID:%x had already been allocated", f_teid.teid);
19
+                    *cause_value = OGS_PFCP_CAUSE_INVALID_F_TEID_ALLOCATION_OPTION;
20
+                    *offending_ie_value = OGS_PFCP_F_TEID_TYPE;
21
+                    return NULL;
22
+                }
23
+            }
24
+        }
25
     }
26
 
27
     pdr->src_if = message->pdi.source_interface.u8;
28
@@ -398,7 +411,6 @@
29
         if (sdf_filter.bid) {
30
             oppsite_direction_rule = ogs_pfcp_rule_find_by_sdf_filter_id(
31
                         sess, sdf_filter.sdf_filter_id);
32
-
33
         }
34
 
35
         if (!oppsite_direction_rule && !sdf_filter.fd) {
36
open5gs_2.6.2.tar.xz/lib/pfcp/handler.h -> open5gs_2.6.3.tar.xz/lib/pfcp/handler.h Changed
9
 
1
@@ -53,6 +53,7 @@
2
 
3
 ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
4
         ogs_pfcp_tlv_create_pdr_t *message,
5
+        ogs_pfcp_sereq_flags_t *sereq_flags,
6
         uint8_t *cause_value, uint8_t *offending_ie_value);
7
 ogs_pfcp_pdr_t *ogs_pfcp_handle_created_pdr(ogs_pfcp_sess_t *sess,
8
         ogs_pfcp_tlv_created_pdr_t *message,
9
open5gs_2.6.2.tar.xz/lib/pfcp/message.c -> open5gs_2.6.3.tar.xz/lib/pfcp/message.c Changed
23
 
1
@@ -20,7 +20,7 @@
2
 /*******************************************************************************
3
  * This file had been created by pfcp-tlv.py script v0.1.0
4
  * Please do not modify this file but regenerate it via script.
5
- * Created on: 2023-03-05 22:26:11.716006 by acetcom
6
+ * Created on: 2023-04-09 20:37:00.518388 by acetcom
7
  * from 29244-h71-modified.docx
8
  ******************************************************************************/
9
 
10
@@ -1546,10 +1546,10 @@
11
 
12
 ogs_tlv_desc_t ogs_pfcp_tlv_desc_pfcpsereq_flags =
13
 {
14
-    OGS_TLV_VAR_STR,
15
+    OGS_TLV_UINT8,
16
     "PFCPSEReq-Flags",
17
     OGS_PFCP_PFCPSEREQ_FLAGS_TYPE,
18
-    0,
19
+    1,
20
     0,
21
     sizeof(ogs_pfcp_tlv_pfcpsereq_flags_t),
22
     { NULL }
23
open5gs_2.6.2.tar.xz/lib/pfcp/message.h -> open5gs_2.6.3.tar.xz/lib/pfcp/message.h Changed
19
 
1
@@ -20,7 +20,7 @@
2
 /*******************************************************************************
3
  * This file had been created by pfcp-tlv.py script v0.1.0
4
  * Please do not modify this file but regenerate it via script.
5
- * Created on: 2023-03-05 22:26:11.698310 by acetcom
6
+ * Created on: 2023-04-09 20:37:00.506639 by acetcom
7
  * from 29244-h71-modified.docx
8
  ******************************************************************************/
9
 
10
@@ -903,7 +903,7 @@
11
 typedef ogs_tlv_octet_t ogs_pfcp_tlv_number_of_reports_t;
12
 typedef ogs_tlv_octet_t ogs_pfcp_tlv_pfcpasrsp_flags_t;
13
 typedef ogs_tlv_octet_t ogs_pfcp_tlv_cp_pfcp_entity_ip_address_t;
14
-typedef ogs_tlv_octet_t ogs_pfcp_tlv_pfcpsereq_flags_t;
15
+typedef ogs_tlv_uint8_t ogs_pfcp_tlv_pfcpsereq_flags_t;
16
 typedef ogs_tlv_octet_t ogs_pfcp_tlv_ip_multicast_address_t;
17
 typedef ogs_tlv_octet_t ogs_pfcp_tlv_source_ip_address_t;
18
 typedef ogs_tlv_octet_t ogs_pfcp_tlv_packet_rate_status_t;
19
open5gs_2.6.2.tar.xz/lib/pfcp/support/pfcp-tlv.py -> open5gs_2.6.3.tar.xz/lib/pfcp/support/pfcp-tlv.py Changed
9
 
1
@@ -519,6 +519,7 @@
2
 type_list"PFCPSRReq-Flags""size" = 1                    # Type 161
3
 type_list"PFCPAUReq-Flags""size" = 1                    # Type 162
4
 type_list"Quota Validity Time""size" = 4                # Type 181
5
+type_list"PFCPSEReq-Flags""size" = 1                    # Type 186
6
 type_list"Data Status""size" = 1                        # Type 260
7
 
8
 f = open(outdir + 'message.h', 'w')
9
open5gs_2.6.2.tar.xz/lib/pfcp/types.h -> open5gs_2.6.3.tar.xz/lib/pfcp/types.h Changed
30
 
1
@@ -1651,6 +1651,28 @@
2
         ogs_tlv_octet_t *octet, ogs_pfcp_user_id_t *user_id,
3
         void *data, int data_len);
4
 
5
+/*
6
+ * 8.2.136 PFCPSEReq-Flags
7
+ *
8
+ * The following bits within Octet 5 shall indicate:
9
+ * - Bit 1 – RESTI (Restoration Indication): if this bit is set to "1",
10
+ *   it indicates to the UP function that the PFCP session to be established is
11
+ *   to restore an existing PFCP session.
12
+ * - Bit 2 – SUMPC (Stop of Usage Measurement to Pause Charging):
13
+ *   if this bit is set to "1", it indicates that the UP function shall
14
+ *   stop the usage measurement for all URRs with the "ASPOC" flag set to "1".
15
+ */
16
+typedef struct ogs_pfcp_sereq_flags_s {
17
+    union {
18
+        struct {
19
+ED3(uint8_t     spare:6;,
20
+    uint8_t     stop_of_usage_measurement_to_pause_charging:1;,
21
+    uint8_t     restoration_indication:1;)
22
+        };
23
+        uint8_t value;
24
+    };
25
+} __attribute__ ((packed)) ogs_pfcp_sereq_flags_t;
26
+
27
 #ifdef __cplusplus
28
 }
29
 #endif
30
open5gs_2.6.2.tar.xz/lib/pfcp/xact.h -> open5gs_2.6.3.tar.xz/lib/pfcp/xact.h Changed
35
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -35,7 +35,7 @@
9
     ogs_lnode_t     lnode;          /**< A node of list */
10
     ogs_lnode_t     tmpnode;        /**< A node of temp-list */
11
 
12
-    ogs_index_t     index;
13
+    ogs_pool_id_t   index;
14
 
15
 #define OGS_PFCP_LOCAL_ORIGINATOR  0
16
 #define OGS_PFCP_REMOTE_ORIGINATOR 1
17
@@ -78,6 +78,9 @@
18
 
19
     bool            epc;            /**< EPC or 5GC */
20
 
21
+#define OGS_PFCP_CREATE_RESTORATION_INDICATION ((uint64_t)1<<0)
22
+    uint64_t        create_flags;
23
+
24
 #define OGS_PFCP_MODIFY_SESSION ((uint64_t)1<<0)
25
 #define OGS_PFCP_MODIFY_DL_ONLY ((uint64_t)1<<1)
26
 #define OGS_PFCP_MODIFY_UL_ONLY ((uint64_t)1<<2)
27
@@ -110,7 +113,6 @@
28
 #define OGS_PFCP_MODIFY_URR_TIME_QUOTA ((uint64_t)1<<29)
29
 #define OGS_PFCP_MODIFY_URR_VOLUME_THRESH ((uint64_t)1<<30)
30
 #define OGS_PFCP_MODIFY_URR_TIME_THRESH ((uint64_t)1<<31)
31
-
32
     uint64_t        modify_flags;
33
 
34
 #define OGS_PFCP_DELETE_TRIGGER_LOCAL_INITIATED 1
35
open5gs_2.6.2.tar.xz/lib/proto/types.h -> open5gs_2.6.3.tar.xz/lib/proto/types.h Changed
9
 
1
@@ -80,6 +80,7 @@
2
 #define OGS_MAX_DNN_LEN                 100
3
 #define OGS_MAX_APN_LEN                 OGS_MAX_DNN_LEN
4
 #define OGS_MAX_PCO_LEN                 251
5
+#define OGS_MAX_EPCO_LEN                65535
6
 #define OGS_MAX_FQDN_LEN                256
7
 
8
 #define OGS_MAX_NUM_OF_SERVED_GUAMI     8
9
open5gs_2.6.2.tar.xz/lib/sbi/context.c -> open5gs_2.6.3.tar.xz/lib/sbi/context.c Changed
173
 
1
@@ -122,8 +122,6 @@
2
 
3
 static int ogs_sbi_context_prepare(void)
4
 {
5
-    self.sbi_port = OGS_SBI_HTTP_PORT;
6
-
7
 #if ENABLE_ACCEPT_ENCODING
8
     self.content_encoding = "gzip";
9
 #endif
10
@@ -242,7 +240,7 @@
11
                         int num_of_advertise = 0;
12
                         const char *advertiseOGS_MAX_NUM_OF_HOSTNAME;
13
 
14
-                        uint16_t port = self.sbi_port;
15
+                        uint16_t port = ogs_sbi_server_default_port();
16
                         const char *dev = NULL;
17
                         ogs_sockaddr_t *addr = NULL;
18
 
19
@@ -410,7 +408,7 @@
20
                         rv = ogs_socknode_probe(
21
                             ogs_app()->parameter.no_ipv4 ? NULL : &list,
22
                             ogs_app()->parameter.no_ipv6 ? NULL : &list6,
23
-                            NULL, self.sbi_port, NULL);
24
+                            NULL, ogs_sbi_server_default_port(), NULL);
25
                         ogs_assert(rv == OGS_OK);
26
 
27
                         node = ogs_list_first(&list);
28
@@ -506,7 +504,7 @@
29
                         int family = AF_UNSPEC;
30
                         int i, num = 0;
31
                         const char *hostnameOGS_MAX_NUM_OF_HOSTNAME;
32
-                        uint16_t port = self.sbi_port;
33
+                        uint16_t port = ogs_sbi_client_default_port();
34
 
35
                         if (ogs_yaml_iter_type(&sbi_array) ==
36
                                 YAML_MAPPING_NODE) {
37
@@ -583,10 +581,7 @@
38
                         if (addr == NULL) continue;
39
 
40
                         client = ogs_sbi_client_add(
41
-                                    ogs_app()->sbi.client.no_tls == false ?
42
-                                        OpenAPI_uri_scheme_https :
43
-                                        OpenAPI_uri_scheme_http,
44
-                                    addr);
45
+                                    ogs_sbi_client_default_scheme(), addr);
46
                         ogs_assert(client);
47
                         OGS_SBI_SETUP_CLIENT(self.nrf_instance, client);
48
 
49
@@ -612,7 +607,7 @@
50
                         int family = AF_UNSPEC;
51
                         int i, num = 0;
52
                         const char *hostnameOGS_MAX_NUM_OF_HOSTNAME;
53
-                        uint16_t port = self.sbi_port;
54
+                        uint16_t port = ogs_sbi_client_default_port();
55
 
56
                         if (ogs_yaml_iter_type(&sbi_array) ==
57
                                 YAML_MAPPING_NODE) {
58
@@ -689,10 +684,7 @@
59
                         if (addr == NULL) continue;
60
 
61
                         client = ogs_sbi_client_add(
62
-                                    ogs_app()->sbi.client.no_tls == false ?
63
-                                        OpenAPI_uri_scheme_https :
64
-                                        OpenAPI_uri_scheme_http,
65
-                                    addr);
66
+                                    ogs_sbi_client_default_scheme(), addr);
67
                         ogs_assert(client);
68
                         OGS_SBI_SETUP_CLIENT(self.scp_instance, client);
69
 
70
@@ -1404,6 +1396,7 @@
71
         }
72
 
73
         if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
74
+            bool is_port = true;
75
             int port = 0;
76
             ogs_sockaddr_t *addr = NULL;
77
             ogs_assert(OGS_OK == ogs_copyaddrinfo(&addr, advertise));
78
@@ -1411,11 +1404,12 @@
79
 
80
             port = OGS_PORT(addr);
81
             if (nf_service->scheme == OpenAPI_uri_scheme_https) {
82
-                if (port == OGS_SBI_HTTPS_PORT) port = 0;
83
+                if (port == OGS_SBI_HTTPS_PORT) is_port = false;
84
             } else if (nf_service->scheme == OpenAPI_uri_scheme_http) {
85
-                if (port == OGS_SBI_HTTP_PORT) port = 0;
86
+                if (port == OGS_SBI_HTTP_PORT) is_port = false;
87
             }
88
 
89
+            nf_service->addrnf_service->num_of_addr.is_port = is_port;
90
             nf_service->addrnf_service->num_of_addr.port = port;
91
             if (addr->ogs_sa_family == AF_INET) {
92
                 nf_service->addrnf_service->num_of_addr.ipv4 = addr;
93
@@ -1439,17 +1433,21 @@
94
 }
95
 
96
 static ogs_sbi_client_t *find_client_by_fqdn(
97
-        OpenAPI_uri_scheme_e scheme, char *fqdn, int port)
98
+        OpenAPI_uri_scheme_e scheme, char *fqdn)
99
 {
100
     int rv;
101
     ogs_sockaddr_t *addr = NULL;
102
     ogs_sbi_client_t *client = NULL;
103
 
104
-    ogs_assert(scheme);
105
+    ogs_assert(scheme == OpenAPI_uri_scheme_https ||
106
+                scheme == OpenAPI_uri_scheme_http);
107
     ogs_assert(fqdn);
108
 
109
-    rv = ogs_getaddrinfo(&addr, AF_UNSPEC, fqdn,
110
-            port ? port : ogs_sbi_self()->sbi_port, 0);
111
+    rv = ogs_getaddrinfo(
112
+            &addr, AF_UNSPEC, fqdn,
113
+            scheme == OpenAPI_uri_scheme_https ?
114
+                OGS_SBI_HTTPS_PORT : OGS_SBI_HTTP_PORT,
115
+            0);
116
     if (rv != OGS_OK) {
117
         ogs_error("Invalid NFProfile.fqdn");
118
         return NULL;
119
@@ -1473,11 +1471,10 @@
120
     ogs_sockaddr_t *addr = NULL;
121
     OpenAPI_uri_scheme_e scheme = OpenAPI_uri_scheme_NULL;
122
 
123
-    scheme = ogs_app()->sbi.client.no_tls == false ?
124
-                OpenAPI_uri_scheme_https : OpenAPI_uri_scheme_http;
125
+    scheme = ogs_sbi_client_default_scheme();
126
 
127
     if (nf_instance->fqdn)
128
-        client = find_client_by_fqdn(scheme, nf_instance->fqdn, 0);
129
+        client = find_client_by_fqdn(scheme, nf_instance->fqdn);
130
 
131
     if (!client) {
132
         /* At this point, CLIENT selection method is very simple. */
133
@@ -1504,7 +1501,7 @@
134
     ogs_assert(nf_service->scheme);
135
 
136
     if (nf_service->fqdn)
137
-        client = find_client_by_fqdn(nf_service->scheme, nf_service->fqdn, 0);
138
+        client = find_client_by_fqdn(nf_service->scheme, nf_service->fqdn);
139
 
140
     if (!client) {
141
         /* At this point, CLIENT selection method is very simple. */
142
@@ -1620,9 +1617,28 @@
143
     nf_service_associate_client_all(nf_instance);
144
 }
145
 
146
-OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void)
147
+OpenAPI_uri_scheme_e ogs_sbi_server_default_scheme(void)
148
+{
149
+    return ogs_app()->sbi.server.no_tls == false ?
150
+            OpenAPI_uri_scheme_https : OpenAPI_uri_scheme_http;
151
+}
152
+
153
+OpenAPI_uri_scheme_e ogs_sbi_client_default_scheme(void)
154
+{
155
+    return ogs_app()->sbi.client.no_tls == false ?
156
+            OpenAPI_uri_scheme_https : OpenAPI_uri_scheme_http;
157
+}
158
+
159
+int ogs_sbi_server_default_port(void)
160
+{
161
+    return ogs_app()->sbi.server.no_tls == false ?
162
+            OGS_SBI_HTTPS_PORT : OGS_SBI_HTTP_PORT;
163
+}
164
+
165
+int ogs_sbi_client_default_port(void)
166
 {
167
-    return OpenAPI_uri_scheme_http;
168
+    return ogs_app()->sbi.client.no_tls == false ?
169
+            OGS_SBI_HTTPS_PORT : OGS_SBI_HTTP_PORT;
170
 }
171
 
172
 ogs_sbi_client_t *ogs_sbi_client_find_by_service_name(
173
open5gs_2.6.2.tar.xz/lib/sbi/context.h -> open5gs_2.6.3.tar.xz/lib/sbi/context.h Changed
30
 
1
@@ -58,8 +58,6 @@
2
         uint8_t keyOGS_ECCKEY_LEN; /* 32 bytes Private Key */
3
     } hnetOGS_HOME_NETWORK_PKI_VALUE_MAX+1; /* PKI Value : 1 ~ 254 */
4
 
5
-    uint16_t sbi_port;                      /* SBI local port */
6
-
7
     ogs_list_t server_list;
8
     ogs_list_t client_list;
9
 
10
@@ -218,6 +216,7 @@
11
     struct {
12
         ogs_sockaddr_t *ipv4;
13
         ogs_sockaddr_t *ipv6;
14
+        bool is_port;
15
         int port;
16
     } addrOGS_SBI_MAX_NUM_OF_IP_ADDRESS;
17
 
18
@@ -401,7 +400,10 @@
19
 
20
 void ogs_sbi_client_associate(ogs_sbi_nf_instance_t *nf_instance);
21
 
22
-OpenAPI_uri_scheme_e ogs_sbi_default_uri_scheme(void);
23
+OpenAPI_uri_scheme_e ogs_sbi_server_default_scheme(void);
24
+OpenAPI_uri_scheme_e ogs_sbi_client_default_scheme(void);
25
+int ogs_sbi_server_default_port(void);
26
+int ogs_sbi_client_default_port(void);
27
 
28
 #define OGS_SBI_SETUP_NF_INSTANCE(__cTX, __nFInstance) \
29
     do { \
30
open5gs_2.6.2.tar.xz/lib/sbi/nnrf-build.c -> open5gs_2.6.3.tar.xz/lib/sbi/nnrf-build.c Changed
10
 
1
@@ -569,7 +569,7 @@
2
                     return NULL;
3
                 }
4
             }
5
-            IpEndPoint->is_port = true;
6
+            IpEndPoint->is_port = nf_service->addri.is_port;
7
             IpEndPoint->port = nf_service->addri.port;
8
             OpenAPI_list_add(IpEndPointList, IpEndPoint);
9
         }
10
open5gs_2.6.2.tar.xz/lib/sbi/nnrf-handler.c -> open5gs_2.6.3.tar.xz/lib/sbi/nnrf-handler.c Changed
50
 
1
@@ -83,7 +83,7 @@
2
         if (nf_instance->num_of_ipv4 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
3
 
4
             rv = ogs_getaddrinfo(&addr, AF_UNSPEC,
5
-                    node->data, ogs_sbi_self()->sbi_port, 0);
6
+                    node->data, ogs_sbi_client_default_port(), 0);
7
             if (rv != OGS_OK) continue;
8
 
9
             nf_instance->ipv4nf_instance->num_of_ipv4 = addr;
10
@@ -101,7 +101,7 @@
11
         if (nf_instance->num_of_ipv6 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
12
 
13
             rv = ogs_getaddrinfo(&addr, AF_UNSPEC,
14
-                    node->data, ogs_sbi_self()->sbi_port, 0);
15
+                    node->data, ogs_sbi_client_default_port(), 0);
16
             if (rv != OGS_OK) continue;
17
 
18
             nf_instance->ipv6nf_instance->num_of_ipv6 = addr;
19
@@ -257,18 +257,10 @@
20
         }
21
 
22
         if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
23
-            if (!IpEndPoint->is_port) {
24
-                if (nf_service->scheme == OpenAPI_uri_scheme_http)
25
-                    port = OGS_SBI_HTTP_PORT;
26
-                else if (nf_service->scheme == OpenAPI_uri_scheme_https)
27
-                    port = OGS_SBI_HTTPS_PORT;
28
-                else {
29
-                    ogs_error("Invalid scheme %d", nf_service->scheme);
30
-                    continue;
31
-                }
32
-            } else {
33
+            if (!IpEndPoint->is_port)
34
+                port = ogs_sbi_client_default_port();
35
+            else
36
                 port = IpEndPoint->port;
37
-            }
38
 
39
             if (IpEndPoint->ipv4_address) {
40
                 rv = ogs_getaddrinfo(&addr, AF_UNSPEC,
41
@@ -291,6 +283,8 @@
42
 
43
             if (addr || addr6) {
44
                 nf_service->addrnf_service->num_of_addr.
45
+                    is_port = IpEndPoint->is_port;
46
+                nf_service->addrnf_service->num_of_addr.
47
                     port = port;
48
                 nf_service->addrnf_service->num_of_addr.
49
                     ipv4 = addr;
50
open5gs_2.6.2.tar.xz/meson.build -> open5gs_2.6.3.tar.xz/meson.build Changed
19
 
1
@@ -16,7 +16,7 @@
2
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
3
 
4
 project('open5gs', 'c', 'cpp',
5
-    version : '2.6.2',
6
+    version : '2.6.3',
7
     license : 'AGPL-3.0-or-later',
8
     meson_version : '>= 0.43.0',
9
     default_options : 
10
@@ -25,7 +25,7 @@
11
     ,
12
 )
13
 
14
-libogslib_version = '2.6.2'
15
+libogslib_version = '2.6.3'
16
 
17
 prefix = get_option('prefix')
18
 bindir = join_paths(prefix, get_option('bindir'))
19
open5gs_2.6.2.tar.xz/misc/db/open5gs-dbctl -> open5gs_2.6.3.tar.xz/misc/db/open5gs-dbctl Changed
62
 
1
@@ -1,6 +1,6 @@
2
 #!/bin/bash
3
 
4
-version=0.10.2
5
+version=0.10.3
6
 
7
 display_help() {
8
     echo "open5gs-dbctl: Open5GS Database Configuration Tool ($version)"
9
@@ -24,6 +24,7 @@
10
     echo "   showall: shows the list of subscriber in the db"
11
     echo "   showpretty: shows the list of subscriber in the db in a pretty json tree format"
12
     echo "   showfiltered: shows {imsi key opc apn ip} information of subscriber"
13
+    echo "   ambr_speed {imsi dl_value dl_unit ul_value ul_unit}: Change AMBR speed from a specific user and the  unit values are \"0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps \""
14
 
15
 
16
 }
17
@@ -785,4 +786,44 @@
18
         exit $?
19
 fi
20
 
21
+if  "$1" = "ambr_speed" ; then
22
+    if  "$#" -eq 6 ; then
23
+        IMSI=$2
24
+        DL_VALUE=$3
25
+        DL_UNIT=$4
26
+        UL_VALUE=$5
27
+        UL_UNIT=$6
28
+        mongosh --eval "db.subscribers.updateOne({\"imsi\": \"$IMSI\"},
29
+            {\$set: { 
30
+                \"ambr\" : {
31
+                    \"downlink\" : {
32
+                        \"value\" : NumberInt($DL_VALUE),
33
+                        \"unit\"  : NumberInt($DL_UNIT)
34
+                    },
35
+                    \"uplink\" :{
36
+                        \"value\": NumberInt($UL_VALUE),
37
+                        \"unit\" : NumberInt($UL_UNIT)
38
+                    }
39
+                },
40
+                \"slice.0.session.0.ambr\": {
41
+                    \"downlink\" : {
42
+                        \"value\" : NumberInt($DL_VALUE),
43
+                        \"unit\"  : NumberInt($DL_UNIT)
44
+                    },
45
+                    \"uplink\" :{
46
+                        \"value\": NumberInt($UL_VALUE),
47
+                        \"unit\" : NumberInt($UL_UNIT)
48
+                    }
49
+                }
50
+                     }
51
+            });" $DB_URI
52
+
53
+
54
+        exit $?
55
+    fi
56
+    echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl ambr_speed imsi dl_value dl_unit ul_value ul_unit dl is for download and ul is for upload and the  unit values are0=bps 1=Kbps 2=Mbps 3=Gbps 4=Tbps  \""
57
+    exit 1
58
+fi
59
+
60
+
61
 display_help
62
open5gs_2.6.2.tar.xz/src/amf/amf-sm.c -> open5gs_2.6.3.tar.xz/src/amf/amf-sm.c Changed
16
 
1
@@ -693,6 +693,14 @@
2
                     break;
3
                 }
4
 
5
+                amf_ue = sess->amf_ue;
6
+                ogs_assert(amf_ue);
7
+                amf_ue = amf_ue_cycle(amf_ue);
8
+                if (!amf_ue) {
9
+                    ogs_error("UE(amf_ue) Context has already been removed");
10
+                    break;
11
+                }
12
+
13
                 ogs_error("%d:%d Cannot receive SBI message",
14
                         sess->psi, sess->pti);
15
                 if (sess->payload_container_type) {
16
open5gs_2.6.2.tar.xz/src/amf/context.c -> open5gs_2.6.3.tar.xz/src/amf/context.c Changed
133
 
1
@@ -29,6 +29,8 @@
2
 static OGS_POOL(ran_ue_pool, ran_ue_t);
3
 static OGS_POOL(amf_sess_pool, amf_sess_t);
4
 
5
+static OGS_POOL(m_tmsi_pool, amf_m_tmsi_t);
6
+
7
 static int context_initialized = 0;
8
 
9
 static int num_of_ran_ue = 0;
10
@@ -60,7 +62,8 @@
11
     ogs_pool_init(&amf_ue_pool, ogs_app()->max.ue);
12
     ogs_pool_init(&ran_ue_pool, ogs_app()->max.ue);
13
     ogs_pool_init(&amf_sess_pool, ogs_app()->pool.sess);
14
-    ogs_pool_init(&self.m_tmsi, ogs_app()->max.ue*2);
15
+    ogs_pool_init(&m_tmsi_pool, ogs_app()->max.ue*2);
16
+    ogs_pool_random_id_generate(&m_tmsi_pool);
17
 
18
     ogs_list_init(&self.gnb_list);
19
     ogs_list_init(&self.amf_ue_list);
20
@@ -98,7 +101,7 @@
21
     ogs_assert(self.supi_hash);
22
     ogs_hash_destroy(self.supi_hash);
23
 
24
-    ogs_pool_final(&self.m_tmsi);
25
+    ogs_pool_final(&m_tmsi_pool);
26
     ogs_pool_final(&amf_sess_pool);
27
     ogs_pool_final(&amf_ue_pool);
28
     ogs_pool_final(&ran_ue_pool);
29
@@ -1697,11 +1700,6 @@
30
             self.guti_ue_hash, guti, sizeof(ogs_nas_5gs_guti_t));
31
 }
32
 
33
-amf_ue_t *amf_ue_find_by_teid(uint32_t teid)
34
-{
35
-    return ogs_pool_find(&amf_ue_pool, teid);
36
-}
37
-
38
 amf_ue_t *amf_ue_find_by_suci(char *suci)
39
 {
40
     ogs_assert(suci);
41
@@ -2114,9 +2112,6 @@
42
     if (sess->nssf.nrf.client)
43
         ogs_sbi_client_remove(sess->nssf.nrf.client);
44
 
45
-    OGS_NAS_CLEAR_DATA(&sess->ue_pco);
46
-    OGS_TLV_CLEAR_DATA(&sess->pgw_pco);
47
-
48
     ogs_pool_free(&amf_sess_pool, sess);
49
 
50
     stats_remove_amf_session();
51
@@ -2368,6 +2363,7 @@
52
     return NULL;
53
 }
54
 
55
+#if 0 /* DEPRECATED */
56
 int amf_m_tmsi_pool_generate(void)
57
 {
58
     int j;
59
@@ -2378,7 +2374,7 @@
60
         amf_m_tmsi_t *m_tmsi = NULL;
61
         int conflict = 0;
62
 
63
-        m_tmsi = &self.m_tmsi.arrayindex;
64
+        m_tmsi = &m_tmsi_pool.arrayindex;
65
         ogs_assert(m_tmsi);
66
         *m_tmsi = ogs_random32();
67
 
68
@@ -2387,10 +2383,10 @@
69
         *m_tmsi &= 0xff00ffff;
70
 
71
         for (j = 0; j < index; j++) {
72
-            if (*m_tmsi == self.m_tmsi.arrayj) {
73
+            if (*m_tmsi == m_tmsi_pool.arrayj) {
74
                 conflict = 1;
75
                 ogs_trace("M-TMSI CONFLICT  %d:0x%x == %d:0x%x",
76
-                        index, *m_tmsi, j, self.m_tmsi.arrayj);
77
+                        index, *m_tmsi, j, m_tmsi_pool.arrayj);
78
                 break;
79
             }
80
         }
81
@@ -2400,26 +2396,48 @@
82
 
83
         index++;
84
     }
85
-    self.m_tmsi.size = index;
86
+    m_tmsi_pool.size = index;
87
     ogs_trace("M-TMSI Pool generate...done");
88
 
89
     return OGS_OK;
90
 }
91
+#endif
92
 
93
 amf_m_tmsi_t *amf_m_tmsi_alloc(void)
94
 {
95
     amf_m_tmsi_t *m_tmsi = NULL;
96
 
97
-    ogs_pool_alloc(&self.m_tmsi, &m_tmsi);
98
+    ogs_pool_alloc(&m_tmsi_pool, &m_tmsi);
99
     ogs_assert(m_tmsi);
100
 
101
+    /* TS23.003
102
+     * 2.8.2.1.2 Mapping in the UE
103
+     *
104
+     * E-UTRAN <M-TMSI> maps as follows:
105
+     * - 6 bits of the E-UTRAN <M-TMSI> starting at bit 29 and down to bit 24
106
+     * are mapped into bit 29 and down to bit 24 of the GERAN/UTRAN <P-TMSI>;
107
+     * - 16 bits of the E-UTRAN <M-TMSI> starting at bit 15 and down to bit 0
108
+     * are mapped into bit 15 and down to bit 0 of the GERAN/UTRAN <P-TMSI>;
109
+     * - and the remaining 8 bits of the E-UTRAN <M-TMSI> are
110
+     * mapped into the 8 Most Significant Bits of the <P-TMSI signature> field.
111
+     *
112
+     * The UE shall fill the remaining 2 octets of the <P-TMSI signature>
113
+     * according to clauses 9.1.1, 9.4.1, 10.2.1, or 10.5.1
114
+     * of 3GPP TS.33.401 89 , as appropriate, for RAU/Attach procedures
115
+     */
116
+
117
+    ogs_assert(*m_tmsi <= 0x003fffff);
118
+
119
+    *m_tmsi = ((*m_tmsi & 0xffff) | ((*m_tmsi & 0x003f0000) << 8));
120
+    *m_tmsi |= 0xc0000000;
121
+
122
     return m_tmsi;
123
 }
124
 
125
 int amf_m_tmsi_free(amf_m_tmsi_t *m_tmsi)
126
 {
127
     ogs_assert(m_tmsi);
128
-    ogs_pool_free(&self.m_tmsi, m_tmsi);
129
+    ogs_pool_free(&m_tmsi_pool, m_tmsi);
130
 
131
     return OGS_OK;
132
 }
133
open5gs_2.6.2.tar.xz/src/amf/context.h -> open5gs_2.6.3.tar.xz/src/amf/context.h Changed
42
 
1
@@ -111,8 +111,6 @@
2
     ogs_hash_t      *suci_hash;     /* hash table (SUCI) */
3
     ogs_hash_t      *supi_hash;     /* hash table (SUPI) */
4
 
5
-    OGS_POOL(m_tmsi, amf_m_tmsi_t); /* M-TMSI Pool */
6
-
7
     uint16_t        ngap_port;      /* Default NGAP Port */
8
 
9
     ogs_list_t      ngap_list;      /* AMF NGAP IPv4 Server List */
10
@@ -650,15 +648,6 @@
11
     ogs_s_nssai_t mapped_hplmn;
12
     char *dnn;
13
 
14
-    /* Save Protocol Configuration Options from UE */
15
-    struct {
16
-        uint8_t length;
17
-        uint8_t *buffer;
18
-    } ue_pco; 
19
-
20
-    /* Save Protocol Configuration Options from PGW */
21
-    ogs_tlv_octet_t pgw_pco;
22
-
23
 } amf_sess_t;
24
 
25
 void amf_context_init(void);
26
@@ -697,7 +686,6 @@
27
 void amf_ue_fsm_fini(amf_ue_t *amf_ue);
28
 
29
 amf_ue_t *amf_ue_find_by_guti(ogs_nas_5gs_guti_t *nas_guti);
30
-amf_ue_t *amf_ue_find_by_teid(uint32_t teid);
31
 amf_ue_t *amf_ue_find_by_suci(char *suci);
32
 amf_ue_t *amf_ue_find_by_supi(char *supi);
33
 
34
@@ -823,7 +811,6 @@
35
 ogs_s_nssai_t *amf_find_s_nssai(
36
         ogs_plmn_id_t *served_plmn_id, ogs_s_nssai_t *s_nssai);
37
 
38
-int amf_m_tmsi_pool_generate(void);
39
 amf_m_tmsi_t *amf_m_tmsi_alloc(void);
40
 int amf_m_tmsi_free(amf_m_tmsi_t *tmsi);
41
 
42
open5gs_2.6.2.tar.xz/src/amf/init.c -> open5gs_2.6.3.tar.xz/src/amf/init.c Changed
11
 
1
@@ -46,9 +46,6 @@
2
     rv = amf_context_nf_info();
3
     if (rv != OGS_OK) return rv;
4
 
5
-    rv = amf_m_tmsi_pool_generate();
6
-    if (rv != OGS_OK) return rv;
7
-
8
     rv = ogs_log_config_domain(
9
             ogs_app()->logger.domain, ogs_app()->logger.level);
10
     if (rv != OGS_OK) return rv;
11
open5gs_2.6.2.tar.xz/src/amf/ngap-handler.c -> open5gs_2.6.3.tar.xz/src/amf/ngap-handler.c Changed
10
 
1
@@ -3140,6 +3140,8 @@
2
     target_ue->initial_context_setup_request_sent =
3
             source_ue->initial_context_setup_request_sent;
4
 
5
+    target_ue->psimask.activated = source_ue->psimask.activated;
6
+
7
     ogs_debug("    Target : RAN_UE_NGAP_ID%d AMF_UE_NGAP_ID%lld ",
8
         target_ue->ran_ue_ngap_id, (long long)target_ue->amf_ue_ngap_id);
9
 
10
open5gs_2.6.2.tar.xz/src/bsf/context.h -> open5gs_2.6.3.tar.xz/src/bsf/context.h Changed
16
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -71,6 +71,7 @@
9
     struct {
10
         char *addr;
11
         char *addr6;
12
+        bool is_port;
13
         int port;
14
     } pcf_ipOGS_SBI_MAX_NUM_OF_IP_ADDRESS;
15
 
16
open5gs_2.6.2.tar.xz/src/bsf/nbsf-handler.c -> open5gs_2.6.3.tar.xz/src/bsf/nbsf-handler.c Changed
59
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -148,27 +148,10 @@
9
 
10
                 OpenAPI_list_for_each(PcfIpEndPointList, node) {
11
                     OpenAPI_ip_end_point_t *IpEndPoint = node->data;
12
-                    int port = 0;
13
 
14
                     if (!IpEndPoint) continue;
15
 
16
                     if (sess->num_of_pcf_ip < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
17
-                        if (!IpEndPoint->is_port) {
18
-                            if (ogs_sbi_default_uri_scheme() ==
19
-                                    OpenAPI_uri_scheme_http)
20
-                                port = OGS_SBI_HTTP_PORT;
21
-                            else if (ogs_sbi_default_uri_scheme() ==
22
-                                    OpenAPI_uri_scheme_https)
23
-                                port = OGS_SBI_HTTPS_PORT;
24
-                            else {
25
-                                ogs_fatal("Invalid scheme %d",
26
-                                    ogs_sbi_default_uri_scheme());
27
-                                ogs_assert_if_reached();
28
-                            }
29
-                        } else {
30
-                            port = IpEndPoint->port;
31
-                        }
32
-
33
                         if (IpEndPoint->ipv4_address ||
34
                             IpEndPoint->ipv6_address) {
35
                             if (IpEndPoint->ipv4_address) {
36
@@ -179,7 +162,12 @@
37
                                 sess->pcf_ipsess->num_of_pcf_ip.addr6 =
38
                                     ogs_strdup(IpEndPoint->ipv6_address);
39
                             }
40
-                            sess->pcf_ipsess->num_of_pcf_ip.port = port;
41
+                            if (IpEndPoint->is_port) {
42
+                                sess->pcf_ipsess->num_of_pcf_ip.is_port =
43
+                                    IpEndPoint->is_port;
44
+                                sess->pcf_ipsess->num_of_pcf_ip.port =
45
+                                    IpEndPoint->port;
46
+                            }
47
                             sess->num_of_pcf_ip++;
48
                         }
49
                     }
50
@@ -259,7 +247,7 @@
51
                     PcfIpEndPoint->ipv4_address = sess->pcf_ipi.addr;
52
                     PcfIpEndPoint->ipv6_address = sess->pcf_ipi.addr6;
53
 
54
-                    PcfIpEndPoint->is_port = true;
55
+                    PcfIpEndPoint->is_port = sess->pcf_ipi.is_port;
56
                     PcfIpEndPoint->port = sess->pcf_ipi.port;
57
 
58
                     OpenAPI_list_add(PcfIpEndPointList, PcfIpEndPoint);
59
open5gs_2.6.2.tar.xz/src/mme/esm-build.c -> open5gs_2.6.3.tar.xz/src/mme/esm-build.c Changed
44
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -228,21 +228,20 @@
9
         apn_ambr_build(apn_ambr, session->ambr.downlink, session->ambr.uplink);
10
     }
11
 
12
-    if (sess->pgw_pco.presence && sess->pgw_pco.len && sess->pgw_pco.data) {
13
-        if (mme_ue->ue_network_capability.
14
-                extended_protocol_configuration_options) {
15
-            activate_default_eps_bearer_context_request->presencemask |=
16
-                OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
17
-            extended_protocol_configuration_options->length = sess->pgw_pco.len;
18
-            extended_protocol_configuration_options->buffer =
19
-                sess->pgw_pco.data;
20
-        } else {
21
-            activate_default_eps_bearer_context_request->presencemask |=
22
-                OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
23
-            protocol_configuration_options->length = sess->pgw_pco.len;
24
-            memcpy(protocol_configuration_options->buffer,
25
-                    sess->pgw_pco.data, protocol_configuration_options->length);
26
-        }
27
+    if (sess->pgw_epco.presence && sess->pgw_epco.len && sess->pgw_epco.data) {
28
+        activate_default_eps_bearer_context_request->presencemask |=
29
+            OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
30
+        extended_protocol_configuration_options->length =
31
+            sess->pgw_epco.len;
32
+        extended_protocol_configuration_options->buffer =
33
+            sess->pgw_epco.data;
34
+    } else if (sess->pgw_pco.presence && sess->pgw_pco.len &&
35
+            sess->pgw_pco.data) {
36
+        activate_default_eps_bearer_context_request->presencemask |=
37
+            OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
38
+        protocol_configuration_options->length = sess->pgw_pco.len;
39
+        memcpy(protocol_configuration_options->buffer,
40
+                sess->pgw_pco.data, protocol_configuration_options->length);
41
     }
42
 
43
     if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST)
44
open5gs_2.6.2.tar.xz/src/mme/esm-handler.c -> open5gs_2.6.3.tar.xz/src/mme/esm-handler.c Changed
46
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -106,9 +106,17 @@
9
     }
10
 
11
     if (req->presencemask &
12
+        OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
13
+        ogs_nas_extended_protocol_configuration_options_t
14
+            *extended_protocol_configuration_options =
15
+            &req->extended_protocol_configuration_options;
16
+
17
+        OGS_NAS_STORE_DATA(&sess->ue_epco,
18
+            extended_protocol_configuration_options);
19
+    } else if (req->presencemask &
20
         OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
21
         ogs_nas_protocol_configuration_options_t
22
-            *protocol_configuration_options = 
23
+            *protocol_configuration_options =
24
             &req->protocol_configuration_options;
25
 
26
         OGS_NAS_STORE_DATA(&sess->ue_pco, protocol_configuration_options);
27
@@ -182,9 +190,17 @@
28
     }
29
 
30
     if (rsp->presencemask &
31
+        OGS_NAS_EPS_ESM_INFORMATION_RESPONSE_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
32
+        ogs_nas_extended_protocol_configuration_options_t
33
+            *extended_protocol_configuration_options =
34
+            &rsp->extended_protocol_configuration_options;
35
+
36
+        OGS_NAS_STORE_DATA(&sess->ue_epco,
37
+            extended_protocol_configuration_options);
38
+    } else if (rsp->presencemask &
39
         OGS_NAS_EPS_ESM_INFORMATION_RESPONSE_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
40
         ogs_nas_protocol_configuration_options_t
41
-            *protocol_configuration_options = 
42
+            *protocol_configuration_options =
43
                 &rsp->protocol_configuration_options;
44
         OGS_NAS_STORE_DATA(&sess->ue_pco, protocol_configuration_options);
45
     }
46
open5gs_2.6.2.tar.xz/src/mme/mme-context.c -> open5gs_2.6.3.tar.xz/src/mme/mme-context.c Changed
201
 
1
@@ -44,11 +44,14 @@
2
 
3
 static OGS_POOL(mme_enb_pool, mme_enb_t);
4
 static OGS_POOL(mme_ue_pool, mme_ue_t);
5
+static OGS_POOL(mme_s11_teid_pool, ogs_pool_id_t);
6
 static OGS_POOL(enb_ue_pool, enb_ue_t);
7
 static OGS_POOL(sgw_ue_pool, sgw_ue_t);
8
 static OGS_POOL(mme_sess_pool, mme_sess_t);
9
 static OGS_POOL(mme_bearer_pool, mme_bearer_t);
10
 
11
+static OGS_POOL(m_tmsi_pool, mme_m_tmsi_t);
12
+
13
 static int context_initialized = 0;
14
 
15
 static int num_of_enb_ue = 0;
16
@@ -100,11 +103,15 @@
17
     ogs_pool_init(&mme_enb_pool, ogs_app()->max.peer*2);
18
 
19
     ogs_pool_init(&mme_ue_pool, ogs_app()->max.ue);
20
+    ogs_pool_init(&mme_s11_teid_pool, ogs_app()->max.ue);
21
+    ogs_pool_random_id_generate(&mme_s11_teid_pool);
22
+
23
     ogs_pool_init(&enb_ue_pool, ogs_app()->max.ue);
24
     ogs_pool_init(&sgw_ue_pool, ogs_app()->max.ue);
25
     ogs_pool_init(&mme_sess_pool, ogs_app()->pool.sess);
26
     ogs_pool_init(&mme_bearer_pool, ogs_app()->pool.bearer);
27
-    ogs_pool_init(&self.m_tmsi, ogs_app()->max.ue*2);
28
+    ogs_pool_init(&m_tmsi_pool, ogs_app()->max.ue*2);
29
+    ogs_pool_random_id_generate(&m_tmsi_pool);
30
 
31
     self.enb_addr_hash = ogs_hash_make();
32
     ogs_assert(self.enb_addr_hash);
33
@@ -114,6 +121,8 @@
34
     ogs_assert(self.imsi_ue_hash);
35
     self.guti_ue_hash = ogs_hash_make();
36
     ogs_assert(self.guti_ue_hash);
37
+    self.mme_s11_teid_hash = ogs_hash_make();
38
+    ogs_assert(self.mme_s11_teid_hash);
39
 
40
     ogs_list_init(&self.mme_ue_list);
41
 
42
@@ -141,11 +150,14 @@
43
     ogs_hash_destroy(self.imsi_ue_hash);
44
     ogs_assert(self.guti_ue_hash);
45
     ogs_hash_destroy(self.guti_ue_hash);
46
+    ogs_assert(self.mme_s11_teid_hash);
47
+    ogs_hash_destroy(self.mme_s11_teid_hash);
48
 
49
-    ogs_pool_final(&self.m_tmsi);
50
+    ogs_pool_final(&m_tmsi_pool);
51
     ogs_pool_final(&mme_bearer_pool);
52
     ogs_pool_final(&mme_sess_pool);
53
     ogs_pool_final(&mme_ue_pool);
54
+    ogs_pool_final(&mme_s11_teid_pool);
55
     ogs_pool_final(&enb_ue_pool);
56
     ogs_pool_final(&sgw_ue_pool);
57
 
58
@@ -2327,11 +2339,6 @@
59
     sgw_ue->sgw = new_sgw;
60
 }
61
 
62
-sgw_ue_t *sgw_ue_find(uint32_t index)
63
-{
64
-    return ogs_pool_find(&sgw_ue_pool, index);
65
-}
66
-
67
 sgw_ue_t *sgw_ue_cycle(sgw_ue_t *sgw_ue)
68
 {
69
     return ogs_pool_cycle(&sgw_ue_pool, sgw_ue);
70
@@ -2564,9 +2571,14 @@
71
 
72
     ogs_list_init(&mme_ue->sess_list);
73
 
74
-    mme_ue->mme_s11_teid = ogs_pool_index(&mme_ue_pool, mme_ue);
75
-    ogs_assert(mme_ue->mme_s11_teid > 0 &&
76
-            mme_ue->mme_s11_teid <= ogs_app()->max.ue);
77
+    /* Set MME-S11_TEID */
78
+    ogs_pool_alloc(&mme_s11_teid_pool, &mme_ue->mme_s11_teid_node);
79
+    ogs_assert(mme_ue->mme_s11_teid_node);
80
+
81
+    mme_ue->mme_s11_teid = *(mme_ue->mme_s11_teid_node);
82
+
83
+    ogs_hash_set(self.mme_s11_teid_hash,
84
+            &mme_ue->mme_s11_teid, sizeof(mme_ue->mme_s11_teid), mme_ue);
85
 
86
     /*
87
      * When used for the first time, if last node is set,
88
@@ -2609,6 +2621,9 @@
89
 
90
     mme_ue_fsm_fini(mme_ue);
91
 
92
+    ogs_hash_set(self.mme_s11_teid_hash,
93
+            &mme_ue->mme_s11_teid, sizeof(mme_ue->mme_s11_teid), NULL);
94
+
95
     ogs_assert(mme_ue->sgw_ue);
96
     sgw_ue_remove(mme_ue->sgw_ue);
97
 
98
@@ -2654,6 +2669,7 @@
99
 
100
     mme_ebi_pool_final(mme_ue);
101
 
102
+    ogs_pool_free(&mme_s11_teid_pool, mme_ue->mme_s11_teid_node);
103
     ogs_pool_free(&mme_ue_pool, mme_ue);
104
 
105
     ogs_info("Removed Number of MME-UEs is now %d",
106
@@ -2729,7 +2745,7 @@
107
 
108
 mme_ue_t *mme_ue_find_by_teid(uint32_t teid)
109
 {
110
-    return ogs_pool_find(&mme_ue_pool, teid);
111
+    return ogs_hash_get(self.mme_s11_teid_hash, &teid, sizeof(teid));
112
 }
113
 
114
 mme_ue_t *mme_ue_find_by_message(ogs_nas_eps_message_t *message)
115
@@ -3244,7 +3260,9 @@
116
     mme_bearer_remove_all(sess);
117
 
118
     OGS_NAS_CLEAR_DATA(&sess->ue_pco);
119
+    OGS_NAS_CLEAR_DATA(&sess->ue_epco);
120
     OGS_TLV_CLEAR_DATA(&sess->pgw_pco);
121
+    OGS_TLV_CLEAR_DATA(&sess->pgw_epco);
122
 
123
     ogs_pool_free(&mme_sess_pool, sess);
124
 
125
@@ -3743,6 +3761,7 @@
126
     return -1;
127
 }
128
 
129
+#if 0 /* DEPRECATED */
130
 int mme_m_tmsi_pool_generate(void)
131
 {
132
     int j;
133
@@ -3753,7 +3772,7 @@
134
         mme_m_tmsi_t *m_tmsi = NULL;
135
         int conflict = 0;
136
 
137
-        m_tmsi = &self.m_tmsi.arrayindex;
138
+        m_tmsi = &m_tmsi_pool.arrayindex;
139
         ogs_assert(m_tmsi);
140
         *m_tmsi = ogs_random32();
141
 
142
@@ -3762,10 +3781,10 @@
143
         *m_tmsi &= 0xff00ffff;
144
 
145
         for (j = 0; j < index; j++) {
146
-            if (*m_tmsi == self.m_tmsi.arrayj) {
147
+            if (*m_tmsi == m_tmsi_pool.arrayj) {
148
                 conflict = 1;
149
                 ogs_trace("M-TMSI CONFLICT  %d:0x%x == %d:0x%x",
150
-                        index, *m_tmsi, j, self.m_tmsi.arrayj);
151
+                        index, *m_tmsi, j, m_tmsi_pool.arrayj);
152
                 break;
153
             }
154
         }
155
@@ -3775,26 +3794,48 @@
156
 
157
         index++;
158
     }
159
-    self.m_tmsi.size = index;
160
+    m_tmsi_pool.size = index;
161
     ogs_trace("M-TMSI Pool generate...done");
162
 
163
     return OGS_OK;
164
 }
165
+#endif
166
 
167
 mme_m_tmsi_t *mme_m_tmsi_alloc(void)
168
 {
169
     mme_m_tmsi_t *m_tmsi = NULL;
170
 
171
-    ogs_pool_alloc(&self.m_tmsi, &m_tmsi);
172
+    ogs_pool_alloc(&m_tmsi_pool, &m_tmsi);
173
     ogs_assert(m_tmsi);
174
 
175
+    /* TS23.003
176
+     * 2.8.2.1.2 Mapping in the UE
177
+     *
178
+     * E-UTRAN <M-TMSI> maps as follows:
179
+     * - 6 bits of the E-UTRAN <M-TMSI> starting at bit 29 and down to bit 24
180
+     * are mapped into bit 29 and down to bit 24 of the GERAN/UTRAN <P-TMSI>;
181
+     * - 16 bits of the E-UTRAN <M-TMSI> starting at bit 15 and down to bit 0
182
+     * are mapped into bit 15 and down to bit 0 of the GERAN/UTRAN <P-TMSI>;
183
+     * - and the remaining 8 bits of the E-UTRAN <M-TMSI> are
184
+     * mapped into the 8 Most Significant Bits of the <P-TMSI signature> field.
185
+     *
186
+     * The UE shall fill the remaining 2 octets of the <P-TMSI signature>
187
+     * according to clauses 9.1.1, 9.4.1, 10.2.1, or 10.5.1
188
+     * of 3GPP TS.33.401 89 , as appropriate, for RAU/Attach procedures
189
+     */
190
+
191
+    ogs_assert(*m_tmsi <= 0x003fffff);
192
+
193
+    *m_tmsi = ((*m_tmsi & 0xffff) | ((*m_tmsi & 0x003f0000) << 8));
194
+    *m_tmsi |= 0xc0000000;
195
+
196
     return m_tmsi;
197
 }
198
 
199
 int mme_m_tmsi_free(mme_m_tmsi_t *m_tmsi)
200
 {
201
open5gs_2.6.2.tar.xz/src/mme/mme-context.h -> open5gs_2.6.3.tar.xz/src/mme/mme-context.h Changed
83
 
1
@@ -145,15 +145,14 @@
2
     /* Generator for unique identification */
3
     uint32_t        mme_ue_s1ap_id;         /* mme_ue_s1ap_id generator */
4
 
5
-    /* M-TMSI Pool */
6
-    OGS_POOL(m_tmsi, mme_m_tmsi_t);
7
-
8
     ogs_list_t      mme_ue_list;
9
 
10
-    ogs_hash_t      *enb_addr_hash;         /* hash table for ENB Address */
11
-    ogs_hash_t      *enb_id_hash;           /* hash table for ENB-ID */
12
-    ogs_hash_t      *imsi_ue_hash;          /* hash table (IMSI : MME_UE) */
13
-    ogs_hash_t      *guti_ue_hash;          /* hash table (GUTI : MME_UE) */
14
+    ogs_hash_t *enb_addr_hash;  /* hash table for ENB Address */
15
+    ogs_hash_t *enb_id_hash;    /* hash table for ENB-ID */
16
+    ogs_hash_t *imsi_ue_hash;   /* hash table (IMSI : MME_UE) */
17
+    ogs_hash_t *guti_ue_hash;   /* hash table (GUTI : MME_UE) */
18
+
19
+    ogs_hash_t *mme_s11_teid_hash;  /* hash table (MME-S11-TEID : MME_UE) */
20
 
21
     struct {
22
         struct {
23
@@ -286,7 +285,6 @@
24
 
25
 struct sgw_ue_s {
26
     ogs_lnode_t     lnode;
27
-    uint32_t        index;
28
 
29
     sgw_ue_t        *source_ue;
30
     sgw_ue_t        *target_ue;
31
@@ -371,7 +369,8 @@
32
         ogs_nas_eps_guti_t guti;
33
     } current, next;
34
 
35
-    uint32_t        mme_s11_teid;   /* MME-S11-TEID is derived from INDEX */
36
+    ogs_pool_id_t   *mme_s11_teid_node; /* A node of MME-S11-TEID */
37
+    uint32_t        mme_s11_teid;   /* MME-S11-TEID is derived from NODE */
38
 
39
     uint16_t        vlr_ostream_id; /* SCTP output stream id for VLR */
40
 
41
@@ -642,8 +641,17 @@
42
         uint8_t *buffer;
43
     } ue_pco;
44
 
45
+    /* Save Extended Protocol Configuration Options from UE */
46
+    struct {
47
+        uint16_t length;
48
+        uint8_t *buffer;
49
+    } ue_epco;
50
+
51
     /* Save Protocol Configuration Options from PGW */
52
     ogs_tlv_octet_t pgw_pco;
53
+
54
+    /* Save Extended Protocol Configuration Options from PGW */
55
+    ogs_tlv_octet_t pgw_epco;
56
 } mme_sess_t;
57
 
58
 #define MME_HAVE_ENB_S1U_PATH(__bEARER) \
59
@@ -685,7 +693,6 @@
60
     ogs_lnode_t     lnode;
61
     ogs_lnode_t     to_modify_node;
62
 
63
-    uint32_t        index;
64
     ogs_fsm_t       sm;             /* State Machine */
65
 
66
     uint8_t         *ebi_node;      /* Pool-Node for EPS Bearer ID */
67
@@ -794,7 +801,6 @@
68
 sgw_ue_t *sgw_ue_add(mme_sgw_t *sgw);
69
 void sgw_ue_remove(sgw_ue_t *sgw_ue);
70
 void sgw_ue_switch_to_sgw(sgw_ue_t *sgw_ue, mme_sgw_t *new_sgw);
71
-sgw_ue_t *sgw_ue_find(uint32_t index);
72
 sgw_ue_t *sgw_ue_cycle(sgw_ue_t *sgw_ue);
73
 
74
 typedef enum {
75
@@ -923,7 +929,6 @@
76
 
77
 int mme_find_served_tai(ogs_eps_tai_t *tai);
78
 
79
-int mme_m_tmsi_pool_generate(void);
80
 mme_m_tmsi_t *mme_m_tmsi_alloc(void);
81
 int mme_m_tmsi_free(mme_m_tmsi_t *tmsi);
82
 
83
open5gs_2.6.2.tar.xz/src/mme/mme-init.c -> open5gs_2.6.3.tar.xz/src/mme/mme-init.c Changed
11
 
1
@@ -61,9 +61,6 @@
2
             ogs_app()->logger.domain, ogs_app()->logger.level);
3
     if (rv != OGS_OK) return rv;
4
 
5
-    rv = mme_m_tmsi_pool_generate();
6
-    if (rv != OGS_OK) return rv;
7
-
8
     ogs_metrics_context_open(ogs_metrics_self());
9
 
10
     rv = mme_fd_init();
11
open5gs_2.6.2.tar.xz/src/mme/mme-s11-build.c -> open5gs_2.6.3.tar.xz/src/mme/mme-s11-build.c Changed
23
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -253,7 +253,13 @@
9
         req->aggregate_maximum_bit_rate.len = sizeof(ambr);
10
     }
11
 
12
-    if (sess->ue_pco.length && sess->ue_pco.buffer) {
13
+    if (sess->ue_epco.length && sess->ue_epco.buffer) {
14
+        req->extended_protocol_configuration_options.presence = 1;
15
+        req->extended_protocol_configuration_options.data =
16
+            sess->ue_epco.buffer;
17
+        req->extended_protocol_configuration_options.len =
18
+            sess->ue_epco.length;
19
+    } else if (sess->ue_pco.length && sess->ue_pco.buffer) {
20
         req->protocol_configuration_options.presence = 1;
21
         req->protocol_configuration_options.data = sess->ue_pco.buffer;
22
         req->protocol_configuration_options.len = sess->ue_pco.length;
23
open5gs_2.6.2.tar.xz/src/mme/mme-s11-handler.c -> open5gs_2.6.3.tar.xz/src/mme/mme-s11-handler.c Changed
23
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -373,8 +373,13 @@
9
                 rsp->pdn_address_allocation.len);
10
     }
11
 
12
+    /* ePCO */
13
+    if (rsp->extended_protocol_configuration_options.presence) {
14
+        OGS_TLV_STORE_DATA(&sess->pgw_epco,
15
+                &rsp->extended_protocol_configuration_options);
16
+
17
     /* PCO */
18
-    if (rsp->protocol_configuration_options.presence) {
19
+    } else if (rsp->protocol_configuration_options.presence) {
20
         OGS_TLV_STORE_DATA(&sess->pgw_pco,
21
                 &rsp->protocol_configuration_options);
22
     }
23
open5gs_2.6.2.tar.xz/src/nssf/context.c -> open5gs_2.6.3.tar.xz/src/nssf/context.c Changed
17
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -110,7 +110,7 @@
9
                         int family = AF_UNSPEC;
10
                         int i, num = 0;
11
                         const char *hostnameOGS_MAX_NUM_OF_HOSTNAME;
12
-                        uint16_t port = ogs_sbi_self()->sbi_port;
13
+                        uint16_t port = ogs_sbi_server_default_port();
14
                         const char *dev = NULL;
15
                         ogs_sockaddr_t *addr = NULL;
16
                         const char *sst = NULL, *sd = NULL;
17
open5gs_2.6.2.tar.xz/src/pcf/nbsf-build.c -> open5gs_2.6.3.tar.xz/src/pcf/nbsf-build.c Changed
17
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -121,7 +121,7 @@
9
                     goto end;
10
                 }
11
             }
12
-            IpEndPoint->is_port = true;
13
+            IpEndPoint->is_port = nf_service->addri.is_port;
14
             IpEndPoint->port = nf_service->addri.port;
15
             OpenAPI_list_add(PcfIpEndPointList, IpEndPoint);
16
         }
17
open5gs_2.6.2.tar.xz/src/sgwc/context.c -> open5gs_2.6.3.tar.xz/src/sgwc/context.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -25,11 +25,15 @@
9
 
10
 int __sgwc_log_domain;
11
 
12
-static OGS_POOL(sgwc_ue_pool, sgwc_ue_t);
13
-static OGS_POOL(sgwc_sess_pool, sgwc_sess_t);
14
 static OGS_POOL(sgwc_bearer_pool, sgwc_bearer_t);
15
 static OGS_POOL(sgwc_tunnel_pool, sgwc_tunnel_t);
16
 
17
+static OGS_POOL(sgwc_ue_pool, sgwc_ue_t);
18
+static OGS_POOL(sgwc_s11_teid_pool, ogs_pool_id_t);
19
+
20
+static OGS_POOL(sgwc_sess_pool, sgwc_sess_t);
21
+static OGS_POOL(sgwc_sxa_seid_pool, ogs_pool_id_t);
22
+
23
 static int context_initialized = 0;
24
 
25
 static int num_of_sgwc_sess = 0;
26
@@ -45,13 +49,23 @@
27
 
28
     ogs_log_install_domain(&__sgwc_log_domain, "sgwc", ogs_core()->log.level);
29
 
30
-    ogs_pool_init(&sgwc_ue_pool, ogs_app()->max.ue);
31
-    ogs_pool_init(&sgwc_sess_pool, ogs_app()->pool.sess);
32
     ogs_pool_init(&sgwc_bearer_pool, ogs_app()->pool.bearer);
33
     ogs_pool_init(&sgwc_tunnel_pool, ogs_app()->pool.tunnel);
34
 
35
+    ogs_pool_init(&sgwc_ue_pool, ogs_app()->max.ue);
36
+    ogs_pool_init(&sgwc_s11_teid_pool, ogs_app()->max.ue);
37
+    ogs_pool_random_id_generate(&sgwc_s11_teid_pool);
38
+
39
+    ogs_pool_init(&sgwc_sess_pool, ogs_app()->pool.sess);
40
+    ogs_pool_init(&sgwc_sxa_seid_pool, ogs_app()->pool.sess);
41
+    ogs_pool_random_id_generate(&sgwc_sxa_seid_pool);
42
+
43
     self.imsi_ue_hash = ogs_hash_make();
44
     ogs_assert(self.imsi_ue_hash);
45
+    self.sgw_s11_teid_hash = ogs_hash_make();
46
+    ogs_assert(self.sgw_s11_teid_hash);
47
+    self.sgwc_sxa_seid_hash = ogs_hash_make();
48
+    ogs_assert(self.sgwc_sxa_seid_hash);
49
 
50
     ogs_list_init(&self.sgw_ue_list);
51
 
52
@@ -66,11 +80,19 @@
53
 
54
     ogs_assert(self.imsi_ue_hash);
55
     ogs_hash_destroy(self.imsi_ue_hash);
56
+    ogs_assert(self.sgw_s11_teid_hash);
57
+    ogs_hash_destroy(self.sgw_s11_teid_hash);
58
+    ogs_assert(self.sgwc_sxa_seid_hash);
59
+    ogs_hash_destroy(self.sgwc_sxa_seid_hash);
60
 
61
     ogs_pool_final(&sgwc_tunnel_pool);
62
     ogs_pool_final(&sgwc_bearer_pool);
63
-    ogs_pool_final(&sgwc_sess_pool);
64
+
65
     ogs_pool_final(&sgwc_ue_pool);
66
+    ogs_pool_final(&sgwc_s11_teid_pool);
67
+
68
+    ogs_pool_final(&sgwc_sess_pool);
69
+    ogs_pool_final(&sgwc_sxa_seid_pool);
70
 
71
     ogs_gtp_node_remove_all(&self.mme_s11_list);
72
     ogs_gtp_node_remove_all(&self.pgw_s5c_list);
73
@@ -192,9 +214,14 @@
74
     ogs_assert(sgwc_ue);
75
     memset(sgwc_ue, 0, sizeof *sgwc_ue);
76
 
77
-    sgwc_ue->sgw_s11_teid = ogs_pool_index(&sgwc_ue_pool, sgwc_ue);
78
-    ogs_assert(sgwc_ue->sgw_s11_teid > 0 &&
79
-                sgwc_ue->sgw_s11_teid <= ogs_app()->max.ue);
80
+    /* Set SGW-S11-TEID */
81
+    ogs_pool_alloc(&sgwc_s11_teid_pool, &sgwc_ue->sgw_s11_teid_node);
82
+    ogs_assert(sgwc_ue->sgw_s11_teid_node);
83
+
84
+    sgwc_ue->sgw_s11_teid = *(sgwc_ue->sgw_s11_teid_node);
85
+
86
+    ogs_hash_set(self.sgw_s11_teid_hash,
87
+            &sgwc_ue->sgw_s11_teid, sizeof(sgwc_ue->sgw_s11_teid), sgwc_ue);
88
 
89
     /* Set IMSI */
90
     sgwc_ue->imsi_len = imsi_len;
91
@@ -219,10 +246,13 @@
92
 
93
     ogs_list_remove(&self.sgw_ue_list, sgwc_ue);
94
 
95
+    ogs_hash_set(self.sgw_s11_teid_hash,
96
+            &sgwc_ue->sgw_s11_teid, sizeof(sgwc_ue->sgw_s11_teid), NULL);
97
     ogs_hash_set(self.imsi_ue_hash, sgwc_ue->imsi, sgwc_ue->imsi_len, NULL);
98
 
99
     sgwc_sess_remove_all(sgwc_ue);
100
 
101
+    ogs_pool_free(&sgwc_s11_teid_pool, sgwc_ue->sgw_s11_teid_node);
102
     ogs_pool_free(&sgwc_ue_pool, sgwc_ue);
103
 
104
     ogs_info("Removed Number of SGWC-UEs is now %d",
105
@@ -255,12 +285,12 @@
106
 {
107
     ogs_assert(imsi && imsi_len);
108
 
109
-    return (sgwc_ue_t *)ogs_hash_get(self.imsi_ue_hash, imsi, imsi_len);
110
+    return ogs_hash_get(self.imsi_ue_hash, imsi, imsi_len);
111
 }
112
 
113
 sgwc_ue_t *sgwc_ue_find_by_teid(uint32_t teid)
114
 {
115
-    return ogs_pool_find(&sgwc_ue_pool, teid);
116
+    return ogs_hash_get(self.sgw_s11_teid_hash, &teid, sizeof(teid));
117
 }
118
 
119
 sgwc_sess_t *sgwc_sess_add(sgwc_ue_t *sgwc_ue, char *apn)
120
@@ -279,12 +309,15 @@
121
 
122
     ogs_pfcp_pool_init(&sess->pfcp);
123
 
124
-    sess->index = ogs_pool_index(&sgwc_sess_pool, sess);
125
-    ogs_assert(sess->index > 0 && sess->index <= ogs_app()->pool.sess);
126
-
127
     /* Set TEID & SEID */
128
-    sess->sgw_s5c_teid = sess->index;
129
-    sess->sgwc_sxa_seid = sess->index;
130
+    ogs_pool_alloc(&sgwc_sxa_seid_pool, &sess->sgwc_sxa_seid_node);
131
+    ogs_assert(sess->sgwc_sxa_seid_node);
132
+
133
+    sess->sgw_s5c_teid = *(sess->sgwc_sxa_seid_node);
134
+    sess->sgwc_sxa_seid = *(sess->sgwc_sxa_seid_node);
135
+
136
+    ogs_hash_set(self.sgwc_sxa_seid_hash,
137
+            &sess->sgwc_sxa_seid, sizeof(sess->sgwc_sxa_seid), sess);
138
 
139
     /* Create BAR in PFCP Session */
140
     ogs_pfcp_bar_new(&sess->pfcp);
141
@@ -400,6 +433,9 @@
142
 
143
     ogs_list_remove(&sgwc_ue->sess_list, sess);
144
 
145
+    ogs_hash_set(self.sgwc_sxa_seid_hash, &sess->sgwc_sxa_seid,
146
+            sizeof(sess->sgwc_sxa_seid), NULL);
147
+
148
     sgwc_bearer_remove_all(sess);
149
 
150
     ogs_assert(sess->pfcp.bar);
151
@@ -410,6 +446,7 @@
152
     ogs_assert(sess->session.name);
153
     ogs_free(sess->session.name);
154
 
155
+    ogs_pool_free(&sgwc_sxa_seid_pool, sess->sgwc_sxa_seid_node);
156
     ogs_pool_free(&sgwc_sess_pool, sess);
157
 
158
     stats_remove_sgwc_session();
159
@@ -426,19 +463,14 @@
160
         sgwc_sess_remove(sess);
161
 }
162
 
163
-sgwc_sess_t *sgwc_sess_find(uint32_t index)
164
-{
165
-    return ogs_pool_find(&sgwc_sess_pool, index);
166
-}
167
-
168
 sgwc_sess_t* sgwc_sess_find_by_teid(uint32_t teid)
169
 {
170
-    return ogs_pool_find(&sgwc_sess_pool, teid);
171
+    return sgwc_sess_find_by_seid(teid);
172
 }
173
 
174
 sgwc_sess_t *sgwc_sess_find_by_seid(uint64_t seid)
175
 {
176
-    return sgwc_sess_find(seid);
177
+    return ogs_hash_get(self.sgwc_sxa_seid_hash, &seid, sizeof(seid));
178
 }
179
 
180
 sgwc_sess_t* sgwc_sess_find_by_apn(sgwc_ue_t *sgwc_ue, char *apn)
181
@@ -578,71 +610,6 @@
182
     return NULL;
183
 }
184
 
185
-sgwc_bearer_t *sgwc_bearer_find_by_error_indication_report(
186
-        sgwc_sess_t *sess,
187
-        ogs_pfcp_tlv_error_indication_report_t *error_indication_report)
188
-{
189
-    ogs_pfcp_f_teid_t *remote_f_teid = NULL;
190
-    sgwc_bearer_t *bearer = NULL;
191
-    sgwc_tunnel_t *tunnel = NULL;
192
-
193
-    uint32_t teid;
194
-    uint16_t len;  /* OGS_IPV4_LEN or OGS_IPV6_LEN */
195
-    uint32_t addr4;
196
-
197
-    ogs_assert(sess);
198
-    ogs_assert(error_indication_report);
199
-
200
-    if (error_indication_report->presence == 0) {
201
open5gs_2.6.2.tar.xz/src/sgwc/context.h -> open5gs_2.6.3.tar.xz/src/sgwc/context.h Changed
90
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -39,18 +39,21 @@
9
 typedef struct sgwc_tunnel_s sgwc_tunnel_t;
10
 
11
 typedef struct sgwc_context_s {
12
-    ogs_list_t      mme_s11_list;   /* MME GTPC Node List */
13
-    ogs_list_t      pgw_s5c_list;   /* PGW GTPC Node List */
14
+    ogs_list_t mme_s11_list;    /* MME GTPC Node List */
15
+    ogs_list_t pgw_s5c_list;    /* PGW GTPC Node List */
16
 
17
-    ogs_hash_t      *imsi_ue_hash;  /* hash table (IMSI : SGW_UE) */
18
+    ogs_hash_t *imsi_ue_hash;   /* hash table (IMSI : SGW_UE) */
19
+    ogs_hash_t *sgw_s11_teid_hash;  /* hash table (SGW-S11-TEID : SGW_UE) */
20
+    ogs_hash_t *sgwc_sxa_seid_hash; /* hash table (SGWC-SXA-SEID : Session) */
21
 
22
-    ogs_list_t      sgw_ue_list;    /* SGW_UE List */
23
+    ogs_list_t sgw_ue_list;    /* SGW_UE List */
24
 } sgwc_context_t;
25
 
26
 typedef struct sgwc_ue_s {
27
     ogs_lnode_t     lnode;
28
+    ogs_pool_id_t   *sgw_s11_teid_node; /* A node of SGW-S11-TEID */
29
 
30
-    uint32_t        sgw_s11_teid;   /* SGW-S11-TEID is derived from INDEX */
31
+    uint32_t        sgw_s11_teid;   /* SGW-S11-TEID is derived from NODE */
32
     uint32_t        mme_s11_teid;   /* MME-S11-TEID is received from MME */
33
 
34
     /* UE identity */
35
@@ -70,15 +73,15 @@
36
 
37
 #define SGWC_SESS(pfcp_sess) ogs_container_of(pfcp_sess, sgwc_sess_t, pfcp)
38
 typedef struct sgwc_sess_s {
39
-    ogs_lnode_t     lnode;          /* A node of list_t */
40
-    uint32_t        index;          /**< An index of this node */
41
+    ogs_lnode_t     lnode;                  /* A node of list_t */
42
+    ogs_pool_id_t   *sgwc_sxa_seid_node;    /* A node of SGWC-SXA-SEID */
43
 
44
     ogs_pfcp_sess_t pfcp;           /* PFCP session context */
45
 
46
-    uint32_t        sgw_s5c_teid;   /* SGW-S5C-TEID is derived from INDEX */
47
+    uint32_t        sgw_s5c_teid;   /* SGW-S5C-TEID is derived from NODE */
48
     uint32_t        pgw_s5c_teid;   /* PGW-S5C-TEID is received from PGW */
49
 
50
-    uint64_t        sgwc_sxa_seid;  /* SGW-C SEID is dervied from INDEX */
51
+    uint64_t        sgwc_sxa_seid;  /* SGW-C SEID is dervied from NODE */
52
     uint64_t        sgwu_sxa_seid;  /* SGW-U SEID is received from Peer */
53
 
54
     /* APN Configuration */
55
@@ -106,7 +109,6 @@
56
 
57
 typedef struct sgwc_tunnel_s {
58
     ogs_lnode_t     lnode;
59
-    uint32_t        index;          /**< An index of this node */
60
 
61
     uint8_t         interface_type;
62
 
63
@@ -147,7 +149,6 @@
64
 int sgwc_sess_remove(sgwc_sess_t *sess);
65
 void sgwc_sess_remove_all(sgwc_ue_t *sgwc_ue);
66
 
67
-sgwc_sess_t *sgwc_sess_find(uint32_t index);
68
 sgwc_sess_t *sgwc_sess_find_by_teid(uint32_t teid);
69
 sgwc_sess_t *sgwc_sess_find_by_seid(uint64_t seid);
70
 
71
@@ -167,9 +168,6 @@
72
                                 sgwc_sess_t *sess, uint8_t ebi);
73
 sgwc_bearer_t *sgwc_bearer_find_by_ue_ebi(
74
                                 sgwc_ue_t *sgwc_ue, uint8_t ebi);
75
-sgwc_bearer_t *sgwc_bearer_find_by_error_indication_report(
76
-        sgwc_sess_t *sess,
77
-        ogs_pfcp_tlv_error_indication_report_t *error_indication_report);
78
 sgwc_bearer_t *sgwc_default_bearer_in_sess(sgwc_sess_t *sess);
79
 sgwc_bearer_t *sgwc_bearer_cycle(sgwc_bearer_t *bearer);
80
 
81
@@ -182,6 +180,8 @@
82
         sgwc_bearer_t *bearer, uint8_t interface_type);
83
 sgwc_tunnel_t *sgwc_tunnel_find_by_pdr_id(
84
         sgwc_sess_t *sess, ogs_pfcp_pdr_id_t pdr_id);
85
+sgwc_tunnel_t *sgwc_tunnel_find_by_far_id(
86
+        sgwc_sess_t *sess, ogs_pfcp_far_id_t far_id);
87
 sgwc_tunnel_t *sgwc_dl_tunnel_in_bearer(sgwc_bearer_t *bearer);
88
 sgwc_tunnel_t *sgwc_ul_tunnel_in_bearer(sgwc_bearer_t *bearer);
89
 
90
open5gs_2.6.2.tar.xz/src/sgwc/gtp-path.c -> open5gs_2.6.3.tar.xz/src/sgwc/gtp-path.c Changed
8
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
open5gs_2.6.2.tar.xz/src/sgwc/pfcp-path.c -> open5gs_2.6.3.tar.xz/src/sgwc/pfcp-path.c Changed
59
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -238,7 +238,8 @@
9
 }
10
 
11
 int sgwc_pfcp_send_session_establishment_request(
12
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf)
13
+        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf,
14
+        uint64_t flags)
15
 {
16
     int rv;
17
     ogs_pkbuf_t *sxabuf = NULL;
18
@@ -262,9 +263,40 @@
19
         }
20
     }
21
     xact->local_seid = sess->sgwc_sxa_seid;
22
+    xact->create_flags = flags;
23
 
24
     memset(&h, 0, sizeof(ogs_pfcp_header_t));
25
     h.type = OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE;
26
+
27
+/*
28
+ * 7.2.2.4.2 Conditions for Sending SEID=0 in PFCP Header
29
+ *
30
+ * If a peer's SEID is not available, the SEID field shall still be present
31
+ * in the header and its value shall be set to "0" in the following messages:
32
+ *
33
+ * - PFCP Session Establishment Request message on Sxa/Sxb/Sxc/N4;
34
+ *
35
+ * - If a node receives a message for which it has no session, i.e.
36
+ *   if SEID in the PFCP header is not known, it shall respond
37
+ *   with "Session context not found" cause in the corresponding
38
+ *   response message to the sender, the SEID used in the PFCP header
39
+ *   in the response message shall be then set to "0";
40
+ *
41
+ * - If a node receives a request message containing protocol error,
42
+ *   e.g. Mandatory IE missing, which requires the receiver
43
+ *   to reject the message as specified in clause 7.6, it shall reject
44
+ *   the request message. For the response message, the node should look up
45
+ *   the remote peer's SEID and accordingly set SEID in the PFCP header
46
+ *   and the message cause code. As an implementation option,
47
+ *   the node may not look up the remote peer's SEID and
48
+ *   set the PFCP header SEID to "0" in the response message.
49
+ *   However in this case, the cause value shall not be set
50
+ *   to "Session not found".
51
+ *
52
+ * - When the UP function sends PFCP Session Report Request message
53
+ *   over N4 towards another SMF or another PFCP entity in the SMF
54
+ *   as specified in clause 5.22.2 and clause 5.22.3.
55
+ */
56
     h.seid = sess->sgwu_sxa_seid;
57
 
58
     sxabuf = sgwc_sxa_build_session_establishment_request(h.type, sess);
59
open5gs_2.6.2.tar.xz/src/sgwc/pfcp-path.h -> open5gs_2.6.3.tar.xz/src/sgwc/pfcp-path.h Changed
18
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -33,7 +33,8 @@
9
         sgwc_sess_t *sess, ogs_pfcp_xact_t *xact);
10
 
11
 int sgwc_pfcp_send_session_establishment_request(
12
-        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf);
13
+        sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact, ogs_pkbuf_t *gtpbuf,
14
+        uint64_t flags);
15
 
16
 int sgwc_pfcp_send_session_modification_request(
17
         sgwc_sess_t *sess, ogs_gtp_xact_t *gtp_xact,
18
open5gs_2.6.2.tar.xz/src/sgwc/pfcp-sm.c -> open5gs_2.6.3.tar.xz/src/sgwc/pfcp-sm.c Changed
132
 
1
@@ -20,6 +20,7 @@
2
 #include "pfcp-path.h"
3
 #include "sxa-handler.h"
4
 
5
+static void pfcp_restoration(ogs_pfcp_node_t *node);
6
 static void node_timeout(ogs_pfcp_xact_t *xact, void *data);
7
 
8
 void sgwc_pfcp_state_initial(ogs_fsm_t *s, sgwc_event_t *e)
9
@@ -188,6 +189,7 @@
10
             ogs_pfcp_send_heartbeat_request(node, node_timeout));
11
 
12
         if (node->restoration_required == true) {
13
+            pfcp_restoration(node);
14
             node->restoration_required = false;
15
             ogs_error("PFCP restoration");
16
         }
17
@@ -220,11 +222,56 @@
18
             ogs_expect(true ==
19
                 ogs_pfcp_handle_heartbeat_request(node, xact,
20
                     &message->pfcp_heartbeat_request));
21
+            if (node->restoration_required == true) {
22
+                if (node->t_association) {
23
+        /*
24
+         * node->t_association that the PFCP entity attempts an association.
25
+         *
26
+         * In this case, even if Remote PFCP entity is restarted,
27
+         * PFCP restoration must be performed after PFCP association.
28
+         *
29
+         * Otherwise, Session related PFCP cannot be initiated
30
+         * because the peer PFCP entity is in a de-associated state.
31
+         */
32
+                    OGS_FSM_TRAN(s, sgwc_pfcp_state_will_associate);
33
+                } else {
34
+
35
+        /*
36
+         * If the peer PFCP entity is performing the association,
37
+         * Restoration can be performed immediately.
38
+         */
39
+                    pfcp_restoration(node);
40
+                    node->restoration_required = false;
41
+                    ogs_error("PFCP restoration");
42
+                }
43
+            }
44
             break;
45
         case OGS_PFCP_HEARTBEAT_RESPONSE_TYPE:
46
             ogs_expect(true ==
47
                 ogs_pfcp_handle_heartbeat_response(node, xact,
48
                     &message->pfcp_heartbeat_response));
49
+            if (node->restoration_required == true) {
50
+        /*
51
+         * node->t_association that the PFCP entity attempts an association.
52
+         *
53
+         * In this case, even if Remote PFCP entity is restarted,
54
+         * PFCP restoration must be performed after PFCP association.
55
+         *
56
+         * Otherwise, Session related PFCP cannot be initiated
57
+         * because the peer PFCP entity is in a de-associated state.
58
+         */
59
+                if (node->t_association) {
60
+                    OGS_FSM_TRAN(s, sgwc_pfcp_state_will_associate);
61
+                } else {
62
+        /*
63
+         * If the peer PFCP entity is performing the association,
64
+         * Restoration can be performed immediately.
65
+         */
66
+                    pfcp_restoration(node);
67
+                    node->restoration_required = false;
68
+                    ogs_error("PFCP restoration");
69
+                }
70
+            }
71
             break;
72
         case OGS_PFCP_ASSOCIATION_SETUP_REQUEST_TYPE:
73
             ogs_warn("PFCPREQ has already been associated %s:%d",
74
@@ -243,9 +290,24 @@
75
         case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
76
             if (!message->h.seid_presence) ogs_error("No SEID");
77
 
78
-            sgwc_sxa_handle_session_establishment_response(
79
-                sess, xact, e->gtp_message,
80
-                &message->pfcp_session_establishment_response);
81
+            if ((xact->create_flags &
82
+                        OGS_PFCP_CREATE_RESTORATION_INDICATION)) {
83
+                ogs_pfcp_session_establishment_response_t *rsp = NULL;
84
+                ogs_pfcp_f_seid_t *up_f_seid = NULL;
85
+
86
+                rsp = &message->pfcp_session_establishment_response;
87
+                if (rsp->up_f_seid.presence == 0) {
88
+                    ogs_error("No UP F-SEID");
89
+                    break;
90
+                }
91
+                up_f_seid = rsp->up_f_seid.data;
92
+                ogs_assert(up_f_seid);
93
+                sess->sgwu_sxa_seid = be64toh(up_f_seid->seid);
94
+            } else {
95
+                sgwc_sxa_handle_session_establishment_response(
96
+                    sess, xact, e->gtp_message,
97
+                    &message->pfcp_session_establishment_response);
98
+            }
99
             break;
100
 
101
         case OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE:
102
@@ -326,6 +388,29 @@
103
     }
104
 }
105
 
106
+static void pfcp_restoration(ogs_pfcp_node_t *node)
107
+{
108
+    sgwc_ue_t *sgwc_ue = NULL;
109
+
110
+    ogs_list_for_each(&sgwc_self()->sgw_ue_list, sgwc_ue) {
111
+        sgwc_sess_t *sess = NULL;
112
+        ogs_assert(sgwc_ue);
113
+
114
+        ogs_list_for_each(&sgwc_ue->sess_list, sess) {
115
+            ogs_assert(sess);
116
+
117
+            if (node == sess->pfcp_node) {
118
+                ogs_info("UE IMSI%s APN%s",
119
+                    sgwc_ue->imsi_bcd, sess->session.name);
120
+                ogs_assert(OGS_OK ==
121
+                    sgwc_pfcp_send_session_establishment_request(
122
+                        sess, NULL, NULL,
123
+                        OGS_PFCP_CREATE_RESTORATION_INDICATION));
124
+            }
125
+        }
126
+    }
127
+}
128
+
129
 static void node_timeout(ogs_pfcp_xact_t *xact, void *data)
130
 {
131
     int rv;
132
open5gs_2.6.2.tar.xz/src/sgwc/s11-handler.c -> open5gs_2.6.3.tar.xz/src/sgwc/s11-handler.c Changed
27
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -234,6 +234,8 @@
9
     sess = sgwc_sess_add(sgwc_ue, apn);
10
     ogs_assert(sess);
11
 
12
+    ogs_info("UE IMSI%s APN%s", sgwc_ue->imsi_bcd, sess->session.name);
13
+
14
     /* Set User Location Information */
15
     if (req->user_location_information.presence == 1) {
16
         decoded = ogs_gtp2_parse_uli(&uli, &req->user_location_information);
17
@@ -376,7 +378,8 @@
18
         sgwc_ue->mme_s11_teid, sgwc_ue->sgw_s11_teid);
19
 
20
     ogs_assert(OGS_OK ==
21
-        sgwc_pfcp_send_session_establishment_request(sess, s11_xact, gtpbuf));
22
+        sgwc_pfcp_send_session_establishment_request(
23
+            sess, s11_xact, gtpbuf, 0));
24
 }
25
 
26
 void sgwc_s11_handle_modify_bearer_request(
27
open5gs_2.6.2.tar.xz/src/sgwc/sxa-handler.c -> open5gs_2.6.3.tar.xz/src/sgwc/sxa-handler.c Changed
101
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -1297,10 +1297,7 @@
9
 
10
     ogs_pfcp_xact_commit(pfcp_xact);
11
 
12
-    if (!gtp_message) {
13
-        ogs_error("No GTP Message");
14
-        goto cleanup;
15
-    }
16
+    if (!gtp_message) goto cleanup;
17
 
18
     if (gtp_message->h.type == OGS_GTP2_DELETE_SESSION_REQUEST_TYPE) {
19
         /*
20
@@ -1380,7 +1377,10 @@
21
     }
22
 
23
 cleanup:
24
-    sgwc_sess_remove(sess);
25
+    if (sgwc_sess_cycle(sess))
26
+        sgwc_sess_remove(sess);
27
+    else
28
+        ogs_error("Session has already been removed");
29
 }
30
 
31
 void sgwc_sxa_handle_session_report_request(
32
@@ -1390,6 +1390,7 @@
33
     sgwc_ue_t *sgwc_ue = NULL;
34
     sgwc_bearer_t *bearer = NULL;
35
     sgwc_tunnel_t *tunnel = NULL;
36
+    ogs_pfcp_far_t *far = NULL;
37
 
38
     ogs_pfcp_report_type_t report_type;
39
     uint8_t cause_value = 0;
40
@@ -1470,22 +1471,44 @@
41
         ogs_error("Cannot find the PDR-ID%d", pdr_id);
42
 
43
     } else if (report_type.error_indication_report) {
44
-        bearer = sgwc_bearer_find_by_error_indication_report(
45
-                sess, &pfcp_req->error_indication_report);
46
-
47
-        if (!bearer) return;
48
-
49
-        ogs_list_for_each(&sgwc_ue->sess_list, sess) {
50
-
51
-            ogs_assert(OGS_OK ==
52
-                sgwc_pfcp_send_session_modification_request(sess,
53
-                /* We only use the `assoc_xact` parameter temporarily here
54
-                 * to pass the `bearer` context. */
55
-                    (ogs_gtp_xact_t *)bearer,
56
-                    NULL,
57
-                    OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE|
58
-                    OGS_PFCP_MODIFY_ERROR_INDICATION));
59
-        }
60
+        far = ogs_pfcp_far_find_by_pfcp_session_report(
61
+                &sess->pfcp, &pfcp_req->error_indication_report);
62
+        if (far) {
63
+            tunnel = sgwc_tunnel_find_by_far_id(sess, far->id);
64
+            ogs_assert(tunnel);
65
+            bearer = tunnel->bearer;
66
+            ogs_assert(bearer);
67
+            if (far->dst_if == OGS_PFCP_INTERFACE_ACCESS) {
68
+                ogs_warn("%s Error Indication from eNB", sgwc_ue->imsi_bcd);
69
+                ogs_list_for_each(&sgwc_ue->sess_list, sess) {
70
+                    ogs_assert(OGS_OK ==
71
+                        sgwc_pfcp_send_session_modification_request(sess,
72
+                    /* We only use the `assoc_xact` parameter temporarily here
73
+                     * to pass the `bearer` context. */
74
+                            (ogs_gtp_xact_t *)bearer,
75
+                            NULL,
76
+                            OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE|
77
+                            OGS_PFCP_MODIFY_ERROR_INDICATION));
78
+                }
79
+            } else if (far->dst_if == OGS_PFCP_INTERFACE_CORE) {
80
+                if (sgwc_default_bearer_in_sess(sess) == bearer) {
81
+                    ogs_error("%s Error Indication(Default Bearer) from SMF",
82
+                                sgwc_ue->imsi_bcd);
83
+                    ogs_assert(OGS_OK ==
84
+                        sgwc_pfcp_send_session_deletion_request(
85
+                            sess, NULL, NULL));
86
+                } else {
87
+                    ogs_error("%s Error Indication(Dedicated Bearer) "
88
+                            "from SMF", sgwc_ue->imsi_bcd);
89
+                    ogs_assert(OGS_OK ==
90
+                        sgwc_pfcp_send_bearer_modification_request(
91
+                            bearer, NULL, NULL, OGS_PFCP_MODIFY_REMOVE));
92
+                }
93
+            } else {
94
+                ogs_error("Error Indication Ignored for Indirect Tunnel");
95
+            }
96
+        } else
97
+            ogs_error("Cannot find Session in Error Indication");
98
 
99
     } else {
100
         ogs_error("Not supported Report Type%d", report_type.value);
101
open5gs_2.6.2.tar.xz/src/sgwu/context.c -> open5gs_2.6.3.tar.xz/src/sgwu/context.c Changed
149
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -24,6 +24,7 @@
9
 int __sgwu_log_domain;
10
 
11
 static OGS_POOL(sgwu_sess_pool, sgwu_sess_t);
12
+static OGS_POOL(sgwu_sxa_seid_pool, ogs_pool_id_t);
13
 
14
 static int context_initialized = 0;
15
 
16
@@ -43,11 +44,15 @@
17
 
18
     ogs_list_init(&self.sess_list);
19
     ogs_pool_init(&sgwu_sess_pool, ogs_app()->pool.sess);
20
+    ogs_pool_init(&sgwu_sxa_seid_pool, ogs_app()->pool.sess);
21
+    ogs_pool_random_id_generate(&sgwu_sxa_seid_pool);
22
 
23
-    self.seid_hash = ogs_hash_make();
24
-    ogs_assert(self.seid_hash);
25
-    self.f_seid_hash = ogs_hash_make();
26
-    ogs_assert(self.f_seid_hash);
27
+    self.sgwu_sxa_seid_hash = ogs_hash_make();
28
+    ogs_assert(self.sgwu_sxa_seid_hash);
29
+    self.sgwc_sxa_seid_hash = ogs_hash_make();
30
+    ogs_assert(self.sgwc_sxa_seid_hash);
31
+    self.sgwc_sxa_f_seid_hash = ogs_hash_make();
32
+    ogs_assert(self.sgwc_sxa_f_seid_hash);
33
 
34
     context_initialized = 1;
35
 }
36
@@ -58,12 +63,15 @@
37
 
38
     sgwu_sess_remove_all();
39
 
40
-    ogs_assert(self.seid_hash);
41
-    ogs_hash_destroy(self.seid_hash);
42
-    ogs_assert(self.f_seid_hash);
43
-    ogs_hash_destroy(self.f_seid_hash);
44
+    ogs_assert(self.sgwu_sxa_seid_hash);
45
+    ogs_hash_destroy(self.sgwu_sxa_seid_hash);
46
+    ogs_assert(self.sgwc_sxa_seid_hash);
47
+    ogs_hash_destroy(self.sgwc_sxa_seid_hash);
48
+    ogs_assert(self.sgwc_sxa_f_seid_hash);
49
+    ogs_hash_destroy(self.sgwc_sxa_f_seid_hash);
50
 
51
     ogs_pool_final(&sgwu_sess_pool);
52
+    ogs_pool_final(&sgwu_sxa_seid_pool);
53
 
54
     context_initialized = 0;
55
 }
56
@@ -137,10 +145,14 @@
57
 
58
     ogs_pfcp_pool_init(&sess->pfcp);
59
 
60
-    sess->index = ogs_pool_index(&sgwu_sess_pool, sess);
61
-    ogs_assert(sess->index > 0 && sess->index <= ogs_app()->pool.sess);
62
+    /* Set SEID */
63
+    ogs_pool_alloc(&sgwu_sxa_seid_pool, &sess->sgwu_sxa_seid_node);
64
+    ogs_assert(sess->sgwu_sxa_seid_node);
65
 
66
-    sess->sgwu_sxa_seid = sess->index;
67
+    sess->sgwu_sxa_seid = *(sess->sgwu_sxa_seid_node);
68
+
69
+    ogs_hash_set(self.sgwu_sxa_seid_hash, &sess->sgwu_sxa_seid,
70
+            sizeof(sess->sgwu_sxa_seid), sess);
71
 
72
     /* Since F-SEID is composed of ogs_ip_t and uint64-seid,
73
      * all these values must be put into the structure-sgwc_sxa_f_eid
74
@@ -149,9 +161,9 @@
75
     ogs_assert(OGS_OK ==
76
             ogs_pfcp_f_seid_to_ip(cp_f_seid, &sess->sgwc_sxa_f_seid.ip));
77
 
78
-    ogs_hash_set(self.f_seid_hash, &sess->sgwc_sxa_f_seid,
79
+    ogs_hash_set(self.sgwc_sxa_f_seid_hash, &sess->sgwc_sxa_f_seid,
80
             sizeof(sess->sgwc_sxa_f_seid), sess);
81
-    ogs_hash_set(self.seid_hash, &sess->sgwc_sxa_f_seid.seid,
82
+    ogs_hash_set(self.sgwc_sxa_seid_hash, &sess->sgwc_sxa_f_seid.seid,
83
             sizeof(sess->sgwc_sxa_f_seid.seid), sess);
84
 
85
     ogs_info("UE F-SEIDUP:0x%lx CP:0x%lx",
86
@@ -172,13 +184,17 @@
87
     ogs_list_remove(&self.sess_list, sess);
88
     ogs_pfcp_sess_clear(&sess->pfcp);
89
 
90
-    ogs_hash_set(self.seid_hash, &sess->sgwc_sxa_f_seid.seid,
91
+    ogs_hash_set(self.sgwu_sxa_seid_hash, &sess->sgwu_sxa_seid,
92
+            sizeof(sess->sgwu_sxa_seid), NULL);
93
+
94
+    ogs_hash_set(self.sgwc_sxa_seid_hash, &sess->sgwc_sxa_f_seid.seid,
95
             sizeof(sess->sgwc_sxa_f_seid.seid), NULL);
96
-    ogs_hash_set(self.f_seid_hash, &sess->sgwc_sxa_f_seid,
97
+    ogs_hash_set(self.sgwc_sxa_f_seid_hash, &sess->sgwc_sxa_f_seid,
98
             sizeof(sess->sgwc_sxa_f_seid), NULL);
99
 
100
     ogs_pfcp_pool_final(&sess->pfcp);
101
 
102
+    ogs_pool_free(&sgwu_sxa_seid_pool, sess->sgwu_sxa_seid_node);
103
     ogs_pool_free(&sgwu_sess_pool, sess);
104
 
105
     ogs_info("Removed Number of SGWU-sessions is now %d",
106
@@ -196,14 +212,9 @@
107
     }
108
 }
109
 
110
-sgwu_sess_t *sgwu_sess_find(uint32_t index)
111
-{
112
-    return ogs_pool_find(&sgwu_sess_pool, index);
113
-}
114
-
115
 sgwu_sess_t *sgwu_sess_find_by_sgwc_sxa_seid(uint64_t seid)
116
 {
117
-    return (sgwu_sess_t *)ogs_hash_get(self.seid_hash, &seid, sizeof(seid));
118
+    return ogs_hash_get(self.sgwc_sxa_seid_hash, &seid, sizeof(seid));
119
 }
120
 
121
 sgwu_sess_t *sgwu_sess_find_by_sgwc_sxa_f_seid(ogs_pfcp_f_seid_t *f_seid)
122
@@ -217,12 +228,12 @@
123
     ogs_assert(OGS_OK == ogs_pfcp_f_seid_to_ip(f_seid, &key.ip));
124
     key.seid = f_seid->seid;
125
 
126
-    return (sgwu_sess_t *)ogs_hash_get(self.f_seid_hash, &key, sizeof(key));
127
+    return ogs_hash_get(self.sgwc_sxa_f_seid_hash, &key, sizeof(key));
128
 }
129
 
130
 sgwu_sess_t *sgwu_sess_find_by_sgwu_sxa_seid(uint64_t seid)
131
 {
132
-    return sgwu_sess_find(seid);
133
+    return ogs_hash_get(self.sgwu_sxa_seid_hash, &seid, sizeof(seid));
134
 }
135
 
136
 sgwu_sess_t *sgwu_sess_add_by_message(ogs_pfcp_message_t *message)
137
@@ -244,7 +255,10 @@
138
     sess = sgwu_sess_find_by_sgwc_sxa_f_seid(f_seid);
139
     if (!sess) {
140
         sess = sgwu_sess_add(f_seid);
141
-        if (!sess) return NULL;
142
+        if (!sess) {
143
+            ogs_error("No Session Context");
144
+            return NULL;
145
+        }
146
     }
147
     ogs_assert(sess);
148
 
149
open5gs_2.6.2.tar.xz/src/sgwu/context.h -> open5gs_2.6.3.tar.xz/src/sgwu/context.h Changed
38
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -37,16 +37,17 @@
9
 #define OGS_LOG_DOMAIN __sgwu_log_domain
10
 
11
 typedef struct sgwu_context_s {
12
-    ogs_hash_t      *seid_hash;     /* hash table (SEID) */
13
-    ogs_hash_t      *f_seid_hash;   /* hash table (F-SEID) */
14
+    ogs_hash_t *sgwu_sxa_seid_hash;    /* hash table (SGWU-SXA-SEID) */
15
+    ogs_hash_t *sgwc_sxa_seid_hash;    /* hash table (SGWC-SXA-SEID) */
16
+    ogs_hash_t *sgwc_sxa_f_seid_hash;  /* hash table (SGWC-SXA-F-SEID) */
17
 
18
-    ogs_list_t      sess_list;
19
+    ogs_list_t sess_list;
20
 } sgwu_context_t;
21
 
22
 #define SGWU_SESS(pfcp_sess) ogs_container_of(pfcp_sess, sgwu_sess_t, pfcp)
23
 typedef struct sgwu_sess_s {
24
     ogs_lnode_t     lnode;
25
-    uint32_t        index;              /**< An index of this node */
26
+    ogs_pool_id_t   *sgwu_sxa_seid_node;    /* A node of SGWU-SXA-SEID */
27
 
28
     ogs_pfcp_sess_t pfcp;
29
 
30
@@ -70,7 +71,6 @@
31
 sgwu_sess_t *sgwu_sess_add(ogs_pfcp_f_seid_t *f_seid);
32
 int sgwu_sess_remove(sgwu_sess_t *sess);
33
 void sgwu_sess_remove_all(void);
34
-sgwu_sess_t *sgwu_sess_find(uint32_t index);
35
 sgwu_sess_t *sgwu_sess_find_by_sgwc_sxa_seid(uint64_t seid);
36
 sgwu_sess_t *sgwu_sess_find_by_sgwc_sxa_f_seid(ogs_pfcp_f_seid_t *f_seid);
37
 sgwu_sess_t *sgwu_sess_find_by_sgwu_sxa_seid(uint64_t seid);
38
open5gs_2.6.2.tar.xz/src/sgwu/gtp-path.c -> open5gs_2.6.3.tar.xz/src/sgwu/gtp-path.c Changed
151
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -28,11 +28,13 @@
9
 {
10
     int len;
11
     ssize_t size;
12
-    char bufOGS_ADDRSTRLEN;
13
+    char buf1OGS_ADDRSTRLEN;
14
+    char buf2OGS_ADDRSTRLEN;
15
 
16
     sgwu_sess_t *sess = NULL;
17
 
18
     ogs_pkbuf_t *pkbuf = NULL;
19
+    ogs_sock_t *sock = NULL;
20
     ogs_sockaddr_t from;
21
 
22
     ogs_gtp2_header_t *gtp_h = NULL;
23
@@ -42,6 +44,8 @@
24
     uint8_t qfi;
25
 
26
     ogs_assert(fd != INVALID_SOCKET);
27
+    sock = data;
28
+    ogs_assert(sock);
29
 
30
     pkbuf = ogs_pkbuf_alloc(packet_pool, OGS_MAX_PKT_LEN);
31
     ogs_assert(pkbuf);
32
@@ -69,14 +73,14 @@
33
     if (gtp_h->type == OGS_GTPU_MSGTYPE_ECHO_REQ) {
34
         ogs_pkbuf_t *echo_rsp;
35
 
36
-        ogs_debug("RECV Echo Request from %s", OGS_ADDR(&from, buf));
37
+        ogs_debug("RECV Echo Request from %s", OGS_ADDR(&from, buf1));
38
         echo_rsp = ogs_gtp2_handle_echo_req(pkbuf);
39
         ogs_expect(echo_rsp);
40
         if (echo_rsp) {
41
             ssize_t sent;
42
 
43
             /* Echo reply */
44
-            ogs_debug("SEND Echo Response to %s", OGS_ADDR(&from, buf));
45
+            ogs_debug("SEND Echo Response to %s", OGS_ADDR(&from, buf1));
46
 
47
             sent = ogs_sendto(fd, echo_rsp->data, echo_rsp->len, 0, &from);
48
             if (sent < 0 || sent != echo_rsp->len) {
49
@@ -91,7 +95,7 @@
50
     teid = be32toh(gtp_h->teid);
51
 
52
     ogs_trace("RECV GPU-U Type %d from %s : TEID0x%x",
53
-            gtp_h->type, OGS_ADDR(&from, buf), teid);
54
+            gtp_h->type, OGS_ADDR(&from, buf1), teid);
55
 
56
     qfi = 0;
57
     if (gtp_h->flags & OGS_GTPU_FLAGS_E) {
58
@@ -139,7 +143,27 @@
59
 
60
         pfcp_object = ogs_pfcp_object_find_by_teid(teid);
61
         if (!pfcp_object) {
62
-            /* TODO : Send Error Indication */
63
+            /*
64
+             * Refer to the following 5G standard
65
+             *
66
+             * TS23.527 Restoration procedures
67
+             * 4.3 UPF Restoration Procedures
68
+             * 4.3.2 Restoration Procedure for PSA UPF Restart
69
+             *
70
+             * The UPF shall not send GTP-U Error indication message
71
+             * for a configurable period after an UPF restart
72
+             * when the UPF receives a G-PDU not matching any PDRs.
73
+             */
74
+            if (ogs_time_ntp32_now() >
75
+                   (ogs_pfcp_self()->local_recovery +
76
+                    ogs_time_sec(
77
+                        ogs_app()->time.message.pfcp.association_interval))) {
78
+                ogs_error("%s Send Error Indication TEID:0x%x to %s",
79
+                        OGS_ADDR(&sock->local_addr, buf1),
80
+                        teid,
81
+                        OGS_ADDR(&from, buf2));
82
+                ogs_gtp1_send_error_indication(sock, teid, 0, &from);
83
+            }
84
             goto cleanup;
85
         }
86
 
87
@@ -164,7 +188,7 @@
88
     } else if (gtp_h->type == OGS_GTPU_MSGTYPE_ERR_IND) {
89
         ogs_pfcp_far_t *far = NULL;
90
 
91
-        far = ogs_pfcp_far_find_by_error_indication(pkbuf);
92
+        far = ogs_pfcp_far_find_by_gtpu_error_indication(pkbuf);
93
         if (far) {
94
             ogs_assert(true ==
95
                 ogs_pfcp_up_handle_error_indication(far, &report));
96
@@ -177,7 +201,6 @@
97
                 ogs_assert(OGS_OK ==
98
                     sgwu_pfcp_send_session_report_request(sess, &report));
99
             }
100
-
101
         } else {
102
             ogs_error("DROP Cannot find FAR by Error-Indication");
103
             ogs_log_hexdump(OGS_LOG_ERROR, pkbuf->data, pkbuf->len);
104
@@ -193,7 +216,27 @@
105
 
106
         pfcp_object = ogs_pfcp_object_find_by_teid(teid);
107
         if (!pfcp_object) {
108
-            /* TODO : Send Error Indication */
109
+            /*
110
+             * Refer to the following 5G standard
111
+             *
112
+             * TS23.527 Restoration procedures
113
+             * 4.3 UPF Restoration Procedures
114
+             * 4.3.2 Restoration Procedure for PSA UPF Restart
115
+             *
116
+             * The UPF shall not send GTP-U Error indication message
117
+             * for a configurable period after an UPF restart
118
+             * when the UPF receives a G-PDU not matching any PDRs.
119
+             */
120
+            if (ogs_time_ntp32_now() >
121
+                   (ogs_pfcp_self()->local_recovery +
122
+                    ogs_time_sec(
123
+                        ogs_app()->time.message.pfcp.association_interval))) {
124
+                ogs_error("%s Send Error Indication TEID:0x%x to %s",
125
+                        OGS_ADDR(&sock->local_addr, buf1),
126
+                        teid,
127
+                        OGS_ADDR(&from, buf2));
128
+                ogs_gtp1_send_error_indication(sock, teid, 0, &from);
129
+            }
130
             goto cleanup;
131
         }
132
 
133
@@ -203,6 +246,8 @@
134
             ogs_assert(pdr);
135
             break;
136
         case OGS_PFCP_OBJ_SESS_TYPE:
137
+            /* SGWU does not use SESS TYPE */
138
+            ogs_assert_if_reached();
139
             pfcp_sess = (ogs_pfcp_sess_t *)pfcp_object;
140
             ogs_assert(pfcp_sess);
141
 
142
@@ -266,7 +311,7 @@
143
 
144
     config.cluster_2048_pool = ogs_app()->pool.packet;
145
 
146
-#if OGS_USE_TALLOC
147
+#if OGS_USE_TALLOC == 1
148
     /* allocate a talloc pool for GTP to ensure it doesn't have to go back
149
      * to the libc malloc all the time */
150
     packet_pool = talloc_pool(__ogs_talloc_core, 1000*1024);
151
open5gs_2.6.2.tar.xz/src/sgwu/pfcp-path.c -> open5gs_2.6.3.tar.xz/src/sgwu/pfcp-path.c Changed
9
 
1
@@ -205,7 +205,6 @@
2
     ogs_pfcp_header_t h;
3
 
4
     ogs_assert(xact);
5
-    ogs_assert(created_pdr);
6
 
7
     memset(&h, 0, sizeof(ogs_pfcp_header_t));
8
     h.type = OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE;
9
open5gs_2.6.2.tar.xz/src/sgwu/pfcp-sm.c -> open5gs_2.6.3.tar.xz/src/sgwu/pfcp-sm.c Changed
17
 
1
@@ -277,12 +277,9 @@
2
                     &message->pfcp_association_setup_response);
3
             break;
4
         case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
5
-            if (message->h.seid_presence && message->h.seid == 0) {
6
-                ogs_expect(!sess);
7
-                sess = sgwu_sess_add_by_message(message);
8
-                if (sess)
9
-                    OGS_SETUP_PFCP_NODE(sess, node);
10
-            }
11
+            sess = sgwu_sess_add_by_message(message);
12
+            if (sess)
13
+                OGS_SETUP_PFCP_NODE(sess, node);
14
             sgwu_sxa_handle_session_establishment_request(
15
                 sess, xact, &message->pfcp_session_establishment_request);
16
             break;
17
open5gs_2.6.2.tar.xz/src/sgwu/sxa-handler.c -> open5gs_2.6.3.tar.xz/src/sgwu/sxa-handler.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -33,6 +33,9 @@
9
     uint8_t offending_ie_value = 0;
10
     int i;
11
 
12
+    ogs_pfcp_sereq_flags_t sereq_flags;
13
+    bool restoration_indication = false;
14
+
15
     ogs_assert(xact);
16
     ogs_assert(req);
17
 
18
@@ -48,9 +51,16 @@
19
         return;
20
     }
21
 
22
+    /* PFCPSEReq-Flags */
23
+    memset(&sereq_flags, 0, sizeof(sereq_flags));
24
+    if (req->pfcpsereq_flags.presence == 1) {
25
+        sereq_flags.value = req->pfcpsereq_flags.u8;
26
+    }
27
+
28
     for (i = 0; i < OGS_MAX_NUM_OF_PDR; i++) {
29
         created_pdri = ogs_pfcp_handle_create_pdr(&sess->pfcp,
30
-                &req->create_pdri, &cause_value, &offending_ie_value);
31
+                &req->create_pdri, &sereq_flags,
32
+                &cause_value, &offending_ie_value);
33
         if (created_pdri == NULL)
34
             break;
35
     }
36
@@ -79,6 +89,18 @@
37
     if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
38
         goto cleanup;
39
 
40
+    /* PFCPSEReq-Flags */
41
+    if (sereq_flags.restoration_indication == 1) {
42
+        for (i = 0; i < num_of_created_pdr; i++) {
43
+            pdr = created_pdri;
44
+            ogs_assert(pdr);
45
+
46
+            if (pdr->f_teid_len)
47
+                ogs_pfcp_pdr_swap_teid(pdr);
48
+        }
49
+        restoration_indication = true;
50
+    }
51
+
52
     /* Setup GTP Node */
53
     ogs_list_for_each(&sess->pfcp.far_list, far) {
54
         ogs_assert(OGS_ERROR != ogs_pfcp_setup_far_gtpu_node(far));
55
@@ -86,70 +108,14 @@
56
             ogs_pfcp_far_f_teid_hash_set(far);
57
     }
58
 
59
-    /* Setup TEID Hash */
60
     for (i = 0; i < num_of_created_pdr; i++) {
61
         pdr = created_pdri;
62
         ogs_assert(pdr);
63
 
64
-        if (pdr->f_teid_len) {
65
-            ogs_pfcp_object_type_e type = OGS_PFCP_OBJ_PDR_TYPE;
66
-
67
-            if (ogs_pfcp_self()->up_function_features.ftup &&
68
-                pdr->f_teid.ch) {
69
-
70
-                ogs_pfcp_pdr_t *choosed_pdr = NULL;
71
-
72
-                if (pdr->f_teid.chid) {
73
-                    type = OGS_PFCP_OBJ_SESS_TYPE;
74
-
75
-                    choosed_pdr = ogs_pfcp_pdr_find_by_choose_id(
76
-                            &sess->pfcp, pdr->f_teid.choose_id);
77
-                    if (!choosed_pdr) {
78
-                        pdr->chid = true;
79
-                        pdr->choose_id = pdr->f_teid.choose_id;
80
-                    }
81
-                }
82
-
83
-                if (choosed_pdr) {
84
-                    pdr->f_teid_len = choosed_pdr->f_teid_len;
85
-                    memcpy(&pdr->f_teid, &choosed_pdr->f_teid, pdr->f_teid_len);
86
-
87
-                } else {
88
-                    ogs_gtpu_resource_t *resource = NULL;
89
-                    resource = ogs_pfcp_find_gtpu_resource(
90
-                            &ogs_gtp_self()->gtpu_resource_list,
91
-                            pdr->apn, OGS_PFCP_INTERFACE_ACCESS);
92
-                    if (resource) {
93
-                        ogs_assert(
94
-                            (resource->info.v4 && pdr->f_teid.ipv4) ||
95
-                            (resource->info.v6 && pdr->f_teid.ipv6));
96
-                        ogs_assert(OGS_OK ==
97
-                            ogs_pfcp_user_plane_ip_resource_info_to_f_teid(
98
-                            &resource->info, &pdr->f_teid, &pdr->f_teid_len));
99
-                        if (resource->info.teidri)
100
-                            pdr->f_teid.teid = OGS_PFCP_GTPU_INDEX_TO_TEID(
101
-                                    pdr->index, resource->info.teidri,
102
-                                    resource->info.teid_range);
103
-                        else
104
-                            pdr->f_teid.teid = pdr->index;
105
-                    } else {
106
-                        ogs_assert(
107
-                            (ogs_gtp_self()->gtpu_addr && pdr->f_teid.ipv4) ||
108
-                            (ogs_gtp_self()->gtpu_addr6 && pdr->f_teid.ipv6));
109
-                        ogs_assert(OGS_OK ==
110
-                            ogs_pfcp_sockaddr_to_f_teid(
111
-                                pdr->f_teid.ipv4 ?
112
-                                    ogs_gtp_self()->gtpu_addr : NULL,
113
-                                pdr->f_teid.ipv6 ?
114
-                                    ogs_gtp_self()->gtpu_addr6 : NULL,
115
-                                &pdr->f_teid, &pdr->f_teid_len));
116
-                        pdr->f_teid.teid = pdr->index;
117
-                    }
118
-                }
119
-            }
120
-
121
-            ogs_pfcp_object_teid_hash_set(type, pdr);
122
-        }
123
+        /* Setup TEID Hash */
124
+        if (pdr->f_teid_len)
125
+            ogs_pfcp_object_teid_hash_set(
126
+                    OGS_PFCP_OBJ_PDR_TYPE, pdr, restoration_indication);
127
     }
128
 
129
     /* Send Buffered Packet to gNB */
130
@@ -159,9 +125,15 @@
131
         }
132
     }
133
 
134
-    ogs_assert(OGS_OK ==
135
-        sgwu_pfcp_send_session_establishment_response(
136
-            xact, sess, created_pdr, num_of_created_pdr));
137
+    if (restoration_indication == true ||
138
+        ogs_pfcp_self()->up_function_features.ftup == 0)
139
+        ogs_assert(OGS_OK ==
140
+            sgwu_pfcp_send_session_establishment_response(
141
+                xact, sess, NULL, 0));
142
+    else
143
+        ogs_assert(OGS_OK ==
144
+            sgwu_pfcp_send_session_establishment_response(
145
+                xact, sess, created_pdr, num_of_created_pdr));
146
     return;
147
 
148
 cleanup:
149
@@ -200,7 +172,7 @@
150
 
151
     for (i = 0; i < OGS_MAX_NUM_OF_PDR; i++) {
152
         created_pdri = ogs_pfcp_handle_create_pdr(&sess->pfcp,
153
-                &req->create_pdri, &cause_value, &offending_ie_value);
154
+                &req->create_pdri, NULL, &cause_value, &offending_ie_value);
155
         if (created_pdri == NULL)
156
             break;
157
     }
158
@@ -301,70 +273,13 @@
159
             ogs_pfcp_far_f_teid_hash_set(far);
160
     }
161
 
162
-    /* Setup TEID Hash */
163
     for (i = 0; i < num_of_created_pdr; i++) {
164
         pdr = created_pdri;
165
         ogs_assert(pdr);
166
 
167
-        if (pdr->f_teid_len) {
168
-            ogs_pfcp_object_type_e type = OGS_PFCP_OBJ_PDR_TYPE;
169
-
170
-            if (ogs_pfcp_self()->up_function_features.ftup &&
171
-                pdr->f_teid.ch) {
172
-
173
-                ogs_pfcp_pdr_t *choosed_pdr = NULL;
174
-
175
-                if (pdr->f_teid.chid) {
176
-                    type = OGS_PFCP_OBJ_SESS_TYPE;
177
-
178
-                    choosed_pdr = ogs_pfcp_pdr_find_by_choose_id(
179
-                            &sess->pfcp, pdr->f_teid.choose_id);
180
-                    if (!choosed_pdr) {
181
-                        pdr->chid = true;
182
-                        pdr->choose_id = pdr->f_teid.choose_id;
183
-                    }
184
-                }
185
-
186
-                if (choosed_pdr) {
187
-                    pdr->f_teid_len = choosed_pdr->f_teid_len;
188
-                    memcpy(&pdr->f_teid, &choosed_pdr->f_teid, pdr->f_teid_len);
189
-
190
-                } else {
191
-                    ogs_gtpu_resource_t *resource = NULL;
192
-                    resource = ogs_pfcp_find_gtpu_resource(
193
-                            &ogs_gtp_self()->gtpu_resource_list,
194
-                            pdr->apn, OGS_PFCP_INTERFACE_ACCESS);
195
-                    if (resource) {
196
-                        ogs_assert(
197
-                            (resource->info.v4 && pdr->f_teid.ipv4) ||
198
-                            (resource->info.v6 && pdr->f_teid.ipv6));
199
-                        ogs_assert(OGS_OK ==
200
-                            ogs_pfcp_user_plane_ip_resource_info_to_f_teid(
201
open5gs_2.6.2.tar.xz/src/smf/binding.c -> open5gs_2.6.3.tar.xz/src/smf/binding.c Changed
23
 
1
@@ -197,10 +197,10 @@
2
                                 &bearer->pgw_s5u_addr, &bearer->pgw_s5u_addr6);
3
                         if (resource->info.teidri)
4
                             bearer->pgw_s5u_teid = OGS_PFCP_GTPU_INDEX_TO_TEID(
5
-                                    ul_pdr->index, resource->info.teidri,
6
+                                    ul_pdr->teid, resource->info.teidri,
7
                                     resource->info.teid_range);
8
                         else
9
-                            bearer->pgw_s5u_teid = ul_pdr->index;
10
+                            bearer->pgw_s5u_teid = ul_pdr->teid;
11
                     } else {
12
                         if (sess->pfcp_node->addr.ogs_sa_family == AF_INET)
13
                             ogs_assert(OGS_OK ==
14
@@ -214,7 +214,7 @@
15
                         else
16
                             ogs_assert_if_reached();
17
 
18
-                        bearer->pgw_s5u_teid = ul_pdr->index;
19
+                        bearer->pgw_s5u_teid = ul_pdr->teid;
20
                     }
21
 
22
                     ogs_assert(OGS_OK ==
23
open5gs_2.6.2.tar.xz/src/smf/context.c -> open5gs_2.6.3.tar.xz/src/smf/context.c Changed
201
 
1
@@ -29,11 +29,12 @@
2
 
3
 static OGS_POOL(smf_gtp_node_pool, smf_gtp_node_t);
4
 static OGS_POOL(smf_ue_pool, smf_ue_t);
5
-static OGS_POOL(smf_sess_pool, smf_sess_t);
6
 static OGS_POOL(smf_bearer_pool, smf_bearer_t);
7
-
8
 static OGS_POOL(smf_pf_pool, smf_pf_t);
9
 
10
+static OGS_POOL(smf_sess_pool, smf_sess_t);
11
+static OGS_POOL(smf_n4_seid_pool, ogs_pool_id_t);
12
+
13
 static int context_initialized = 0;
14
 
15
 static int num_of_smf_sess = 0;
16
@@ -82,16 +83,20 @@
17
 
18
     ogs_pool_init(&smf_gtp_node_pool, ogs_app()->pool.nf);
19
     ogs_pool_init(&smf_ue_pool, ogs_app()->max.ue);
20
-    ogs_pool_init(&smf_sess_pool, ogs_app()->pool.sess);
21
     ogs_pool_init(&smf_bearer_pool, ogs_app()->pool.bearer);
22
-
23
     ogs_pool_init(&smf_pf_pool,
24
             ogs_app()->pool.bearer * OGS_MAX_NUM_OF_FLOW_IN_BEARER);
25
 
26
+    ogs_pool_init(&smf_sess_pool, ogs_app()->pool.sess);
27
+    ogs_pool_init(&smf_n4_seid_pool, ogs_app()->pool.sess);
28
+    ogs_pool_random_id_generate(&smf_n4_seid_pool);
29
+
30
     self.supi_hash = ogs_hash_make();
31
     ogs_assert(self.supi_hash);
32
     self.imsi_hash = ogs_hash_make();
33
     ogs_assert(self.imsi_hash);
34
+    self.smf_n4_seid_hash = ogs_hash_make();
35
+    ogs_assert(self.smf_n4_seid_hash);
36
     self.ipv4_hash = ogs_hash_make();
37
     ogs_assert(self.ipv4_hash);
38
     self.ipv6_hash = ogs_hash_make();
39
@@ -99,7 +104,6 @@
40
     self.n1n2message_hash = ogs_hash_make();
41
     ogs_assert(self.n1n2message_hash);
42
 
43
-
44
     context_initialized = 1;
45
 }
46
 
47
@@ -114,6 +118,8 @@
48
     ogs_hash_destroy(self.supi_hash);
49
     ogs_assert(self.imsi_hash);
50
     ogs_hash_destroy(self.imsi_hash);
51
+    ogs_assert(self.smf_n4_seid_hash);
52
+    ogs_hash_destroy(self.smf_n4_seid_hash);
53
     ogs_assert(self.ipv4_hash);
54
     ogs_hash_destroy(self.ipv4_hash);
55
     ogs_assert(self.ipv6_hash);
56
@@ -123,10 +129,11 @@
57
 
58
     ogs_pool_final(&smf_ue_pool);
59
     ogs_pool_final(&smf_bearer_pool);
60
-    ogs_pool_final(&smf_sess_pool);
61
-
62
     ogs_pool_final(&smf_pf_pool);
63
 
64
+    ogs_pool_final(&smf_sess_pool);
65
+    ogs_pool_final(&smf_n4_seid_pool);
66
+
67
     ogs_list_for_each_entry_safe(&self.sgw_s5c_list, next_gnode, gnode, node) {
68
         smf_gtp_node_t *smf_gnode = gnode->data_ptr;
69
         ogs_assert(smf_gnode);
70
@@ -1198,8 +1205,14 @@
71
     ogs_assert(sess->index > 0 && sess->index <= ogs_app()->pool.sess);
72
 
73
     /* Set TEID & SEID */
74
-    sess->smf_n4_teid = sess->index;
75
-    sess->smf_n4_seid = sess->index;
76
+    ogs_pool_alloc(&smf_n4_seid_pool, &sess->smf_n4_seid_node);
77
+    ogs_assert(sess->smf_n4_seid_node);
78
+
79
+    sess->smf_n4_teid = *(sess->smf_n4_seid_node);
80
+    sess->smf_n4_seid = *(sess->smf_n4_seid_node);
81
+
82
+    ogs_hash_set(self.smf_n4_seid_hash, &sess->smf_n4_seid,
83
+            sizeof(sess->smf_n4_seid), sess);
84
 
85
     /* Set Charging ID */
86
     sess->charging.id = sess->index;
87
@@ -1403,9 +1416,18 @@
88
     sess->index = ogs_pool_index(&smf_sess_pool, sess);
89
     ogs_assert(sess->index > 0 && sess->index <= ogs_app()->pool.sess);
90
 
91
+    /* Set TEID & SEID */
92
+    ogs_pool_alloc(&smf_n4_seid_pool, &sess->smf_n4_seid_node);
93
+    ogs_assert(sess->smf_n4_seid_node);
94
+
95
+    sess->smf_n4_teid = *(sess->smf_n4_seid_node);
96
+    sess->smf_n4_seid = *(sess->smf_n4_seid_node);
97
+
98
+    ogs_hash_set(self.smf_n4_seid_hash, &sess->smf_n4_seid,
99
+            sizeof(sess->smf_n4_seid), sess);
100
+
101
     /* Set SmContextRef in 5GC */
102
-    sess->sm_context_ref = ogs_msprintf("%d",
103
-            (int)ogs_pool_index(&smf_sess_pool, sess));
104
+    sess->sm_context_ref = ogs_msprintf("%d", sess->index);
105
     ogs_assert(sess->sm_context_ref);
106
 
107
     /* Create BAR in PFCP Session */
108
@@ -1420,10 +1442,6 @@
109
     sess->mapped_hplmn.sst = 0;
110
     sess->mapped_hplmn.sd.v = OGS_S_NSSAI_NO_SD_VALUE;
111
 
112
-    /* Set TEID & SEID */
113
-    sess->smf_n4_teid = sess->index;
114
-    sess->smf_n4_seid = sess->index;
115
-
116
     /* Set Charging Id */
117
     sess->charging.id = sess->index;
118
 
119
@@ -1623,68 +1641,6 @@
120
             sess);
121
 }
122
 
123
-smf_sess_t *smf_sess_find_by_error_indication_report(
124
-        smf_ue_t *smf_ue,
125
-        ogs_pfcp_tlv_error_indication_report_t *error_indication_report)
126
-{
127
-    smf_sess_t *sess = NULL;
128
-    ogs_pfcp_f_teid_t *remote_f_teid = NULL;
129
-
130
-    uint32_t teid;
131
-    uint16_t len;  /* OGS_IPV4_LEN or OGS_IPV6_LEN */
132
-    uint32_t addr4;
133
-
134
-    ogs_assert(smf_ue);
135
-    ogs_assert(error_indication_report);
136
-
137
-    if (error_indication_report->presence == 0) {
138
-        ogs_error("No Error Indication Report");
139
-        return NULL;
140
-    }
141
-
142
-    if (error_indication_report->remote_f_teid.presence == 0) {
143
-        ogs_error("No Remote F-TEID");
144
-        return NULL;
145
-    }
146
-
147
-    remote_f_teid = error_indication_report->remote_f_teid.data;
148
-    ogs_assert(remote_f_teid);
149
-
150
-    teid = be32toh(remote_f_teid->teid);
151
-    if (remote_f_teid->ipv4 && remote_f_teid->ipv6) {
152
-        ogs_error("User plane should not set both IPv4 and IPv6");
153
-        return NULL;
154
-    } else if (remote_f_teid->ipv4) {
155
-        len = OGS_IPV4_LEN;
156
-        memcpy(addr, &remote_f_teid->addr, len);
157
-    } else if (remote_f_teid->ipv6) {
158
-        len = OGS_IPV6_LEN;
159
-        memcpy(addr, remote_f_teid->addr6, len);
160
-    } else {
161
-        ogs_error("No IPv4 and IPv6");
162
-        return NULL;
163
-    }
164
-
165
-    ogs_list_reverse_for_each(&smf_ue->sess_list, sess) {
166
-        if (teid == sess->gnb_n3_teid) {
167
-            if (len == OGS_IPV4_LEN && sess->gnb_n3_ip.ipv4 &&
168
-                memcmp(addr, &sess->gnb_n3_ip.addr, len) == 0) {
169
-                return sess;
170
-            } else if (len == OGS_IPV6_LEN && sess->gnb_n3_ip.ipv6 &&
171
-                        memcmp(addr, sess->gnb_n3_ip.addr6, len) == 0) {
172
-                return sess;
173
-            }
174
-        }
175
-    }
176
-
177
-    ogs_error("Cannot find the session context "
178
-            "TEID:%d,LEN:%d,ADDR:%08x %08x %08x %08x",
179
-            teid, len, be32toh(addr0), be32toh(addr1),
180
-            be32toh(addr2), be32toh(addr3));
181
-
182
-    return NULL;
183
-}
184
-
185
 void smf_sess_remove(smf_sess_t *sess)
186
 {
187
     int i;
188
@@ -1711,17 +1667,21 @@
189
     ogs_fsm_fini(&sess->sm, &e);
190
 
191
     OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco);
192
+    OGS_TLV_CLEAR_DATA(&sess->gtp.ue_epco);
193
     OGS_TLV_CLEAR_DATA(&sess->gtp.user_location_information);
194
     OGS_TLV_CLEAR_DATA(&sess->gtp.ue_timezone);
195
     OGS_TLV_CLEAR_DATA(&sess->gtp.charging_characteristics);
196
     OGS_TLV_CLEAR_DATA(&sess->gtp.v1.qos);
197
 
198
-    OGS_NAS_CLEAR_DATA(&sess->nas.ue_pco);
199
+    OGS_NAS_CLEAR_DATA(&sess->nas.ue_epco);
200
 
201
open5gs_2.6.2.tar.xz/src/smf/context.h -> open5gs_2.6.3.tar.xz/src/smf/context.h Changed
79
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -88,6 +88,7 @@
9
     ogs_hash_t      *imsi_hash;     /* hash table (IMSI) */
10
     ogs_hash_t      *ipv4_hash;     /* hash table (IPv4 Address) */
11
     ogs_hash_t      *ipv6_hash;     /* hash table (IPv6 Address) */
12
+    ogs_hash_t      *smf_n4_seid_hash; /* hash table (SMF-N4-SEID) */
13
     ogs_hash_t      *n1n2message_hash; /* hash table (N1N2Message Location) */
14
 
15
     uint16_t        mtu;            /* MTU to advertise in PCO */
16
@@ -173,8 +174,6 @@
17
     ogs_lnode_t     to_modify_node;
18
     ogs_lnode_t     to_delete_node;
19
 
20
-    uint32_t        index;
21
-
22
     ogs_pfcp_pdr_t  *dl_pdr;
23
     ogs_pfcp_pdr_t  *ul_pdr;
24
     ogs_pfcp_far_t  *dl_far;
25
@@ -215,7 +214,10 @@
26
 #define SMF_SESS(pfcp_sess) ogs_container_of(pfcp_sess, smf_sess_t, pfcp)
27
 typedef struct smf_sess_s {
28
     ogs_sbi_object_t sbi;
29
-    uint32_t        index;          /**< An index of this node */
30
+
31
+    uint32_t        index;              /* An index of this node */
32
+    ogs_pool_id_t   *smf_n4_seid_node;  /* A node of SMF-N4-SEID */
33
+
34
     ogs_fsm_t       sm;             /* A state machine */
35
     struct {
36
         bool gx_ccr_init_in_flight; /* Waiting for Gx CCA */
37
@@ -236,12 +238,12 @@
38
 
39
     uint64_t        smpolicycontrol_features; /* SBI features */
40
 
41
-    uint32_t        smf_n4_teid;    /* SMF-N4-TEID is derived from INDEX */
42
+    uint32_t        smf_n4_teid;    /* SMF-N4-TEID is derived from NODE */
43
 
44
     uint32_t        sgw_s5c_teid;   /* SGW-S5C-TEID is received from SGW */
45
     ogs_ip_t        sgw_s5c_ip;     /* SGW-S5C IPv4/IPv6 */
46
 
47
-    uint64_t        smf_n4_seid;    /* SMF SEID is dervied from INDEX */
48
+    uint64_t        smf_n4_seid;    /* SMF SEID is dervied from NODE */
49
     uint64_t        upf_n4_seid;    /* UPF SEID is received from Peer */
50
 
51
     uint32_t        upf_n3_teid;    /* UPF-N3 TEID */
52
@@ -323,6 +325,7 @@
53
     struct {
54
         uint8_t version; /* GTPC version */
55
         ogs_tlv_octet_t ue_pco;
56
+        ogs_tlv_octet_t ue_epco;
57
         ogs_tlv_octet_t user_location_information;
58
         ogs_tlv_octet_t ue_timezone;
59
         ogs_tlv_octet_t charging_characteristics;
60
@@ -352,7 +355,7 @@
61
     } gy;
62
 
63
     struct {
64
-        ogs_nas_extended_protocol_configuration_options_t ue_pco;
65
+        ogs_nas_extended_protocol_configuration_options_t ue_epco;
66
     } nas; /* Saved from NAS-5GS */
67
 
68
     struct {
69
@@ -463,9 +466,6 @@
70
 smf_sess_t *smf_sess_find_by_ipv6(uint32_t *addr6);
71
 smf_sess_t *smf_sess_find_by_paging_n1n2message_location(
72
         char *n1n2message_location);
73
-smf_sess_t *smf_sess_find_by_error_indication_report(
74
-        smf_ue_t *smf_ue,
75
-        ogs_pfcp_tlv_error_indication_report_t *error_indication_report);
76
 
77
 void smf_sess_create_indirect_data_forwarding(smf_sess_t *sess);
78
 bool smf_sess_have_indirect_data_forwarding(smf_sess_t *sess);
79
open5gs_2.6.2.tar.xz/src/smf/fd-path.c -> open5gs_2.6.3.tar.xz/src/smf/fd-path.c Changed
9
 
1
@@ -62,6 +62,7 @@
2
     }
3
 
4
     smf_gx_final();
5
+    smf_gy_final();
6
     smf_s6b_final();
7
 
8
     ogs_diam_final();
9
open5gs_2.6.2.tar.xz/src/smf/gsm-build.c -> open5gs_2.6.3.tar.xz/src/smf/gsm-build.c Changed
92
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -48,8 +48,8 @@
9
     ogs_nas_qos_flow_description_t
10
         qos_flow_descriptionOGS_NAS_MAX_NUM_OF_QOS_FLOW_DESCRIPTION;
11
 
12
-    uint8_t pco_bufOGS_MAX_PCO_LEN;
13
-    int16_t pco_len;
14
+    uint8_t *epco_buf = NULL;
15
+    int16_t epco_len;
16
 
17
     selected_pdu_session_type = &pdu_session_establishment_accept->
18
         selected_pdu_session_type;
19
@@ -134,11 +134,11 @@
20
     rv = ogs_nas_build_qos_rules(authorized_qos_rules, qos_rule, 1);
21
     if (rv != OGS_OK) {
22
         ogs_error("ogs_nas_build_qos_rules() failed");
23
-        return NULL;
24
+        goto cleanup;
25
     }
26
     if (!authorized_qos_rules->length) {
27
         ogs_error("No length");
28
-        return NULL;
29
+        goto cleanup;
30
     }
31
 
32
     /* Session-AMBR */
33
@@ -167,7 +167,7 @@
34
         pdu_address->length = OGS_NAS_PDU_ADDRESS_IPV4V6_LEN;
35
     } else {
36
         ogs_error("Unexpected PDN Type %u", pdu_address->pdn_type);
37
-        return NULL;
38
+        goto cleanup;
39
     }
40
 
41
     /* GSM cause */
42
@@ -211,22 +211,24 @@
43
             authorized_qos_flow_descriptions, qos_flow_description, 1);
44
     if (rv != OGS_OK) {
45
         ogs_error("ogs_nas_build_qos_flow_descriptions() failed");
46
-        return NULL;
47
+        goto cleanup;
48
     }
49
     if (!authorized_qos_flow_descriptions->length) {
50
         ogs_error("No length");
51
-        return NULL;
52
+        goto cleanup;
53
     }
54
 
55
     /* Extended protocol configuration options */
56
-    if (sess->nas.ue_pco.buffer && sess->nas.ue_pco.length) {
57
-        pco_len = smf_pco_build(pco_buf,
58
-                sess->nas.ue_pco.buffer, sess->nas.ue_pco.length);
59
-        ogs_assert(pco_len > 0);
60
+    if (sess->nas.ue_epco.buffer && sess->nas.ue_epco.length) {
61
+        epco_buf = ogs_calloc(OGS_MAX_EPCO_LEN, sizeof(uint8_t));
62
+        ogs_assert(epco_buf);
63
+        epco_len = smf_pco_build(epco_buf,
64
+                sess->nas.ue_epco.buffer, sess->nas.ue_epco.length);
65
+        ogs_assert(epco_len > 0);
66
         pdu_session_establishment_accept->presencemask |=
67
             OGS_NAS_5GS_PDU_SESSION_ESTABLISHMENT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
68
-        extended_protocol_configuration_options->buffer = pco_buf;
69
-        extended_protocol_configuration_options->length = pco_len;
70
+        extended_protocol_configuration_options->buffer = epco_buf;
71
+        extended_protocol_configuration_options->length = epco_len;
72
     }
73
 
74
     /* DNN */
75
@@ -240,8 +242,14 @@
76
     pkbuf = ogs_nas_5gs_plain_encode(&message);
77
     ogs_assert(pkbuf);
78
 
79
-    ogs_free(authorized_qos_rules->buffer);
80
-    ogs_free(authorized_qos_flow_descriptions->buffer);
81
+cleanup:
82
+    if (epco_buf)
83
+        ogs_free(epco_buf);
84
+
85
+    if (authorized_qos_rules->buffer)
86
+        ogs_free(authorized_qos_rules->buffer);
87
+    if (authorized_qos_flow_descriptions->buffer)
88
+        ogs_free(authorized_qos_flow_descriptions->buffer);
89
 
90
     return pkbuf;
91
 }
92
open5gs_2.6.2.tar.xz/src/smf/gsm-handler.c -> open5gs_2.6.3.tar.xz/src/smf/gsm-handler.c Changed
17
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -62,7 +62,7 @@
9
 
10
     if (pdu_session_establishment_request->presencemask &
11
         OGS_NAS_5GS_PDU_SESSION_ESTABLISHMENT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT) {
12
-        OGS_NAS_STORE_DATA(&sess->nas.ue_pco,
13
+        OGS_NAS_STORE_DATA(&sess->nas.ue_epco,
14
             &pdu_session_establishment_request->
15
                 extended_protocol_configuration_options);
16
     }
17
open5gs_2.6.2.tar.xz/src/smf/gsm-sm.c -> open5gs_2.6.3.tar.xz/src/smf/gsm-sm.c Changed
115
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -452,7 +452,7 @@
9
             OGS_FSM_TRAN(s, &smf_gsm_state_wait_pfcp_establishment);
10
             ogs_assert(OGS_OK ==
11
                 smf_epc_pfcp_send_session_establishment_request(
12
-                    sess, e->gtp_xact));
13
+                    sess, e->gtp_xact, 0));
14
         } else {
15
             /* FIXME: tear down Gx/Gy session
16
              * if its sm_data.*init_err == ER_DIAMETER_SUCCESS */
17
@@ -671,21 +671,28 @@
18
                     send_gtp_create_err_msg(sess, e->gtp_xact, gtp_cause);
19
                     return;
20
                 }
21
-                switch (gtp_xact->gtp_version) {
22
-                case 1:
23
-                    rv = smf_gtp1_send_create_pdp_context_response(sess, gtp_xact);
24
-                    break;
25
-                case 2:
26
-                    rv = smf_gtp2_send_create_session_response(sess, gtp_xact);
27
-                    break;
28
-                default:
29
-                    rv = OGS_ERROR;
30
-                    break;
31
-                }
32
-                /* If no CreatePDPCtxResp can be sent, then tear down the session: */
33
-                if (rv != OGS_OK) {
34
-                    OGS_FSM_TRAN(s, &smf_gsm_state_wait_pfcp_deletion);
35
-                    return;
36
+
37
+                gtp_xact = pfcp_xact->assoc_xact;
38
+                if (gtp_xact) {
39
+                    switch (gtp_xact->gtp_version) {
40
+                    case 1:
41
+                        rv = smf_gtp1_send_create_pdp_context_response(
42
+                                sess, gtp_xact);
43
+                        break;
44
+                    case 2:
45
+                        rv = smf_gtp2_send_create_session_response(
46
+                                sess, gtp_xact);
47
+                        break;
48
+                    default:
49
+                        rv = OGS_ERROR;
50
+                        break;
51
+                    }
52
+                    /* If no CreatePDPCtxResp can be sent,
53
+                     * then tear down the session: */
54
+                    if (rv != OGS_OK) {
55
+                        OGS_FSM_TRAN(s, &smf_gsm_state_wait_pfcp_deletion);
56
+                        return;
57
+                    }
58
                 }
59
 
60
                 if (sess->gtp_rat_type == OGS_GTP2_RAT_TYPE_WLAN) {
61
@@ -739,6 +746,9 @@
62
     smf_sess_t *sess = NULL;
63
     ogs_pkbuf_t *pkbuf = NULL;
64
 
65
+    ogs_pfcp_xact_t *pfcp_xact = NULL;
66
+    ogs_pfcp_message_t *pfcp_message = NULL;
67
+
68
     ogs_nas_5gs_message_t *nas_message = NULL;
69
 
70
     ogs_sbi_stream_t *stream = NULL;
71
@@ -815,6 +825,43 @@
72
         }
73
         break;
74
 
75
+    case SMF_EVT_N4_MESSAGE:
76
+        pfcp_xact = e->pfcp_xact;
77
+        ogs_assert(pfcp_xact);
78
+        pfcp_message = e->pfcp_message;
79
+        ogs_assert(pfcp_message);
80
+
81
+        switch (pfcp_message->h.type) {
82
+        case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
83
+            if ((pfcp_xact->create_flags &
84
+                        OGS_PFCP_CREATE_RESTORATION_INDICATION)) {
85
+                ogs_pfcp_session_establishment_response_t *rsp = NULL;
86
+                ogs_pfcp_f_seid_t *up_f_seid = NULL;
87
+
88
+                rsp = &pfcp_message->pfcp_session_establishment_response;
89
+                if (rsp->up_f_seid.presence == 0) {
90
+                    ogs_error("No UP F-SEID");
91
+                    break;
92
+                }
93
+                up_f_seid = rsp->up_f_seid.data;
94
+                ogs_assert(up_f_seid);
95
+                sess->upf_n4_seid = be64toh(up_f_seid->seid);
96
+            } else {
97
+                ogs_error("cannot handle PFCP Session Establishment Response");
98
+            }
99
+            break;
100
+
101
+        case OGS_PFCP_SESSION_DELETION_RESPONSE_TYPE:
102
+            ogs_error("Session Released by Error Indication");
103
+            OGS_FSM_TRAN(s, smf_gsm_state_session_will_release);
104
+            break;
105
+
106
+        default:
107
+            ogs_error("cannot handle PFCP message type%d",
108
+                    pfcp_message->h.type);
109
+        }
110
+        break;
111
+
112
     case OGS_EVENT_SBI_SERVER:
113
         sbi_message = e->h.sbi.message;
114
         ogs_assert(sbi_message);
115
open5gs_2.6.2.tar.xz/src/smf/gx-handler.c -> open5gs_2.6.3.tar.xz/src/smf/gx-handler.c Changed
32
 
1
@@ -202,10 +202,10 @@
2
                 &bearer->pgw_s5u_addr, &bearer->pgw_s5u_addr6);
3
             if (resource->info.teidri)
4
                 bearer->pgw_s5u_teid = OGS_PFCP_GTPU_INDEX_TO_TEID(
5
-                        ul_pdr->index, resource->info.teidri,
6
+                        ul_pdr->teid, resource->info.teidri,
7
                         resource->info.teid_range);
8
             else
9
-                bearer->pgw_s5u_teid = ul_pdr->index;
10
+                bearer->pgw_s5u_teid = ul_pdr->teid;
11
         } else {
12
             if (sess->pfcp_node->addr.ogs_sa_family == AF_INET)
13
                 ogs_assert(OGS_OK ==
14
@@ -218,7 +218,7 @@
15
             else
16
                 ogs_assert_if_reached();
17
 
18
-            bearer->pgw_s5u_teid = ul_pdr->index;
19
+            bearer->pgw_s5u_teid = ul_pdr->teid;
20
         }
21
 
22
         ogs_assert(OGS_OK ==
23
@@ -231,7 +231,7 @@
24
             ogs_pfcp_sockaddr_to_f_teid(
25
                 bearer->pgw_s5u_addr, bearer->pgw_s5u_addr6,
26
                 &cp2up_pdr->f_teid, &cp2up_pdr->f_teid_len));
27
-        cp2up_pdr->f_teid.teid = cp2up_pdr->index;
28
+        cp2up_pdr->f_teid.teid = cp2up_pdr->teid;
29
 
30
         ogs_assert(OGS_OK ==
31
             ogs_pfcp_sockaddr_to_f_teid(
32
open5gs_2.6.2.tar.xz/src/smf/n4-build.c -> open5gs_2.6.3.tar.xz/src/smf/n4-build.c Changed
35
 
1
@@ -21,7 +21,7 @@
2
 #include "n4-build.h"
3
 
4
 ogs_pkbuf_t *smf_n4_build_session_establishment_request(
5
-        uint8_t type, smf_sess_t *sess)
6
+        uint8_t type, smf_sess_t *sess, ogs_pfcp_xact_t *xact)
7
 {
8
     ogs_pfcp_message_t *pfcp_message = NULL;
9
     ogs_pfcp_session_establishment_request_t *req = NULL;
10
@@ -46,6 +46,7 @@
11
     ogs_assert(sess);
12
     smf_ue = sess->smf_ue;
13
     ogs_assert(smf_ue);
14
+    ogs_assert(xact);
15
 
16
     pfcp_message = ogs_calloc(1, sizeof(*pfcp_message));
17
     if (!pfcp_message) {
18
@@ -159,6 +160,16 @@
19
         req->s_nssai.data = &sess->s_nssai;
20
     }
21
 
22
+    /* Restoration Indication */
23
+    if (xact->create_flags & OGS_PFCP_CREATE_RESTORATION_INDICATION) {
24
+        ogs_pfcp_sereq_flags_t sereq_flags;
25
+        sereq_flags.value = 0;
26
+
27
+        sereq_flags.restoration_indication = 1;
28
+        req->pfcpsereq_flags.presence = 1;
29
+        req->pfcpsereq_flags.u8 = sereq_flags.value;
30
+    }
31
+
32
     pfcp_message->h.type = type;
33
     pkbuf = ogs_pfcp_build_msg(pfcp_message);
34
     ogs_expect(pkbuf);
35
open5gs_2.6.2.tar.xz/src/smf/n4-build.h -> open5gs_2.6.3.tar.xz/src/smf/n4-build.h Changed
10
 
1
@@ -27,7 +27,7 @@
2
 #endif
3
 
4
 ogs_pkbuf_t *smf_n4_build_session_establishment_request(
5
-        uint8_t type, smf_sess_t *sess);
6
+        uint8_t type, smf_sess_t *sess, ogs_pfcp_xact_t *xact);
7
 ogs_pkbuf_t *smf_n4_build_pdr_to_modify_list(
8
         uint8_t type, smf_sess_t *sess, ogs_pfcp_xact_t *xact);
9
 ogs_pkbuf_t *smf_n4_build_qos_flow_to_modify_list(
10
open5gs_2.6.2.tar.xz/src/smf/n4-handler.c -> open5gs_2.6.3.tar.xz/src/smf/n4-handler.c Changed
118
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -148,8 +148,6 @@
9
 {
10
     int i;
11
 
12
-    ogs_sbi_stream_t *stream = NULL;
13
-
14
     uint8_t cause_value = OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
15
     uint8_t offending_ie_value = 0;
16
 
17
@@ -164,9 +162,6 @@
18
 
19
     ogs_debug("Session Establishment Response 5gc");
20
 
21
-    stream = xact->assoc_stream;
22
-    ogs_assert(stream);
23
-
24
     ogs_pfcp_xact_commit(xact);
25
 
26
     if (rsp->up_f_seid.presence == 0) {
27
@@ -732,7 +727,6 @@
28
     uint8_t cause_value = OGS_PFCP_CAUSE_REQUEST_ACCEPTED;
29
 
30
     smf_bearer_t *bearer = NULL;
31
-    ogs_gtp_xact_t *gtp_xact = NULL;
32
 
33
     ogs_pfcp_f_seid_t *up_f_seid = NULL;
34
 
35
@@ -742,9 +736,6 @@
36
 
37
     ogs_debug("Session Establishment Response epc");
38
 
39
-    gtp_xact = xact->assoc_xact;
40
-    ogs_assert(gtp_xact);
41
-
42
     ogs_pfcp_xact_commit(xact);
43
 
44
     if (rsp->up_f_seid.presence == 0) {
45
@@ -1157,9 +1148,11 @@
46
         smf_sess_t *sess, ogs_pfcp_xact_t *pfcp_xact,
47
         ogs_pfcp_session_report_request_t *pfcp_req)
48
 {
49
+    smf_ue_t *smf_ue = NULL;
50
     smf_bearer_t *qos_flow = NULL;
51
     smf_bearer_t *bearer = NULL;
52
     ogs_pfcp_pdr_t *pdr = NULL;
53
+    ogs_pfcp_far_t *far = NULL;
54
 
55
     ogs_pfcp_report_type_t report_type;
56
     uint8_t cause_value = 0;
57
@@ -1193,6 +1186,9 @@
58
     }
59
 
60
     ogs_assert(sess);
61
+    smf_ue = sess->smf_ue;
62
+    ogs_assert(smf_ue);
63
+
64
     report_type.value = pfcp_req->report_type.u8;
65
 
66
     if (report_type.downlink_data_report) {
67
@@ -1279,21 +1275,10 @@
68
     }
69
 
70
     if (report_type.error_indication_report) {
71
-        smf_ue_t *smf_ue = sess->smf_ue;
72
-        smf_sess_t *error_indication_session = NULL;
73
-        ogs_assert(smf_ue);
74
-
75
-        error_indication_session = smf_sess_find_by_error_indication_report(
76
-                smf_ue, &pfcp_req->error_indication_report);
77
-
78
-        if (error_indication_session) {
79
-            ogs_assert(OGS_OK ==
80
-                smf_5gc_pfcp_send_all_pdr_modification_request(
81
-                    error_indication_session, NULL,
82
-                    OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE|
83
-                    OGS_PFCP_MODIFY_ERROR_INDICATION,
84
-                    0));
85
-        }
86
+        far = ogs_pfcp_far_find_by_pfcp_session_report(
87
+                &sess->pfcp, &pfcp_req->error_indication_report);
88
+        if (!far)
89
+            ogs_error("Cannot find Session in Error Indication");
90
     }
91
 
92
     if (report_type.usage_report) {
93
@@ -1350,4 +1335,24 @@
94
             smf_pfcp_send_session_report_response(
95
                 pfcp_xact, sess, OGS_PFCP_CAUSE_SYSTEM_FAILURE));
96
     }
97
+
98
+    /* Error Indication is handled last */
99
+    if (report_type.error_indication_report && far) {
100
+        if (sess->epc == true) {
101
+            ogs_error("%s:%s Error Indication from SGW-C",
102
+                smf_ue->imsi_bcd, sess->session.name);
103
+            ogs_assert(OGS_OK ==
104
+                smf_epc_pfcp_send_session_deletion_request(
105
+                    sess, NULL));
106
+        } else {
107
+            ogs_warn("%s:%s Error Indication from gNB",
108
+                smf_ue->supi, sess->session.name);
109
+            ogs_assert(OGS_OK ==
110
+                smf_5gc_pfcp_send_all_pdr_modification_request(
111
+                    sess, NULL,
112
+                    OGS_PFCP_MODIFY_DL_ONLY|OGS_PFCP_MODIFY_DEACTIVATE|
113
+                    OGS_PFCP_MODIFY_ERROR_INDICATION,
114
+                    0));
115
+        }
116
+    }
117
 }
118
open5gs_2.6.2.tar.xz/src/smf/npcf-handler.c -> open5gs_2.6.3.tar.xz/src/smf/npcf-handler.c Changed
41
 
1
@@ -585,10 +585,10 @@
2
                 &sess->upf_n3_addr, &sess->upf_n3_addr6);
3
             if (resource->info.teidri)
4
                 sess->upf_n3_teid = OGS_PFCP_GTPU_INDEX_TO_TEID(
5
-                        ul_pdr->index, resource->info.teidri,
6
+                        ul_pdr->teid, resource->info.teidri,
7
                         resource->info.teid_range);
8
             else
9
-                sess->upf_n3_teid = ul_pdr->index;
10
+                sess->upf_n3_teid = ul_pdr->teid;
11
         } else {
12
             if (sess->pfcp_node->addr.ogs_sa_family == AF_INET)
13
                 ogs_assert(OGS_OK ==
14
@@ -601,7 +601,7 @@
15
             else
16
                 ogs_assert_if_reached();
17
 
18
-            sess->upf_n3_teid = ul_pdr->index;
19
+            sess->upf_n3_teid = ul_pdr->teid;
20
         }
21
 
22
         ogs_assert(OGS_OK ==
23
@@ -614,7 +614,7 @@
24
             ogs_pfcp_sockaddr_to_f_teid(
25
                 sess->upf_n3_addr, sess->upf_n3_addr6,
26
                 &cp2up_pdr->f_teid, &cp2up_pdr->f_teid_len));
27
-        cp2up_pdr->f_teid.teid = cp2up_pdr->index;
28
+        cp2up_pdr->f_teid.teid = cp2up_pdr->teid;
29
 
30
         ogs_assert(OGS_OK ==
31
             ogs_pfcp_sockaddr_to_f_teid(
32
@@ -630,7 +630,7 @@
33
     up2cp_pdr->precedence = OGS_PFCP_UP2CP_PDR_PRECEDENCE;
34
 
35
     ogs_assert(OGS_OK ==
36
-        smf_5gc_pfcp_send_session_establishment_request(sess, stream));
37
+            smf_5gc_pfcp_send_session_establishment_request(sess, 0));
38
 
39
     return true;
40
 
41
open5gs_2.6.2.tar.xz/src/smf/pfcp-path.c -> open5gs_2.6.3.tar.xz/src/smf/pfcp-path.c Changed
126
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -362,7 +362,7 @@
9
 }
10
 
11
 int smf_5gc_pfcp_send_session_establishment_request(
12
-        smf_sess_t *sess, ogs_sbi_stream_t *stream)
13
+        smf_sess_t *sess, uint64_t flags)
14
 {
15
     int rv;
16
     ogs_pkbuf_t *n4buf = NULL;
17
@@ -370,7 +370,6 @@
18
     ogs_pfcp_xact_t *xact = NULL;
19
 
20
     ogs_assert(sess);
21
-    ogs_assert(stream);
22
 
23
     xact = ogs_pfcp_xact_local_create(sess->pfcp_node, sess_5gc_timeout, sess);
24
     if (!xact) {
25
@@ -378,14 +377,44 @@
26
         return OGS_ERROR;
27
     }
28
 
29
-    xact->assoc_stream = stream;
30
     xact->local_seid = sess->smf_n4_seid;
31
+    xact->create_flags = flags;
32
 
33
     memset(&h, 0, sizeof(ogs_pfcp_header_t));
34
     h.type = OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE;
35
+
36
+/*
37
+ * 7.2.2.4.2 Conditions for Sending SEID=0 in PFCP Header
38
+ *
39
+ * If a peer's SEID is not available, the SEID field shall still be present
40
+ * in the header and its value shall be set to "0" in the following messages:
41
+ *
42
+ * - PFCP Session Establishment Request message on Sxa/Sxb/Sxc/N4;
43
+ *
44
+ * - If a node receives a message for which it has no session, i.e.
45
+ *   if SEID in the PFCP header is not known, it shall respond
46
+ *   with "Session context not found" cause in the corresponding
47
+ *   response message to the sender, the SEID used in the PFCP header
48
+ *   in the response message shall be then set to "0";
49
+ *
50
+ * - If a node receives a request message containing protocol error,
51
+ *   e.g. Mandatory IE missing, which requires the receiver
52
+ *   to reject the message as specified in clause 7.6, it shall reject
53
+ *   the request message. For the response message, the node should look up
54
+ *   the remote peer's SEID and accordingly set SEID in the PFCP header
55
+ *   and the message cause code. As an implementation option,
56
+ *   the node may not look up the remote peer's SEID and
57
+ *   set the PFCP header SEID to "0" in the response message.
58
+ *   However in this case, the cause value shall not be set
59
+ *   to "Session not found".
60
+ *
61
+ * - When the UP function sends PFCP Session Report Request message
62
+ *   over N4 towards another SMF or another PFCP entity in the SMF
63
+ *   as specified in clause 5.22.2 and clause 5.22.3.
64
+ */
65
     h.seid = sess->upf_n4_seid;
66
 
67
-    n4buf = smf_n4_build_session_establishment_request(h.type, sess);
68
+    n4buf = smf_n4_build_session_establishment_request(h.type, sess, xact);
69
     if (!n4buf) {
70
         ogs_error("smf_n4_build_session_establishment_request() failed");
71
         return OGS_ERROR;
72
@@ -506,7 +535,7 @@
73
 }
74
 
75
 int smf_epc_pfcp_send_session_establishment_request(
76
-        smf_sess_t *sess, void *gtp_xact)
77
+        smf_sess_t *sess, void *gtp_xact, uint64_t flags)
78
 {
79
     int rv;
80
     ogs_pkbuf_t *n4buf = NULL;
81
@@ -524,12 +553,43 @@
82
     xact->epc = true; /* EPC PFCP transaction */
83
     xact->assoc_xact = gtp_xact;
84
     xact->local_seid = sess->smf_n4_seid;
85
+    xact->create_flags = flags;
86
 
87
     memset(&h, 0, sizeof(ogs_pfcp_header_t));
88
     h.type = OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE;
89
+
90
+/*
91
+ * 7.2.2.4.2 Conditions for Sending SEID=0 in PFCP Header
92
+ *
93
+ * If a peer's SEID is not available, the SEID field shall still be present
94
+ * in the header and its value shall be set to "0" in the following messages:
95
+ *
96
+ * - PFCP Session Establishment Request message on Sxa/Sxb/Sxc/N4;
97
+ *
98
+ * - If a node receives a message for which it has no session, i.e.
99
+ *   if SEID in the PFCP header is not known, it shall respond
100
+ *   with "Session context not found" cause in the corresponding
101
+ *   response message to the sender, the SEID used in the PFCP header
102
+ *   in the response message shall be then set to "0";
103
+ *
104
+ * - If a node receives a request message containing protocol error,
105
+ *   e.g. Mandatory IE missing, which requires the receiver
106
+ *   to reject the message as specified in clause 7.6, it shall reject
107
+ *   the request message. For the response message, the node should look up
108
+ *   the remote peer's SEID and accordingly set SEID in the PFCP header
109
+ *   and the message cause code. As an implementation option,
110
+ *   the node may not look up the remote peer's SEID and
111
+ *   set the PFCP header SEID to "0" in the response message.
112
+ *   However in this case, the cause value shall not be set
113
+ *   to "Session not found".
114
+ *
115
+ * - When the UP function sends PFCP Session Report Request message
116
+ *   over N4 towards another SMF or another PFCP entity in the SMF
117
+ *   as specified in clause 5.22.2 and clause 5.22.3.
118
+ */
119
     h.seid = sess->upf_n4_seid;
120
 
121
-    n4buf = smf_n4_build_session_establishment_request(h.type, sess);
122
+    n4buf = smf_n4_build_session_establishment_request(h.type, sess, xact);
123
     if (!n4buf) {
124
         ogs_error("smf_n4_build_session_establishment_request() failed");
125
         return OGS_ERROR;
126
open5gs_2.6.2.tar.xz/src/smf/pfcp-path.h -> open5gs_2.6.3.tar.xz/src/smf/pfcp-path.h Changed
19
 
1
@@ -36,7 +36,7 @@
2
         ogs_pfcp_xact_t *xact, ogs_time_t duration);
3
 
4
 int smf_5gc_pfcp_send_session_establishment_request(
5
-        smf_sess_t *sess, ogs_sbi_stream_t *stream);
6
+        smf_sess_t *sess, uint64_t flags);
7
 int smf_5gc_pfcp_send_all_pdr_modification_request(
8
         smf_sess_t *sess, ogs_sbi_stream_t *stream,
9
         uint64_t flags, ogs_time_t duration);
10
@@ -47,7 +47,7 @@
11
         smf_sess_t *sess, ogs_sbi_stream_t *stream, int trigger);
12
 
13
 int smf_epc_pfcp_send_session_establishment_request(
14
-        smf_sess_t *sess, void *gtp_xact);
15
+        smf_sess_t *sess, void *gtp_xact, uint64_t flags);
16
 int smf_epc_pfcp_send_all_pdr_modification_request(
17
         smf_sess_t *sess, void *gtp_xact, ogs_pkbuf_t *gtpbuf,
18
         uint64_t flags, uint8_t gtp_pti, uint8_t gtp_cause);
19
open5gs_2.6.2.tar.xz/src/smf/pfcp-sm.c -> open5gs_2.6.3.tar.xz/src/smf/pfcp-sm.c Changed
135
 
1
@@ -22,6 +22,7 @@
2
 
3
 #include "n4-handler.h"
4
 
5
+static void pfcp_restoration(ogs_pfcp_node_t *node);
6
 static void reselect_upf(ogs_pfcp_node_t *node);
7
 static void node_timeout(ogs_pfcp_xact_t *xact, void *data);
8
 
9
@@ -191,7 +192,7 @@
10
             ogs_pfcp_send_heartbeat_request(node, node_timeout));
11
 
12
         if (node->restoration_required == true) {
13
-            /* PFCP Restoration is being performed after PFCP association */
14
+            pfcp_restoration(node);
15
             node->restoration_required = false;
16
             ogs_error("PFCP restoration");
17
         }
18
@@ -244,6 +245,7 @@
19
          * If the peer PFCP entity is performing the association,
20
          * Restoration can be performed immediately.
21
          */
22
+                    pfcp_restoration(node);
23
                     node->restoration_required = false;
24
                     ogs_error("PFCP restoration");
25
                 }
26
@@ -270,6 +272,7 @@
27
          * If the peer PFCP entity is performing the association,
28
          * Restoration can be performed immediately.
29
          */
30
+                    pfcp_restoration(node);
31
                     node->restoration_required = false;
32
                     ogs_error("PFCP restoration");
33
                 }
34
@@ -409,10 +412,52 @@
35
     }
36
 }
37
 
38
+static void pfcp_restoration(ogs_pfcp_node_t *node)
39
+{
40
+    smf_ue_t *smf_ue = NULL;
41
+
42
+    char buf1OGS_ADDRSTRLEN;
43
+    char buf2OGS_ADDRSTRLEN;
44
+
45
+    ogs_list_for_each(&smf_self()->smf_ue_list, smf_ue) {
46
+        smf_sess_t *sess = NULL;
47
+        ogs_assert(smf_ue);
48
+
49
+        ogs_list_for_each(&smf_ue->sess_list, sess) {
50
+            ogs_assert(sess);
51
+
52
+            if (node == sess->pfcp_node) {
53
+                if (sess->epc) {
54
+                    ogs_info("UE IMSI%s APN%s IPv4%s IPv6%s",
55
+                        smf_ue->imsi_bcd, sess->session.name,
56
+                        sess->ipv4 ?
57
+                            OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "",
58
+                        sess->ipv6 ?
59
+                            OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : "");
60
+                    ogs_assert(OGS_OK ==
61
+                        smf_epc_pfcp_send_session_establishment_request(
62
+                            sess, NULL,
63
+                            OGS_PFCP_CREATE_RESTORATION_INDICATION));
64
+                } else {
65
+                    ogs_info("UE SUPI%s DNN%s IPv4%s IPv6%s",
66
+                        smf_ue->supi, sess->session.name,
67
+                        sess->ipv4 ?
68
+                            OGS_INET_NTOP(&sess->ipv4->addr, buf1) : "",
69
+                        sess->ipv6 ?
70
+                            OGS_INET6_NTOP(&sess->ipv6->addr, buf2) : "");
71
+                    ogs_assert(OGS_OK ==
72
+                            smf_5gc_pfcp_send_session_establishment_request(
73
+                                sess, OGS_PFCP_CREATE_RESTORATION_INDICATION));
74
+                }
75
+            }
76
+        }
77
+    }
78
+}
79
+
80
 static void reselect_upf(ogs_pfcp_node_t *node)
81
 {
82
     int r;
83
-    smf_ue_t *smf_ue = NULL, *next_ue = NULL;;
84
+    smf_ue_t *smf_ue = NULL;
85
     ogs_pfcp_node_t *iter = NULL;
86
 
87
     ogs_assert(node);
88
@@ -434,19 +479,18 @@
89
         return;
90
     }
91
 
92
-    ogs_list_for_each_safe(&smf_self()->smf_ue_list, next_ue, smf_ue) {
93
-        smf_sess_t *sess = NULL, *next_sess = NULL;;
94
+    ogs_list_for_each(&smf_self()->smf_ue_list, smf_ue) {
95
+        smf_sess_t *sess = NULL;
96
         ogs_assert(smf_ue);
97
 
98
-        ogs_list_for_each_safe(&smf_ue->sess_list, next_sess, sess) {
99
+        ogs_list_for_each(&smf_ue->sess_list, sess) {
100
             ogs_assert(sess);
101
-            if (sess->epc) {
102
-                ogs_error("%s:%s EPC restoration is not implemented",
103
-                        smf_ue->imsi_bcd, sess->session.name);
104
-            } else {
105
-                ogs_assert(sess->sm_context_ref);
106
 
107
-                if (node == sess->pfcp_node) {
108
+            if (node == sess->pfcp_node) {
109
+                if (sess->epc) {
110
+                    ogs_error("%s:%s EPC restoration is not implemented",
111
+                            smf_ue->imsi_bcd, sess->session.name);
112
+                } else {
113
                     smf_npcf_smpolicycontrol_param_t param;
114
 
115
                     ogs_info("%s:%d SMF-initiated Deletion",
116
@@ -479,18 +523,6 @@
117
     switch (type) {
118
     case OGS_PFCP_HEARTBEAT_REQUEST_TYPE:
119
         ogs_assert(data);
120
-
121
-
122
-    /*
123
-     * The code below is not secure.
124
-     * Session does not differentiate between EPC and 5GC.
125
-     * And, it does not check whether there are other PFCP Nodes.
126
-     *
127
-     * So, UPF redundancy will be implemented later.
128
-     *
129
-     * We plan to do this again after testing with restoration first
130
-     * in case peer PFCP restarts.
131
-     */
132
         reselect_upf(data);
133
 
134
         e = smf_event_new(SMF_EVT_N4_NO_HEARTBEAT);
135
open5gs_2.6.2.tar.xz/src/smf/s5c-build.c -> open5gs_2.6.3.tar.xz/src/smf/s5c-build.c Changed
126
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -28,6 +28,8 @@
9
     int rv;
10
     smf_bearer_t *bearer = NULL;
11
 
12
+    ogs_pkbuf_t *pkbuf = NULL;
13
+
14
     ogs_gtp2_message_t gtp_message;
15
     ogs_gtp2_create_session_response_t *rsp = NULL;
16
 
17
@@ -45,6 +47,8 @@
18
     int len;
19
     uint8_t pco_bufOGS_MAX_PCO_LEN;
20
     int16_t pco_len;
21
+    uint8_t *epco_buf = NULL;
22
+    int16_t epco_len;
23
 
24
     ogs_debug("SMF Create Session Response");
25
 
26
@@ -85,7 +89,7 @@
27
             &smf_s5c_teid, &len);
28
     if (rv != OGS_OK) {
29
         ogs_error("ogs_gtp2_sockaddr_to_f_teid() failed");
30
-        return NULL;
31
+        goto cleanup;
32
     }
33
     rsp->pgw_s5_s8__s2a_s2b_f_teid_for_pmip_based_interface_or_for_gtp_based_control_plane_interface.
34
         presence = 1;
35
@@ -141,6 +145,19 @@
36
         rsp->protocol_configuration_options.len = pco_len;
37
     }
38
 
39
+    /* ePCO */
40
+    if (sess->gtp.ue_epco.presence &&
41
+            sess->gtp.ue_epco.len && sess->gtp.ue_epco.data) {
42
+        epco_buf = ogs_calloc(OGS_MAX_EPCO_LEN, sizeof(uint8_t));
43
+        ogs_assert(epco_buf);
44
+        epco_len = smf_pco_build(
45
+                epco_buf, sess->gtp.ue_epco.data, sess->gtp.ue_epco.len);
46
+        ogs_assert(epco_len > 0);
47
+        rsp->extended_protocol_configuration_options.presence = 1;
48
+        rsp->extended_protocol_configuration_options.data = epco_buf;
49
+        rsp->extended_protocol_configuration_options.len = epco_len;
50
+    }
51
+
52
     i = 0;
53
     ogs_list_for_each(&sess->bearer_list, bearer) {
54
         ogs_assert(i < OGS_BEARER_PER_UE);
55
@@ -190,7 +207,7 @@
56
             &pgw_s5u_teidi, &pgw_s5u_leni);
57
         if (rv != OGS_OK) {
58
             ogs_error("ogs_gtp2_sockaddr_to_f_teid() failed");
59
-            return NULL;
60
+            goto cleanup;
61
         }
62
 
63
         switch (sess->gtp_rat_type) {
64
@@ -219,18 +236,28 @@
65
     }
66
 
67
     gtp_message.h.type = type;
68
-    return ogs_gtp2_build_msg(&gtp_message);
69
+    pkbuf = ogs_gtp2_build_msg(&gtp_message);
70
+
71
+cleanup:
72
+    if (epco_buf)
73
+        ogs_free(epco_buf);
74
+
75
+    return pkbuf;
76
 }
77
 
78
 ogs_pkbuf_t *smf_s5c_build_delete_session_response(
79
         uint8_t type, smf_sess_t *sess)
80
 {
81
+    ogs_pkbuf_t *pkbuf = NULL;
82
+
83
     ogs_gtp2_message_t gtp_message;
84
     ogs_gtp2_delete_session_response_t *rsp = NULL;
85
 
86
     ogs_gtp2_cause_t cause;
87
     uint8_t pco_bufOGS_MAX_PCO_LEN;
88
     int16_t pco_len;
89
+    uint8_t *epco_buf = NULL;
90
+    int16_t epco_len;
91
 
92
     /* prepare cause */
93
     memset(&cause, 0, sizeof(cause));
94
@@ -257,11 +284,30 @@
95
         rsp->protocol_configuration_options.len = pco_len;
96
     }
97
 
98
+    /* ePCO */
99
+    if (sess->gtp.ue_epco.presence &&
100
+            sess->gtp.ue_epco.len && sess->gtp.ue_epco.data) {
101
+        epco_buf = ogs_calloc(OGS_MAX_EPCO_LEN, sizeof(uint8_t));
102
+        ogs_assert(epco_buf);
103
+        epco_len = smf_pco_build(
104
+                epco_buf, sess->gtp.ue_epco.data, sess->gtp.ue_epco.len);
105
+        ogs_assert(epco_len > 0);
106
+        rsp->extended_protocol_configuration_options.presence = 1;
107
+        rsp->extended_protocol_configuration_options.data = epco_buf;
108
+        rsp->extended_protocol_configuration_options.len = epco_len;
109
+    }
110
+
111
     /* Private Extension */
112
 
113
     /* build */
114
     gtp_message.h.type = type;
115
-    return ogs_gtp2_build_msg(&gtp_message);
116
+    pkbuf = ogs_gtp2_build_msg(&gtp_message);
117
+
118
+cleanup:
119
+    if (epco_buf)
120
+        ogs_free(epco_buf);
121
+
122
+    return pkbuf;
123
 }
124
 
125
 ogs_pkbuf_t *smf_s5c_build_modify_bearer_response(
126
open5gs_2.6.2.tar.xz/src/smf/s5c-handler.c -> open5gs_2.6.3.tar.xz/src/smf/s5c-handler.c Changed
49
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -347,8 +347,13 @@
9
         sess->session.ambr.uplink = be32toh(ambr->uplink) * 1000;
10
     }
11
 
12
+    /* ePCO */
13
+    if (req->extended_protocol_configuration_options.presence) {
14
+        OGS_TLV_STORE_DATA(&sess->gtp.ue_epco,
15
+                &req->extended_protocol_configuration_options);
16
+
17
     /* PCO */
18
-    if (req->protocol_configuration_options.presence) {
19
+    } else if (req->protocol_configuration_options.presence) {
20
         OGS_TLV_STORE_DATA(&sess->gtp.ue_pco,
21
                 &req->protocol_configuration_options);
22
     }
23
@@ -420,13 +425,24 @@
24
         OGS_TLV_STORE_DATA(&sess->gtp.ue_pco,
25
                 &req->protocol_configuration_options);
26
     } else {
27
-        /* 
28
+        /*
29
          * Clear contents to reflect whether PCO IE was included or not as part
30
          * of session deletion procedure
31
          */
32
         OGS_TLV_CLEAR_DATA(&sess->gtp.ue_pco);
33
     }
34
 
35
+    if (req->extended_protocol_configuration_options.presence) {
36
+        OGS_TLV_STORE_DATA(&sess->gtp.ue_epco,
37
+                &req->extended_protocol_configuration_options);
38
+    } else {
39
+        /*
40
+         * Clear contents to reflect whether PCO IE was included or not as part
41
+         * of session deletion procedure
42
+         */
43
+        OGS_TLV_CLEAR_DATA(&sess->gtp.ue_epco);
44
+    }
45
+
46
     ogs_debug("    SGW_S5C_TEID0x%x SMF_N4_TEID0x%x",
47
             sess->sgw_s5c_teid, sess->smf_n4_teid);
48
 
49
open5gs_2.6.2.tar.xz/src/smf/smf-sm.c -> open5gs_2.6.3.tar.xz/src/smf/smf-sm.c Changed
29
 
1
@@ -928,7 +928,12 @@
2
         }
3
 
4
         ogs_assert(sess);
5
-        ogs_assert(OGS_FSM_STATE(&sess->sm));
6
+        sess = smf_sess_cycle(sess);
7
+        if (!sess) {
8
+            ogs_error("Session has already been removed");
9
+            ogs_pkbuf_free(pkbuf);
10
+            break;
11
+        }
12
 
13
         e->nas.message = &nas_message;
14
         ogs_fsm_dispatch(&sess->sm, e);
15
@@ -946,7 +951,12 @@
16
         ogs_assert(e->ngap.type);
17
 
18
         ogs_assert(sess);
19
-        ogs_assert(OGS_FSM_STATE(&sess->sm));
20
+        sess = smf_sess_cycle(sess);
21
+        if (!sess) {
22
+            ogs_error("Session has already been removed");
23
+            ogs_pkbuf_free(pkbuf);
24
+            break;
25
+        }
26
 
27
         ogs_fsm_dispatch(&sess->sm, e);
28
 
29
open5gs_2.6.2.tar.xz/src/upf/context.c -> open5gs_2.6.3.tar.xz/src/upf/context.c Changed
160
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -25,6 +25,7 @@
9
 int __upf_log_domain;
10
 
11
 static OGS_POOL(upf_sess_pool, upf_sess_t);
12
+static OGS_POOL(upf_n4_seid_pool, ogs_pool_id_t);
13
 
14
 static int context_initialized = 0;
15
 
16
@@ -49,11 +50,15 @@
17
 
18
     ogs_list_init(&self.sess_list);
19
     ogs_pool_init(&upf_sess_pool, ogs_app()->pool.sess);
20
+    ogs_pool_init(&upf_n4_seid_pool, ogs_app()->pool.sess);
21
+    ogs_pool_random_id_generate(&upf_n4_seid_pool);
22
 
23
-    self.seid_hash = ogs_hash_make();
24
-    ogs_assert(self.seid_hash);
25
-    self.f_seid_hash = ogs_hash_make();
26
-    ogs_assert(self.f_seid_hash);
27
+    self.upf_n4_seid_hash = ogs_hash_make();
28
+    ogs_assert(self.upf_n4_seid_hash);
29
+    self.smf_n4_seid_hash = ogs_hash_make();
30
+    ogs_assert(self.smf_n4_seid_hash);
31
+    self.smf_n4_f_seid_hash = ogs_hash_make();
32
+    ogs_assert(self.smf_n4_f_seid_hash);
33
     self.ipv4_hash = ogs_hash_make();
34
     ogs_assert(self.ipv4_hash);
35
     self.ipv6_hash = ogs_hash_make();
36
@@ -77,10 +82,12 @@
37
 
38
     upf_sess_remove_all();
39
 
40
-    ogs_assert(self.seid_hash);
41
-    ogs_hash_destroy(self.seid_hash);
42
-    ogs_assert(self.f_seid_hash);
43
-    ogs_hash_destroy(self.f_seid_hash);
44
+    ogs_assert(self.upf_n4_seid_hash);
45
+    ogs_hash_destroy(self.upf_n4_seid_hash);
46
+    ogs_assert(self.smf_n4_seid_hash);
47
+    ogs_hash_destroy(self.smf_n4_seid_hash);
48
+    ogs_assert(self.smf_n4_f_seid_hash);
49
+    ogs_hash_destroy(self.smf_n4_f_seid_hash);
50
     ogs_assert(self.ipv4_hash);
51
     ogs_hash_destroy(self.ipv4_hash);
52
     ogs_assert(self.ipv6_hash);
53
@@ -90,6 +97,7 @@
54
     free_upf_route_trie_node(self.ipv6_framed_routes);
55
 
56
     ogs_pool_final(&upf_sess_pool);
57
+    ogs_pool_final(&upf_n4_seid_pool);
58
 
59
     context_initialized = 0;
60
 }
61
@@ -171,10 +179,14 @@
62
 
63
     ogs_pfcp_pool_init(&sess->pfcp);
64
 
65
-    sess->index = ogs_pool_index(&upf_sess_pool, sess);
66
-    ogs_assert(sess->index > 0 && sess->index <= ogs_app()->pool.sess);
67
+    /* Set UPF-N4-SEID */
68
+    ogs_pool_alloc(&upf_n4_seid_pool, &sess->upf_n4_seid_node);
69
+    ogs_assert(sess->upf_n4_seid_node);
70
 
71
-    sess->upf_n4_seid = sess->index;
72
+    sess->upf_n4_seid = *(sess->upf_n4_seid_node);
73
+
74
+    ogs_hash_set(self.upf_n4_seid_hash, &sess->upf_n4_seid,
75
+            sizeof(sess->upf_n4_seid), sess);
76
 
77
     /* Since F-SEID is composed of ogs_ip_t and uint64-seid,
78
      * all these values must be put into the structure-smf_n4_f_seid
79
@@ -183,9 +195,9 @@
80
     ogs_assert(OGS_OK ==
81
             ogs_pfcp_f_seid_to_ip(cp_f_seid, &sess->smf_n4_f_seid.ip));
82
 
83
-    ogs_hash_set(self.f_seid_hash, &sess->smf_n4_f_seid,
84
+    ogs_hash_set(self.smf_n4_f_seid_hash, &sess->smf_n4_f_seid,
85
             sizeof(sess->smf_n4_f_seid), sess);
86
-    ogs_hash_set(self.seid_hash, &sess->smf_n4_f_seid.seid,
87
+    ogs_hash_set(self.smf_n4_seid_hash, &sess->smf_n4_f_seid.seid,
88
             sizeof(sess->smf_n4_f_seid.seid), sess);
89
 
90
     ogs_list_add(&self.sess_list, sess);
91
@@ -206,9 +218,12 @@
92
     ogs_list_remove(&self.sess_list, sess);
93
     ogs_pfcp_sess_clear(&sess->pfcp);
94
 
95
-    ogs_hash_set(self.seid_hash, &sess->smf_n4_f_seid.seid,
96
+    ogs_hash_set(self.upf_n4_seid_hash, &sess->upf_n4_seid,
97
+            sizeof(sess->upf_n4_seid), NULL);
98
+
99
+    ogs_hash_set(self.smf_n4_seid_hash, &sess->smf_n4_f_seid.seid,
100
             sizeof(sess->smf_n4_f_seid.seid), NULL);
101
-    ogs_hash_set(self.f_seid_hash, &sess->smf_n4_f_seid,
102
+    ogs_hash_set(self.smf_n4_f_seid_hash, &sess->smf_n4_f_seid,
103
             sizeof(sess->smf_n4_f_seid), NULL);
104
 
105
     if (sess->ipv4) {
106
@@ -226,7 +241,10 @@
107
 
108
     ogs_pfcp_pool_final(&sess->pfcp);
109
 
110
+    ogs_pool_free(&upf_n4_seid_pool, sess->upf_n4_seid_node);
111
     ogs_pool_free(&upf_sess_pool, sess);
112
+    if (sess->apn_dnn)
113
+        ogs_free(sess->apn_dnn);
114
     upf_metrics_inst_global_dec(UPF_METR_GLOB_GAUGE_UPF_SESSIONNBR);
115
 
116
     ogs_info("Removed Number of UPF-sessions is now %d",
117
@@ -244,14 +262,9 @@
118
     }
119
 }
120
 
121
-upf_sess_t *upf_sess_find(uint32_t index)
122
-{
123
-    return ogs_pool_find(&upf_sess_pool, index);
124
-}
125
-
126
 upf_sess_t *upf_sess_find_by_smf_n4_seid(uint64_t seid)
127
 {
128
-    return (upf_sess_t *)ogs_hash_get(self.seid_hash, &seid, sizeof(seid));
129
+    return ogs_hash_get(self.smf_n4_seid_hash, &seid, sizeof(seid));
130
 }
131
 
132
 upf_sess_t *upf_sess_find_by_smf_n4_f_seid(ogs_pfcp_f_seid_t *f_seid)
133
@@ -265,12 +278,12 @@
134
     ogs_assert(OGS_OK == ogs_pfcp_f_seid_to_ip(f_seid, &key.ip));
135
     key.seid = f_seid->seid;
136
 
137
-    return (upf_sess_t *)ogs_hash_get(self.f_seid_hash, &key, sizeof(key));
138
+    return ogs_hash_get(self.smf_n4_f_seid_hash, &key, sizeof(key));
139
 }
140
 
141
 upf_sess_t *upf_sess_find_by_upf_n4_seid(uint64_t seid)
142
 {
143
-    return upf_sess_find(seid);
144
+    return ogs_hash_get(self.upf_n4_seid_hash, &seid, sizeof(seid));
145
 }
146
 
147
 upf_sess_t *upf_sess_find_by_ipv4(uint32_t addr)
148
@@ -355,7 +368,10 @@
149
     sess = upf_sess_find_by_smf_n4_f_seid(f_seid);
150
     if (!sess) {
151
         sess = upf_sess_add(f_seid);
152
-        if (!sess) return NULL;
153
+        if (!sess) {
154
+            ogs_error("No Session Context");
155
+            return NULL;
156
+        }
157
     }
158
     ogs_assert(sess);
159
 
160
open5gs_2.6.2.tar.xz/src/upf/context.h -> open5gs_2.6.3.tar.xz/src/upf/context.h Changed
64
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -48,14 +48,18 @@
9
 struct upf_route_trie_node;
10
 
11
 typedef struct upf_context_s {
12
-    ogs_hash_t                 *seid_hash;     /* hash table (SEID) */
13
-    ogs_hash_t                 *f_seid_hash;   /* hash table (F-SEID) */
14
-    ogs_hash_t                 *ipv4_hash;     /* hash table (IPv4 Address) */
15
-    ogs_hash_t                 *ipv6_hash;     /* hash table (IPv6 Address) */
16
-    struct upf_route_trie_node *ipv4_framed_routes; /* IPv4 framed routes trie */
17
-    struct upf_route_trie_node *ipv6_framed_routes; /* IPv6 framed routes trie */
18
+    ogs_hash_t *upf_n4_seid_hash;   /* hash table (UPF-N4-SEID) */
19
+    ogs_hash_t *smf_n4_seid_hash;   /* hash table (SMF-N4-SEID) */
20
+    ogs_hash_t *smf_n4_f_seid_hash; /* hash table (SMF-N4-F-SEID) */
21
+    ogs_hash_t *ipv4_hash;  /* hash table (IPv4 Address) */
22
+    ogs_hash_t *ipv6_hash;  /* hash table (IPv6 Address) */
23
+
24
+    /* IPv4 framed routes trie */
25
+    struct upf_route_trie_node *ipv4_framed_routes;
26
+    /* IPv6 framed routes trie */
27
+    struct upf_route_trie_node *ipv6_framed_routes;
28
 
29
-    ogs_list_t                  sess_list;
30
+    ogs_list_t sess_list;
31
 } upf_context_t;
32
 
33
 /* trie mapping from IP framed routes to session. */
34
@@ -96,11 +100,11 @@
35
 #define UPF_SESS(pfcp_sess) ogs_container_of(pfcp_sess, upf_sess_t, pfcp)
36
 typedef struct upf_sess_s {
37
     ogs_lnode_t     lnode;
38
-    uint32_t        index;              /**< An index of this node */
39
+    ogs_pool_id_t   *upf_n4_seid_node;  /* A node of UPF-N4-SEID */
40
 
41
     ogs_pfcp_sess_t pfcp;
42
 
43
-    uint64_t        upf_n4_seid;        /* UPF SEID is dervied from INDEX */
44
+    uint64_t        upf_n4_seid;        /* UPF SEID is dervied from NODE */
45
     struct {
46
         uint64_t    seid;
47
         ogs_ip_t    ip;
48
@@ -118,6 +122,7 @@
49
 
50
     /* Accounting: */
51
     upf_sess_urr_acc_t urr_accOGS_MAX_NUM_OF_URR; /* FIXME: This probably needs to be mved to a hashtable or alike */
52
+    char            *apn_dnn;            /* APN/DNN Item */
53
 } upf_sess_t;
54
 
55
 void upf_context_init(void);
56
@@ -131,7 +136,6 @@
57
 upf_sess_t *upf_sess_add(ogs_pfcp_f_seid_t *f_seid);
58
 int upf_sess_remove(upf_sess_t *sess);
59
 void upf_sess_remove_all(void);
60
-upf_sess_t *upf_sess_find(uint32_t index);
61
 upf_sess_t *upf_sess_find_by_smf_n4_seid(uint64_t seid);
62
 upf_sess_t *upf_sess_find_by_smf_n4_f_seid(ogs_pfcp_f_seid_t *f_seid);
63
 upf_sess_t *upf_sess_find_by_upf_n4_seid(uint64_t seid);
64
open5gs_2.6.2.tar.xz/src/upf/gtp-path.c -> open5gs_2.6.3.tar.xz/src/upf/gtp-path.c Changed
138
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -258,11 +258,13 @@
9
 {
10
     int len;
11
     ssize_t size;
12
-    char bufOGS_ADDRSTRLEN;
13
+    char buf1OGS_ADDRSTRLEN;
14
+    char buf2OGS_ADDRSTRLEN;
15
 
16
     upf_sess_t *sess = NULL;
17
 
18
     ogs_pkbuf_t *pkbuf = NULL;
19
+    ogs_sock_t *sock = NULL;
20
     ogs_sockaddr_t from;
21
 
22
     ogs_gtp2_header_t *gtp_h = NULL;
23
@@ -272,6 +274,8 @@
24
     uint8_t qfi;
25
 
26
     ogs_assert(fd != INVALID_SOCKET);
27
+    sock = data;
28
+    ogs_assert(sock);
29
 
30
     pkbuf = ogs_pkbuf_alloc(packet_pool, OGS_MAX_PKT_LEN);
31
     ogs_assert(pkbuf);
32
@@ -300,14 +304,14 @@
33
     if (gtp_h->type == OGS_GTPU_MSGTYPE_ECHO_REQ) {
34
         ogs_pkbuf_t *echo_rsp;
35
 
36
-        ogs_debug("RECV Echo Request from %s", OGS_ADDR(&from, buf));
37
+        ogs_debug("RECV Echo Request from %s", OGS_ADDR(&from, buf1));
38
         echo_rsp = ogs_gtp2_handle_echo_req(pkbuf);
39
         ogs_expect(echo_rsp);
40
         if (echo_rsp) {
41
             ssize_t sent;
42
 
43
             /* Echo reply */
44
-            ogs_debug("SEND Echo Response to %s", OGS_ADDR(&from, buf));
45
+            ogs_debug("SEND Echo Response to %s", OGS_ADDR(&from, buf1));
46
 
47
             sent = ogs_sendto(fd, echo_rsp->data, echo_rsp->len, 0, &from);
48
             if (sent < 0 || sent != echo_rsp->len) {
49
@@ -322,7 +326,7 @@
50
     teid = be32toh(gtp_h->teid);
51
 
52
     ogs_trace("RECV GPU-U Type %d from %s : TEID0x%x",
53
-            gtp_h->type, OGS_ADDR(&from, buf), teid);
54
+            gtp_h->type, OGS_ADDR(&from, buf1), teid);
55
 
56
     qfi = 0;
57
     if (gtp_h->flags & OGS_GTPU_FLAGS_E) {
58
@@ -369,7 +373,7 @@
59
     } else if (gtp_h->type == OGS_GTPU_MSGTYPE_ERR_IND) {
60
         ogs_pfcp_far_t *far = NULL;
61
 
62
-        far = ogs_pfcp_far_find_by_error_indication(pkbuf);
63
+        far = ogs_pfcp_far_find_by_gtpu_error_indication(pkbuf);
64
         if (far) {
65
             ogs_assert(true ==
66
                 ogs_pfcp_up_handle_error_indication(far, &report));
67
@@ -419,12 +423,32 @@
68
 
69
         pfcp_object = ogs_pfcp_object_find_by_teid(teid);
70
         if (!pfcp_object) {
71
-            /* TODO : Send Error Indication */
72
+            /*
73
+             * TS23.527 Restoration procedures
74
+             * 4.3 UPF Restoration Procedures
75
+             * 4.3.2 Restoration Procedure for PSA UPF Restart
76
+             *
77
+             * The UPF shall not send GTP-U Error indication message
78
+             * for a configurable period after an UPF restart
79
+             * when the UPF receives a G-PDU not matching any PDRs.
80
+             */
81
+            if (ogs_time_ntp32_now() >
82
+                   (ogs_pfcp_self()->local_recovery +
83
+                    ogs_time_sec(
84
+                        ogs_app()->time.message.pfcp.association_interval))) {
85
+                ogs_error("%s Send Error Indication TEID:0x%x to %s",
86
+                        OGS_ADDR(&sock->local_addr, buf1),
87
+                        teid,
88
+                        OGS_ADDR(&from, buf2));
89
+                ogs_gtp1_send_error_indication(sock, teid, qfi, &from);
90
+            }
91
             goto cleanup;
92
         }
93
 
94
         switch(pfcp_object->type) {
95
         case OGS_PFCP_OBJ_PDR_TYPE:
96
+            /* UPF does not use PDR TYPE */
97
+            ogs_assert_if_reached();
98
             pdr = (ogs_pfcp_pdr_t *)pfcp_object;
99
             ogs_assert(pdr);
100
             break;
101
@@ -456,7 +480,26 @@
102
             }
103
 
104
             if (!pdr) {
105
-                /* TODO : Send Error Indication */
106
+                /*
107
+                 * TS23.527 Restoration procedures
108
+                 * 4.3 UPF Restoration Procedures
109
+                 * 4.3.2 Restoration Procedure for PSA UPF Restart
110
+                 *
111
+                 * The UPF shall not send GTP-U Error indication message
112
+                 * for a configurable period after an UPF restart
113
+                 * when the UPF receives a G-PDU not matching any PDRs.
114
+                 */
115
+                if (ogs_time_ntp32_now() >
116
+                       (ogs_pfcp_self()->local_recovery +
117
+                        ogs_time_sec(
118
+                            ogs_app()->time.message.pfcp.association_interval))) {
119
+                    ogs_error(
120
+                            "%s Send Error Indication TEID:0x%x to %s",
121
+                            OGS_ADDR(&sock->local_addr, buf1),
122
+                            teid,
123
+                            OGS_ADDR(&from, buf2));
124
+                    ogs_gtp1_send_error_indication(sock, teid, qfi, &from);
125
+                }
126
                 goto cleanup;
127
             }
128
 
129
@@ -684,7 +727,7 @@
130
 
131
     config.cluster_2048_pool = ogs_app()->pool.packet;
132
 
133
-#if OGS_USE_TALLOC
134
+#if OGS_USE_TALLOC == 1
135
     /* allocate a talloc pool for GTP to ensure it doesn't have to go back
136
      * to the libc malloc all the time */
137
     packet_pool = talloc_pool(__ogs_talloc_core, 1000*1024);
138
open5gs_2.6.2.tar.xz/src/upf/metrics.c -> open5gs_2.6.3.tar.xz/src/upf/metrics.c Changed
10
 
1
@@ -286,7 +286,7 @@
2
     ogs_assert(dnn_key);
3
 
4
     if (dnn) {
5
-        strcpy(dnn_key->dnn, dnn);
6
+        ogs_cpystrn(dnn_key->dnn, dnn, ogs_min(strlen(dnn), OGS_MAX_DNN_LEN)+1);
7
     } else {
8
         dnn_key->dnn0 = '\0';
9
     }
10
open5gs_2.6.2.tar.xz/src/upf/n4-handler.c -> open5gs_2.6.3.tar.xz/src/upf/n4-handler.c Changed
201
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -55,6 +55,9 @@
9
     uint8_t offending_ie_value = 0;
10
     int i;
11
 
12
+    ogs_pfcp_sereq_flags_t sereq_flags;
13
+    bool restoration_indication = false;
14
+
15
     upf_metrics_inst_global_inc(UPF_METR_GLOB_CTR_SM_N4SESSIONESTABREQ);
16
 
17
     ogs_assert(xact);
18
@@ -74,9 +77,14 @@
19
         return;
20
     }
21
 
22
+    memset(&sereq_flags, 0, sizeof(sereq_flags));
23
+    if (req->pfcpsereq_flags.presence == 1)
24
+        sereq_flags.value = req->pfcpsereq_flags.u8;
25
+
26
     for (i = 0; i < OGS_MAX_NUM_OF_PDR; i++) {
27
         created_pdri = ogs_pfcp_handle_create_pdr(&sess->pfcp,
28
-                &req->create_pdri, &cause_value, &offending_ie_value);
29
+                &req->create_pdri, &sereq_flags,
30
+                &cause_value, &offending_ie_value);
31
         if (created_pdri == NULL)
32
             break;
33
     }
34
@@ -96,17 +104,24 @@
35
     if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
36
         goto cleanup;
37
 
38
+    if (req->apn_dnn.presence) {
39
+        char apn_dnnOGS_MAX_DNN_LEN+1;
40
+
41
+        ogs_assert(0 < ogs_fqdn_parse(apn_dnn, req->apn_dnn.data,
42
+                ogs_min(req->apn_dnn.len, OGS_MAX_DNN_LEN)));
43
+
44
+        if (sess->apn_dnn)
45
+            ogs_free(sess->apn_dnn);
46
+        sess->apn_dnn = ogs_strdup(apn_dnn);
47
+        ogs_assert(sess->apn_dnn);
48
+    }
49
+
50
     for (i = 0; i < OGS_MAX_NUM_OF_QER; i++) {
51
         if (ogs_pfcp_handle_create_qer(&sess->pfcp, &req->create_qeri,
52
                     &cause_value, &offending_ie_value) == NULL)
53
             break;
54
-        if (req->apn_dnn.presence == 1) {
55
-            upf_metrics_inst_by_dnn_add(req->apn_dnn.data,
56
-                    UPF_METR_GAUGE_UPF_QOSFLOWS, 1);
57
-        } else {
58
-            upf_metrics_inst_by_dnn_add(NULL,
59
-                    UPF_METR_GAUGE_UPF_QOSFLOWS, 1);
60
-        }
61
+        upf_metrics_inst_by_dnn_add(sess->apn_dnn,
62
+                UPF_METR_GAUGE_UPF_QOSFLOWS, 1);
63
     }
64
     if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
65
         goto cleanup;
66
@@ -116,6 +131,18 @@
67
     if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
68
         goto cleanup;
69
 
70
+    /* PFCPSEReq-Flags */
71
+    if (sereq_flags.restoration_indication == 1) {
72
+        for (i = 0; i < num_of_created_pdr; i++) {
73
+            pdr = created_pdri;
74
+            ogs_assert(pdr);
75
+
76
+            if (pdr->f_teid_len)
77
+                ogs_pfcp_pdr_swap_teid(pdr);
78
+        }
79
+        restoration_indication = true;
80
+    }
81
+
82
     /* Setup GTP Node */
83
     ogs_list_for_each(&sess->pfcp.far_list, far) {
84
         ogs_assert(OGS_ERROR != ogs_pfcp_setup_far_gtpu_node(far));
85
@@ -155,65 +182,9 @@
86
         }
87
 
88
         /* Setup UPF-N3-TEID & QFI Hash */
89
-        if (pdr->f_teid_len) {
90
-            ogs_pfcp_object_type_e type = OGS_PFCP_OBJ_SESS_TYPE;
91
-
92
-            if (ogs_pfcp_self()->up_function_features.ftup &&
93
-                pdr->f_teid.ch) {
94
-
95
-                ogs_pfcp_pdr_t *choosed_pdr = NULL;
96
-
97
-                if (pdr->f_teid.chid) {
98
-                    choosed_pdr = ogs_pfcp_pdr_find_by_choose_id(
99
-                            &sess->pfcp, pdr->f_teid.choose_id);
100
-                    if (!choosed_pdr) {
101
-                        pdr->chid = true;
102
-                        pdr->choose_id = pdr->f_teid.choose_id;
103
-                    }
104
-                } else {
105
-                    type = OGS_PFCP_OBJ_PDR_TYPE;
106
-                }
107
-
108
-                if (choosed_pdr) {
109
-                    pdr->f_teid_len = choosed_pdr->f_teid_len;
110
-                    memcpy(&pdr->f_teid, &choosed_pdr->f_teid, pdr->f_teid_len);
111
-
112
-                } else {
113
-                    ogs_gtpu_resource_t *resource = NULL;
114
-                    resource = ogs_pfcp_find_gtpu_resource(
115
-                            &ogs_gtp_self()->gtpu_resource_list,
116
-                            pdr->dnn, OGS_PFCP_INTERFACE_ACCESS);
117
-                    if (resource) {
118
-                        ogs_assert(
119
-                            (resource->info.v4 && pdr->f_teid.ipv4) ||
120
-                            (resource->info.v6 && pdr->f_teid.ipv6));
121
-                        ogs_assert(OGS_OK ==
122
-                            ogs_pfcp_user_plane_ip_resource_info_to_f_teid(
123
-                            &resource->info, &pdr->f_teid, &pdr->f_teid_len));
124
-                        if (resource->info.teidri)
125
-                            pdr->f_teid.teid = OGS_PFCP_GTPU_INDEX_TO_TEID(
126
-                                    pdr->index, resource->info.teidri,
127
-                                    resource->info.teid_range);
128
-                        else
129
-                            pdr->f_teid.teid = pdr->index;
130
-                    } else {
131
-                        ogs_assert(
132
-                            (ogs_gtp_self()->gtpu_addr && pdr->f_teid.ipv4) ||
133
-                            (ogs_gtp_self()->gtpu_addr6 && pdr->f_teid.ipv6));
134
-                        ogs_assert(OGS_OK ==
135
-                            ogs_pfcp_sockaddr_to_f_teid(
136
-                                pdr->f_teid.ipv4 ?
137
-                                    ogs_gtp_self()->gtpu_addr : NULL,
138
-                                pdr->f_teid.ipv6 ?
139
-                                    ogs_gtp_self()->gtpu_addr6 : NULL,
140
-                                &pdr->f_teid, &pdr->f_teid_len));
141
-                        pdr->f_teid.teid = pdr->index;
142
-                    }
143
-                }
144
-            }
145
-
146
-            ogs_pfcp_object_teid_hash_set(type, pdr);
147
-        }
148
+        if (pdr->f_teid_len)
149
+            ogs_pfcp_object_teid_hash_set(
150
+                    OGS_PFCP_OBJ_SESS_TYPE, pdr, restoration_indication);
151
     }
152
 
153
     /* Send Buffered Packet to gNB/SGW */
154
@@ -223,9 +194,16 @@
155
         }
156
     }
157
 
158
-    ogs_assert(OGS_OK ==
159
-        upf_pfcp_send_session_establishment_response(
160
-            xact, sess, created_pdr, num_of_created_pdr));
161
+    if (restoration_indication == true ||
162
+        ogs_pfcp_self()->up_function_features.ftup == 0)
163
+        ogs_assert(OGS_OK ==
164
+            upf_pfcp_send_session_establishment_response(
165
+                xact, sess, NULL, 0));
166
+    else
167
+        ogs_assert(OGS_OK ==
168
+            upf_pfcp_send_session_establishment_response(
169
+                xact, sess, created_pdr, num_of_created_pdr));
170
+
171
     return;
172
 
173
 cleanup:
174
@@ -266,7 +244,7 @@
175
 
176
     for (i = 0; i < OGS_MAX_NUM_OF_PDR; i++) {
177
         created_pdri = ogs_pfcp_handle_create_pdr(&sess->pfcp,
178
-                &req->create_pdri, &cause_value, &offending_ie_value);
179
+                &req->create_pdri, NULL, &cause_value, &offending_ie_value);
180
         if (created_pdri == NULL)
181
             break;
182
     }
183
@@ -358,7 +336,7 @@
184
         if (ogs_pfcp_handle_create_qer(&sess->pfcp, &req->create_qeri,
185
                     &cause_value, &offending_ie_value) == NULL)
186
             break;
187
-        upf_metrics_inst_by_dnn_add(NULL,
188
+        upf_metrics_inst_by_dnn_add(sess->apn_dnn,
189
                 UPF_METR_GAUGE_UPF_QOSFLOWS, 1);
190
     }
191
     if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
192
@@ -376,7 +354,7 @@
193
         if (ogs_pfcp_handle_remove_qer(&sess->pfcp, &req->remove_qeri,
194
                 &cause_value, &offending_ie_value) == false)
195
             break;
196
-        upf_metrics_inst_by_dnn_add(NULL,
197
+        upf_metrics_inst_by_dnn_add(sess->apn_dnn,
198
                 UPF_METR_GAUGE_UPF_QOSFLOWS, -1);
199
     }
200
     if (cause_value != OGS_PFCP_CAUSE_REQUEST_ACCEPTED)
201
open5gs_2.6.2.tar.xz/src/upf/pfcp-path.c -> open5gs_2.6.3.tar.xz/src/upf/pfcp-path.c Changed
9
 
1
@@ -208,7 +208,6 @@
2
     ogs_pfcp_header_t h;
3
 
4
     ogs_assert(xact);
5
-    ogs_assert(created_pdr);
6
 
7
     memset(&h, 0, sizeof(ogs_pfcp_header_t));
8
     h.type = OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE;
9
open5gs_2.6.2.tar.xz/src/upf/pfcp-sm.c -> open5gs_2.6.3.tar.xz/src/upf/pfcp-sm.c Changed
17
 
1
@@ -281,12 +281,9 @@
2
                     &message->pfcp_association_setup_response);
3
             break;
4
         case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE:
5
-            if (message->h.seid_presence && message->h.seid == 0) {
6
-                ogs_expect(!sess);
7
-                sess = upf_sess_add_by_message(message);
8
-                if (sess)
9
-                    OGS_SETUP_PFCP_NODE(sess, node);
10
-            }
11
+            sess = upf_sess_add_by_message(message);
12
+            if (sess)
13
+                OGS_SETUP_PFCP_NODE(sess, node);
14
             upf_n4_handle_session_establishment_request(
15
                 sess, xact, &message->pfcp_session_establishment_request);
16
             break;
17
open5gs_2.6.2.tar.xz/tests/af/context.c -> open5gs_2.6.3.tar.xz/tests/af/context.c Changed
43
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -267,17 +267,21 @@
9
 }
10
 
11
 static ogs_sbi_client_t *find_client_by_fqdn(
12
-        OpenAPI_uri_scheme_e scheme, char *fqdn, int port)
13
+        OpenAPI_uri_scheme_e scheme, char *fqdn)
14
 {
15
     int rv;
16
     ogs_sockaddr_t *addr = NULL;
17
     ogs_sbi_client_t *client = NULL;
18
 
19
-    ogs_assert(scheme);
20
+    ogs_assert(scheme == OpenAPI_uri_scheme_https ||
21
+                scheme == OpenAPI_uri_scheme_http);
22
     ogs_assert(fqdn);
23
 
24
-    rv = ogs_getaddrinfo(&addr, AF_UNSPEC, fqdn,
25
-            port ? port : ogs_sbi_self()->sbi_port, 0);
26
+    rv = ogs_getaddrinfo(
27
+            &addr, AF_UNSPEC, fqdn,
28
+            scheme == OpenAPI_uri_scheme_https ?
29
+                OGS_SBI_HTTPS_PORT : OGS_SBI_HTTP_PORT,
30
+            0);
31
     if (rv != OGS_OK) {
32
         ogs_error("Invalid NFProfile.fqdn");
33
         return NULL;
34
@@ -306,7 +310,7 @@
35
                 OpenAPI_uri_scheme_https : OpenAPI_uri_scheme_http;
36
 
37
     if (sess->pcf.fqdn && strlen(sess->pcf.fqdn))
38
-        client = find_client_by_fqdn(scheme, sess->pcf.fqdn, 0);
39
+        client = find_client_by_fqdn(scheme, sess->pcf.fqdn);
40
 
41
     if (!client) {
42
         /* At this point, CLIENT selection method is very simple. */
43
open5gs_2.6.2.tar.xz/tests/af/context.h -> open5gs_2.6.3.tar.xz/tests/af/context.h Changed
16
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019-2022 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -72,6 +72,7 @@
9
         struct {
10
             ogs_sockaddr_t *addr;
11
             ogs_sockaddr_t *addr6;
12
+            bool is_port;
13
             int port;
14
         } ipOGS_SBI_MAX_NUM_OF_IP_ADDRESS;
15
 
16
open5gs_2.6.2.tar.xz/tests/af/nbsf-handler.c -> open5gs_2.6.3.tar.xz/tests/af/nbsf-handler.c Changed
41
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -67,21 +67,10 @@
9
         if (!IpEndPoint) continue;
10
 
11
         if (sess->pcf.num_of_ip < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
12
-            if (!IpEndPoint->is_port) {
13
-                if (ogs_sbi_default_uri_scheme() ==
14
-                        OpenAPI_uri_scheme_http)
15
-                    port = OGS_SBI_HTTP_PORT;
16
-                else if (ogs_sbi_default_uri_scheme() ==
17
-                        OpenAPI_uri_scheme_https)
18
-                    port = OGS_SBI_HTTPS_PORT;
19
-                else {
20
-                    ogs_fatal("Invalid scheme %d",
21
-                        ogs_sbi_default_uri_scheme());
22
-                    ogs_assert_if_reached();
23
-                }
24
-            } else {
25
+            if (!IpEndPoint->is_port)
26
+                port = ogs_sbi_client_default_port();
27
+            else
28
                 port = IpEndPoint->port;
29
-            }
30
 
31
             if (IpEndPoint->ipv4_address) {
32
                 rv = ogs_getaddrinfo(&addr, AF_UNSPEC,
33
@@ -95,6 +84,7 @@
34
             }
35
 
36
             if (addr || addr6) {
37
+                sess->pcf.ipsess->pcf.num_of_ip.is_port = IpEndPoint->is_port;
38
                 sess->pcf.ipsess->pcf.num_of_ip.port = port;
39
                 sess->pcf.ipsess->pcf.num_of_ip.addr = addr;
40
                 sess->pcf.ipsess->pcf.num_of_ip.addr6 = addr6;
41
open5gs_2.6.2.tar.xz/tests/attach/guti-test.c -> open5gs_2.6.3.tar.xz/tests/attach/guti-test.c Changed
17
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -228,7 +228,7 @@
9
     memset(&sess->pdn_connectivity_param,
10
             0, sizeof(sess->pdn_connectivity_param));
11
     sess->pdn_connectivity_param.eit = 1;
12
-    sess->pdn_connectivity_param.pco = 1;
13
+    sess->pdn_connectivity_param.epco = 1;
14
     sess->pdn_connectivity_param.request_type =
15
         OGS_NAS_EPS_REQUEST_TYPE_INITIAL;
16
     esmbuf = testesm_build_pdn_connectivity_request(sess, false);
17
open5gs_2.6.2.tar.xz/tests/attach/simple-test.c -> open5gs_2.6.3.tar.xz/tests/attach/simple-test.c Changed
17
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -149,7 +149,7 @@
9
     tests1ap_recv(test_ue, recvbuf);
10
 
11
     /* Send ESM Information Response */
12
-    sess->esm_information_param.pco = 1;
13
+    sess->esm_information_param.epco = 1;
14
     esmbuf = testesm_build_esm_information_response(sess);
15
     ABTS_PTR_NOTNULL(tc, esmbuf);
16
     sendbuf = test_s1ap_build_uplink_nas_transport(test_ue, esmbuf);
17
open5gs_2.6.2.tar.xz/tests/common/context.h -> open5gs_2.6.3.tar.xz/tests/common/context.h Changed
23
 
1
@@ -257,10 +257,11 @@
2
 typedef struct test_pdn_connectivity_param_s {
3
     union {
4
         struct {
5
-        ED6(uint8_t eit:1;,
6
+        ED7(uint8_t eit:1;,
7
             uint8_t eit_no_required:1;,
8
             uint8_t apn:1;,
9
             uint8_t pco:1;,
10
+            uint8_t epco:1;,
11
             uint8_t spare:1;,
12
             uint8_t request_type:3;)
13
         };
14
@@ -272,7 +273,7 @@
15
     union {
16
         struct {
17
         ED8(uint8_t pco:1;,
18
-            uint8_t spare1:1;,
19
+            uint8_t epco:1;,
20
             uint8_t spare2:1;,
21
             uint8_t spare3:1;,
22
             uint8_t spare4:1;,
23
open5gs_2.6.2.tar.xz/tests/common/esm-build.c -> open5gs_2.6.3.tar.xz/tests/common/esm-build.c Changed
78
 
1
@@ -1,5 +1,5 @@
2
 /*
3
- * Copyright (C) 2019,2020 by Sukchan Lee <acetcom@gmail.com>
4
+ * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
  *
6
  * This file is part of Open5GS.
7
  *
8
@@ -34,6 +34,8 @@
9
         &pdn_connectivity_request->esm_information_transfer_flag;
10
     ogs_nas_protocol_configuration_options_t *protocol_configuration_options =
11
         &pdn_connectivity_request->protocol_configuration_options;
12
+    ogs_nas_extended_protocol_configuration_options_t *extended_protocol_configuration_options =
13
+        &pdn_connectivity_request->extended_protocol_configuration_options;
14
 #if 0
15
     uint8_t ue_pco29 =
16
             "\x80\x80\x21\x10\x01\x01\x00\x10\x81\x06\x00\x00\x00\x00"
17
@@ -87,12 +89,25 @@
18
         pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
19
         protocol_configuration_options->length = sizeof(ue_pco);
20
         memcpy(protocol_configuration_options->buffer, ue_pco, sizeof(ue_pco));
21
+    } else if (sess->pdn_connectivity_param.epco) {
22
+        pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
23
+        extended_protocol_configuration_options->length = sizeof(ue_pco);
24
+        extended_protocol_configuration_options->buffer =
25
+            ogs_calloc(sizeof(uint8_t), extended_protocol_configuration_options->length);
26
+        ogs_assert(extended_protocol_configuration_options->buffer);
27
+        memcpy(extended_protocol_configuration_options->buffer, ue_pco, sizeof(ue_pco));
28
     }
29
 
30
     if (integrity_protected)
31
-        return test_nas_eps_security_encode(test_ue, &message);
32
+        pkbuf = test_nas_eps_security_encode(test_ue, &message);
33
     else
34
-        return ogs_nas_eps_plain_encode(&message);
35
+        pkbuf = ogs_nas_eps_plain_encode(&message);
36
+    ogs_assert(pkbuf);
37
+
38
+    if (extended_protocol_configuration_options->buffer)
39
+        ogs_free(extended_protocol_configuration_options->buffer);
40
+
41
+    return pkbuf;
42
 }
43
 
44
 ogs_pkbuf_t *testesm_build_pdn_disconnect_request(test_sess_t *sess)
45
@@ -139,6 +154,8 @@
46
         &esm_information_response->access_point_name;
47
     ogs_nas_protocol_configuration_options_t *protocol_configuration_options =
48
         &esm_information_response->protocol_configuration_options;
49
+    ogs_nas_extended_protocol_configuration_options_t *extended_protocol_configuration_options =
50
+        &esm_information_response->extended_protocol_configuration_options;
51
 
52
 #if 0
53
     uint8_t ue_pco29 =
54
@@ -191,9 +208,22 @@
55
         esm_information_response->presencemask |= OGS_NAS_EPS_ESM_INFORMATION_RESPONSE_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
56
         protocol_configuration_options->length = sizeof(ue_pco);
57
         memcpy(protocol_configuration_options->buffer, ue_pco, sizeof(ue_pco));
58
+    } else if (sess->esm_information_param.epco) {
59
+        esm_information_response->presencemask |= OGS_NAS_EPS_ESM_INFORMATION_RESPONSE_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
60
+        extended_protocol_configuration_options->length = sizeof(ue_pco);
61
+        extended_protocol_configuration_options->buffer =
62
+            ogs_calloc(sizeof(uint8_t), extended_protocol_configuration_options->length);
63
+        ogs_assert(extended_protocol_configuration_options->buffer);
64
+        memcpy(extended_protocol_configuration_options->buffer, ue_pco, sizeof(ue_pco));
65
     }
66
 
67
-    return test_nas_eps_security_encode(test_ue, &message);
68
+    pkbuf = test_nas_eps_security_encode(test_ue, &message);
69
+    ogs_assert(pkbuf);
70
+
71
+    if (extended_protocol_configuration_options->buffer)
72
+        ogs_free(extended_protocol_configuration_options->buffer);
73
+
74
+    return pkbuf;
75
 }
76
 
77
 ogs_pkbuf_t *testesm_build_activate_default_eps_bearer_context_accept(
78
open5gs_2.6.2.tar.xz/tests/common/gtpu.c -> open5gs_2.6.3.tar.xz/tests/common/gtpu.c Changed
10
 
1
@@ -499,7 +499,7 @@
2
         ogs_assert_if_reached();
3
     }
4
 
5
-    pkbuf = ogs_gtp2_build_error_indication(teid, node->addr);
6
+    pkbuf = ogs_gtp1_build_error_indication(teid, node->addr);
7
     ogs_assert(pkbuf);
8
 
9
     memset(&gtp_hdesc, 0, sizeof(gtp_hdesc));
10
open5gs_2.6.2.tar.xz/tests/core/memory-test.c -> open5gs_2.6.3.tar.xz/tests/core/memory-test.c Changed
19
 
1
@@ -41,7 +41,7 @@
2
 
3
 static void test3_func(abts_case *tc, void *data)
4
 {
5
-#if OGS_USE_TALLOC != 1
6
+#if OGS_USE_TALLOC == 0
7
     char *ptr = ogs_realloc(0, 10);
8
     ABTS_PTR_NOTNULL(tc, ptr);
9
     ogs_free(ptr);
10
@@ -54,7 +54,7 @@
11
 
12
 static void test4_func(abts_case *tc, void *data)
13
 {
14
-#if OGS_USE_TALLOC != 1
15
+#if OGS_USE_TALLOC == 0
16
     char *p, *q;
17
 
18
     p = ogs_malloc(10);
19
open5gs_2.6.2.tar.xz/tests/handover/5gc-n2-test.c -> open5gs_2.6.3.tar.xz/tests/handover/5gc-n2-test.c Changed
61
 
1
@@ -806,9 +806,6 @@
2
     rv = testgnb_ngap_send(ngap2, sendbuf);
3
     ABTS_INT_EQUAL(tc, OGS_OK, rv);
4
 
5
-    /* Waiting for N4 */
6
-    ogs_msleep(100);
7
-
8
     /* Receive End Mark */
9
     recvbuf = test_gtpu_read(gtpu1);
10
     ABTS_PTR_NOTNULL(tc, recvbuf);
11
@@ -926,9 +923,6 @@
12
     rv = testgnb_ngap_send(ngap1, sendbuf);
13
     ABTS_INT_EQUAL(tc, OGS_OK, rv);
14
 
15
-    /* Waiting for N4 */
16
-    ogs_msleep(100);
17
-
18
     /* Receive End Mark */
19
     recvbuf = test_gtpu_read(gtpu2);
20
     ABTS_PTR_NOTNULL(tc, recvbuf);
21
@@ -1844,9 +1838,6 @@
22
     rv = testgnb_ngap_send(ngap2, sendbuf);
23
     ABTS_INT_EQUAL(tc, OGS_OK, rv);
24
 
25
-    /* Waiting for N4 */
26
-    ogs_msleep(100);
27
-
28
     /* Receive End Mark */
29
     recvbuf = test_gtpu_read(gtpu1);
30
     ABTS_PTR_NOTNULL(tc, recvbuf);
31
@@ -1916,6 +1907,9 @@
32
     ABTS_PTR_NOTNULL(tc, recvbuf);
33
     ogs_pkbuf_free(recvbuf);
34
 
35
+    /* Waiting for removing Indirect Data Forwarding */
36
+    ogs_msleep(100);
37
+
38
     /* Send HandoverRequired */
39
     sendbuf = testngap_build_handover_required(
40
             test_ue, NGAP_HandoverType_intra5gs,
41
@@ -1992,9 +1986,6 @@
42
     rv = testgnb_ngap_send(ngap1, sendbuf);
43
     ABTS_INT_EQUAL(tc, OGS_OK, rv);
44
 
45
-    /* Waiting for N4 */
46
-    ogs_msleep(100);
47
-
48
     /* Receive End Mark */
49
     recvbuf = test_gtpu_read(gtpu2);
50
     ABTS_PTR_NOTNULL(tc, recvbuf);
51
@@ -2500,9 +2491,6 @@
52
     rv = testgnb_ngap_send(ngap2, sendbuf);
53
     ABTS_INT_EQUAL(tc, OGS_OK, rv);
54
 
55
-    /* Waiting for N4 */
56
-    ogs_msleep(100);
57
-
58
     /* Receive End Mark */
59
     recvbuf = test_gtpu_read(gtpu1);
60
     ABTS_PTR_NOTNULL(tc, recvbuf);
61
open5gs_2.6.2.tar.xz/webui/package-lock.json -> open5gs_2.6.3.tar.xz/webui/package-lock.json Changed
9
 
1
@@ -1,6 +1,6 @@
2
 {
3
   "name": "open5gs",
4
-  "version": "2.6.1",
5
+  "version": "2.6.3",
6
   "lockfileVersion": 2,
7
   "requires": true,
8
   "packages": {
9
open5gs_2.6.2.tar.xz/webui/package.json -> open5gs_2.6.3.tar.xz/webui/package.json Changed
9
 
1
@@ -1,6 +1,6 @@
2
 {
3
   "name": "open5gs",
4
-  "version": "2.6.1",
5
+  "version": "2.6.3",
6
   "description": "Open5gs",
7
   "main": "index.js",
8
   "repository": "https://github.com/open5gs/open5gs/webui",
9