Add exception handling for #568

If packet buffer is exhausted, the packet is sliently discarded
This commit is contained in:
Sukchan Lee 2020-09-18 14:53:23 -04:00
parent e828adfba4
commit 7ae1600e04
9 changed files with 50 additions and 7 deletions

View File

@ -28,11 +28,21 @@
OGS_GNUC_NORETURN void ogs_abort(void)
{
#if HAVE_BACKTRACE
int i;
int nptrs;
void *buffer[100];
char **strings;
nptrs = backtrace(buffer, OGS_ARRAY_SIZE(buffer));
backtrace_symbols_fd(buffer, nptrs, 2);
ogs_fatal("backtrace() returned %d addresses", nptrs);
strings = backtrace_symbols(buffer, nptrs);
if (strings) {
for (i = 1; i < nptrs; i++)
ogs_log_print(OGS_LOG_FATAL, "%s\n", strings[i]);
free(strings);
}
abort();
#elif defined(_WIN32)

View File

@ -177,6 +177,7 @@ ogs_pkbuf_t *ogs_pkbuf_alloc(ogs_pkbuf_pool_t *pool, unsigned int size)
cluster = cluster_alloc(pool, size);
if (!cluster) {
ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
ogs_thread_mutex_unlock(&pool->mutex);
return NULL;
}
ogs_assert(cluster);
@ -238,6 +239,11 @@ ogs_pkbuf_t *ogs_pkbuf_copy(ogs_pkbuf_t *pkbuf)
ogs_thread_mutex_lock(&pool->mutex);
ogs_pool_alloc(&pool->pkbuf, &newbuf);
if (!newbuf) {
ogs_error("ogs_pkbuf_copy() failed");
ogs_thread_mutex_unlock(&pool->mutex);
return NULL;
}
ogs_assert(newbuf);
memcpy(newbuf, pkbuf, sizeof *pkbuf);

View File

@ -128,7 +128,14 @@ void ogs_pfcp_up_handle_pdr(
memset(report, 0, sizeof(*report));
sendbuf = ogs_pkbuf_copy(recvbuf);
ogs_assert(sendbuf);
if (!sendbuf) {
ogs_error("CHECK CONFIGURATION : Not enough packet buffer");
ogs_error("Edit sgwu.yaml in EPC or upf.yaml in 5GC");
ogs_error("pool");
ogs_error(" packet: 32768");
return;
}
buffering = false;

View File

@ -1516,6 +1516,7 @@ static int parse_multipart(
http->part[http->num_of_part].content_type;
message->part[message->num_of_part].pkbuf =
ogs_pkbuf_copy(http->part[http->num_of_part].pkbuf);
ogs_assert(message->part[message->num_of_part].pkbuf);
http->num_of_part++;
message->num_of_part++;

View File

@ -200,6 +200,7 @@ void nas_5gs_send_identity_request(amf_ue_t *amf_ue)
}
amf_ue->t3570.pkbuf = ogs_pkbuf_copy(gmmbuf);
ogs_assert(amf_ue->t3570.pkbuf);
ogs_timer_start(amf_ue->t3570.timer,
amf_timer_cfg(AMF_TIMER_T3570)->duration);
@ -224,6 +225,7 @@ void nas_5gs_send_authentication_request(amf_ue_t *amf_ue)
}
amf_ue->t3560.pkbuf = ogs_pkbuf_copy(gmmbuf);
ogs_assert(amf_ue->t3560.pkbuf);
ogs_timer_start(amf_ue->t3560.timer,
amf_timer_cfg(AMF_TIMER_T3560)->duration);
@ -265,6 +267,7 @@ void nas_5gs_send_security_mode_command(amf_ue_t *amf_ue)
}
amf_ue->t3560.pkbuf = ogs_pkbuf_copy(gmmbuf);
ogs_assert(amf_ue->t3560.pkbuf);
ogs_timer_start(amf_ue->t3560.timer,
amf_timer_cfg(AMF_TIMER_T3560)->duration);
@ -287,6 +290,7 @@ void nas_5gs_send_configuration_update_command(
ogs_expect_or_return(gmmbuf);
amf_ue->t3555.pkbuf = ogs_pkbuf_copy(gmmbuf);
ogs_assert(amf_ue->t3555.pkbuf);
ogs_timer_start(amf_ue->t3555.timer,
amf_timer_cfg(AMF_TIMER_T3555)->duration);
@ -296,6 +300,7 @@ void nas_5gs_send_configuration_update_command(
if (param->acknowledgement_requested) {
amf_ue->t3555.pkbuf = ogs_pkbuf_copy(gmmbuf);
ogs_assert(amf_ue->t3555.pkbuf);
ogs_timer_start(amf_ue->t3555.timer,
amf_timer_cfg(AMF_TIMER_T3555)->duration);
}
@ -444,7 +449,7 @@ void nas_5gs_send_back_5gsm_message(
ogs_assert(sess->payload_container);
pbuf = ogs_pkbuf_copy(sess->payload_container);
ogs_expect_or_return(pbuf);
ogs_assert(pbuf);
nas_5gs_send_gsm_reject(sess, sess->payload_container_type, pbuf,
cause, AMF_NAS_BACKOFF_TIME);

View File

@ -367,6 +367,7 @@ void ngap_send_paging(amf_ue_t *amf_ue, NGAP_CNDomain_t cn_domain)
}
amf_ue->t3413.pkbuf = ogs_pkbuf_copy(ngapbuf);
ogs_assert(amf_ue->t3413.pkbuf);
rv = ngap_send_to_gnb(gnb, ngapbuf, NGAP_NON_UE_SIGNALLING);
ogs_expect(rv == OGS_OK);

View File

@ -164,6 +164,7 @@ void nas_eps_send_identity_request(mme_ue_t *mme_ue)
}
mme_ue->t3470.pkbuf = ogs_pkbuf_copy(emmbuf);
ogs_assert(mme_ue->t3470.pkbuf);
ogs_timer_start(mme_ue->t3470.timer,
mme_timer_cfg(MME_TIMER_T3470)->duration);
@ -191,6 +192,7 @@ void nas_eps_send_authentication_request(
}
mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf);
ogs_assert(mme_ue->t3460.pkbuf);
ogs_timer_start(mme_ue->t3460.timer,
mme_timer_cfg(MME_TIMER_T3460)->duration);
@ -217,6 +219,7 @@ void nas_eps_send_security_mode_command(mme_ue_t *mme_ue)
}
mme_ue->t3460.pkbuf = ogs_pkbuf_copy(emmbuf);
ogs_assert(mme_ue->t3460.pkbuf);
ogs_timer_start(mme_ue->t3460.timer,
mme_timer_cfg(MME_TIMER_T3460)->duration);
@ -310,6 +313,7 @@ void nas_eps_send_esm_information_request(mme_bearer_t *bearer)
}
bearer->t3489.pkbuf = ogs_pkbuf_copy(esmbuf);
ogs_assert(bearer->t3489.pkbuf);
ogs_timer_start(bearer->t3489.timer,
mme_timer_cfg(MME_TIMER_T3489)->duration);

