From 24a4df3691fcdba34c7c4d692ce3ba826fe4dcd8 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sun, 26 Jul 2020 23:10:53 -0400 Subject: [PATCH] fix SMF crash [#512] --- configs/open5gs/amf.yaml.in | 6 +-- configs/open5gs/ausf.yaml.in | 6 +-- configs/open5gs/nrf.yaml.in | 6 +-- configs/open5gs/smf.yaml.in | 6 +-- configs/open5gs/udm.yaml.in | 6 +-- configs/open5gs/udr.yaml.in | 6 +-- lib/app/ogs-config.c | 4 +- src/smf/pfcp-path.c | 83 ++++++++++++++++++++++++++++++++---- 8 files changed, 94 insertions(+), 29 deletions(-) diff --git a/configs/open5gs/amf.yaml.in b/configs/open5gs/amf.yaml.in index 75f045b48..a247dda2e 100644 --- a/configs/open5gs/amf.yaml.in +++ b/configs/open5gs/amf.yaml.in @@ -301,9 +301,9 @@ pool: # nf_instance: # heartbeat: 10 # -# o Message Wait Duration (Default : 2000ms = 2 seconds) +# o Message Wait Duration (Default : 1000ms = 1 second) # -# o Message Wait Duration (3 seconds) +# o Message Wait Duration (1200 ms) # message: -# duration: 3000 +# duration: 1200 time: diff --git a/configs/open5gs/ausf.yaml.in b/configs/open5gs/ausf.yaml.in index c215b7bde..e3aa07e97 100644 --- a/configs/open5gs/ausf.yaml.in +++ b/configs/open5gs/ausf.yaml.in @@ -177,9 +177,9 @@ pool: # nf_instance: # heartbeat: 10 # -# o Message Wait Duration (Default : 2000ms = 2 seconds) +# o Message Wait Duration (Default : 1000ms = 1 second) # -# o Message Wait Duration (3 seconds) +# o Message Wait Duration (1200 ms) # message: -# duration: 3000 +# duration: 1200 time: diff --git a/configs/open5gs/nrf.yaml.in b/configs/open5gs/nrf.yaml.in index b882c1024..2b7f34eda 100644 --- a/configs/open5gs/nrf.yaml.in +++ b/configs/open5gs/nrf.yaml.in @@ -153,9 +153,9 @@ pool: # subscription: # validity: 3600 # -# o Message Wait Duration (Default : 2000ms = 2 seconds) +# o Message Wait Duration (Default : 1000ms = 1 second) # -# o Message Wait Duration (3 seconds) +# o Message Wait Duration (1200 ms) # message: -# duration: 3000 +# duration: 1200 time: diff --git a/configs/open5gs/smf.yaml.in b/configs/open5gs/smf.yaml.in index df1f5505e..0b3f58e93 100644 --- a/configs/open5gs/smf.yaml.in +++ b/configs/open5gs/smf.yaml.in @@ -361,9 +361,9 @@ pool: # nf_instance: # heartbeat: 10 # -# o Message Wait Duration (Default : 2000ms = 2 seconds) +# o Message Wait Duration (Default : 1000ms = 1 second) # -# o Message Wait Duration (3 seconds) +# o Message Wait Duration (1200 ms) # message: -# duration: 3000 +# duration: 1200 time: diff --git a/configs/open5gs/udm.yaml.in b/configs/open5gs/udm.yaml.in index fc0e4e31a..0b14604d4 100644 --- a/configs/open5gs/udm.yaml.in +++ b/configs/open5gs/udm.yaml.in @@ -177,9 +177,9 @@ pool: # nf_instance: # heartbeat: 10 # -# o Message Wait Duration (Default : 2000ms = 2 seconds) +# o Message Wait Duration (Default : 1000ms = 1 second) # -# o Message Wait Duration (3 seconds) +# o Message Wait Duration (1200 ms) # message: -# duration: 3000 +# duration: 1200 time: diff --git a/configs/open5gs/udr.yaml.in b/configs/open5gs/udr.yaml.in index 968e0a909..8aeadd7ad 100644 --- a/configs/open5gs/udr.yaml.in +++ b/configs/open5gs/udr.yaml.in @@ -179,9 +179,9 @@ pool: # nf_instance: # heartbeat: 10 # -# o Message Wait Duration (Default : 2000ms = 2 seconds) +# o Message Wait Duration (Default : 1000ms = 1 second) # -# o Message Wait Duration (3 seconds) +# o Message Wait Duration (1200 ms) # message: -# duration: 3000 +# duration: 1200 time: diff --git a/lib/app/ogs-config.c b/lib/app/ogs-config.c index fada77d17..2f25606c8 100644 --- a/lib/app/ogs-config.c +++ b/lib/app/ogs-config.c @@ -266,8 +266,8 @@ static int config_prepare(void) /* 86400 seconds = 1 day */ self.time.subscription.validity_duration = 86400; - /* Message Wait Duration : 2 seconds */ - self.time.message.duration = ogs_time_from_sec(2); + /* Message Wait Duration : 1 seconds */ + self.time.message.duration = ogs_time_from_sec(1); regenerate_all_timer_duration(); diff --git a/src/smf/pfcp-path.c b/src/smf/pfcp-path.c index 1a4faaf33..892e35181 100644 --- a/src/smf/pfcp-path.c +++ b/src/smf/pfcp-path.c @@ -17,8 +17,7 @@ * along with this program. If not, see . */ -#include "context.h" - +#include "sbi-path.h" #include "pfcp-path.h" #include "n4-build.h" @@ -197,6 +196,73 @@ static void timeout(ogs_pfcp_xact_t *xact, void *data) } break; default: + ogs_error("Not implemented [type:%d]", type); + break; + } +} + +static void sess_5gc_timeout(ogs_pfcp_xact_t *xact, void *data) +{ + smf_ue_t *smf_ue = NULL; + smf_sess_t *sess = NULL; + ogs_sbi_session_t *session = NULL; + uint8_t type; + char *strerror = NULL; + + ogs_assert(xact); + ogs_assert(data); + + sess = data; + ogs_assert(sess); + session = sess->sbi.session; + ogs_assert(session); + smf_ue = sess->smf_ue; + ogs_assert(smf_ue); + + type = xact->seq[0].type; + switch (type) { + case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE: + ogs_error("No PFCP session establishment response"); + break; + case OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE: + strerror = ogs_msprintf("[%s:%d] No PFCP session modification response", + smf_ue->supi, sess->psi); + smf_sbi_send_sm_context_update_error(session, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, + strerror, NULL, NULL, NULL); + break; + case OGS_PFCP_SESSION_DELETION_REQUEST_TYPE: + strerror = ogs_msprintf("[%s:%d] No PFCP session deletion response", + smf_ue->supi, sess->psi); + ogs_sbi_server_send_error(session, + OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL, strerror, NULL); + ogs_free(strerror); + break; + default: + ogs_error("Not implemented [type:%d]", type); + break; + } +} + +static void sess_epc_timeout(ogs_pfcp_xact_t *xact, void *data) +{ + uint8_t type; + + ogs_assert(xact); + type = xact->seq[0].type; + + switch (type) { + case OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE: + ogs_error("No PFCP session establishment response"); + break; + case OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE: + ogs_error("No PFCP session modification response"); + break; + case OGS_PFCP_SESSION_DELETION_REQUEST_TYPE: + ogs_error("No PFCP session deletion response"); + break; + default: + ogs_error("Not implemented [type:%d]", type); break; } } @@ -287,7 +353,7 @@ void smf_5gc_pfcp_send_session_establishment_request(smf_sess_t *sess) ogs_expect_or_return(n4buf); xact = ogs_pfcp_xact_local_create( - sess->pfcp_node, &h, n4buf, timeout, sess); + sess->pfcp_node, &h, n4buf, sess_5gc_timeout, sess); ogs_expect_or_return(xact); rv = ogs_pfcp_xact_commit(xact); @@ -300,7 +366,6 @@ void smf_5gc_pfcp_send_session_modification_request(smf_sess_t *sess) ogs_pkbuf_t *n4buf = NULL; ogs_pfcp_header_t h; ogs_pfcp_xact_t *xact = NULL; - smf_bearer_t *bearer = NULL; ogs_assert(sess); @@ -312,7 +377,7 @@ void smf_5gc_pfcp_send_session_modification_request(smf_sess_t *sess) ogs_expect_or_return(n4buf); xact = ogs_pfcp_xact_local_create( - sess->pfcp_node, &h, n4buf, timeout, bearer); + sess->pfcp_node, &h, n4buf, sess_5gc_timeout, sess); ogs_expect_or_return(xact); xact->assoc_session = sess->sbi.session; @@ -338,7 +403,7 @@ void smf_5gc_pfcp_send_session_deletion_request(smf_sess_t *sess, int trigger) ogs_expect_or_return(n4buf); xact = ogs_pfcp_xact_local_create( - sess->pfcp_node, &h, n4buf, timeout, sess); + sess->pfcp_node, &h, n4buf, sess_5gc_timeout, sess); ogs_expect_or_return(xact); xact->assoc_session = sess->sbi.session; xact->trigger = trigger; @@ -365,7 +430,7 @@ void smf_epc_pfcp_send_session_establishment_request( ogs_expect_or_return(n4buf); xact = ogs_pfcp_xact_local_create( - sess->pfcp_node, &h, n4buf, timeout, sess); + sess->pfcp_node, &h, n4buf, sess_epc_timeout, sess); ogs_expect_or_return(xact); xact->assoc_xact = gtp_xact; @@ -393,7 +458,7 @@ void smf_epc_pfcp_send_session_modification_request(smf_bearer_t *bearer) ogs_expect_or_return(n4buf); xact = ogs_pfcp_xact_local_create( - sess->pfcp_node, &h, n4buf, timeout, bearer); + sess->pfcp_node, &h, n4buf, sess_epc_timeout, bearer); ogs_expect_or_return(xact); rv = ogs_pfcp_xact_commit(xact); @@ -418,7 +483,7 @@ void smf_epc_pfcp_send_session_deletion_request( ogs_expect_or_return(n4buf); xact = ogs_pfcp_xact_local_create( - sess->pfcp_node, &h, n4buf, timeout, sess); + sess->pfcp_node, &h, n4buf, sess_epc_timeout, sess); ogs_expect_or_return(xact); xact->assoc_xact = gtp_xact;