Commit Graph

2293 Commits

Author SHA1 Message Date
Shigeru Ishida 0c3fd10c24 [MME] add facility to select smf(pgwu) by tac and e_cell_id.
[mme.yaml]
# o SMF selection by eNodeB TAC
#   (either single TAC or multiple TACs, DECIMAL representation)
#
#   gtpc:
#     - addr: 127.0.0.4
#       tac: 26000
#     - addr: 127.0.2.4
#       tac: [25000, 27000, 28000]
#
# o SMF selection by e_cell_id(28bit)
#   (either single or multiple e_cell_id, HEX representation)
#
#   gtpc:
#     - addr: 127.0.0.4
#       e_cell_id: abcde01
#     - addr: 127.0.2.4
#       e_cell_id: [12345, a9413, 98765]
2023-05-05 10:23:46 +05:00
Sukchan Lee 7580d3df16 Follow-up #2551 2023-04-22 07:53:22 +09:00
Sukchan Lee e0f6ba3571 Merge branch 'gh_upf_metrics_wrong_dnn' of https://github.com/gstaa/open5gs into gstaa-gh_upf_metrics_wrong_dnn 2023-04-22 07:30:28 +09:00
Sukchan Lee 01d3db4b6e [MME/SMF] Added Extended-PCO in 4G/LTE (#2261) 2023-04-22 00:06:50 +09:00
Sukchan Lee de7e0d3b45 [SBI] Fixed an issue with FQDN/TLS (#2252) 2023-04-21 22:37:07 +09:00
gstaa 9e0467e534
Merge branch 'main' into gh_upf_metrics_wrong_dnn 2023-04-17 06:47:15 +02: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
Gaber Stare 2e3d287afc [UPF metrics] Use APN/DNN to expose dnn label
SMF started to provide APN/DNN in PFCP Establishment.
APN/DNN is used to provide dnn label of metric fivegs_upffunction_upf_qosflows.
2023-04-14 05:14:23 +00:00
Bostjan Meglic 7686507eaa [AMF] Fix N2 Handover - copy PDU session info
After N2 Handover (1 AMF, multiple gNB's) was successfully executed, the
PDU session was not properly released afterwards on PDU Session Release
Request from UE.

The reason was that after N2 Handover the new 'ran_ue' context did not
have any information about the active PDU sessions.

Copy the information about PDU sessions from old ran_ue context to the
new one.
2023-04-13 21:27:40 +09:00
Abdelmuhaimen Seaudi 69831c43f5 add support for sigscale ocs
added several changes to correctly work with sigscal ocs offline charging
2023-04-12 22:31:01 +02:00
Bostjan Meglic bc3b27339e [SMF] Check if session has been removed already between different events
This fix is needed to prevent SMF crash in case that one of the
neighbouring NF (AMF) crashed in the middle of the procedure.
2023-04-05 21:25:54 +09:00
Bostjan Meglic 200414ccca [AMF] Check if session has been removed already between different events
This fix is needed to prevent AMF crash in case that one of the
neighbouring NF (SMF) crashed in the middle of the procedure.
2023-04-05 21:25:54 +09:00
Sukchan Lee 32019df0f0 Fixed MacOSX compile error 2023-04-04 21:53:39 +09:00
Sukchan Lee e828f98bb6 [SMF] Fixed Gy Service-Context-Id 2023-04-04 21:33:55 +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 939b311b2d [UPF] Remove Metrics in Data Plane (#2210) 2023-04-01 11:48:24 +09:00
Gaber Stare 65f379640c [SMF] Release PDU session with skipInd
Follow-up on [#2048](https://github.com/open5gs/open5gs/pull/2048)

AMF crashes when 'skipInd' field is missing:
```
amf  | 03/21 07:45:04.092: [amf] FATAL: [imsi-001010000000000] No skipInd (../src/amf/namf-handler.c:392)
amf  | 03/21 07:45:04.092: [amf] FATAL: amf_namf_comm_handle_n1_n2_message_transfer: should not be reached. (../src/amf/namf-handler.c:393)
```
In case of CM_CONNECTED skipInd is not important.
In case of CM_IDLE the proper relase would contain skipInd.
2023-03-27 22:17:40 +09:00
Sukchan Lee d469809192 [AMF/MME] PLMN access control
These mechanisms are described in the GSMA roaming guidelines.
Chapters called Access Control.

For 4g: https://www.gsma.com/newsroom/wp-content/uploads//IR.88-v21.0.pdf
For 5g: https://www.gsma.com/newsroom/wp-content/uploads//NG.113-v6.0.pdf
2023-03-25 09:59:20 +09:00
Gaber Stare 6f593432a4 [AMF metrics] Initial histogram support
Version of histogram support without ogs_metrics_spec_new_ex().
Buckets are now, just like labels, passed to ogs_metrics_spec_new() as a pointer.
2023-03-24 23:03:49 +09:00
Sukchan Lee 84e46a0ff1 [MME] Add protection code for INVALID S1AP (#2184) 2023-03-23 20:50:41 +09:00
Bostjan Meglic df25013e54 [AMF] Do not issue SBI requests to other NF's if RAN UE already disconnected 2023-03-23 20:33:43 +09:00
Sukchan Lee 424f382265 [AMF/MME] Support TAI Range 2023-03-19 18:31:45 +09:00
Sukchan Lee 2944fa2549 [AMF/MME] for num_of_XXX variable (uint8_t -> int) 2023-03-19 18:31:45 +09:00
Gaber Stare e923f204aa [AMF, PCF] Don't free unallocated memory
SMF already handles the freeing in labels correctly.
In the same manner the memsets are moved to the beginning of the
problematic functions in AMF and PCF.
2023-03-18 16:39:31 +09:00
Bostjan Meglic a73814dad2 [AMF] Fix Network Initiated Deregistration
When UDM issues a SDM Data Change Notification with request to modify
RAT restrictions, AMF would crash when it tried to send a SDM
subscription delete as part of Network Initiated Deregistration.

Function amf_ue_sbi_discover_and_send() changed from returning boolean,
to returning integer (one of OGS_OK/OGS_ERROR/...).
2023-03-18 16:35:44 +09:00
Bostjan Meglic 5f377d0126 [PCF] Fix crash when both IPv4 and IPv6 Frame Routes are set
When both IPv4 and IPv6 Frame Routes are set, IPv4 Frame Route list
was subsequently cleared.
When UE tried to deregister, PCF would crash when it tried to free the
Frame Routing list.
2023-03-15 17:59:53 +09:00
Sukchan Lee 7c87389b16 [SBI] Check POST format in Subscription (#2152)
POST requests to {apiRoot}/nnrf-nfm/v1/subscriptions/{subscriptionID} return an error
2023-03-12 23:00:14 +09:00
Sukchan Lee dd2c85b1b0 [SBI] Conforms standard in Subscription API(#2152)
POST requests to {apiRoot}/nnrf-nfm/v1/subscriptions return
a HTTP Location header in 201 respose
in the form {apiRoot}/nnrf-nfm/v1/subscriptions/{subscriptionID}
2023-03-12 23:00:14 +09:00
Sukchan Lee ad9e5b28cf [SBI] Added Handler for Subscription PATCH (#2152) 2023-03-12 22:06:19 +09:00
Bostjan Meglic 359882fd49 [AMF] Fix handling Service Request
In case that handling Service Request results in an error, AMF sends a
Service Reject and sets UE's context to exception state. Without the
'break', the code would set UE's context to registered state.
2023-03-11 18:45:52 +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 ff4eab2e51 [SMF] Fixed crash during UPF-HA process (#2115) 2023-03-06 21:04:43 +09:00
Gaber Stare e6ba84bbef [AMF] Expose more metrics
[ETSI TS 128 552 V16.9.0](https://www.etsi.org/deliver/etsi_ts/128500_128599/128552/16.09.00_60/ts_128552v160900p.pdf)

5.2.2 Registration procedure related measurements

SNSSAI labels are not provided.

- Number of registration requests received by the AMF is
exposed for each registration type.
```
fivegs_amffunction_rm_reginitreq 1
fivegs_amffunction_rm_regmobreq 0
fivegs_amffunction_rm_regperiodreq 0
fivegs_amffunction_rm_regemergreq 0
```

- Number of successful initial registrations at the AMF is
exposed for each registration type.
```
fivegs_amffunction_rm_reginitsucc 1
fivegs_amffunction_rm_regmobsucc 0
fivegs_amffunction_rm_regperiodsucc 0
fivegs_amffunction_rm_regemergsucc 0
```

- The existing counter of failed registrations at the AMF
is exposed separately for each registration type.
```
fivegs_amffunction_rm_reginitfail
fivegs_amffunction_rm_regmobfail
fivegs_amffunction_rm_regperiodfail
fivegs_amffunction_rm_regemergfail
```

5.2.5.2 Measurements for 5G paging

Number of 5G paging procedures initiated at the AMF:
```
fivegs_amffunction_mm_paging5greq 1
```
Number of successful 5G paging procedures initiated at the AMF:
```
fivegs_amffunction_mm_paging5gsucc 1
```

5.2.11 Authentication procedure related measurements

Number of authentication requests:
```
fivegs_amffunction_amf_authreq 2
```
Number of authentication rejections:
```
fivegs_amffunction_amf_authreject 1
```
Number of failed authentications due to parameter error:
```
fivegs_amffunction_amf_authfail{cause="21"} 1
```

5.2.8 UE Configuration Update procedure related measurements

Number of UE Configuration Update commands requested by the AMF:
```
fivegs_amffunction_mm_confupdate 2
```
Number of UE Configuration Update complete messages received by the AMF:
```
fivegs_amffunction_mm_confupdatesucc 1
```
2023-03-06 20:18:35 +09:00
Sukchan Lee c3f0c57554 Follow-up on #2100 2023-03-04 23:43:36 +09:00
Bostjan Meglic 10168f1f19 [AMF] Disallow handling service requests unless UE is already registered 2023-03-04 23:43:14 +09:00
Sukchan Lee 4d44b1843e [Release-17] Upgrade SBI to v17.x.0 2023-03-01 19:56:49 +09:00
Sukchan Lee ce668c556c [SBI] Fixed openapitools MAP generation (#2103)
MAP was generated incorrectly because {{#items}}..{{#items}} was
missing.

Because of this, If scpInfo has scpPort, NRF crashes.
2023-02-26 10:01:08 +09:00
mitmitmitm 1d8324af9f [PFCP] Support pfcp advertise address 2023-02-24 20:53:28 +09:00
Sukchan Lee 10477ecdc9 [Release-17] Upgrade S1AP/NGAP to v17.3.9 2023-02-21 21:48:06 +09:00
mitmitmitm 22be888dae Don't left-shift by negative amount, which is UB according to C17 2023-02-20 21:00:16 +09:00
Sukchan Lee 82e9016164 [AMF/SMF] Fixed a crash (#2030, #2074, #2085) 2023-02-20 20:49:48 +09:00
Sukchan Lee 0df402bd49 [SBI] Move HNET PKI conf inside UDM 2023-02-18 12:41:08 +09:00
Sukchan Lee 05fbaf6958 [SBI] HTTP2-TLS verification - ConfFile Changed
You should add the following configuration if you would not use TLS.

sbi:
    server:
      no_tls: true
    client:
      no_tls: true
2023-02-18 10:58:29 +09:00
Spencer Sevilla 5f55ece521 [gtpc] silently handle OGS_GTP2_CAUSE_UE_ALREADY_RE_ATTACHED (#17)
no need to log "GTP Failed"; just handle silently or move on.
2023-02-16 11:57:00 -10:00
Sukchan Lee 74fdb14f7a [MME] KeNB derive from TAU(active flag=1) (#2063)
TS33.401
7 Security procedures between UE and EPS access network elements
7.2 Handling of user-related keys in E-UTRAN
7.2.7 Key handling for the TAU procedure when registered in E-UTRAN

If the "active flag" is set in the TAU request message or
the MME chooses to establish radio bearers when there is pending downlink
UP data or pending downlink signalling, radio bearers will be established
as part of the TAU procedure and a KeNB derivation is necessary.
2023-02-13 06:33:22 -10:00
Sukchan Lee 888e58a94e [AMF] Network Deregister (#2056, #2014, #2021)
Fixed a crash on explicit network-initiated deregister
with SUBSCRIPTION_WITHDRAWN
2023-02-10 23:09:39 +09:00
Bostjan Meglic 474b2d4134 [SBI,NF] Don't treat SBI connection errors as asserts 2023-02-07 22:49:11 +09:00
Sukchan Lee 8973a0bfdc [AMF] Delete UERadioCapability (#2040, #1917)
23.501 (5G NAS stage 2)
5.4.4.1:
"When the AMF receives Registration Request with the Registration type set
to Initial Registration or when it receives the first Registration Request
after E-UTRA/EPC Attach with Registration type set to Mobility Registration
Update, the AMF deletes the UE radio capability."
2023-02-07 22:29:53 +09:00
Sukchan Lee f7a4d64f00 [AMF] Network-Initiated Deregister (#2014, #2021)
I accidentally missed one so I added it again.
2023-02-06 21:09:19 +09:00
Sukchan Lee b44fa29a7d [AMF/MME] Delete UERadioCapability (#2040, #1917)
o TS24.301(4G/LTE)
  5.5.1 Attach procedure
  5.5.1.2 Attach procedure for EPS services
  5.5.1.2.4 Attach accepted by the network

If the attach request is accepted by the network,
the MME shall delete the stored UE radio capability information
or the UE radio capability ID, if any.

o TS24.501(5G)
  5.5.2 De-registration procedure
  5.5.2.1 General

When the AMF enters the state 5GMM-DEREGISTERED for 3GPP access,
the AMF shall delete the stored UE radio capability information
or the UE radio capability ID, if any.
2023-02-05 12:03:00 +09:00
Sukchan Lee b6aa3aba5b Follow-up on #2048 2023-02-04 22:41:11 +09:00
Flander Bojan af07cc75ec Support for UPF HA - release/establish new PDU session 2023-02-04 22:40:33 +09:00
Sukchan Lee bae3998c31 [SBI/NF] Follow-up on #2045 2023-02-04 21:35:12 +09:00
Bostjan Meglic c791d97ed7 [NF] Fix double-free crash when NF is under heavy load
<nf>/init.c:<nf>_main() :
ogs_pollset_poll() receives the time of the expiration of next timer as
an argument. If this timeout is in very near future (1 millisecond),
and if there are multiple events that need to be processed by
ogs_pollset_poll(), these could take more than 1 millisecond for
processing, resulting in the timer already passed the expiration.

In case that another NF is under heavy load and responds to an SBI
request with some delay of a few seconds, it can happen that
ogs_pollset_poll() adds SBI responses to the event list for further
processing, then ogs_timer_mgr_expire() is called which will add an
additional event for timer expiration. When all events are processed
one-by-one, the SBI xact would get deleted twice in a row, resulting in
a crash.

0  __GI_abort () at ./stdlib/abort.c:107
1  0x00007f9de91693b1 in ?? () from /lib/x86_64-linux-gnu/libtalloc.so.2
2  0x00007f9de9a21745 in ogs_talloc_free (ptr=0x7f9d906c2c70, location=0x7f9de960bf41 "../lib/sbi/message.c:2423") at ../lib/core/ogs-memory.c:107
3  0x00007f9de95dbf31 in ogs_sbi_discovery_option_free (discovery_option=0x7f9d9090e670) at ../lib/sbi/message.c:2423
4  0x00007f9de95f7c47 in ogs_sbi_xact_remove (xact=0x7f9db630b630) at ../lib/sbi/context.c:1702
5  0x000055a482784846 in amf_state_operational (s=0x7f9d9488bbb0, e=0x7f9d90aecf20) at ../src/amf/amf-sm.c:604
6  0x00007f9de9a33cf0 in ogs_fsm_dispatch (fsm=0x7f9d9488bbb0, event=0x7f9d90aecf20) at ../lib/core/ogs-fsm.c:127
7  0x000055a48275b32e in amf_main (data=0x0) at ../src/amf/init.c:149
8  0x00007f9de9a249eb in thread_worker (arg=0x55a483d41d90) at ../lib/core/ogs-thread.c:67
9  0x00007f9de8fd2b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
10 0x00007f9de9063bb4 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100
2023-02-04 21:25:46 +09:00
Sukchan Lee 79f73fae2a [Gx/Gy] MAX_CC_REQUESTER_NUMBER(32->64) (#2038)
Incrased MAX_CC_REQUESTER_NUMBER from 32 to 64
2023-02-04 20:53:44 +09:00
Sukchan Lee 8a92c7e219 [AMF] Network-Initiated Deregister (#2014, #2021)
Fixed a bug network-initiated implicit/explict deregistration
2023-02-04 20:43:31 +09:00
Sukchan Lee 8a6c36daca [AMF] Network Initiated De-Register (#2014, #2021)
Resolved Network Initiated Implicit/Explicit De-Registration
2023-01-29 22:44:44 +09:00
Sukchan Lee b7386284a7 [NRF] Fixed a crash during NRF discovery (#2034)
Other NF instances are obtained through NRF
or created directly through configuration files.

Other NFs created by the config file should not be passed
through NRF discovery or anything like that.

Since self-created NF Instances do not have an ID,
they are implemented to exclude them from NRF Discovery.
2023-01-29 11:22:45 +09:00
Sukchan Lee 610b998038 [AMX] Fixed a crash due to deregistration (#2021)
Fixed an issue where AMF would crash
if an implicit deregistration occurred twice.
2023-01-29 09:09:52 +09:00
Sukchan Lee f50591a8f7 Added Service-MAP to Requester-Features (#2027)
ALWAYS Added Service-MAP to Requester-Features in Discovery Option
2023-01-29 01:35:47 +09:00
Sukchan Lee 728ca41103 [MME] Fixed crash due to Paging routine (#2017) 2023-01-27 16:42:23 +09:00
mitmitmitm 739cb599d1 [UDR] Read framed routes from DB send them in sm-data
The framed routes are stored in mongo as

 {
     "imsi" : "$IMSI",
     ...,
     "slice" :
     [{
         ...,
         "session" :
             ...,
             "ipv4_framed_routes" : ["10.45.33.0/24", "10.45.35.0/24"],
         }],
     }],
 },
2023-01-26 22:37:58 +09:00
mitmitmitm 11568bbff7 ogs_session_s.framed_routes type change to (char **)
OpenAPI_list_t wasn't optimal as it created a dependency on ogs-sbi.h.
2023-01-26 22:37:58 +09:00
Sukchan Lee b82a898646 update it 2023-01-26 21:22:24 +09:00
Sukchan Lee 9e6cff7225 Merge branch 'MMENetworkDeregTimers' of https://github.com/jmasterfunk84/open5gs into jmasterfunk84-MMENetworkDeregTimers 2023-01-26 21:15:32 +09:00
Sukchan Lee 95e5d95faf [AMF] Fixed crashes from malformed 5GS-ID (#2020) 2023-01-26 20:48:55 +09:00
Sukchan Lee 85981effc7 [AMF/AMF] Not assert for ogs_asn_copy_ie() (#2018)
Does not raise an assertion even if open5gs cannot handle the ASN in
ogs_asn_copy_ie()
2023-01-25 23:16:59 +09:00
jmasterfunk84 ee2eded848
Merge branch 'main' into MMENetworkDeregTimers 2023-01-24 12:47:33 -06:00
jmasterfunk84 e96b6be245 no Purge Timer, no config, expanded code 2023-01-24 12:35:47 -06:00
Sukchan Lee 596a2f1b5e [SBI] Fixed crash if no BW Unit(Xbps) (#2000) 2023-01-24 21:55:06 +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 11aac6a164 [CORE] Rollback ogs_pkbuf_copy() from (#2012)
In the previous #2012 working, I've added ogs_pkbuf_free() for original
buffer. But, this rasied double free. So, I've rollback it,
2023-01-24 00:17:10 +09:00
Sukchan Lee c6fd4ae6b8 [LOG] remove ogs_expect_or_return()/return_val() 2023-01-24 00:01:36 +09:00
Sukchan Lee ed5cd4d513 [MME] Fixed a crash when no UE context (#2016) 2023-01-23 18:49:12 +09:00
Sukchan Lee 54331d77ee [UPF] URR time threshold log to info (#1997) 2023-01-23 15:58:55 +09:00
Sukchan Lee 689574a2d9 [AMF/MME] Fixed crash when no NG/S1 context(#2012) 2023-01-23 10:37:22 +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 3e980e006f [PCF] Handle framed routes, forward them to BSF 2023-01-23 09:26:26 +09:00
mitmitmitm 88209f52df [BSF] Handle Ipv4FrameRouteList, save it into context 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 df4c83372d [AMF] Fixed MEMORY LEAK (#1925) 2023-01-21 09:02:44 +09:00
Sukchan Lee a712d865cd [METRICS] Re-order init/final (#1985, #2001) 2023-01-20 21:16:45 +09:00
jmasterfunk84 5c3f10aa0e [MME] Introduce aging timers
* Creating three new timers
* mirroring work done by gstaa on the AMF
* Implicit detach procedures added
* Fix for detach from unknown UE
2023-01-18 20:39:27 -06:00
Sukchan Lee ce7b60dbb5 [AMF] Fixed RM metric RegisteredSubNbr (#2001) 2023-01-18 22:29:44 +09:00
Sukchan Lee 4933c7ee24 More follow-up on #1911 2023-01-14 10:34:21 +09:00
Sukchan Lee 01a7b3c9b8 Follow-up on #1991 2023-01-14 09:20:52 +09:00
jmasterfunk84 3fd7ecc9a2
[MME] Add Purge-UE Capability (#1991)
* [MME] Add Purge-UE Capability

* Add OGS_GTP_..._PURGE_AND_REMOVE to split CLR case
2023-01-14 09:13:48 +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
ridzafauzi 92efca1fbf changed error tagged log to info tagged log for handling 5g guti information during Configuration Update procedure 2023-01-11 23:12:20 +09:00
Sukchan Lee c0a61fb71e [PCRF] More fixes for crashes (#1981) 2023-01-10 16:13:44 +09:00
Sukchan Lee 7f9afa0213 [AMF] More Follow-up on #1987 2023-01-08 20:02:18 +09:00
Sukchan Lee 9f4a9790e3 [AMF] Follow-up on #1987
[AMF] Implicit Network-initiated Deregistration

    Two timers are introduced (both with duration of T3512 + 4 min):
    -MOBILE_REACHABLE
    -IMPLICIT_DEREGISTRATION
    MOBILE_REACHABLE is set when NAS connection for the UE is released.
    IMPLICIT_DEREGISTRATION is set when MOBILE_REACHABLE expires.

    On MOBILE_REACHABLE expiry Paging is ignored.
    On IMPLICIT_DEREGISTRATION expiry:
    -UE's RM_State is set to DEREGISTERED
    -UE is Nudm_SDM_Unsubscribed
    -UE is Nudm_UECM_Deregistered
    -PDU sessions are released
    -AM policies are deleted

    Existing flag amf_ue->network_initiated_de_reg is used.
2023-01-08 13:53:48 +09:00
Gaber Stare bfd5cefe53 [AMF] Implicit Network-initiated Deregistration
Two timers are introduced (both with duration of T3512 + 4 min):
-MOBILE_REACHABLE
-IMPLICIT_DEREGISTRATION
MOBILE_REACHABLE is set when NAS connection for the UE is released.
IMPLICIT_DEREGISTRATION is set when MOBILE_REACHABLE expires.

On MOBILE_REACHABLE expiry Paging is ignored.
On IMPLICIT_DEREGISTRATION expiry:
-UE's RM_State is set to DEREGISTERED
-UE is Nudm_SDM_Unsubscribed
-UE is Nudm_UECM_Deregistered
-PDU sessions are released
-AM policies are deleted

Existing flag amf_ue->network_initiated_de_reg is used.
2023-01-08 13:48:32 +09:00
Sukchan Lee 8553c77733 [METRICS] Fixed a core dump in SMF/UPF/PCF (#1985) 2023-01-07 21:17:14 +09:00
Sukchan Lee 2ec1f484b4 [PCRF] Fixed a crash (#1981)
An assertion was fired when switching between video and audio.
2023-01-07 15:21:17 +09:00
Sukchan Lee 4510176da2 [MME] Clear UE Context for Attach Reject (#1848)
Attach Reject + PDN Connectivity Reject need to clear UE Context
2022-12-27 21:08:48 +09:00
Sukchan Lee 8373d0e331 SIDF only required in UDM, not AUSF (#1779) 2022-12-25 20:12:26 +09:00
Sukchan Lee 0d2c31fe06 Fixed SMF-METRICS bug in EPC 2022-12-25 17:33:13 +09:00
Matej Gradisar 1d93e7a7bc New AMF ID in SMF session context for 'inter-AMF change or mobility' 2022-12-25 00:11:17 +09:00
Sukchan Lee 79d46be086 Introduced Subscription identifier de-concealing
o Generate the private key as below.
   $ openssl genpkey -algorithm X25519 -out /etc/open5gs/hnet/curve25519-1.key
   $ openssl ecparam -name prime256v1 -genkey -conv_form compressed -out /etc/open5gs/hnet/secp256r1-2.key

 o The private and public keys can be viewed with the command.
   The public key is used when creating the SIM.
   $ openssl pkey -in /etc/open5gs/hnet/curve25519-1.key -text
   $ openssl ec -in /etc/open5gs/hnet/secp256r1-2.key -conv_form compressed -text

In ausf/udm.yaml

 hnet:
    o Home network public key identifier(PKI) value : 1
      Protection scheme identifier : ECIES scheme profile A
    - id: 1
      scheme: 1
      key: /etc/open5gs/hnet/curve25519-1.key

    o Home network public key identifier(PKI) value : 2
      Protection scheme identifier : ECIES scheme profile B
    - id: 2
      scheme: 2
      key: /etc/open5gs/hnet/secp256r1-2.key

    o Home network public key identifier(PKI) value : 3
      Protection scheme identifier : ECIES scheme profile A
    - id: 3
      scheme: 1
      key: /etc/open5gs/hnet/curve25519-1.key

    o Home network public key identifier(PKI) value : 4
      Protection scheme identifier : ECIES scheme profile B
    - id: 4
      scheme: 2
      key: /etc/open5gs/hnet/secp256r1-2.key

Related to #1779
2022-12-24 20:22:45 +09:00
Bostjan Meglic 38aadb77e0 [SMF] Fix metric bearers_active
Metric 'bearers_active' was incremented in only one code path
(smf_bearer_add() for 4G only), while it was decremented from two paths
(smf_bearer_remove() for both 4G and 5G).
Increment metric also for 5G path (smf_qos_flow_add()), so it won't get
decremented into negative values.
2022-12-17 16:27:42 +09:00
Gaber Stare b56c33479e Add NF load to NRF Heartbeat
The current load percentage of the NF Service Consumer is provided
in the payload body of the PATCH request when periodically
contacting the NRF (heart-beat).

AMF: ratio between currently connected ran_ue and maximum number of them
SMF: ratio between current PDU sessions and maximum available
PCF: ratio between current AM+SM policy associations and maximum available
     or ratio between currently connected UEs and maximum number of them
     (the load which is higher)
AUSF, UDM: ratio between currently connected UE and maximum number of them
BSF: ratio between current sessions and maximum available
NSSF: ratio between currently used NSIs and maximum number of them

NRF currently doesn't determine that the NF Profile has changed.
2022-12-14 22:53:56 +09:00
mitmitmitm 6ad320a97c [AMF] Fix deletion of auth data from AUSF 2022-12-09 07:25:12 +09:00
Gaber Stare 3edceecf66 [SMF] Add SM metrics support
Expose SM metrics with labels according to ETSI TS 128 552 V16.13.0 in
SMF by using hash.

The metrics are named respecting the rule:
<generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552>
Existing gauge sessions_active is renamed!

Since slice itself is not unique, the plmnid label is exposed in
addition to snssai.

Exposed metrics example:
-standard gauges:
fivegs_smffunction_sm_sessionnbr{plmnid="00101",snssai="1000009"} 0
fivegs_smffunction_sm_qos_flow_nbr{plmnid="00101",snssai="1000009",fiveqi="9"} 0

-nonstandard counters:
fivegs_smffunction_sm_n4sessionestabfail{cause="71"} 68
fivegs_smffunction_sm_n4sessionreport 1
fivegs_smffunction_sm_n4sessionreportsucc 1
fivegs_smffunction_sm_n4sessionestabreq 1
2022-12-08 20:57:11 +09:00
Gaber Stare 4c76a254ee [AMF] Add RM metrics support
Expose RM metrics with labels according to ETSI TS 128 552 V16.13.0 in
AMF by using hash.

The metrics are named respecting the rule:
<generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552>

Since slice itself is not unique, the plmnid label is exposed in
addition to snssai.

RegInitFail is exposed as an alternative to RegInitReq and RegInitSucc
counters so cause label can be provided. It counts rejected registrations
and rejected authentications.
Rejected authentications are counted under label cause="0".

Exposed metrics example:
-standard gauge:
fivegs_amffunction_rm_registeredsubnbr{plmnid="00101",snssai="1000009"} 1

-nonstandard counter:
fivegs_amffunction_rm_reginitfail{cause="3"} 4
2022-12-08 20:57:11 +09:00
Bostjan Meglic 3e22059916 [SMF] fix crash due free-ing invalid pointer
In case that database is (manually) corrupted for a specific UE, SSC
mode and ARP preemption vulnerability fields are not set correctly,
SMF will crash when trying to build a request to create PCF association.

Function smf_npcf_smpolicycontrol_build_create() will end prematurely,
and when cleaning up resources it will try to free() up invalid pointer,
which was not set to 0 at beginning of the function.

[smf] ERROR: SSCMode is not allowed (../src/smf/nudm-handler.c:165)
[sbi] DEBUG: STATUS [201] (../lib/sbi/nghttp2-server.c:443)
[sbi] DEBUG: SENDING...: 3 (../lib/sbi/nghttp2-server.c:451)
[sbi] DEBUG: {
} (../lib/sbi/nghttp2-server.c:452)
[sbi] DEBUG: STREAM closed [1] (../lib/sbi/nghttp2-server.c:962)
[smf] ERROR: No Arp.preempt_cap (../src/smf/npcf-build.c:132)
<crash>

0  __GI_abort () at ./stdlib/abort.c:107
1  0x00007f9348fe43b1 in ?? () from /lib/x86_64-linux-gnu/libtalloc.so.2
2  0x00007f9349aef745 in ogs_talloc_free (ptr=0x7f9348e38dab <_int_free+1675>,
    location=0x5591b8675d27 "../src/smf/npcf-build.c:181") at ../lib/core/ogs-memory.c:107
3  0x00005591b8653c45 in smf_npcf_smpolicycontrol_build_create (sess=0x7f9343070010, data=0x0)
    at ../src/smf/npcf-build.c:181
4  0x00007f9349abc2b4 in ogs_sbi_xact_add (sbi_object=0x7f9343070010,
    service_type=OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL, discovery_option=0x7f9338006d90,
    build=0x5591b86531d0 <smf_npcf_smpolicycontrol_build_create>, context=0x7f9343070010, data=0x0)
    at ../lib/sbi/context.c:1699
5  0x00005591b86580be in smf_sbi_discover_and_send (service_type=OGS_SBI_SERVICE_TYPE_NPCF_SMPOLICYCONTROL,
    discovery_option=0x0, build=0x5591b86531d0 <smf_npcf_smpolicycontrol_build_create>, sess=0x7f9343070010,
    stream=0x7f9344fce0a0, state=0, data=0x0) at ../src/smf/sbi-path.c:110
6  0x00005591b864e9da in smf_nudm_sdm_handle_get (sess=0x7f9343070010, stream=0x7f9344fce0a0,
    recvmsg=0x7f933f52d5a0) at ../src/smf/nudm-handler.c:290
7  0x00005591b8600c96 in smf_gsm_state_wait_5gc_sm_policy_association (s=0x7f9343070610, e=0x7f9338076730)
    at ../src/smf/gsm-sm.c:523
...
2022-12-07 21:21:01 +09:00
Sukchan Lee 1be6176e8d Follow-up on #1940 - Fixed compile error 2022-12-07 20:41:18 +09:00
Sukchan Lee fbd9ada101 Follow-up on #1940 2022-12-06 22:59:06 +09:00
Gaber Stare 0c2a3b0f39 [PCF] Add metrics support
Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in
PCF by using hash.

The metrics are named respecting the rule:
<generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552>

Since slice itself is not unique, the plmnid label is exposed in
addition to snssai.

AM policy:
fivegs_pcffunction_pa_policyamassoreq and
fivegs_pcffunction_pa_policyamassosucc do not expose snssai label
since it is not available at the time of exposure.
plmnid is defined during AM policy processing, so not to lose the
difference to ...succ, the basic metric
fivegs_pcffunction_pa_policyamassoreq is preserved.

SM policy:
snssai is defined during SM policy processing, so not to lose the
difference to ...succ, the basic metric
fivegs_pcffunction_pa_policysmassoreq is preserved.

Those 2 basic metrics retain their position but are exposed with empty
labels.
Metrics with labels are called later, when the label values are known.

Exposed metrics example:
-standard counters:
fivegs_pcffunction_pa_policyamassoreq{plmnid=""} 3
fivegs_pcffunction_pa_policyamassoreq{plmnid="99970"} 3
fivegs_pcffunction_pa_policyamassosucc{plmnid="99970"} 3
fivegs_pcffunction_pa_policysmassoreq{plmnid="",snssai=""} 3
fivegs_pcffunction_pa_policysmassoreq{plmnid="99970",snssai="1000009"} 3
fivegs_pcffunction_pa_policysmassosucc{plmnid="99970",snssai="1000009"} 3

-nonstandard gauge (added for controlling purposes -
same metric as existing metric on AMF and SMF):
fivegs_pcffunction_pa_sessionnbr{plmnid="99970",snssai="1000009"} 0
2022-12-06 22:57:24 +09:00
Gaber Stare 40b4c9d1c9 [UPF] Add metrics support
Expose metrics with labels according to ETSI TS 128 552 V16.13.0 in
UPF by using hash.

The metrics are named respecting the rule:
<generation>_<measurement_object_class>_<measurement_family_name>_<metric_name_as_in_TS_128_552>

5qi is not available in UPF.
To present 5qi to the user, MN will have to maintain a table qfi->5qi
for each QoS flow (will have to get information from SMF).
So UPF has to expose qfi. qfi itself is not useful. When used, UPF will
have to expose additional label to define the session (e.g. source
interface).

Label dnn is set to value of APN/DNN received in Establishment.
Since SMF does not add APN/DNN to Establishment, the label is empty.
When APN/DNN will be set by SMF, it should be added to sess in UPF
and used in metrics on Modification and Deletion.

Both datavolumeqosleveln3upf are exposed in bytes.
MN is providing the transformation to kbits.

fivegs_upffunction_upf_qosflows should expose the number of QFIs used in
sessions, but exposes number of QER rules, which is currently equal to
QFIs.
The label snsssai is not provided since the slice is not available on UPF.

Exposed metrics example:
Standard counters:
fivegs_ep_n3_gtp_indatapktn3upf 28637
fivegs_ep_n3_gtp_outdatapktn3upf 14729
fivegs_upffunction_sm_n4sessionestabreq 4
fivegs_upffunction_sm_n4sessionestabfail{cause="66"} 1
fivegs_upffunction_sm_n4sessionestabfail{cause="71"} 68
fivegs_upffunction_sm_n4sessionestabfail{cause="68"} 4
fivegs_upffunction_sm_n4sessionestabfail{cause="72"} 15
fivegs_upffunction_sm_n4sessionestabfail{cause="75"} 3
fivegs_upffunction_sm_n4sessionestabfail{cause="65"} 4
fivegs_upffunction_sm_n4sessionreport 0
fivegs_upffunction_sm_n4sessionreportsucc 0
fivegs_ep_n3_gtp_indatavolumeqosleveln3upf{qfi="1"} 39792997
fivegs_ep_n3_gtp_outdatavolumeqosleveln3upf{qfi="1"} 737548
Nonstandard gauge (added for controlling purposes -
same metric as existing metric on AMF and SMF):
fivegs_upffunction_upf_sessionnbr 1
Standard gauge:
fivegs_upffunction_upf_qosflows{dnn=""} 1
2022-12-06 22:57:24 +09:00
Lester 0fe904d593 free replybuf after sent replay message 2022-12-05 12:05:39 +09:00
Miguel Borges de Freitas f1aff3c233 amf: fix regression for smf selection 2022-12-04 15:12:15 +09:00
Sukchan Lee bd30e5534b [AMF] Fixed a crash while NGReset (#1928) 2022-12-04 15:01:43 +09:00
Sukchan Lee 817007d0ae [AMF] Wrongly sending PDU Session Release (#1925) 2022-12-04 14:32:19 +09:00
Sukchan Lee a4dc990bf1 Added more log in GTP Error (#1920) 2022-12-02 09:10:49 +09:00
Sukchan Lee fa5b2fe075 [SBI] Remove redundant code (#1923) 2022-11-30 17:01:30 +09:00
Sukchan Lee 944adaabbf [AMF/MME] Added Timer Configuration (#1905) 2022-11-29 23:22:16 +09:00
mitmitmitm ea09a7921a [AMF] Handle am-data/subscribedUeAmbr change notification
When such a notification arrives from UDM, notify the GNB of the new values
AMBR uplink/downlink values.
2022-11-29 23:10:49 +09:00
mitmitmitm 3b043b082a [AMF] Handle am-data/ratRestrictions change notification
When such a notification arrives from UDM, delete the corresponding SDM
subscription from the UDM and deregister the UE if it becomes RAT restricted.
2022-11-29 23:10:49 +09:00
mitmitmitm 3870216a6b [AMF] Add support for SDM subscription and authentication deletion 2022-11-29 23:10:49 +09:00
mitmitmitm 9364cd7513 [AMF] Allow unspecified (infinity) ue_ambr up/downlink limits 2022-11-29 23:10:49 +09:00
mitmitmitm 4ec5dedaf4 [AUSF] Handle UEAuthentication DELETE 2022-11-29 23:10:49 +09:00
mitmitmitm bdc9c1373f [UDM/UDR] Handle UEAuthentication authRemovalInd 2022-11-29 23:10:49 +09:00
mitmitmitm 89c3f3e1c0 [UDM] Handle SDM unsubscribe 2022-11-29 23:10:49 +09:00
Sukchan Lee 9170617df1 [AMF/MME] forget UE Radio Capability (#1917)
forgetting the UE Radio Capabilities
when UE is sending NAS "De-Registration Request" with "type = Switch-off
2022-11-27 09:03:44 +09:00
Sukchan Lee f85ff227c8 Continue to fix alpine stack overflow (#1911) 2022-11-27 00:11:34 +09:00
Sukchan Lee d82f338246 Fixed alpine stack overflow (#1911) 2022-11-27 00:03:56 +09:00
Sukchan Lee 8ce18b3828 [AMF/MME] Refactor SM to prevent crash (#1912) 2022-11-26 21:38:46 +09:00
Lester 3f772823a6 get amf_ue from sess
amf_ue will be null and cause a coredump when type is OGS_SBI_OBJ_SESS_TYPE.
2022-11-26 18:27:50 +09:00
mitmitmitm b85ad61e2b OpenAPI: Generate patch_item.[ch] from OpenAPI specifications 2022-11-24 17:30:38 +09:00
Sukchan Lee 982ac61894 Prometheus metrics set to default 2022-11-21 22:06:29 +09:00
Sukchan Lee 57f1f2c21a Fixed crash after 48 hours of running (#1893) 2022-11-18 23:28:35 +09:00
Bostjan Meglic b084edeee1 [metrics] Fix log output for metrics
Even if the configured log level for the application was set to "error",
the first "info" message of the metrics library was output to the log.
Reorder the initialization of the metrics library.
2022-11-15 23:50:15 +09:00
Sukchan Lee 0859dd4453 Follow-up on #1865 2022-11-12 09:37:43 +09:00
Bostjan Meglic ba8a7ce1af [AMF] Add implicit_unsubscribe field to SDMSubscription 2022-11-08 15:57:21 +09:00
Sukchan Lee ddf09f270a [SMF] Fixed PTI when PDU Session Reject 2022-11-07 16:51:51 +09:00
Sukchan Lee fa35b06963 Follow-up on #1876 2022-11-04 14:58:47 +09:00
Sukchan Lee cca53fb8e8 SCP had a serioud memory problem and fixed it 2022-10-30 13:35:25 +09:00
Sukchan Lee 243bf9850a [NAS] Discard message if Integrity failed (#1848) 2022-10-29 21:31:18 +09:00
Sukchan Lee 0df2cba257 Support SMF Security Indication IE (#1851) 2022-10-29 12:26:09 +09:00
mitmitmitm b9f6432e54 [AMF] Support REREGISTRATION_REQUIRED in dereg notify 2022-10-26 14:40:41 +09:00
Sukchan Lee e3ba32c85d Fixed the bug of SGW-C session deletion (#1825) 2022-10-25 21:22:14 +09:00
Sukchan Lee ec4acd4eca remove warning in MacOSX (#1797) 2022-10-25 21:14:53 +09:00
Sukchan Lee 5ccb5f0f99 SCP(Model D) is now the default setting. 2022-10-22 11:26:04 +09:00
Sukchan Lee 24e20f2503 Follow-up on #1827 2022-10-13 17:52:02 +09:00
jmasterfunk84 8fb85db310 [DBI] Disable Change Streams with mongo Version
Support for change stream is only available in mongoc >=1.9.0
- Disabled related functions in dbi.
Support for bson to json used in debug statement only in libbson >=1.7.0
- Simple debug message in lower versions
2022-10-13 17:33:35 +09:00
Sukchan Lee 0daef1686a Follow-up on #1827 2022-10-11 17:50:41 +09:00
Sukchan Lee 82863653eb Follow-up on #1828 2022-10-11 17:44:55 +09:00
Bostjan Meglic 395707831a [AMF] Reject registration requests when pool for UE contexts is empty
AMF does not crash anymore when a new UE registration request arrives,
and there is no available space left in UE context pool. Now it just
rejects the request with an error.
2022-10-11 17:35:50 +09:00
Bostjan Meglic b019dce982 [AMF] Increase size of TMSI pool
Each UE context has 'current' and 'next' TMSI values. AMF first
allocates the 'next' value, before confirming it and releasing the
'previous'. This means that we potentially need pool size of 2x the
amount of maximum configured UE.

Without this change, AMF would crash in case that there are 'x'
configured maximum amount of UE, and there are already 'x' registered
UE.

[gmm] INFO: Registration request (../src/amf/gmm-sm.c:135)
[gmm] INFO: [suci-0-001-01-1234-0-1-1000000000]    SUCI (../src/amf/gmm-handler.c:149)
[gmm] DEBUG:     OLD TSC[UE:0,AMF:0] KSI[UE:7,AMF:0] (../src/amf/gmm-handler.c:179)
[gmm] DEBUG:     NEW TSC[UE:0,AMF:0] KSI[UE:7,AMF:0] (../src/amf/gmm-handler.c:186)
[amf] FATAL: amf_m_tmsi_alloc: Assertion `m_tmsi' failed. (../src/amf/context.c:2160)
[core] FATAL: backtrace() returned 13 addresses (../lib/core/ogs-abort.c:37)
2022-10-11 17:35:38 +09:00
Sukchan Lee 704fe72d11 Updated SBI module
- Introduced NF_INSTANCE_ID/NF_INSTANCE_TYPE
- Skip SCP in configuration validation
2022-10-08 11:48:12 +09:00
Sukchan Lee 3955e9ba8d Revert the previous commit on #1797 2022-10-07 14:06:30 +09:00
Sukchan Lee d1ed8aa61d [SMF] Update PFCP report error situation (#1819) 2022-10-07 10:41:53 +09:00
Bostjan Meglic a99a76d916 [AMF,UDM] Add support to subscribe to SDM changes
AMF subscribes to UDM for each registered UE.

At the moment, UDM does not send callback to AMF when any of the UE's
properties in the database changes.
At the moment, AMF does properly parse the ModificationNotification, but
does not do anything useful.
2022-10-06 21:20:10 +09:00
Sukchan Lee dc6ca962bb Follow-up on #1797 2022-10-06 10:10:31 +09:00
Spencer Sevilla be2af54682 ogs_info swaps CP and UP SEIDs 2022-10-05 17:41:42 +09:00
Sukchan Lee 6d27fbb8cc Follow-up on #1797 2022-10-05 14:50:52 +09:00
jmasterfunk84 15680003b5
[MME] Cancel Location while Idle (#1797)
* Cancel Location while Idle Fix

* Forgot about SGSAP on MME Change.

Added "action" to sgsap_send_detach..

* Make handle_clr uniform with other handlers

* Added Robustness for Any Detach Type

* Memory wasn't freed upon CLR for unknown IMSIs

* Moving MME Detach to new PR
2022-10-05 11:06:01 +09:00
Sukchan Lee c537166d37 Follow-on up #1794 2022-10-02 19:41:52 +09:00
jmasterfunk84 1f2a8678ed
[MME] Support for Insert Subscriber Data (#1794)
* [MME] Support for Insert Subscriber Data

* Supported AVPs in IDR will overwrite existing subscription information
* Provide error on partial APN updates
* IDR and ULA use same function to process AVPs
* Move subdatamask values into s6a, so both HSS and MME can use them
* Updates are not actioned at this time.  A Re-attach is required for
  most changes to take effect

* Memory issue on IDR exceptions

* Remove of handling MSIDSN change until DSR is used
2022-10-02 19:36:24 +09:00
Sukchan Lee 71a1516b03 [Security] Fixed a crash for port scanning (#1767) 2022-10-01 13:28:41 +09:00
Sukchan Lee 1acb7f72b4 [UPF] test code for unspecified address (#1776) 2022-10-01 13:23:15 +09:00
Sukchan Lee 773c7df3e6 [5GC] Fixed session deletion in a BSF (#1725) 2022-10-01 13:11:13 +09:00
Bostjan Meglic f71022ad4a [AMF] Fix for switching state when sending Deregistration Request fails
Provide pointer to state machine, instead of pointer to timer structure.
Bug was noticed when switching compiler optimization to -O2.
2022-10-01 13:08:38 +09:00
Sukchan Lee 4b26dd2a5c Follow-on up #1793 2022-10-01 13:07:54 +09:00
Dibas Das f72a1edc6e Fix UL and DL URR Usage Report 2022-10-01 13:07:04 +09:00
Sukchan Lee 7d5fbc6e06 [MME] Added protection code if no PDN-Type (#1756) 2022-09-25 22:41:11 +09:00
Bostjan Meglic 2d4fbf92eb [config,metrics] Move metrics configuration section under respective NF section
Without this change, using metrics with core setup configurations
(configs/vonr.yaml for example) would not be possible. Having one
metrics section for whole config file causes every NF to start metrics
server on same port causing an abort.
2022-09-25 19:17:49 +09:00
Sukchan Lee 721f5e212c [GTP] Changes the print message (#1772) 2022-09-25 19:16:32 +09:00
Spencer Sevilla e704ac108e add addr/port to pfcp assoc/de-assoc logs (#40)
pfcp association log adds addr/port
2022-09-25 18:58:53 +09:00
Sukchan Lee fdc84406e0 [SGWC] Fixed a crash (#1765)
Session context could be deleted before a response message is not
received from SMF
2022-09-25 18:55:04 +09:00
Sukchan Lee 31fcedc12e Follow-up on #1770 2022-09-25 16:42:46 +09:00
Sukchan Lee a0d643e17f Follow-up on #1758 2022-09-23 21:25:58 +09:00
jmasterfunk84 7f5476b111
[HSS] Enable Change Streams (#1758)
* [HSS] Enable Change Streams
* Enable Events and Timers in HSS
* Integrate change streams in dbi
* mongodb should be configured with replica sets enabled to use feature
* Change streams are optional in HSS
* Timer will poll change stream for changes in the database
* As changes are detected, event is created to perform the correct
  action

* Changes made as suggested
2022-09-23 21:24:50 +09:00
Sukchan Lee 2b8db5d488 Follow-up on #1757 2022-09-23 20:42:04 +09:00
Gaber Stare d3d4e5ce60 [AMF] Add amfInfoList to NFProfile
The actual configured GUAMIs and TAIs are used to form NF profile.
Comparing to SMF the "info" section is not introduced into amf.yaml!
Each amf_id (region, set) produces a separate Info in the InfoList.
Guami list consists of all GUAMIs of particular Info.
taiList consists of all TAIs for all PLMNs of particular Info.

Examle:

amf.yaml:
    guami:
      - plmn_id:
          mcc: 999
          mnc: 70
        amf_id:
          region: 2
          set: 2
          pointer: 4
      - plmn_id:
          mcc: 001
          mnc: 01
        amf_id:
          region: 2
          set: 1
      - plmn_id:
          mcc: 001
          mnc: 02
        amf_id:
          region: 2
          set: 2
    tai:
      - plmn_id:
          mcc: 001
          mnc: 01
        tac: [1, 2, 3]
    tai:
      - plmn_id:
          mcc: 002
          mnc: 02
        tac: 4
      - plmn_id:
          mcc: 001
          mnc: 02
        tac: 10
    tai:
      - plmn_id:
          mcc: 004
          mnc: 04
        tac: [6, 7]
      - plmn_id:
          mcc: 005
          mnc: 05
        tac: 8
      - plmn_id:
          mcc: 999
          mnc: 70
        tac: [9, 10]

"amfInfoList":  {
        "1":    {
                "amfSetId":     "002",
                "amfRegionId":  "02",
                "guamiList":    [{
                                "plmnId":       {
                                        "mcc":  "999",
                                        "mnc":  "70"
                                },
                                "amfId":        "020084"
                        }, {
                                "plmnId":       {
                                        "mcc":  "001",
                                        "mnc":  "02"
                                },
                                "amfId":        "020080"
                        }],
                "taiList":      [{
                                "plmnId":       {
                                        "mcc":  "001",
                                        "mnc":  "02"
                                },
                                "tac":  "00000a"
                        }, {
                                "plmnId":       {
                                        "mcc":  "999",
                                        "mnc":  "70"
                                },
                                "tac":  "000009"
                        }, {
                                "plmnId":       {
                                        "mcc":  "999",
                                        "mnc":  "70"
                                },
                                "tac":  "00000a"
                        }]
        },
        "2":    {
                "amfSetId":     "001",
                "amfRegionId":  "02",
                "guamiList":    [{
                                "plmnId":       {
                                        "mcc":  "001",
                                        "mnc":  "01"
                                },
                                "amfId":        "020040"
                        }],
                "taiList":      [{
                                "plmnId":       {
                                        "mcc":  "001",
                                        "mnc":  "01"
                                },
                                "tac":  "000001"
                        }, {
                                "plmnId":       {
                                        "mcc":  "001",
                                        "mnc":  "01"
                                },
                                "tac":  "000002"
                        }, {
                                "plmnId":       {
                                        "mcc":  "001",
                                        "mnc":  "01"
                                },
                                "tac":  "000003"
                        }]
        }
}
2022-09-23 20:37:47 +09:00
Bostjan Meglic 0f5d968149 [SMF] Wait for both N1&N2 release signals before releasing session
When UE would send a request to release PDU session, AMF would
eventually send "PDU Session Resource Release Command" downlink to both
UE (N1) and gNB (N2). Each UE and gNB would then reply with "PDU Session
Resource Release Response" indicating they released their own resources.

Usually the first one to respond would be gNB. SMF made an assumption
that this would always be the case. And it would wait for signal that UE
resources were freed, before releasing session resources. But
occasionally the situation is that UE responds first, and SMF releases
resources prematurely.

This situation does not normally occur. But under high stress (100's of
UE PDU releases at the same time) this happens occasionally.
According to the standard, this situation is perfectly normal.

3GPP TS 23.502 Rel. 16
4.3.4.2 UE or network requested PDU Session Release for Non-Roaming and
Roaming with Local Breakout
...
Steps 8-10 may happen before steps 6-7.
...
2022-09-13 21:39:21 +09:00
Sukchan Lee 5520cb65a5 Follow-up on #1744 2022-09-13 17:03:18 +09:00
jmasterfunk84 775520d7a8
Introduce Cancel Location and Insert Subscriber Data features to HSS. (#1744)
* Introduce Cancel Location and Insert Subscriber Data features to HSS.
* HSS database will keep track of last known MME and Update Time
* Purged UE flag is established in HSS for future PUR handling
* HSS Thread will connect to database and watch change stream
  mongoDB must be configured with a Replica Set to use this
* HSS will send IDR if subscription data changes
* HSS will send CLR to old MME if MME host or realm changes
* Function created to allow ULA and IDR to generate Subscription-Data AVP
* MME Hostname and Realm shown in WebUI

* Resolve freeDiameter errors

During a ULR, if database does not contain a last known MME, a CLR is being sent to a Null destination.  This will ensure that a destination is available in the database before sending the CLR.

* Removed change streams.  Added PUR handling.

* newline needed at end of file.

* Removed temp variable.

* * Change WebUI to 2x2 display
* Including UE Purged indicator
* Using pointers in ogs_subscription_data_t
* better memory mangement with pointers
* Tweak to Destination used by hss_s6a_send_idr to use last known MME

* Check for null mme_host and mme_realms

Do this before trying to compare the strings.
2022-09-13 16:48:20 +09:00
Sukchan Lee 1f165c1c33 Follow-up on #1747 2022-09-08 23:17:04 +09:00
Bostjan Meglic 31a3788021 [AMF] Handle APN/DNN names as case-insensitive
In case that APN name sent from UE does not case-match with the one
configured in the database, AMF would reject the registration with the
message:

[gmm] WARNING: [imsi-xxx] DNN Not Supported OR Not Subscribed in the
Slice (../src/amf/gmm-handler.c:1051)
2022-09-08 23:13:47 +09:00
Sukchan Lee f54bccacf5 Support service-based NF subscription 2022-09-08 22:12:01 +09:00
Bostjan Meglic 87cd34d300 Minor typo fix 2022-09-07 18:01:21 +09:00
Bostjan Meglic 51669d73a0
[AMF] Accept Deregistration Notification from UDM only for registered UE (#1737)
Add additional check when receiving Deregistration Notification from
UDM. UE should already be in registered state before accepting the
request and deregistering the UE.

Also add additional check that PCF association policy exists before
sending a delete request to PCF.
2022-09-06 19:47:42 +09:00
Sukchan Lee c716a1294a [CORE] Check if timer is double free in SBI module 2022-09-03 15:59:39 +09:00
Sukchan Lee acc36a344f [PCF] Check NF service configuration
* npcf-smpolicycontrol - enabled or disabled
* npcf-policyauthorization - enabled or disabled

Only one of npcf-smpolicycontrol and npcf-policyauthorization cannot be enabled. (../src/pcf/sbi-path.c:151)

They can be enabled or disabled together.
2022-09-03 13:07:00 +09:00
Sukchan Lee d87d61e851 Follow-up on #1729 2022-09-03 09:20:48 +09:00
mitmitmitm af1f8d4f4a [SMF] Handle upCnxState=ACTIVATING by replying with 200 instead of 204
According to TS 29.502 5.2.2.3.2.2., we should reply with a 200 response
including the upCnxState attribute.
2022-09-03 09:08:27 +09:00
Sukchan Lee fcb15b69f7 [MME] Fixed buffer overflow (#1728) 2022-09-02 23:39:59 +09:00
Sukchan Lee 1d17e68c56 [ALL] Removing trailing whitespace and tab 2022-09-02 23:38:39 +09:00
Sukchan Lee 5295c108ad Added Service-based NF discovery
== Known limitation ==
Placing npcf-smpolicycontrol and pcf-policyauthorization
in different NFs is not supported. Both npcf-smpolicycontrol
and pcf-policyauthorization should be placed in the same NF.
2022-09-02 23:04:57 +09:00
Alexander Couzens b175394839 [SMF] fixup send 3GPP-Charging-Characteristics on Gx if received on S5/8c
- Gy instead of Gx AVP was used.
- Use correct avp position and avp variables.

Fixes: 657eef9169 ("[SMF] send 3GPP-Charging-Characteristics on Gx if received on S5/8c")
2022-08-31 06:38:08 +09:00
Sukchan Lee eab29fad9a Follow up on #1715
* Changed <TAB> to <SPACE>*4

* Changed snprintf to ogs_snprintf
2022-08-27 18:43:34 +09:00
Alexander Couzens 657eef9169 [SMF] send 3GPP-Charging-Characteristics on Gx if received on S5/8c
The 3GPP-Charging-Characteristics is an operator specific AVP
(optional). The 3GPP-Charging-Characteristics can be filled by the HSS
and forwarded by the MME towards the SMF.
2022-08-27 18:36:54 +09:00
Sukchan Lee 9f98d421a0 [SBI] Added config for service-names discovery 2022-08-27 10:49:07 +09:00
Sukchan Lee f020732ce9 [SBI] Support service-names in discovery option 2022-08-27 00:12:22 +09:00
Sukchan Lee 9b10d70c77 [NRF] Fixed library load error 2022-08-26 10:57:11 +09:00
Sukchan Lee 83a20b82c7 Follow up on #1714
* Changed sprintf to ogs_snprintf

* Limited to 80 column
2022-08-25 16:35:27 +09:00
jmasterfunk84 49349cdb75
[MME] Dictionary Updates and IDR Support (#1714)
* Add Diameter Dictionary Elements

* Initial IDR Framework

* Resolve Compile Issues

* Moving Closer

* Compile error

* Somewhat Working stuffing Code

* Add Timestamp Changes

* Cleanup some of this code.  mme_s6a_handle_idr in s6a-handler.c removed for now, since it will only come in handy when IDR flag is set to request current location, which would involve breaking out into paging.  I think there's a few other things we can do just within fd-path first.

* further removal of mme_s6a_handle_idr
2022-08-25 15:43:21 +09:00
Bostjan Meglic def99aff7f [SMF] Fix abort on app exit when no Diameter configuration
In case that SMF was configured to run without Diameter, it would crash
on application exit due to uninitialized variables/pointers.

ERROR  pid:unnamed in fd_sess_handler_destroy@sessions.c:324: ERROR: Invalid parameter '(handler && ( ((*handler) != ((void *)0)) && ( ((struct session_handler *)(*handler))->eyec == 0x53554AD1) ))', 22
[smf] FATAL: smf_gx_final: Assertion `ret == 0' failed. (../src/smf/gx-path.c:1353)
2022-08-24 01:39:24 +09:00
Sukchan Lee 242b138597 [MME] UE-initiated detach removes S1 only (#1698) 2022-08-20 01:08:20 +09:00
Sukchan Lee 9bb9a4cae9 [MME] Detach removed MME-UE context (#1698) 2022-08-20 00:17:55 +09:00
Sukchan Lee 321c8d4cf9 [SGsAP] Changed message if Paging failed (#1701)
The problem occurred in the following scenario:

1. VLR sent PAGING-REQUEST to the MME
2. MME sent S1-Paging to the UE
3. Paging failed
4. MME responded SERVICE-REQUEST to the VLR
5. VLR sent DOWNLINK-UNITDATA to the MME
6. Even though there is no S1 Context,
   MME try to sent DownlinkNASTransport message to the UE.
7. So, the problem occurred.

I've changed the number 4 PAGING-REJECT instead of SERVICE-REQUEST.
2022-08-19 18:58:55 +09:00
Sukchan Lee 909f407c20 [MME] Fixed GTP transaction crash (#1696) 2022-08-19 17:23:10 +09:00
Sukchan Lee a9694d6474 [MME] Follow-up Cancel Location Handling (#1698) 2022-08-19 16:52:39 +09:00
jmasterfunk84 c98333bbfe
[MME] Cancel Location Handling (#1698)
* CLR while idle is broken after 7031856cd7

Cancel Location Request arriving while UE is idle will not proceed to paging due to this check for S1 connection.  Using new flag "isAnswer" to bypass this check to allow paging to occur when we are not doing a AIA/ULA related procedure.

* No Context Setup is required when sending the detach request.  If the paging was due to wanting to send a Detach Request to the UE, then we fast track to sending the detach request.

* emm-sm.c:
In the case of MME initiated detach while UE is idle, there is no initial conext setup.  We go right from the service request after paging into sending the detach request.  TS23.401

mme-path.c:
Using nas_eps.type in the case of MME Initiated Detach while UE is idle does not work.  nas_eps.type would represent the service request.

mme-s11-handler.c:
After S11 action, no action should be taken.  We want to wait for the detach accept from the UE before proceeding with the S1 release (detach).

* InitialContextSetup should occur for detach.
2022-08-19 16:44:06 +09:00
herlesupreeth 7162684486 [SMF]: Update stored PCO IE requested over Gn in SMF context
As per 3GPP TS 29.060 version 15.3.0, section 7.3.3, 7.3.4, 7.3.5 and 7.3.6

Only if PCO IE is included in Update/Delete PDP Context Request then it
must be present in Update/Delete PDP Context Response.

In order to reflect on whether the request contained PCO IE or not
the SMF context containing the GTP request needs to be updated
i.e. update if present else clear the contents
2022-08-13 09:30:28 +09:00
herlesupreeth 16ea972937 [SMF]: Update stored PCO IE requested in GTPv2 over S5c in SMF context
As per 3GPP TS 29.274 version 10.5.0, section 7.2.9 and 7.2.10,
Only if PCO IE is included in Delete Session Request then it
must be present in Delete Session Response.

In order to reflect on whether the request contained PCO IE or not
the SMF context containing the GTP request needs to be updated
i.e. update if present else clear the contents
2022-08-13 09:30:28 +09:00
Sukchan Lee e6a14cb73d Move src/../nf-sm.[ch] to lib/sbi/nf-sm.[ch] 2022-08-12 14:03:53 +09:00
Sukchan Lee 4cb657c804 [MME] Changed CauseNas_detach in DETACH (#1676) 2022-08-06 14:00:54 +09:00
Sukchan Lee 700c71ef4c Changed configuration name from gnb to peer
And restored gtp_peer configuration
2022-08-05 16:56:36 +09:00
Sukchan Lee f772bf3a62 [PFCP] Revert Changes 5e18b2b and d21e9aa
To protect malicious or buggy, we need to check that session context is NULL.
2022-08-04 09:55:17 +09:00
Sukchan Lee cca3027e90 [NRF] Fixed the nfInstanceUri (#1683) 2022-08-03 17:32:15 +09:00
Sukchan Lee e88c43e8df [Diameter] Fixed Coding convention (#1680) 2022-08-03 14:34:21 +09:00
jmasterfunk84 415e5276ba [MME+HSS] AVP Occurring Too Many Times
Do not Set Origin-Hosts with fd_msg_rescode_set before potential use of ogs_diam_message_experimental_rescode_set.  This results in multiple Origin-Host/Realm AVPs.
2022-08-03 14:32:57 +09:00
Sukchan Lee d21e9aa5e0 [PFCP] Revert Changes 5e18b2b 2022-08-03 14:13:35 +09:00
Sukchan Lee 7231dafbf1 [SBI] Fixed nf_instance memory leak
- Rollback commit ed3444eef5
- Do not modify reference count when REGISTER/DEREGISTER notified from NRF
2022-08-02 09:44:13 +09:00
Sukchan Lee 7031856cd7 [MME] Changed S1AP_Cause in S1AP Release (#1676)
S1AP_CauseNas_detach -> S1AP_CauseNas_normal_release
2022-07-31 12:38:11 +09:00
Sukchan Lee 5524dc5e29 Refact paging module (#1676) 2022-07-30 14:44:34 +09:00
jmasterfunk84 47cbaca149 [MME] Introduce support for S6a Cancel Location Request
- Added diameter dictionary definitions for Cancel Location
- Cancel Location will completely remove UE from MME, allow for a fresh IMSI attach to occur on next attempt.
- T3422 is used for detach request.
- Added new handling for s6a events in mme-sm, as not all s6a messages are at attach now.  Maybe there's something in a state machine I should've been using here instead of a new flag?

- Testing was completed with UE in idle and connected.  With CLR flags indicating re-attach required and without.  Also sending CLR after UE detach.  And then sending again when mme_ue is empty.
2022-07-30 14:37:43 +09:00
Sukchan Lee 9b762158a6 Refine code of discovery option param (#1671) 2022-07-24 19:47:04 +09:00
Sukchan Lee 4e8492e878 Oops! Warning removed! 2022-07-24 15:15:06 +09:00
Sukchan Lee a5010a61ef Support Discovery Optional Parameter (#1671)
To support target-nf-instance-id in the discovery,
Discovery optional parameter is implemeted
2022-07-24 15:10:09 +09:00
jmasterfunk84 eb03704015 Moving handling of assigning sub level cc into the pdn to s11. 2022-07-24 12:29:01 +09:00
jmasterfunk84 68140efce4 [MME] Handle Charging Characteristics
Found no support for HSS provided charging characteristics.  Following TS32.251 A.4:
- Use PDN level CC, if one wasn't provided then use subscription level CC
- Don't send CC in S11 if it wasn't included
2022-07-24 12:29:01 +09:00
jmasterfunk84 d2ef555ce4 Set default Network-Access-Mode to 0
For HSS's which do not include the NAM, the MME should not treat this as a fatal error.  MME should just assume PACKET_AND_CIRCUIT (0), as was decided in a previous PR.
2022-07-23 00:26:55 +09:00
Bostjan Meglic 7e6568d800 [SMF] Send PDU Session Establish Accept to serving AMF
In case there are multiple AMF registered to NRF, SMF would pick only
the first AMF from the list.
In the case of sending PDU Session Establishment Accept from SMF to
AMF, this would mean a high chance of failure since the AMF might
be different than the original requester, and would not know about a
particular UE.

Modify SMF to use ServingNfId field from original request
SmContextCreateData from AMF to determine to which AMF should it send
PDU Session Establishment Accept message.
2022-07-22 12:24:26 +09:00
Sukchan Lee eb50d64271 Add more protection code for (#1652) 2022-07-21 17:13:32 +09:00
Sukchan Lee 9aa5559c5f Refactor for the UERANSIM 500 test (#1652) 2022-07-21 12:41:19 +09:00
Sukchan Lee f35afa2ff7 Add missing pkbuf_free() (#1652) 2022-07-21 01:00:44 +09:00
Sukchan Lee 776103698d Oops! Redundant code is removed (#1652) 2022-07-21 00:35:08 +09:00
Sukchan Lee 2b41a215d7 Fixed the crash in UERANSIM 500 test (#1652) 2022-07-21 00:02:31 +09:00
Sukchan Lee fb95f1ff71 Fixed ASSERT when context has already been removed 2022-07-19 19:42:24 +09:00
Sukchan Lee 668cc59f94 [AMF] Fixed 5GMM cause in Reject message (#1660)
When a UE that requests slices tries to connect and there are no slices configured, the reject message is:

5GMM cause = 0x7 (5GS Services not allowed)

however it should be:

5GMM cause = 0x3e (No network slices available)

All 5GMM cause value in reject message is reviewed in this commit
2022-07-19 12:42:02 +09:00
Sukchan Lee 5e18b2bd13 [SCP] Support of Indirect Communication 2022-07-16 13:27:18 +09:00
Bostjan Meglic aa3cded11a [AMF] Handle namf-callback DeregNotify message from UDM
UDM may send a Deregistration Notification to AMF, to deregister
specific UE from the network - Network-Initiated Deregistration.
Deregistration procedure includes sending Deregistration Request to UE,
starting a timer T3522, releasing PDU sessions from SMF, releasing PCF
policies from PCF, and waiting for Deregistration Accept from UE.

Not yet implemented is:
- to prevent deregistration of UE in case it has any emergency sessions,
- page UE when UE is in IDLE mode.
2022-07-11 22:53:21 +09:00
Bostjan Meglic d1a2971990 [NAS] modify library to include both directions of deregistration requests
Definitions in NAS library now include both directions of deregistration
requests/accepts - from UE and from network.
2022-07-11 22:53:21 +09:00
Bostjan Meglic babc30940a [AMF] Do not send Deregistration Event to UDM when UE deregisters
According to TS 23.502, 4.2.2.2.2, AMF sends Registration event to UDM
in the following cases:
- If the AMF has changed since the last Registration procedure, or
- if the UE provides a SUPI which doesn't refer to a valid context in
the AMF,
- or if the UE registers to the same AMF it has already registered
to a non- 3GPP access (i.e. the UE is registered over a non-3GPP access
and initiates this Registration procedure to add a 3GPP access).

In case that UE re-registers to the network with a GUTI, it bypasses
authentication check to the AUSF. In this case, AMF does not send
Registration event to UDM.
Consequently, when UE deregisters again, AMF would send a Deregistration
Event to a UDM, which does not have a context for it.

3GPP standard does not say when AMF sends Deregistration Event to UDM,
only that it is optional.

These (De-)Registration events are for (de-)registering AMF to the UDM
for serving the UE. And not for (de-)registering UE itself for purpose
of tracking when UE is registered on the network.

This partially reverts commit 7be7029ac4
2022-07-11 22:44:07 +09:00
Sukchan Lee eabe8dfec5 [PFCP] Added UE IP address in the EPC (#1642) 2022-07-04 17:37:00 +09:00
Networkmama 29525b21a4 [SMF] copy UE ip address to uplink PDR rules.
This helps UPF to add ACL based on src ip

Signed-off-by: Networkmama <networkmama12@gmail.com>
2022-07-04 17:34:40 +09:00
Bostjan Meglic ab11220dcc [ALL] Fix differences in function parameter names between definition and declaration 2022-07-01 21:38:47 +09:00
Sukchan Lee 50be661cf9 Fixed a crash when slice/session overflow (#1637) 2022-06-30 13:33:16 +09:00
Sukchan Lee ad159d1755 [GTP] Refine error code path without assertion
Refer to #1635, #1620, #1606, #1594
2022-06-30 10:53:19 +09:00
Sukchan Lee b1d982a1ee [PFCP] Refine error code path without assertion
Refer to #1635, #1620
2022-06-30 10:35:03 +09:00
Sukchan Lee 0be5e765c8 Revert "[SGWC] pfcp: Retrieve sess when SEID=0 (#1620)"
This reverts commit 9700563023.
2022-06-30 09:11:38 +09:00
Sukchan Lee 6332f10593 Revert "[GTP] context when TEID=0 (#1620, #1606, #1594)"
This reverts commit 0d61f7a7f9.
2022-06-30 09:11:31 +09:00
Pau Espin b5956e5596
[UPF] N4: Remove unnecessary assert (#1634) 2022-06-29 11:10:43 +09:00