View File

@ -350,6 +350,7 @@ void s1ap_send_paging(mme_ue_t *mme_ue, S1AP_CNDomain_t cn_domain)
}
mme_ue->t3413.pkbuf = ogs_pkbuf_copy(s1apbuf);
ogs_assert(mme_ue->t3413.pkbuf);
rv = s1ap_send_to_enb(enb, s1apbuf, S1AP_NON_UE_SIGNALLING);
ogs_expect(rv == OGS_OK);

View File

@ -218,8 +218,10 @@ void sgwc_pfcp_send_session_establishment_request(
sess->pfcp_node, &h, sxabuf, sess_timeout, sess);
ogs_expect_or_return(xact);
xact->assoc_xact = gtp_xact;
if (gtpbuf)
if (gtpbuf) {
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_assert(xact->gtpbuf);
}
rv = ogs_pfcp_xact_commit(xact);
ogs_expect(rv == OGS_OK);
@ -248,8 +250,10 @@ void sgwc_pfcp_send_sess_modification_request(
ogs_expect_or_return(xact);
xact->assoc_xact = gtp_xact;
xact->modify_flags = flags | OGS_PFCP_MODIFY_SESSION;
if (gtpbuf)
if (gtpbuf) {
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_assert(xact->gtpbuf);
}
rv = ogs_pfcp_xact_commit(xact);
ogs_expect(rv == OGS_OK);
@ -281,8 +285,10 @@ void sgwc_pfcp_send_bearer_modification_request(
ogs_expect_or_return(xact);
xact->assoc_xact = gtp_xact;
xact->modify_flags = flags;
if (gtpbuf)
if (gtpbuf) {
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_assert(xact->gtpbuf);
}
rv = ogs_pfcp_xact_commit(xact);
ogs_expect(rv == OGS_OK);
@ -309,8 +315,10 @@ void sgwc_pfcp_send_session_deletion_request(
sess->pfcp_node, &h, sxabuf, sess_timeout, sess);
ogs_expect_or_return(xact);
xact->assoc_xact = gtp_xact;
if (gtpbuf)
if (gtpbuf) {
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_assert(xact->gtpbuf);
}
rv = ogs_pfcp_xact_commit(xact);
ogs_expect(rv == OGS_OK);