Commit Graph

188 Commits

Author SHA1 Message Date
Sukchan Lee f960047ccb [SMF/UPF] Follow-up on Pull #3137 (Issues #2975) 2024-04-14 09:19:07 +09:00
Sukchan Lee a6830b30a0 [SMF/UPF] Changes subnet configuration (#2975)
The way subnet is set up has changed as shown below.

```
<OLD Format>
smf:
  session:
    - subnet: 10.45.0.1/16

<NEW Format>
smf:
  session:
    - subnet: 10.45.0.0/16
      gateway: 10.45.0.1
```

For more information, please refer to Pull Request #2975.
2024-04-13 19:31:19 +09:00
Pau Espin 3ee4bb7d3c pfcp: Fix missing fields in ogs_pfcp_build_update_urr()
Flag bitmask check elements are reordered to follow same order as
IEs in 3GPP TS 29.244 7.5.4.4 "Update URR".
2024-04-04 23:23:32 +09:00
Sukchan Lee 581d255c53 Revert "[GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)"
This reverts commit a667525041.
2024-03-26 08:04:26 +09:00
Sukchan Lee cf4ad1f248 [PFCP] Session removal while waiting PFCP reply (#3040)
'node_timeout' and some other functions can remove a smf_sess_t
while that session is still waiting for a PFCP reply
and has an active PFCP xact.

In this case, xact->data points to the deleted session
and xact's timeout function (sess_5gc_timeout for example)
eventually refers to this already freed session.

This fix prevents duplicate deletes from occurring by checking to see
if the session context has already been deleted when the timeout occurs.

Additionally, it moves session deletions out of timer callbacks into
state machine by reselect_upf().

Due to the way 'ogs_timer_mgr_expire' calls timer callbacks,
one must not stop or expire timers from within a timer callback.

And now one must not remove sessions from within a timer callback.
2024-03-24 09:50:23 +09:00
Sukchan Lee a667525041 [GTP/PFCP]] incorrect dst TEI=0/SEID=0 (#3043)
If eg. PCRF or AAA diameter link is not yet ready (eg. PCRF crashed), and
a client sends a CreateSessionRequest announcing its ow F-TEID,
then open5gs-smfd answers with Create Session Response Cause=
"Remote peer not responding", but it is not setting the received F-TEID
in the header of the response, instead it sends with TEI=0.

As a result, the peer cannot match the CreateSessionResponse, and needs
to rely on its own timeout timer to figure out that specific request failed.

This also happens in PFCP, so to solve this problem, I added teid/seid_presence
to the interface that sends the error message as shown below.

void ogs_gtp2_send_error_message(ogs_gtp_xact_t *xact,
        int teid_presence, uint32_t teid, uint8_t type, uint8_t cause_value);
void ogs_pfcp_send_error_message(
    ogs_pfcp_xact_t *xact, int seid_presence, uint64_t seid, uint8_t type,
    uint8_t cause_value, uint16_t offending_ie_value);
2024-03-23 10:06:16 +09:00
Matej Gradisar 24b9150c15 [SMF] Check config file for overlapping UE subnets for subnets with no DNN 2024-02-28 12:06:02 +00:00
Sukchan Lee 41d8934677 [SMF] Added Bi-Directional Flow (#2909)
For bi-directions, the rules are created in the same form as for downlink
as shown below, so to apply them for uplink, we need to swap the rules
according to the interface.

RX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
GX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
PFCP : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
RULE : Source <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> Destination <UE_IP> <UE_PORT>
TFT : Local <UE_IP> <UE_PORT> REMOTE <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>

RX : permit in from <UE_IP> <UE_PORT> to <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
GX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
PFCP : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
RULE : Source <UE_IP> <UE_PORT> Destination <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
TFT : Local <UE_IP> <UE_PORT> REMOTE <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
2024-02-17 20:43:15 +01:00
Sukchan Lee 93110d011e [GTP-U] Fixed ogs_pfcp_find_gtpu_resource()(#2923)
As mentioned in the sgwu.yaml configuration file, it is possible to configure multiple addresses with different source_interface values for the gtpu interface.

Following the this section, I defined two addresses, one with source_interface set to 0 and another with source_interface set to 1. My expectation was to see different addresses for the two PDRs in the Session Establishment Response message during session establishment. However, both addresses were the same, and it was the address I had set for source_interface = 0.

When I looked into the code, I found the reason for the issue. In the lib/pfcp/context.c file, on line 1185, the function that determines the address is called as follows:

...
        } else {
            ogs_gtpu_resource_t *resource = NULL;
            resource = ogs_pfcp_find_gtpu_resource(
                    &ogs_gtp_self()->gtpu_resource_list,
                    pdr->dnn, OGS_PFCP_INTERFACE_ACCESS);
            if (resource) {
...
In the last parameter of this function, a constant value, OGS_PFCP_INTERFACE_ACCESS, is used. This causes every PDR with any source_interface to be considered as "access," and the value 0 is used for its interface.

I replaced the value with pdr->src_if, and the bug was resolved.
2024-01-30 22:39:34 +09:00
Bostjan Meglic dcdfc970ce initialize variables before using them 2024-01-22 17:34:59 +09:00
Sukchan Lee 97e1b1bd30 [PFCP] Fixed incorrect TLV names (#2887)
Fixed standards documentation that described incorrect TLV names.
2024-01-19 23:40:20 +09:00
Pau Espin 75f32e07de xact: Fix debug message printed when not needed 2023-12-21 22:13:45 +09:00
mitmitmitm cecb87b346 Fix small typo in ogs_pfcp_sendto 2023-12-16 18:44:36 +09:00
Sukchan Lee e92293e0af
[SEPP] Initial Update for 5G Roaming (#2739)
[SEPP] Initial Update for 5G Roaming
2023-11-19 19:34:51 +09:00
mitmitmitm 5623b1a0a1 [PFCP] Reply with QER_ID instead of FAR_ID type for QER mismatch 2023-09-25 22:02:19 +09:00
Matej Gradisar 227dc1a90d [SMF] return a subnet with available IP addresses
Enables to use multiple UE subnets with the same DNN and family
2023-09-19 21:06:00 +09:00
Matej Gradisar d454e2428f [SMF] Check config file for overlapping UE subnets 2023-09-19 21:06:00 +09:00
Sukchan Lee 05ed95d623 [GTPU] Fixed PDCP SN handling (#2584, #2477)
Scenario is handover on S1AP, data forwarding is enabled, and
the Source ENB is forwarding DL PDCP packets to EPC(SGWU)
with PDCP SN included. SGWU is also forwarding these packets
to the Target ENB.

However the PDCP SN is not present in the forwarded packets
from SGWU to Target ENB.

I modified this part, and there was the same problem in 5GC, fixed it as well.

A lot of code in GTP-U has been modified,
so if you have any problems, please let us know right away.
2023-09-10 22:37:42 +09:00
Sukchan Lee 2fbc445d32 [PFCP] Fixed Possible heap buffer overflow (#2585)
After examining the call stack and reading the source code, I found that
in /lib/core/ogs-pool.h line 152: (pool)->array[i] = i+1;
then in lib/pfcp/context.c line 78: pdr_random_to_index[ogs_pfcp_pdr_teid_pool.array[i]] = i;
ogs_pfcp_pdr_teid_pool.array[i] may exceed the size of pdr_random_to_index, leading to a heap-buffer-overflow.
2023-09-06 07:14:51 +09:00
Sukchan Lee 4b0bade80e [TLV] PFCP parser crash from FuzzingLabs (#2523) 2023-08-18 22:19:46 +09:00
Bostjan Meglic 9e20617a8f [PFCP] Fix calculation of AMBR
When converting bitrates from bits per second to kilobits per second,
if the conversion results in fractions, the resulting value should be
rounded upwards
2023-06-03 09:19:52 +09:00
Sukchan Lee f969309f11 [CORE] Rollback ogs_pool_init/final (#2339)
ogs_pool_init() shall be used in the initialization routine.
Otherwise, memory will be fragment since this function uses system malloc()

Compared with ogs_pool_init()

ogs_pool_create() could be called while the process is running,
so this function should use ogs_malloc() instead of system malloc()
2023-05-28 22:50:28 +09:00
mitmitmitm 928a80ef26 [PFCP] Support PFCP advertise address in F-SEID 2023-05-25 22:46:52 +09:00
mitmitmitm cd485944cb [PFCP] Fix IPv4 PFCP advertise addresses 2023-05-25 22:46:52 +09:00
Sukchan Lee aed52a9ad8 [GTP-U] Send Error Indication for unknown PDR 2023-04-16 12:30:36 +09:00
Sukchan Lee d2e2a58232 [PFCP] Implement the Restoration Indication 2023-04-16 12:30:36 +09:00
Sukchan Lee 642d9e2e18 [PFCP/GTP] SEID/TEID Randomness (#1303) 2023-04-16 12:30:36 +09:00
Sukchan Lee b9a3157467
[PFCP] SGWU/UPF Restoration (#2223)
TS23.007 17.4.1
19A PFCP based restart procedures

After a PFCP entity has restarted, it shall immediately update all local Recovery Time Stamps and shall clear all remote
Recovery Time Stamps. When peer PFCP entities information is available, i.e. when the PFCP Association is still alive,
the restarted PFCP entity shall send its updated Recovery Time Stamps in a Heartbeat Request message to the peer
PFCP entities before initiating any PFCP session signalling.
2023-04-04 21:22:03 +09:00
Sukchan Lee 2944fa2549 [AMF/MME] for num_of_XXX variable (uint8_t -> int) 2023-03-19 18:31:45 +09:00
Sukchan Lee 69c080c8f2 [NAS/GTP/PFCP] Upgrade IE to Release-17
As raised in #2147, AMF fails to decode S1 UE Network Capability.

So I reviewed all IE in NAS, GTP and PFCP and fixed it for Release-17.
2023-03-11 18:42:30 +09:00
Sukchan Lee a8790713d7 [Release-17] Upgrade PFCP to v17.7.1 2023-03-05 22:33:01 +09:00
Sukchan Lee fd9c211005 [PFCP/GTP] Fixed security bug (#2127,#2128,#2129) 2023-03-05 08:35:30 +09:00
mitmitmitm 1d8324af9f [PFCP] Support pfcp advertise address 2023-02-24 20:53:28 +09:00
Sukchan Lee 82e9016164 [AMF/SMF] Fixed a crash (#2030, #2074, #2085) 2023-02-20 20:49:48 +09:00
Sukchan Lee b80db453e8 [GTP/PFCP] Follow-up on #2073 2023-02-17 06:55:22 +09:00
Spencer Sevilla d30fcbb848
[pfcp] response_timeout should not call ogs_pfcp_xact_delete (#2072)
* [pfcp] response_timeout should never call ogs_pfcp_xact_delete (#50)

* also remove ogs_pfcp_xact_delete since never called

* also had to catch one more ogs_pfcp_sendto()

---------

Co-authored-by: Spencer Sevilla <spencer@MacBook-Air.local>
2023-02-17 06:50:50 +09:00
Sukchan Lee b108ae0aff [PFCP] buffer overflow in ALPINE (#1911, #2009)
A buffer overflow occurred in ALPINE
because the size of the pfcp message structure increased by

    ogs_pfcp_tlv_framed_route_t framed_route[8];
    ogs_pfcp_tlv_framed_ipv6_route_t framed_ipv6_route[8];
2023-01-24 19:03:00 +09:00
Sukchan Lee c6fd4ae6b8 [LOG] remove ogs_expect_or_return()/return_val() 2023-01-24 00:01:36 +09:00
Sukchan Lee a8f83989f4 Follow-up on #2009 2023-01-23 09:29:00 +09:00
mitmitmitm f6439b998c [SMF] Handle framed routes, forward them to UPF and PCF 2023-01-23 09:26:26 +09:00
mitmitmitm 990abbab2c [UPF] Handle framed routes 2023-01-23 09:26:26 +09:00
mitmitmitm 337a4e5159 [PFCP] Allow up to 8 framed routes for each IP type 2023-01-23 09:26:26 +09:00
Sukchan Lee ff261681c0 [PROTO] Increase SDU buffer 8k->16k (#2008) 2023-01-21 12:58:43 +09:00
Sukchan Lee 0e0085c69f [UPF] Fixed bug when 2 PDRs with same TEID (#2003) 2023-01-18 23:31:54 +09:00
Sukchan Lee 5128ebc6c6 [SMF] Added User-ID, APP_DNN, S-NSSAI (#1986)
Added User-ID, APP_DNN, S-NSSAI in N4 PFCP Session Establishment Request
2023-01-13 10:28:40 +09:00
Bostjan Meglic ddfd7b9373 [pfcp] Fix code style 2023-01-09 21:47:30 +09:00
Sukchan Lee d82f338246 Fixed alpine stack overflow (#1911) 2022-11-27 00:03:56 +09:00
safaorhann e9aaceee98 fix dropped_dl_traffic_threshold ie. 2022-10-06 10:40:08 +09:00
Bostjan Meglic 87cd34d300 Minor typo fix 2022-09-07 18:01:21 +09:00
Sukchan Lee 9b10d70c77 [NRF] Fixed library load error 2022-08-26 10:57:11 +09:00