[SGWC] pfcp: Retrieve sess when SEID=0 (#1620)

This commit is contained in:
Sukchan Lee 2022-06-28 13:20:46 +09:00
parent 5eaf66262a
commit 9700563023
5 changed files with 31 additions and 108 deletions

View File

@ -212,6 +212,8 @@ int sgwc_pfcp_send_bearer_to_modify_list(
ogs_assert(sess);
ogs_assert(xact);
xact->local_seid = sess->sgwc_sxa_seid;
memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE;
h.seid = sess->sgwu_sxa_seid;
@ -246,6 +248,7 @@ int sgwc_pfcp_send_session_establishment_request(
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_expect_or_return_val(xact->gtpbuf, OGS_ERROR);
}
xact->local_seid = sess->sgwc_sxa_seid;
memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_ESTABLISHMENT_REQUEST_TYPE;
@ -311,6 +314,7 @@ int sgwc_pfcp_send_bearer_modification_request(
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_expect_or_return_val(xact->gtpbuf, OGS_ERROR);
}
xact->local_seid = sess->sgwc_sxa_seid;
ogs_list_add(&xact->bearer_to_modify_list, &bearer->to_modify_node);
@ -348,6 +352,7 @@ int sgwc_pfcp_send_session_deletion_request(
xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_expect_or_return_val(xact->gtpbuf, OGS_ERROR);
}
xact->local_seid = sess->sgwc_sxa_seid;
memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_DELETION_REQUEST_TYPE;
@ -373,6 +378,7 @@ int sgwc_pfcp_send_session_report_response(
ogs_pfcp_header_t h;
ogs_assert(xact);
xact->local_seid = sess->sgwc_sxa_seid;
memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_REPORT_RESPONSE_TYPE;

View File

@ -183,8 +183,16 @@ void sgwc_pfcp_state_associated(ogs_fsm_t *s, sgwc_event_t *e)
xact = e->pfcp_xact;
ogs_assert(xact);
if (message->h.seid_presence && message->h.seid != 0)
if (message->h.seid_presence && message->h.seid != 0) {
sess = sgwc_sess_find_by_seid(message->h.seid);
} else if (xact->local_seid) { /* rx no SEID or SEID=0 */
/* 3GPP TS 29.244 7.2.2.4.2: we receive SEID=0 under some
* conditions, such as cause "Session context not found". In those
* cases, we still want to identify the local session which
* originated the message, so try harder by using the SEID we
* locacally stored in xact when sending the original request: */
sess = sgwc_sess_find_by_seid(xact->local_seid);
}
switch (message->h.type) {
case OGS_PFCP_HEARTBEAT_REQUEST_TYPE:
@ -208,44 +216,32 @@ void sgwc_pfcp_state_associated(ogs_fsm_t *s, sgwc_event_t *e)
&message->pfcp_association_setup_response);
break;
case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
if (!message->h.seid_presence) {
if (!message->h.seid_presence)
ogs_error("No SEID");
break;
}
sgwc_sxa_handle_session_establishment_response(
sess, xact, e->gtp_message,
&message->pfcp_session_establishment_response);
break;
case OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE:
if (!message->h.seid_presence) {
if (!message->h.seid_presence)
ogs_error("No SEID");
break;
}
sgwc_sxa_handle_session_modification_response(
sess, xact, e->gtp_message,
&message->pfcp_session_modification_response);
break;
case OGS_PFCP_SESSION_DELETION_RESPONSE_TYPE:
if (!message->h.seid_presence) {
if (!message->h.seid_presence)
ogs_error("No SEID");
break;
}
sgwc_sxa_handle_session_deletion_response(
sess, xact, e->gtp_message,
&message->pfcp_session_deletion_response);
break;
case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
if (!message->h.seid_presence) {
if (!message->h.seid_presence)
ogs_error("No SEID");
break;
}
sgwc_sxa_handle_session_report_request(
sess, xact, &message->pfcp_session_report_request);
break;

View File

@ -157,6 +157,7 @@ void sgwc_sxa_handle_session_establishment_response(
ogs_debug("Session Establishment Response");
ogs_assert(sess);
ogs_assert(pfcp_xact);
ogs_assert(pfcp_rsp);
ogs_assert(recv_message);
@ -171,11 +172,6 @@ void sgwc_sxa_handle_session_establishment_response(
cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED;
if (!sess) {
ogs_warn("No Context");
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}
if (pfcp_rsp->up_f_seid.presence == 0) {
ogs_error("No UP F-SEID");
cause_value = OGS_GTP2_CAUSE_MANDATORY_IE_MISSING;
@ -451,6 +447,7 @@ void sgwc_sxa_handle_session_modification_response(
ogs_debug("Session Modification Response");
ogs_assert(sess);
ogs_assert(pfcp_xact);
ogs_assert(pfcp_rsp);
@ -460,30 +457,12 @@ void sgwc_sxa_handle_session_modification_response(
cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED;
if (flags & OGS_PFCP_MODIFY_SESSION) {
if (!sess) {
ogs_warn("No Context");
sess = pfcp_xact->data;
ogs_assert(sess);
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}
sgwc_ue = sess->sgwc_ue;
ogs_assert(sgwc_ue);
} else {
bearer = pfcp_xact->data;
ogs_assert(bearer);
if (!sess) {
ogs_warn("No Context");
sess = bearer->sess;
ogs_assert(sess);
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}
sgwc_ue = bearer->sgwc_ue;
ogs_assert(sgwc_ue);
}
@ -1202,16 +1181,12 @@ void sgwc_sxa_handle_session_deletion_response(
ogs_debug("Session Deletion Response");
ogs_assert(sess);
ogs_assert(pfcp_xact);
ogs_assert(pfcp_rsp);
cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED;
if (!sess) {
ogs_warn("No Context");
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}
if (pfcp_rsp->cause.presence) {
if (pfcp_rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
ogs_warn("PFCP Cause[%d] : Not Accepted", pfcp_rsp->cause.u8);
@ -1320,16 +1295,12 @@ void sgwc_sxa_handle_session_report_request(
ogs_debug("Session Report Request");
ogs_assert(sess);
ogs_assert(pfcp_xact);
ogs_assert(pfcp_req);
cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED;
if (!sess) {
ogs_warn("No Context");
cause_value = OGS_PFCP_CAUSE_SESSION_CONTEXT_NOT_FOUND;
}
if (pfcp_req->report_type.presence == 0) {
ogs_error("No Report Type");
cause_value = OGS_GTP2_CAUSE_MANDATORY_IE_MISSING;

View File

@ -255,6 +255,7 @@ void smf_5gc_n4_handle_session_modification_response(
ogs_debug("Session Modification Response [5gc]");
ogs_assert(sess);
ogs_assert(xact);
ogs_assert(rsp);
@ -279,11 +280,6 @@ void smf_5gc_n4_handle_session_modification_response(
status = OGS_SBI_HTTP_STATUS_OK;
if (!sess) {
ogs_warn("No Context");
status = OGS_SBI_HTTP_STATUS_NOT_FOUND;
}
if (rsp->cause.presence) {
if (rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
ogs_warn("PFCP Cause [%d] : Not Accepted", rsp->cause.u8);
@ -624,10 +620,7 @@ int smf_5gc_n4_handle_session_deletion_response(
status = OGS_SBI_HTTP_STATUS_OK;
if (!sess) {
ogs_warn("No Context");
status = OGS_SBI_HTTP_STATUS_NOT_FOUND;
}
ogs_assert(sess);
if (rsp->cause.presence) {
if (rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
@ -669,8 +662,6 @@ int smf_5gc_n4_handle_session_deletion_response(
return status;
}
ogs_assert(sess);
return status;
}
@ -803,6 +794,7 @@ void smf_epc_n4_handle_session_modification_response(
OGS_LIST(pdr_to_create_list);
ogs_assert(sess);
ogs_assert(xact);
ogs_assert(rsp);
@ -831,11 +823,6 @@ void smf_epc_n4_handle_session_modification_response(
ogs_pfcp_xact_commit(xact);
if (!sess) {
ogs_error("No Context");
return;
}
if (rsp->cause.presence) {
if (rsp->cause.u8 != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
ogs_error("PFCP Cause [%d] : Not Accepted", rsp->cause.u8);
@ -1111,6 +1098,7 @@ void smf_n4_handle_session_report_request(
uint16_t pdr_id = 0;
unsigned int i;
ogs_assert(sess);
ogs_assert(pfcp_xact);
ogs_assert(pfcp_req);
@ -1118,11 +1106,6 @@ void smf_n4_handle_session_report_request(
cause_value = OGS_GTP2_CAUSE_REQUEST_ACCEPTED;
if (!sess) {
ogs_warn("No Context");
cause_value = OGS_PFCP_CAUSE_SESSION_CONTEXT_NOT_FOUND;
}
if (pfcp_req->report_type.presence == 0) {
ogs_error("No Report Type");
cause_value = OGS_GTP2_CAUSE_MANDATORY_IE_MISSING;
@ -1135,7 +1118,6 @@ void smf_n4_handle_session_report_request(
return;
}
ogs_assert(sess);
report_type.value = pfcp_req->report_type.u8;
if (report_type.downlink_data_report) {

View File

@ -222,28 +222,13 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
if (!message->h.seid_presence)
ogs_error("No SEID");
if (!sess) {
ogs_gtp_xact_t *gtp_xact = xact->assoc_xact;
ogs_assert(gtp_xact);
if (gtp_xact->gtp_version == 1)
ogs_gtp1_send_error_message(gtp_xact, 0,
OGS_GTP1_CREATE_PDP_CONTEXT_RESPONSE_TYPE,
OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND);
else
ogs_gtp2_send_error_message(gtp_xact, 0,
OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE,
OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND);
break;
}
ogs_assert(sess);
ogs_fsm_dispatch(&sess->sm, e);
break;
case OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE:
if (!message->h.seid_presence) {
if (!message->h.seid_presence)
ogs_error("No SEID");
break;
}
if (xact->epc)
smf_epc_n4_handle_session_modification_response(
sess, xact, e->gtp2_message,
@ -256,30 +241,13 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
case OGS_PFCP_SESSION_DELETION_RESPONSE_TYPE:
if (!message->h.seid_presence)
ogs_error("No SEID");
if (!sess) {
ogs_gtp_xact_t *gtp_xact = xact->assoc_xact;
if (!gtp_xact)
break;
if (gtp_xact->gtp_version == 1)
ogs_gtp1_send_error_message(gtp_xact, 0,
OGS_GTP1_CREATE_PDP_CONTEXT_RESPONSE_TYPE,
OGS_GTP1_CAUSE_CONTEXT_NOT_FOUND);
else
ogs_gtp2_send_error_message(gtp_xact, 0,
OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE,
OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND);
break;
}
ogs_assert(sess);
ogs_fsm_dispatch(&sess->sm, e);
break;
case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
if (!message->h.seid_presence) {
if (!message->h.seid_presence)
ogs_error("No SEID");
break;
}
smf_n4_handle_session_report_request(
sess, xact, &message->pfcp_session_report_request);
break;