Commit c77a9a40 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Process Create SM Context Request colliding with an existing SM Context

parent 7369359d
...@@ -770,23 +770,7 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -770,23 +770,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return; return;
} }
//Step 4. Verify the session is already existed //Step 4. create a context for this supi if not existed, otherwise update
if (is_scid_2_smf_context(supi64, dnn, snssai, pdu_session_id)) {
//TODO: should delete the local context (including and any associated resources in the UPF and PCF) and create a new one
Logger::smf_app().warn(
"PDU Session already existed (SUPI " SUPI_64_FMT ", DNN %s, NSSAI (sst %d, sd %s), PDU Session ID %d)",
supi64, dnn.c_str(), snssai.sST, snssai.sD.c_str(), pdu_session_id);
//TODO: temporary disable this action to test with AMF
/*
//trigger to send reply to AMF
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_406_NOT_ACCEPTABLE, smreq->pid,
N11_SESSION_CREATE_SM_CONTEXT_RESPONSE);
return;
*/
}
//Step 5. create a context for this supi if not existed, otherwise update
std::shared_ptr<smf_context> sc = { }; std::shared_ptr<smf_context> sc = { };
if (is_supi_2_smf_context(supi64)) { if (is_supi_2_smf_context(supi64)) {
Logger::smf_app().debug("Update SMF context with SUPI " SUPI_64_FMT "", Logger::smf_app().debug("Update SMF context with SUPI " SUPI_64_FMT "",
...@@ -802,7 +786,7 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -802,7 +786,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
set_supi_2_smf_context(supi64, sc); set_supi_2_smf_context(supi64, sc);
} }
//Step 6. Create/update context with dnn information //Step 5. Create/update context with dnn information
std::shared_ptr<dnn_context> sd = { }; std::shared_ptr<dnn_context> sd = { };
if (!sc.get()->find_dnn_context(snssai, dnn, sd)) { if (!sc.get()->find_dnn_context(snssai, dnn, sd)) {
...@@ -818,6 +802,16 @@ void smf_app::handle_pdu_session_create_sm_context_request( ...@@ -818,6 +802,16 @@ void smf_app::handle_pdu_session_create_sm_context_request(
} }
} }
//Step 6. if colliding with an existing SM context (session is already existed and request type is INITIAL_REQUEST)
//Delete the local context (including and any associated resources in the UPF and PCF) and create a new one
if (is_scid_2_smf_context(supi64, dnn, snssai, pdu_session_id) && (request_type.compare("INITIAL_REQUEST") == 0)) {
//remove smf_pdu_session (including all flows associated to this session)
sd.get()->remove_pdu_session(pdu_session_id);
Logger::smf_app().warn(
"PDU Session already existed (SUPI " SUPI_64_FMT ", DNN %s, NSSAI (sst %d, sd %s), PDU Session ID %d)",
supi64, dnn.c_str(), snssai.sST, snssai.sD.c_str(), pdu_session_id);
}
//Step 7. retrieve Session Management Subscription data from UDM if not available (step 4, section 4.3.2 3GPP TS 23.502) //Step 7. retrieve Session Management Subscription data from UDM if not available (step 4, section 4.3.2 3GPP TS 23.502)
std::string dnn_selection_mode = smreq->req.get_dnn_selection_mode(); std::string dnn_selection_mode = smreq->req.get_dnn_selection_mode();
//if the Session Management Subscription data is not available, get from configuration file or UDM //if the Session Management Subscription data is not available, get from configuration file or UDM
......
This diff is collapsed.
...@@ -233,6 +233,12 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { ...@@ -233,6 +233,12 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
*/ */
void remove_qos_flow(smf_qos_flow &flow); void remove_qos_flow(smf_qos_flow &flow);
/*
* Remove all QoS flow associated with this PDU Session
* @return void
*/
void remove_qos_flows();
/* /*
* Set current status of PDU Session * Set current status of PDU Session
* @param [const pdu_session_status_e &] status: status to be set * @param [const pdu_session_status_e &] status: status to be set
...@@ -428,8 +434,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> { ...@@ -428,8 +434,7 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
uint8_t number_of_supported_packet_filters; //number_of_supported_packet_filters uint8_t number_of_supported_packet_filters; //number_of_supported_packet_filters
util::uint_generator<uint32_t> qos_rule_id_generator; util::uint_generator<uint32_t> qos_rule_id_generator;
// Recursive lock mutable std::shared_mutex m_pdu_session_mutex;
mutable std::recursive_mutex m_pdu_session_mutex;
}; };
...@@ -438,7 +443,8 @@ class session_management_subscription { ...@@ -438,7 +443,8 @@ class session_management_subscription {
session_management_subscription(snssai_t snssai) session_management_subscription(snssai_t snssai)
: :
single_nssai(snssai), single_nssai(snssai),
dnn_configurations() { dnn_configurations(),
m_mutex() {
} }
/* /*
...@@ -471,6 +477,7 @@ class session_management_subscription { ...@@ -471,6 +477,7 @@ class session_management_subscription {
private: private:
snssai_t single_nssai; snssai_t single_nssai;
std::map<std::string, std::shared_ptr<dnn_configuration_t>> dnn_configurations; //dnn <->dnn_configuration std::map<std::string, std::shared_ptr<dnn_configuration_t>> dnn_configurations; //dnn <->dnn_configuration
mutable std::shared_mutex m_mutex;
}; };
/* /*
...@@ -513,6 +520,14 @@ class dnn_context { ...@@ -513,6 +520,14 @@ class dnn_context {
*/ */
void insert_pdu_session(std::shared_ptr<smf_pdu_session> &sp); void insert_pdu_session(std::shared_ptr<smf_pdu_session> &sp);
/*
* Delete a PDU Session identified by its ID
* @param [const uint32_t] pdu_session_id
* @return bool: return true if the pdu session is deleted, otherwise, return false
*/
bool remove_pdu_session(const uint32_t pdu_session_id);
/* /*
* Get number of pdu sessions associated with this context (dnn and Nssai) * Get number of pdu sessions associated with this context (dnn and Nssai)
* @param void * @param void
...@@ -531,7 +546,7 @@ class dnn_context { ...@@ -531,7 +546,7 @@ class dnn_context {
std::string dnn_in_use; // The DNN currently used, as received from the AMF std::string dnn_in_use; // The DNN currently used, as received from the AMF
snssai_t nssai; snssai_t nssai;
std::vector<std::shared_ptr<smf_pdu_session>> pdu_sessions; //Store all PDU Sessions associated with this DNN context std::vector<std::shared_ptr<smf_pdu_session>> pdu_sessions; //Store all PDU Sessions associated with this DNN context
mutable std::recursive_mutex m_context; mutable std::shared_mutex m_context;
}; };
class smf_context; class smf_context;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment