From 88346c014183ee0d81dcaaac1d75c3b69a19ec59 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 1 Jan 2021 15:56:46 -0500 Subject: [PATCH] fix: SBI heartbeat timer usage changed (#741) --- configs/open5gs/amf.yaml.in | 13 +++++----- configs/open5gs/ausf.yaml.in | 13 +++++----- configs/open5gs/nrf.yaml.in | 10 ++++++++ configs/open5gs/pcf.yaml.in | 13 +++++----- configs/open5gs/smf.yaml.in | 13 +++++----- configs/open5gs/udm.yaml.in | 13 +++++----- configs/open5gs/udr.yaml.in | 11 ++++++++- lib/app/ogs-context.c | 4 +-- lib/sbi/nnrf-build.c | 5 +++- lib/sbi/nnrf-handler.c | 1 + src/amf/nf-sm.c | 3 ++- src/amf/nnrf-handler.c | 7 +++++- src/ausf/nf-sm.c | 3 ++- src/ausf/nnrf-handler.c | 7 +++++- src/ausf/nudm-handler.c | 3 ++- src/nrf/context.c | 5 ++++ src/nrf/nf-sm.c | 3 ++- src/nrf/nnrf-handler.c | 47 +++++++++++++++++++++++++++++++++--- src/pcf/nf-sm.c | 3 ++- src/pcf/nnrf-handler.c | 7 +++++- src/smf/nf-sm.c | 3 ++- src/smf/nnrf-handler.c | 7 +++++- src/udm/nf-sm.c | 3 ++- src/udm/nnrf-handler.c | 7 +++++- src/udr/nf-sm.c | 3 ++- src/udr/nnrf-handler.c | 7 +++++- 26 files changed, 162 insertions(+), 52 deletions(-) diff --git a/configs/open5gs/amf.yaml.in b/configs/open5gs/amf.yaml.in index e50cae5db..ab5ab09d8 100644 --- a/configs/open5gs/amf.yaml.in +++ b/configs/open5gs/amf.yaml.in @@ -283,15 +283,16 @@ pool: # # time: # -# o NF Instance Heartbeat (Default : 10 seconds) +# o NF Instance Heartbeat (Default : 0) +# NFs will not send heart-beat timer in NFProfile +# NRF will send heart-beat timer in NFProfile # -# o NF Instance Heartbeat (Disabled) -# nf_instance: -# heartbeat: 0 +# o NF Instance Heartbeat (20 seconds) +# NFs will send heart-beat timer (20 seconds) in NFProfile +# NRF can change heart-beat timer in NFProfile # -# o NF Instance Heartbeat (10 seconds) # nf_instance: -# heartbeat: 10 +# heartbeat: 20 # # o Message Wait Duration (Default : 10,000 ms = 10 seconds) # diff --git a/configs/open5gs/ausf.yaml.in b/configs/open5gs/ausf.yaml.in index 0f24abca3..fa8cbc90a 100644 --- a/configs/open5gs/ausf.yaml.in +++ b/configs/open5gs/ausf.yaml.in @@ -159,15 +159,16 @@ pool: # # time: # -# o NF Instance Heartbeat (Default : 10 seconds) +# o NF Instance Heartbeat (Default : 0) +# NFs will not send heart-beat timer in NFProfile +# NRF will send heart-beat timer in NFProfile # -# o NF Instance Heartbeat (Disabled) -# nf_instance: -# heartbeat: 0 +# o NF Instance Heartbeat (20 seconds) +# NFs will send heart-beat timer (20 seconds) in NFProfile +# NRF can change heart-beat timer in NFProfile # -# o NF Instance Heartbeat (10 seconds) # nf_instance: -# heartbeat: 10 +# heartbeat: 20 # # o Message Wait Duration (Default : 10,000 ms = 10 seconds) # diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in index 8b8537666..abe227f96 100644 --- a/configs/open5gs/nrf.yaml.in +++ b/configs/open5gs/nrf.yaml.in @@ -131,6 +131,16 @@ pool: # # time: # +# o NF Instance Heartbeat (Default : 10 seconds) +# +# o NF Instance Heartbeat (Disabled) +# nf_instance: +# heartbeat: 0 +# +# o NF Instance Heartbeat (5 seconds) +# nf_instance: +# heartbeat: 5 +# # o NF Instance Validity (Default : 3600 seconds = 1 hour) # # o NF Instance Validity (10 seconds) diff --git a/configs/open5gs/pcf.yaml.in b/configs/open5gs/pcf.yaml.in index 6cc8b6ef6..26670692d 100644 --- a/configs/open5gs/pcf.yaml.in +++ b/configs/open5gs/pcf.yaml.in @@ -161,15 +161,16 @@ pool: # # time: # -# o NF Instance Heartbeat (Default : 10 seconds) +# o NF Instance Heartbeat (Default : 0) +# NFs will not send heart-beat timer in NFProfile +# NRF will send heart-beat timer in NFProfile # -# o NF Instance Heartbeat (Disabled) -# nf_instance: -# heartbeat: 0 +# o NF Instance Heartbeat (20 seconds) +# NFs will send heart-beat timer (20 seconds) in NFProfile +# NRF can change heart-beat timer in NFProfile # -# o NF Instance Heartbeat (10 seconds) # nf_instance: -# heartbeat: 10 +# heartbeat: 20 # # o Message Wait Duration (Default : 10,000 ms = 10 seconds) # diff --git a/configs/open5gs/smf.yaml.in b/configs/open5gs/smf.yaml.in index 22a8fd67c..21083c5a5 100644 --- a/configs/open5gs/smf.yaml.in +++ b/configs/open5gs/smf.yaml.in @@ -336,15 +336,16 @@ pool: # # time: # -# o NF Instance Heartbeat (Default : 10 seconds) +# o NF Instance Heartbeat (Default : 0) +# NFs will not send heart-beat timer in NFProfile +# NRF will send heart-beat timer in NFProfile # -# o NF Instance Heartbeat (Disabled) -# nf_instance: -# heartbeat: 0 +# o NF Instance Heartbeat (20 seconds) +# NFs will send heart-beat timer (20 seconds) in NFProfile +# NRF can change heart-beat timer in NFProfile # -# o NF Instance Heartbeat (10 seconds) # nf_instance: -# heartbeat: 10 +# heartbeat: 20 # # o Message Wait Duration (Default : 10,000 ms = 10 seconds) # diff --git a/configs/open5gs/udm.yaml.in b/configs/open5gs/udm.yaml.in index 8302556ca..63ded0bcd 100644 --- a/configs/open5gs/udm.yaml.in +++ b/configs/open5gs/udm.yaml.in @@ -159,15 +159,16 @@ pool: # # time: # -# o NF Instance Heartbeat (Default : 10 seconds) +# o NF Instance Heartbeat (Default : 0) +# NFs will not send heart-beat timer in NFProfile +# NRF will send heart-beat timer in NFProfile # -# o NF Instance Heartbeat (Disabled) -# nf_instance: -# heartbeat: 0 +# o NF Instance Heartbeat (20 seconds) +# NFs will send heart-beat timer (20 seconds) in NFProfile +# NRF can change heart-beat timer in NFProfile # -# o NF Instance Heartbeat (10 seconds) # nf_instance: -# heartbeat: 10 +# heartbeat: 20 # # o Message Wait Duration (Default : 10,000 ms = 10 seconds) # diff --git a/configs/open5gs/udr.yaml.in b/configs/open5gs/udr.yaml.in index 4780b1073..a69034f31 100644 --- a/configs/open5gs/udr.yaml.in +++ b/configs/open5gs/udr.yaml.in @@ -161,7 +161,16 @@ pool: # # time: # -# o NF Instance Heartbeat (Default : 10 seconds) +# o NF Instance Heartbeat (Default : 0) +# NFs will not send heart-beat timer in NFProfile +# NRF will send heart-beat timer in NFProfile +# +# o NF Instance Heartbeat (20 seconds) +# NFs will send heart-beat timer (20 seconds) in NFProfile +# NRF can change heart-beat timer in NFProfile +# +# nf_instance: +# heartbeat: 20 # # o NF Instance Heartbeat (Disabled) # nf_instance: diff --git a/lib/app/ogs-context.c b/lib/app/ogs-context.c index bd6ad9857..e74066378 100644 --- a/lib/app/ogs-context.c +++ b/lib/app/ogs-context.c @@ -183,8 +183,8 @@ static void app_context_prepare(void) recalculate_pool_size(); - /* 10 second */ - self.time.nf_instance.heartbeat_interval = 10; + /* + * Heartbeat Interval(e.g: 10 seconds) + No Heartbeat Margin(1 second) */ self.time.nf_instance.no_heartbeat_margin = 1; /* 3600 seconds = 1 hour */ diff --git a/lib/sbi/nnrf-build.c b/lib/sbi/nnrf-build.c index b3506f417..765c14510 100644 --- a/lib/sbi/nnrf-build.c +++ b/lib/sbi/nnrf-build.c @@ -18,6 +18,7 @@ */ #include "ogs-sbi.h" +#include "ogs-app.h" OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile( ogs_sbi_nf_instance_t *nf_instance) @@ -259,7 +260,9 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_register( NFProfile = ogs_nnrf_nfm_build_nf_profile(nf_instance); ogs_assert(NFProfile); - NFProfile->heart_beat_timer = nf_instance->time.heartbeat_interval; + NFProfile->nf_profile_changes_support_ind = true; + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer = + ogs_app()->time.nf_instance.heartbeat_interval; message.NFProfile = NFProfile; diff --git a/lib/sbi/nnrf-handler.c b/lib/sbi/nnrf-handler.c index e22aaa11d..2014574ec 100644 --- a/lib/sbi/nnrf-handler.c +++ b/lib/sbi/nnrf-handler.c @@ -18,6 +18,7 @@ */ #include "ogs-sbi.h" +#include "ogs-app.h" bool ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_profile_t *NFProfile, diff --git a/src/amf/nf-sm.c b/src/amf/nf-sm.c index 83aca2f17..7aa2c0726 100644 --- a/src/amf/nf-sm.c +++ b/src/amf/nf-sm.c @@ -195,7 +195,8 @@ void amf_nf_state_registered(ogs_fsm_t *s, amf_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: if (NF_INSTANCE_IS_SELF(nf_instance->id)) { - ogs_info("[%s] NF registered", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); client = nf_instance->client; ogs_assert(client); diff --git a/src/amf/nnrf-handler.c b/src/amf/nnrf-handler.c index c83cc0acc..adb192de3 100644 --- a/src/amf/nnrf-handler.c +++ b/src/amf/nnrf-handler.c @@ -40,7 +40,12 @@ void amf_nnrf_handle_nf_register( } /* TIME : Update heartbeat from NRF */ - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + if (NFProfile->nf_profile_changes_ind == true) { + if (NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } else { + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } } void amf_nnrf_handle_nf_status_subscribe( diff --git a/src/ausf/nf-sm.c b/src/ausf/nf-sm.c index 699a46436..676649c32 100644 --- a/src/ausf/nf-sm.c +++ b/src/ausf/nf-sm.c @@ -195,7 +195,8 @@ void ausf_nf_state_registered(ogs_fsm_t *s, ausf_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: if (NF_INSTANCE_IS_SELF(nf_instance->id)) { - ogs_info("[%s] NF registered", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); client = nf_instance->client; ogs_assert(client); diff --git a/src/ausf/nnrf-handler.c b/src/ausf/nnrf-handler.c index 8c2282c29..1e1dacc77 100644 --- a/src/ausf/nnrf-handler.c +++ b/src/ausf/nnrf-handler.c @@ -38,7 +38,12 @@ void ausf_nnrf_handle_nf_register( } /* TIME : Update heartbeat from NRF */ - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + if (NFProfile->nf_profile_changes_ind == true) { + if (NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } else { + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } } void ausf_nnrf_handle_nf_status_subscribe( diff --git a/src/ausf/nudm-handler.c b/src/ausf/nudm-handler.c index fbb072056..3b5b86c62 100644 --- a/src/ausf/nudm-handler.c +++ b/src/ausf/nudm-handler.c @@ -66,12 +66,13 @@ bool ausf_nudm_ueau_handle_get(ausf_ue_t *ausf_ue, return false; } + /* See TS29.509 6.1.7.3 Application Errors */ if (AuthenticationInfoResult->auth_type != OpenAPI_auth_type_5G_AKA) { ogs_error("[%s] Not supported Auth Method [%d]", ausf_ue->suci, AuthenticationInfoResult->auth_type); ogs_sbi_server_send_error(stream, - OGS_SBI_HTTP_STATUS_FORBIDDEN, + OGS_SBI_HTTP_STATUS_NOT_IMPLEMENTED, recvmsg, "Not supported Auth Method", ausf_ue->suci); return false; } diff --git a/src/nrf/context.c b/src/nrf/context.c index e4792b74b..e322a2e7e 100644 --- a/src/nrf/context.c +++ b/src/nrf/context.c @@ -59,6 +59,11 @@ nrf_context_t *nrf_self(void) static int nrf_context_prepare(void) { + /* NF Instance Heartbeat + * Default value is 10 seconds if it is not configured in nrf.yaml */ + if (!ogs_app()->time.nf_instance.heartbeat_interval) + ogs_app()->time.nf_instance.heartbeat_interval = 10; + return OGS_OK; } diff --git a/src/nrf/nf-sm.c b/src/nrf/nf-sm.c index 018891a50..cf7fea636 100644 --- a/src/nrf/nf-sm.c +++ b/src/nrf/nf-sm.c @@ -185,7 +185,8 @@ void nrf_nf_state_registered(ogs_fsm_t *s, nrf_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: - ogs_info("[%s] NF registred", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); if (nf_instance->time.heartbeat_interval) { ogs_timer_start(nf_instance->t_no_heartbeat, ogs_time_from_sec( diff --git a/src/nrf/nnrf-handler.c b/src/nrf/nnrf-handler.c index f9f6530ea..42f7e887b 100644 --- a/src/nrf/nnrf-handler.c +++ b/src/nrf/nnrf-handler.c @@ -40,6 +40,10 @@ bool nrf_nnrf_handle_nf_register(ogs_sbi_nf_instance_t *nf_instance, return false; } + /* Store NFProfile */ + nf_instance->nf_profile = OpenAPI_nf_profile_copy( + nf_instance->nf_profile, NFProfile); + /* ogs_sbi_nnrf_handle_nf_profile() sends error response */ handled = ogs_sbi_nnrf_handle_nf_profile( nf_instance, NFProfile, stream, recvmsg); @@ -53,11 +57,46 @@ bool nrf_nnrf_handle_nf_register(ogs_sbi_nf_instance_t *nf_instance, } else ogs_assert_if_reached(); - /* Store NFProfile */ - nf_instance->nf_profile = OpenAPI_nf_profile_copy( - nf_instance->nf_profile, NFProfile); + /* NRF uses pre-configured heartbeat if NFs did not send it */ + if (!NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = + ogs_app()->time.nf_instance.heartbeat_interval; + + /* + * TS29.510 + * Annex B (normative):NF Profile changes in NFRegister and NFUpdate + * (NF Profile Complete Replacement) responses + */ + if (NFProfile->nf_profile_changes_support_ind == true) { + + OpenAPI_nf_profile_t NFProfileChanges; + ogs_sbi_message_t sendmsg; + + memset(&NFProfileChanges, 0, sizeof(NFProfileChanges)); + NFProfileChanges.nf_instance_id = NFProfile->nf_instance_id; + NFProfileChanges.nf_type = NFProfile->nf_type; + NFProfileChanges.nf_status = NFProfile->nf_status; + if (!NFProfile->heart_beat_timer) + NFProfileChanges.heart_beat_timer = + nf_instance->time.heartbeat_interval; + NFProfileChanges.nf_profile_changes_ind = true; + + memset(&sendmsg, 0, sizeof(sendmsg)); + sendmsg.http.location = recvmsg->http.location; + sendmsg.NFProfile = &NFProfileChanges; + + response = ogs_sbi_build_response(&sendmsg, status); + + } else { + + if (!NFProfile->heart_beat_timer) + NFProfile->heart_beat_timer = + nf_instance->time.heartbeat_interval; + + response = ogs_sbi_build_response(recvmsg, status); + + } - response = ogs_sbi_build_response(recvmsg, status); ogs_assert(response); ogs_sbi_server_send_response(stream, response); diff --git a/src/pcf/nf-sm.c b/src/pcf/nf-sm.c index 196ce393f..16c4d7e2a 100644 --- a/src/pcf/nf-sm.c +++ b/src/pcf/nf-sm.c @@ -195,7 +195,8 @@ void pcf_nf_state_registered(ogs_fsm_t *s, pcf_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: if (NF_INSTANCE_IS_SELF(nf_instance->id)) { - ogs_info("[%s] NF registered", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); client = nf_instance->client; ogs_assert(client); diff --git a/src/pcf/nnrf-handler.c b/src/pcf/nnrf-handler.c index 1c6a1fb4f..b198413fc 100644 --- a/src/pcf/nnrf-handler.c +++ b/src/pcf/nnrf-handler.c @@ -38,7 +38,12 @@ void pcf_nnrf_handle_nf_register( } /* TIME : Update heartbeat from NRF */ - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + if (NFProfile->nf_profile_changes_ind == true) { + if (NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } else { + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } } void pcf_nnrf_handle_nf_status_subscribe( diff --git a/src/smf/nf-sm.c b/src/smf/nf-sm.c index 417422aa8..5e2730885 100644 --- a/src/smf/nf-sm.c +++ b/src/smf/nf-sm.c @@ -196,7 +196,8 @@ void smf_nf_state_registered(ogs_fsm_t *s, smf_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: if (NF_INSTANCE_IS_SELF(nf_instance->id)) { - ogs_info("[%s] NF registered", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); client = nf_instance->client; ogs_assert(client); diff --git a/src/smf/nnrf-handler.c b/src/smf/nnrf-handler.c index 195ff5cf8..355bd87b2 100644 --- a/src/smf/nnrf-handler.c +++ b/src/smf/nnrf-handler.c @@ -38,7 +38,12 @@ void smf_nnrf_handle_nf_register( } /* TIME : Update heartbeat from NRF */ - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + if (NFProfile->nf_profile_changes_ind == true) { + if (NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } else { + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } } void smf_nnrf_handle_nf_status_subscribe( diff --git a/src/udm/nf-sm.c b/src/udm/nf-sm.c index d5e0437f7..a1e628531 100644 --- a/src/udm/nf-sm.c +++ b/src/udm/nf-sm.c @@ -195,7 +195,8 @@ void udm_nf_state_registered(ogs_fsm_t *s, udm_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: if (NF_INSTANCE_IS_SELF(nf_instance->id)) { - ogs_info("[%s] NF registered", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); client = nf_instance->client; ogs_assert(client); diff --git a/src/udm/nnrf-handler.c b/src/udm/nnrf-handler.c index dd900371e..1d1a4dc72 100644 --- a/src/udm/nnrf-handler.c +++ b/src/udm/nnrf-handler.c @@ -38,7 +38,12 @@ void udm_nnrf_handle_nf_register( } /* TIME : Update heartbeat from NRF */ - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + if (NFProfile->nf_profile_changes_ind == true) { + if (NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } else { + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } } void udm_nnrf_handle_nf_status_subscribe( diff --git a/src/udr/nf-sm.c b/src/udr/nf-sm.c index 2d063640b..ce011e11a 100644 --- a/src/udr/nf-sm.c +++ b/src/udr/nf-sm.c @@ -195,7 +195,8 @@ void udr_nf_state_registered(ogs_fsm_t *s, udr_event_t *e) switch (e->id) { case OGS_FSM_ENTRY_SIG: if (NF_INSTANCE_IS_SELF(nf_instance->id)) { - ogs_info("[%s] NF registered", nf_instance->id); + ogs_info("[%s] NF registred [Heartbeat:%ds]", + nf_instance->id, nf_instance->time.heartbeat_interval); client = nf_instance->client; ogs_assert(client); diff --git a/src/udr/nnrf-handler.c b/src/udr/nnrf-handler.c index ee3c3cc58..c481c6e23 100644 --- a/src/udr/nnrf-handler.c +++ b/src/udr/nnrf-handler.c @@ -38,7 +38,12 @@ void udr_nnrf_handle_nf_register( } /* TIME : Update heartbeat from NRF */ - nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + if (NFProfile->nf_profile_changes_ind == true) { + if (NFProfile->heart_beat_timer) + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } else { + nf_instance->time.heartbeat_interval = NFProfile->heart_beat_timer; + } } void udr_nnrf_handle_nf_status_subscribe(