Skip to content

Commit 44652b3

Browse files
[smf][sgwc] fix upf/sgwc assignment when no_pfcp_rr_select: true (#67)
1 parent 0ed8355 commit 44652b3

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

src/sgwc/context.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,9 @@ static ogs_pfcp_node_t *selected_sgwu_node(
370370
}
371371
}
372372

373+
// If we get here, it means no suitable UPF can be found
373374
ogs_error("No SGWUs are PFCP associated that are suited to RR");
374-
return ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list);
375+
return NULL;
375376
}
376377

377378
void sgwc_sess_select_sgwu(sgwc_sess_t *sess)
@@ -391,6 +392,11 @@ void sgwc_sess_select_sgwu(sgwc_sess_t *sess)
391392
/* setup GTP session with selected SGW-U */
392393
ogs_pfcp_self()->pfcp_node =
393394
selected_sgwu_node(ogs_pfcp_self()->pfcp_node, sess);
395+
396+
if (ogs_pfcp_self()->pfcp_node == NULL) {
397+
return;
398+
}
399+
394400
ogs_assert(ogs_pfcp_self()->pfcp_node);
395401
OGS_SETUP_PFCP_NODE(sess, ogs_pfcp_self()->pfcp_node);
396402
ogs_debug("UE using SGW-U on IP[%s]",

src/sgwc/s11-handler.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ void sgwc_s11_handle_create_session_request(
298298
sgwc_sess_select_sgwu(sess);
299299

300300
/* Check if selected SGW-U is associated with SGW-C */
301-
ogs_assert(sess->pfcp_node);
302-
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, sgwc_pfcp_state_associated)) {
301+
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, sgwc_pfcp_state_associated)) {
303302
ogs_gtp_send_error_message(
304303
s11_xact, sgwc_ue ? sgwc_ue->mme_s11_teid : 0,
305304
OGS_GTP2_CREATE_SESSION_RESPONSE_TYPE,

src/smf/context.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,9 @@ static ogs_pfcp_node_t *selected_upf_node(
991991
}
992992
}
993993

994+
// If we get here, it means no suitable UPF can be found
994995
ogs_error("No UPFs are PFCP associated that are suited to RR");
995-
return ogs_list_first(&ogs_pfcp_self()->pfcp_peer_list);
996+
return NULL;
996997
}
997998

998999
void smf_sess_select_upf(smf_sess_t *sess)
@@ -1012,6 +1013,11 @@ void smf_sess_select_upf(smf_sess_t *sess)
10121013
/* setup GTP session with selected UPF */
10131014
ogs_pfcp_self()->pfcp_node =
10141015
selected_upf_node(ogs_pfcp_self()->pfcp_node, sess);
1016+
1017+
if (ogs_pfcp_self()->pfcp_node == NULL) {
1018+
return;
1019+
}
1020+
10151021
ogs_assert(ogs_pfcp_self()->pfcp_node);
10161022
OGS_SETUP_PFCP_NODE(sess, ogs_pfcp_self()->pfcp_node);
10171023
ogs_debug("UE using UPF on IP[%s]",

src/smf/gn-handler.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,9 @@ uint8_t smf_gn_handle_create_pdp_context_request(
258258
smf_sess_select_upf(sess);
259259

260260
/* Check if selected PGW is associated with SMF */
261-
ogs_assert(sess->pfcp_node);
262-
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated))
261+
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated))
263262
return OGS_GTP1_CAUSE_NO_RESOURCES_AVAILABLE;
264-
263+
265264
if ((pfcp_cause = smf_sess_set_ue_ip(sess)) != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
266265
cause_value = gtp_cause_from_pfcp(pfcp_cause, 1);
267266
return cause_value;

src/smf/npcf-handler.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ bool smf_npcf_smpolicycontrol_handle_create(
445445
smf_sess_select_upf(sess);
446446

447447
/* Check if selected UPF is associated with SMF */
448-
ogs_assert(sess->pfcp_node);
449-
if (!OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated)) {
448+
if (!sess->pfcp_node || !OGS_FSM_CHECK(&sess->pfcp_node->sm, smf_pfcp_state_associated)) {
450449
ogs_error("[%s] No associated UPF", smf_ue->supi);
451450
return false;
452451
}

src/smf/s5c-handler.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ uint8_t smf_s5c_handle_create_session_request(
245245
smf_sess_select_upf(sess);
246246

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

252251
/* UE IP Address */

0 commit comments

Comments
 (0)