mirror of
https://github.com/open5gs/open5gs.git
synced 2025-10-23 07:41:57 +00:00
[SEC/SMF] Handle invalid NAMF_COMM API messages and escalate SBI logs to errors (#4000)
Added a handler to catch invalid NAMF_COMM API messages and prevent assertion failures, and upgraded related SBI log statements from warnings to errors.
This commit is contained in:
@@ -285,10 +285,10 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_POST)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
|
||||
@@ -343,7 +343,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_EAP_SESSION)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -365,7 +365,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_AM_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SDM_SUBSCRIPTIONS)
|
||||
@@ -407,7 +407,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
}
|
||||
break;
|
||||
DEFAULT
|
||||
ogs_warn("[%s] Ignore invalid HTTP method [%s]",
|
||||
ogs_error("[%s] Ignore invalid HTTP method [%s]",
|
||||
amf_ue->suci, sbi_message->h.method);
|
||||
END
|
||||
break;
|
||||
@@ -431,7 +431,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_REGISTRATIONS)
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PATCH)
|
||||
SWITCH(sbi_message->h.resource.component[2])
|
||||
@@ -486,7 +486,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
}
|
||||
break;
|
||||
DEFAULT
|
||||
ogs_warn("Ignoring invalid resource name [%s]",
|
||||
ogs_error("Ignoring invalid resource name [%s]",
|
||||
sbi_message->h.resource.component[2]);
|
||||
END
|
||||
break;
|
||||
@@ -514,7 +514,7 @@ void gmm_state_de_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
ogs_error("[%s] HTTP response error [%d]",
|
||||
amf_ue->supi, sbi_message->res_status);
|
||||
}
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
@@ -883,10 +883,10 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_POST)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
CLEAR_5G_AKA_CONFIRMATION(amf_ue);
|
||||
@@ -941,7 +941,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_EAP_SESSION)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -963,7 +963,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_AM_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SDM_SUBSCRIPTIONS)
|
||||
@@ -1035,7 +1035,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_REGISTRATIONS)
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PATCH)
|
||||
SWITCH(sbi_message->h.resource.component[2])
|
||||
@@ -1133,7 +1133,7 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e)
|
||||
ogs_error("[%s] HTTP response error [%d]",
|
||||
amf_ue->supi, sbi_message->res_status);
|
||||
}
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
@@ -2047,7 +2047,7 @@ void gmm_state_authentication(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SDM_SUBSCRIPTIONS)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -2327,13 +2327,13 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e)
|
||||
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_POST)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
DEFAULT
|
||||
ogs_error("[%s] Invalid HTTP method [%s]",
|
||||
@@ -2345,7 +2345,7 @@ void gmm_state_security_mode(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_EAP_SESSION)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -2508,13 +2508,13 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e)
|
||||
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_POST)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
DEFAULT
|
||||
ogs_error("[%s] Invalid HTTP method [%s]",
|
||||
@@ -2526,7 +2526,7 @@ void gmm_state_initial_context_setup(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_EAP_SESSION)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -3149,13 +3149,13 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
|
||||
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_POST)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
CASE(OGS_SBI_HTTP_METHOD_DELETE)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
DEFAULT
|
||||
ogs_error("[%s] Invalid HTTP method [%s]",
|
||||
@@ -3167,7 +3167,7 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_5G_AKA_CONFIRMATION)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_EAP_SESSION)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -3195,7 +3195,7 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
|
||||
|
||||
SWITCH(sbi_message->h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
DEFAULT
|
||||
ogs_error("[%s] Invalid HTTP method [%s]",
|
||||
@@ -3224,7 +3224,7 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SMF_SELECT_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXT_IN_SMF_DATA)
|
||||
CASE(OGS_SBI_RESOURCE_NAME_SDM_SUBSCRIPTIONS)
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->supi);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->supi);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
@@ -3243,7 +3243,7 @@ void gmm_state_exception(ogs_fsm_t *s, amf_event_t *e)
|
||||
ogs_error("[%s] HTTP response error [%d]",
|
||||
amf_ue->supi, sbi_message->res_status);
|
||||
}
|
||||
ogs_warn("[%s] Ignore SBI message", amf_ue->suci);
|
||||
ogs_error("[%s] Ignore SBI message", amf_ue->suci);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
|
@@ -1589,6 +1589,23 @@ void smf_gsm_state_wait_pfcp_deletion(ogs_fsm_t *s, smf_event_t *e)
|
||||
stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
n1smbuf, OpenAPI_n2_sm_info_type_NULL, NULL);
|
||||
break;
|
||||
CASE(OGS_SBI_SERVICE_NAME_NAMF_COMM)
|
||||
SWITCH(sbi_message->h.resource.component[0])
|
||||
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS)
|
||||
ogs_error("[%s:%d] Ignore SBI message "
|
||||
"state [%d] res_status [%d]",
|
||||
smf_ue->supi, sess->psi,
|
||||
e->h.sbi.state, sbi_message->res_status);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
ogs_error("[%s:%d] Invalid resource name [%s]",
|
||||
smf_ue->supi, sess->psi,
|
||||
sbi_message->h.resource.component[0]);
|
||||
ogs_assert_if_reached();
|
||||
END
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
ogs_error("[%s:%d] Invalid API name [%s]",
|
||||
smf_ue->supi, sess->psi, sbi_message->h.service.name);
|
||||
@@ -1809,7 +1826,7 @@ void smf_gsm_state_wait_5gc_n1_n2_release(ogs_fsm_t *s, smf_event_t *e)
|
||||
CASE(OGS_SBI_SERVICE_NAME_NAMF_COMM)
|
||||
SWITCH(sbi_message->h.resource.component[0])
|
||||
CASE(OGS_SBI_RESOURCE_NAME_UE_CONTEXTS)
|
||||
ogs_warn("[%s:%d] state [%d] res_status [%d]",
|
||||
ogs_error("[%s:%d] state [%d] res_status [%d]",
|
||||
smf_ue->supi, sess->psi,
|
||||
e->h.sbi.state, sbi_message->res_status);
|
||||
smf_namf_comm_handle_n1_n2_message_transfer(
|
||||
@@ -1878,7 +1895,7 @@ void smf_gsm_state_wait_5gc_n1_n2_release(ogs_fsm_t *s, smf_event_t *e)
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
ogs_warn("[%s] Ignore invalid HTTP method [%s]",
|
||||
ogs_error("[%s] Ignore invalid HTTP method [%s]",
|
||||
smf_ue->supi, sbi_message->h.method);
|
||||
END
|
||||
break;
|
||||
@@ -2243,7 +2260,7 @@ void smf_gsm_state_5gc_session_will_deregister(ogs_fsm_t *s, smf_event_t *e)
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
ogs_warn("Ignore invalid HTTP method [%s]",
|
||||
ogs_error("Ignore invalid HTTP method [%s]",
|
||||
sbi_message->h.method);
|
||||
END
|
||||
break;
|
||||
|
Reference in New Issue
Block a user