[AMF] improve HTTP/2 timeout handling and error logging (#3862, #3863)

- Check ran_ue existence and abort if NG context has already been removed
- Detect deassociated RAN-UE (invalid amf_ue_id) and
  break to avoid further processing
- Validate AMF-UE ID matches ran_ue->amf_ue_id and skip on mismatch
This commit is contained in:
Sukchan Lee
2025-05-06 15:47:17 +09:00
parent 2231e48870
commit aab6940cd5
6 changed files with 91 additions and 7 deletions

View File

@@ -2433,8 +2433,12 @@ void ogs_sbi_object_free(ogs_sbi_object_t *sbi_object)
ogs_assert(sbi_object);
if (ogs_list_count(&sbi_object->xact_list))
if (ogs_list_count(&sbi_object->xact_list)) {
ogs_sbi_xact_t *xact = NULL; \
ogs_error("SBI running [%d]", ogs_list_count(&sbi_object->xact_list));
ogs_list_for_each(&sbi_object->xact_list, xact)
OGS_SBI_XACT_LOG(xact);
}
for (i = 0; i < OGS_SBI_MAX_NUM_OF_SERVICE_TYPE; i++) {
if (sbi_object->service_type_array[i].nf_instance_id)

View File

@@ -225,6 +225,35 @@ typedef struct ogs_sbi_object_s {
typedef ogs_sbi_request_t *(*ogs_sbi_build_f)(
void *context, void *data);
#define OGS_SBI_XACT_LOG(xact) \
do { \
ogs_error(" requester-nf-type[%s:%d]", \
OpenAPI_nf_type_ToString((xact)->requester_nf_type), \
(xact)->requester_nf_type); \
ogs_error(" service-name[%s:%d]", \
ogs_sbi_service_type_to_name((xact)->service_type), \
(xact)->service_type); \
if ((xact)->request) { \
int i; \
ogs_sbi_request_t *request = (xact)->request; \
if (request->h.method) \
ogs_error(" h.method[%s]", request->h.method); \
if (request->h.uri) \
ogs_error(" h.uri[%s]", request->h.uri); \
if (request->h.service.name) \
ogs_error(" h.service.name[%s]", request->h.service.name); \
if (request->h.api.version) \
ogs_error(" h.api.version[%s]", request->h.api.version); \
for (i = 0; i < OGS_SBI_MAX_NUM_OF_RESOURCE_COMPONENT && \
request->h.resource.component[i]; i++) \
ogs_error(" h.resource.component[%s:%d]", \
request->h.resource.component[i], i); \
ogs_error(" http.content_length[%d]", \
(int)request->http.content_length); \
if (request->http.content) \
ogs_error(" http.content[%s]", request->http.content); \
} \
} while(0)
typedef struct ogs_sbi_xact_s {
ogs_lnode_t lnode;

View File

@@ -751,7 +751,9 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
break;
}
ogs_error("[%s] Cannot receive SBI message", amf_ue->suci);
ogs_error("[%s:%s] Cannot receive SBI message",
amf_ue->supi, amf_ue->suci);
r = nas_5gs_send_gmm_reject_from_sbi(amf_ue,
OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT);
ogs_expect(r == OGS_OK);
@@ -771,8 +773,31 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e)
break;
}
ogs_error("[%d:%d] Cannot receive SBI message",
sess->psi, sess->pti);
ogs_error("[%s:%s:%d:%d] Cannot receive SBI message",
amf_ue->supi, amf_ue->suci, sess->psi, sess->pti);
ran_ue = ran_ue_find_by_id(sess->ran_ue_id);
if (!ran_ue) {
ogs_error("[%s:%s:%d:%d] "
"NG Context has already been removed",
amf_ue->supi, amf_ue->suci, sess->psi, sess->pti);
break;
}
if (ran_ue->amf_ue_id == OGS_INVALID_POOL_ID) {
ogs_error("[%s:%s:%d:%d] "
"RAN-UE has already been deassociated",
amf_ue->supi, amf_ue->suci, sess->psi, sess->pti);
break;
}
if (amf_ue->id != ran_ue->amf_ue_id) {
ogs_error("[%s:%s:%d:%d] AMF-UE mismatched [%d!=%d]",
amf_ue->supi, amf_ue->suci, sess->psi, sess->pti,
amf_ue->id, ran_ue->amf_ue_id);
break;
}
if (sess->payload_container_type) {
r = nas_5gs_send_back_gsm_message(
ran_ue_find_by_id(sess->ran_ue_id), sess,

View File

@@ -1033,8 +1033,11 @@ amf_sess_t *amf_sess_add(amf_ue_t *amf_ue, uint8_t psi);
ogs_assert(sbi_object); \
\
if (ogs_list_count(&sbi_object->xact_list)) { \
ogs_sbi_xact_t *xact = NULL; \
ogs_error("SBI running [%d]", \
ogs_list_count(&sbi_object->xact_list)); \
ogs_list_for_each(&sbi_object->xact_list, xact) \
OGS_SBI_XACT_LOG(xact); \
} else { \
amf_sess_remove(__sESS); \
} \

View File

@@ -315,7 +315,13 @@ ogs_pkbuf_t *ngap_build_downlink_nas_transport(
ogs_assert(gmmbuf);
ogs_assert(ran_ue);
amf_ue = amf_ue_find_by_id(ran_ue->amf_ue_id);
ogs_assert(amf_ue);
if (!amf_ue) {
ogs_fatal(" AMF-UE-ID[%d] RAN_UE_NGAP_ID[%lld] AMF_UE_NGAP_ID[%lld]",
ran_ue->amf_ue_id,
(long long)ran_ue->ran_ue_ngap_id,
(long long)ran_ue->amf_ue_ngap_id);
ogs_assert_if_reached();
}
ogs_debug("DownlinkNASTransport");

View File

@@ -80,6 +80,7 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e)
ogs_sbi_message_t sbi_message;
ogs_sbi_xact_t *sbi_xact = NULL;
ogs_pool_id_t sbi_xact_id = OGS_INVALID_POOL_ID;
ogs_sbi_object_t *sbi_object = NULL;
ogs_pool_id_t sbi_object_id = OGS_INVALID_POOL_ID;
ogs_nas_5gs_message_t nas_message;
@@ -1040,14 +1041,30 @@ void smf_state_operational(ogs_fsm_t *s, smf_event_t *e)
/* Here, we should not use ogs_assert(stream)
* since 'namf-comm' service has no an associated stream. */
sbi_object = sbi_xact->sbi_object;
ogs_assert(sbi_object);
sbi_object_id = sbi_xact->sbi_object_id;
ogs_assert(sbi_object_id >= OGS_MIN_POOL_ID &&
sbi_object_id <= OGS_MAX_POOL_ID);
ogs_sbi_xact_remove(sbi_xact);
ogs_error("Cannot receive SBI message");
sess = smf_sess_find_by_id(sbi_object_id);
if (!sess) {
ogs_error("Session has already been removed");
break;
}
smf_ue = smf_ue_find_by_id(sess->smf_ue_id);
ogs_assert(smf_ue);
ogs_error("[%s:%d] Cannot receive SBI message",
smf_ue->supi, sess->psi);
if (stream) {
ogs_assert(true ==
ogs_sbi_server_send_error(stream,
OGS_SBI_HTTP_STATUS_GATEWAY_TIMEOUT, NULL,
"Cannot receive SBI message", NULL, NULL));
"Cannot receive SBI message", smf_ue->supi, NULL));
}
break;