fix: UE Context Request IE handling (#771)

This commit is contained in:
Sukchan Lee 2021-01-23 13:42:59 -05:00
parent 776d323a16
commit 61778f9142
2 changed files with 52 additions and 56 deletions

View File

@ -66,6 +66,7 @@ int nas_5gs_send_to_downlink_nas_transport(amf_ue_t *amf_ue, ogs_pkbuf_t *pkbuf)
void nas_5gs_send_registration_accept(amf_ue_t *amf_ue)
{
int rv;
bool transfer_needed = false;
ran_ue_t *ran_ue = NULL;
@ -79,8 +80,28 @@ void nas_5gs_send_registration_accept(amf_ue_t *amf_ue)
gmmbuf = gmm_build_registration_accept(amf_ue);
ogs_expect_or_return(gmmbuf);
if (ran_ue->ue_context_requested == true &&
ran_ue->initial_context_setup_request_sent == false) {
/*
* Previously, AMF would sends PDUSessionResourceSetupRequest
* when the following conditions were met:
* - gNB didn't send UE Context Request IE of InitialUEMessage
* - AMF should send SMF generated TRANSFER message(PDU_RES_SETUP_REQ)
* to the gNB
*
* However, in issues #771, the gNB did not accept
* PDUSessionResourceSetupRequest. Perhaps the gNB engineer thought
* that if gNB needs to send data traffic to the UE, AMF should send
* an InitialContextSetupRequest regardless of UE Context Request IE.
* This is because gNB requires the kgNB security context
* for data connection.
*
* So, in this case, Open5GS-AMF decided to send
* an InitialContexSetupRequest regardless of
* whether it received UE Context Request IE of InitialUEMessage.
*/
transfer_needed = PDU_RES_SETUP_REQ_TRANSFER_NEEDED(amf_ue);
if (ran_ue->initial_context_setup_request_sent == false &&
(ran_ue->ue_context_requested == true || transfer_needed == true)) {
ngapbuf = ngap_ue_build_initial_context_setup_request(amf_ue, gmmbuf);
ogs_expect_or_return(ngapbuf);
@ -89,32 +110,9 @@ void nas_5gs_send_registration_accept(amf_ue_t *amf_ue)
ran_ue->initial_context_setup_request_sent = true;
} else {
if (PDU_RES_SETUP_REQ_TRANSFER_NEEDED(amf_ue)) {
/*
* Previously, AMF would sends PDUSessionResourceSetupRequest
* when the following conditions were met:
* - gNB didn't send UE Context Request IE of InitialUEMessage
* - AMF should send SMF generated TRANSFER message(PDU_RES_SETUP_REQ)
* to the gNB
*
* However, in issues #771, the gNB did not accept
* PDUSessionResourceSetupRequest. Perhaps the gNB engineer thought
* that if gNB needs to send data traffic to the UE, AMF should send
* an InitialContextSetupRequest regardless of UE Context Request IE.
* This is because gNB requires the kgNB security context
* for data connection.
*
* So, in this case, Open5GS-AMF decided to send
* an InitialContexSetupRequest regardless of
* whether it received UE Context Request IE of InitialUEMessage.
*/
#if WILL_BE_REMOVED
if (transfer_needed == true) {
ngapbuf = ngap_ue_build_pdu_session_resource_setup_request(
amf_ue, gmmbuf);
#else
ngapbuf = ngap_ue_build_initial_context_setup_request(
amf_ue, gmmbuf);
#endif
ogs_expect_or_return(ngapbuf);
rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf);
@ -150,6 +148,7 @@ void nas_5gs_send_registration_reject(
void nas_5gs_send_service_accept(amf_ue_t *amf_ue)
{
int rv;
bool transfer_needed = false;
ran_ue_t *ran_ue = NULL;
ogs_pkbuf_t *gmmbuf = NULL;
@ -162,8 +161,28 @@ void nas_5gs_send_service_accept(amf_ue_t *amf_ue)
gmmbuf = gmm_build_service_accept(amf_ue);
ogs_expect_or_return(gmmbuf);
if (ran_ue->ue_context_requested == true &&
ran_ue->initial_context_setup_request_sent == false) {
/*
* Previously, AMF would sends PDUSessionResourceSetupRequest
* when the following conditions were met:
* - gNB didn't send UE Context Request IE of InitialUEMessage
* - AMF should send SMF generated TRANSFER message(PDU_RES_SETUP_REQ)
* to the gNB
*
* However, in issues #771, the gNB did not accept
* PDUSessionResourceSetupRequest. Perhaps the gNB engineer thought
* that if gNB needs to send data traffic to the UE, AMF should send
* an InitialContextSetupRequest regardless of UE Context Request IE.
* This is because gNB requires the kgNB security context
* for data connection.
*
* So, in this case, Open5GS-AMF decided to send
* an InitialContexSetupRequest regardless of
* whether it received UE Context Request IE of InitialUEMessage.
*/
transfer_needed = PDU_RES_SETUP_REQ_TRANSFER_NEEDED(amf_ue);
if (ran_ue->initial_context_setup_request_sent == false &&
(ran_ue->ue_context_requested == true || transfer_needed == true)) {
ngapbuf = ngap_ue_build_initial_context_setup_request(amf_ue, gmmbuf);
ogs_expect_or_return(ngapbuf);
@ -172,32 +191,9 @@ void nas_5gs_send_service_accept(amf_ue_t *amf_ue)
ran_ue->initial_context_setup_request_sent = true;
} else {
if (PDU_RES_SETUP_REQ_TRANSFER_NEEDED(amf_ue)) {
/*
* Previously, AMF would sends PDUSessionResourceSetupRequest
* when the following conditions were met:
* - gNB didn't send UE Context Request IE of InitialUEMessage
* - AMF should send SMF generated TRANSFER message(PDU_RES_SETUP_REQ)
* to the gNB
*
* However, in issues #771, the gNB did not accept
* PDUSessionResourceSetupRequest. Perhaps the gNB engineer thought
* that if gNB needs to send data traffic to the UE, AMF should send
* an InitialContextSetupRequest regardless of UE Context Request IE.
* This is because gNB requires the kgNB security context
* for data connection.
*
* So, in this case, Open5GS-AMF decided to send
* an InitialContexSetupRequest regardless of
* whether it received UE Context Request IE of InitialUEMessage.
*/
#if WILL_BE_REMOVED
if (transfer_needed == true) {
ngapbuf = ngap_ue_build_pdu_session_resource_setup_request(
amf_ue, gmmbuf);
#else
ngapbuf = ngap_ue_build_initial_context_setup_request(
amf_ue, gmmbuf);
#endif
ogs_expect_or_return(ngapbuf);
rv = nas_5gs_send_to_gnb(amf_ue, ngapbuf);

View File

@ -1153,18 +1153,18 @@ static void test3_func(abts_case *tc, void *data)
rv = testgnb_ngap_send(ngap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive InitialContextSetupRequest +
/* Receive PDUSessionResourceSetupRequest +
* Service accept */
recvbuf = testgnb_ngap_read(ngap);
ABTS_PTR_NOTNULL(tc, recvbuf);
testngap_recv(test_ue, recvbuf);
ABTS_INT_EQUAL(tc,
NGAP_ProcedureCode_id_InitialContextSetup,
NGAP_ProcedureCode_id_PDUSessionResourceSetup,
test_ue->ngap_procedure_code);
ABTS_INT_EQUAL(tc, 0x0000, test_ue->pdu_session_reactivation_result);
/* Send InitialContextSetupResponse */
sendbuf = testngap_build_initial_context_setup_response(test_ue, true);
/* Send PDUSessionResourceSetupResponse */
sendbuf = testngap_ue_build_pdu_session_resource_setup_response(test_ue);
ABTS_PTR_NOTNULL(tc, sendbuf);
rv = testgnb_ngap_send(ngap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);