smf: don't assert if we run out of IPs

currently if no IP address is available from the configured
subnets in the SMF when attempting to assign an IP to an UE
we assert and the SMF crashes. Handle the error more gracefully
by returning an error cause instead.
This commit is contained in:
Emanuele Di Pascale 2023-10-05 11:28:40 +02:00 committed by Sukchan Lee
parent 53fe8f1e6d
commit 7ea37ef618
1 changed files with 21 additions and 1 deletions

View File

@ -250,7 +250,27 @@ uint8_t smf_s5c_handle_create_session_request(
rv = ogs_gtp2_paa_to_ip(paa, &sess->session.ue_ip);
ogs_assert(rv == OGS_OK);
ogs_assert(OGS_PFCP_CAUSE_REQUEST_ACCEPTED == smf_sess_set_ue_ip(sess));
/* Set UE IP Address */
rv = smf_sess_set_ue_ip(sess);
if (rv != OGS_PFCP_CAUSE_REQUEST_ACCEPTED) {
/* only two possibilities are:
* OGS_PFCP_CAUSE_ALL_DYNAMIC_ADDRESS_ARE_OCCUPIED
* OGS_PFCP_CAUSE_NO_RESOURCES_AVAILABLE
*/
ogs_error("Failed to set UE IP Address");
switch(rv) {
case OGS_PFCP_CAUSE_ALL_DYNAMIC_ADDRESS_ARE_OCCUPIED:
cause_value = OGS_GTP2_CAUSE_ALL_DYNAMIC_ADDRESSES_ARE_OCCUPIED;
break;
case OGS_PFCP_CAUSE_NO_RESOURCES_AVAILABLE:
cause_value = OGS_GTP2_CAUSE_NO_RESOURCES_AVAILABLE;
break;
default:
cause_value = OGS_GTP2_CAUSE_REQUEST_REJECTED_REASON_NOT_SPECIFIED;
break;
}
return cause_value;
}
ogs_info("UE IMSI[%s] APN[%s] IPv4[%s] IPv6[%s]",
smf_ue->imsi_bcd,