Skip to content

Commit

Permalink
[PFCP] Refine error code path without assertion
Browse files Browse the repository at this point in the history
Refer to #1635, #1620
  • Loading branch information
acetcom committed Jun 30, 2022
1 parent 0be5e76 commit b1d982a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
4 changes: 4 additions & 0 deletions src/sgwc/pfcp-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,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;
Expand Down Expand Up @@ -281,6 +282,7 @@ int sgwc_pfcp_send_session_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_for_each(&sess->bearer_list, bearer)
ogs_list_add(&xact->bearer_to_modify_list, &bearer->to_modify_node);
Expand Down Expand Up @@ -311,6 +313,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);

Expand Down Expand Up @@ -348,6 +351,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;
Expand Down
30 changes: 13 additions & 17 deletions src/sgwc/pfcp-sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -208,43 +216,31 @@ 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) {
ogs_error("No SEID");
break;
}
if (!message->h.seid_presence) ogs_error("No SEID");

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) {
ogs_error("No SEID");
break;
}
if (!message->h.seid_presence) ogs_error("No SEID");

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) {
ogs_error("No SEID");
break;
}
if (!message->h.seid_presence) ogs_error("No SEID");

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) {
ogs_error("No SEID");
break;
}
if (!message->h.seid_presence) ogs_error("No SEID");

sgwc_sxa_handle_session_report_request(
sess, xact, &message->pfcp_session_report_request);
Expand Down
1 change: 1 addition & 0 deletions src/sgwc/s11-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ void sgwc_s11_handle_modify_bearer_request(
current_xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
ogs_assert(current_xact->gtpbuf);
}
current_xact->local_seid = sess->sgwc_sxa_seid;

ogs_list_add(&pfcp_xact_list, &current_xact->tmpnode);
}
Expand Down
2 changes: 0 additions & 2 deletions src/smf/pfcp-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ int smf_pfcp_send_modify_list(
ogs_assert(sess);
ogs_assert(xact);

xact->local_seid = sess->smf_n4_seid;

memset(&h, 0, sizeof(ogs_pfcp_header_t));
h.type = OGS_PFCP_SESSION_MODIFICATION_REQUEST_TYPE;
h.seid = sess->upf_n4_seid;
Expand Down
18 changes: 6 additions & 12 deletions src/smf/pfcp-sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
&message->pfcp_association_setup_response);
break;
case OGS_PFCP_SESSION_ESTABLISHMENT_RESPONSE_TYPE:
if (!message->h.seid_presence)
ogs_error("No SEID");
if (!message->h.seid_presence) ogs_error("No SEID");

if (!sess) {
ogs_gtp_xact_t *gtp_xact = xact->assoc_xact;
ogs_assert(gtp_xact);
Expand All @@ -239,10 +239,7 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
break;

case OGS_PFCP_SESSION_MODIFICATION_RESPONSE_TYPE:
if (!message->h.seid_presence) {
ogs_error("No SEID");
break;
}
if (!message->h.seid_presence) ogs_error("No SEID");

if (xact->epc)
smf_epc_n4_handle_session_modification_response(
Expand All @@ -254,8 +251,8 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
break;

case OGS_PFCP_SESSION_DELETION_RESPONSE_TYPE:
if (!message->h.seid_presence)
ogs_error("No SEID");
if (!message->h.seid_presence) ogs_error("No SEID");

if (!sess) {
ogs_gtp_xact_t *gtp_xact = xact->assoc_xact;
if (!gtp_xact)
Expand All @@ -275,10 +272,7 @@ void smf_pfcp_state_associated(ogs_fsm_t *s, smf_event_t *e)
break;

case OGS_PFCP_SESSION_REPORT_REQUEST_TYPE:
if (!message->h.seid_presence) {
ogs_error("No SEID");
break;
}
if (!message->h.seid_presence) ogs_error("No SEID");

smf_n4_handle_session_report_request(
sess, xact, &message->pfcp_session_report_request);
Expand Down
1 change: 1 addition & 0 deletions src/smf/s5c-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ void smf_s5c_handle_modify_bearer_request(

pfcp_xact->gtp_pti = OGS_NAS_PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED;
pfcp_xact->gtp_cause = OGS_GTP2_CAUSE_UNDEFINED_VALUE;
pfcp_xact->local_seid = sess->smf_n4_seid;

ogs_assert(gtpbuf);
pfcp_xact->gtpbuf = ogs_pkbuf_copy(gtpbuf);
Expand Down

0 comments on commit b1d982a

Please sign in to comment.