Skip to content

Commit

Permalink
[smf][sgwc] fix upf/sgwc assignment when no_pfcp_rr_select: true (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencersevilla committed Jan 24, 2024
1 parent 849a959 commit 165331d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
10 changes: 8 additions & 2 deletions src/sgwc/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ static ogs_pfcp_node_t *selected_sgwu_node(
}
}

ogs_error("No SGWUs are PFCP associated that are suited to RR");
return ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list);
// If we get here, it means no suitable SGWU can be found
ogs_error("No SGWUs are PFCP associated that are suited to RR for UE TAC %u", sess->sgwc_ue->e_tai.tac);
return NULL;
}

void sgwc_sess_select_sgwu(sgwc_sess_t *sess)
Expand All @@ -423,6 +424,11 @@ void sgwc_sess_select_sgwu(sgwc_sess_t *sess)
/* setup GTP session with selected SGW-U */
ogs_pfcp_self()->pfcp_node =
selected_sgwu_node(ogs_pfcp_self()->pfcp_node, sess);

if (ogs_pfcp_self()->pfcp_node == NULL) {
return;
}

ogs_assert(ogs_pfcp_self()->pfcp_node);
OGS_SETUP_PFCP_NODE(sess, ogs_pfcp_self()->pfcp_node);
ogs_debug("UE using SGW-U on IP[%s]",
Expand Down
3 changes: 1 addition & 2 deletions src/sgwc/s11-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ void sgwc_s11_handle_create_session_request(
sgwc_sess_select_sgwu(sess);

/* Check if selected SGW-U is associated with SGW-C */
ogs_assert(sess->pfcp_node);
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, sgwc_pfcp_state_associated)) {
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, sgwc_pfcp_state_associated)) {
ogs_gtp_send_error_message(
s11_xact, sgwc_ue ? sgwc_ue->mme_s11_teid : 0,
OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE,
Expand Down
10 changes: 8 additions & 2 deletions src/smf/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,9 @@ static ogs_pfcp_node_t *selected_upf_node(
}
}

ogs_error("No UPFs are PFCP associated that are suited to RR");
return ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list);
// If we get here, it means no suitable UPF can be found
ogs_error("No UPFs are PFCP associated that are suited to RR for UE TAC %u", sess->e_tai.tac);
return NULL;
}

void smf_sess_select_upf(smf_sess_t *sess)
Expand All @@ -1190,6 +1191,11 @@ void smf_sess_select_upf(smf_sess_t *sess)
/* setup GTP session with selected UPF */
ogs_pfcp_self()->pfcp_node =
selected_upf_node(ogs_pfcp_self()->pfcp_node, sess);

if (ogs_pfcp_self()->pfcp_node == NULL) {
return;
}

ogs_assert(ogs_pfcp_self()->pfcp_node);
OGS_SETUP_PFCP_NODE(sess, ogs_pfcp_self()->pfcp_node);
ogs_debug("UE using UPF on IP[%s]",
Expand Down
5 changes: 2 additions & 3 deletions src/smf/gn-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ uint8_t smf_gn_handle_create_pdp_context_request(
smf_sess_select_upf(sess);

/* Check if selected PGW is associated with SMF */
ogs_assert(sess->pfcp_node);
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated))
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated))
return OGS_GTP1_CAUSE_NO_RESOURCES_AVAILABLE;

if ((pfcp_cause = smf_sess_set_ue_ip(sess)) != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
cause_value = gtp_cause_from_pfcp(pfcp_cause, 1);
return cause_value;
Expand Down
3 changes: 1 addition & 2 deletions src/smf/npcf-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,7 @@ bool smf_npcf_smpolicycontrol_handle_create(
smf_sess_select_upf(sess);

/* Check if selected UPF is associated with SMF */
ogs_assert(sess->pfcp_node);
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated)) {
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated)) {
ogs_error("[%s:%d] No associated UPF", smf_ue->supi, sess->psi);
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/smf/s5c-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ uint8_t smf_s5c_handle_create_session_request(
smf_sess_select_upf(sess);

/* Check if selected PGW is associated with SMF */
ogs_assert(sess->pfcp_node);
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated))
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated))
return OGS_GTP2_CAUSE_REMOTE_PEER_NOT_RESPONDING;

/* UE IP Address */
Expand Down

0 comments on commit 165331d

Please sign in to comment.