Commit 94d5f4cb authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add procedure for N4 node failure

parent 48243648
......@@ -369,6 +369,24 @@ class itti_n4_node_report_response : public itti_n4_msg {
pfcp::pfcp_node_report_response pfcp_ies;
};
//-----------------------------------------------------------------------------
class itti_n4_node_failure : public itti_n4_msg {
public:
itti_n4_node_failure(const task_id_t origin, const task_id_t destination)
: itti_n4_msg(N4_NODE_FAILURE, origin, destination), node_id() {}
itti_n4_node_failure(const itti_n4_node_failure& i) : itti_n4_msg(i) {
node_id = i.node_id;
}
itti_n4_node_failure(
const itti_n4_node_failure& i, const task_id_t orig, const task_id_t dest)
: itti_n4_msg(i, orig, dest) {
node_id = i.node_id;
}
const char* get_msg_name() { return typeid(itti_n4_node_failure).name(); };
pfcp::node_id_t node_id;
};
//-----------------------------------------------------------------------------
class itti_n4_session_set_deletion_request : public itti_n4_msg {
public:
......
......@@ -92,6 +92,7 @@ typedef enum {
N4_VERSION_NOT_SUPPORTED_RESPONSE,
N4_NODE_REPORT_REQUEST,
N4_NODE_REPORT_RESPONSE,
N4_NODE_FAILURE,
N4_SESSION_SET_DELETION_REQUEST,
N4_SESSION_SET_DELETION_RESPONSE,
N4_SESSION_ESTABLISHMENT_REQUEST,
......
......@@ -211,6 +211,17 @@ void smf_app_task(void*) {
}
break;
case N4_SESSION_REPORT_REQUEST:
smf_app_inst->handle_itti_msg(
std::static_pointer_cast<itti_n4_session_report_request>(
shared_msg));
break;
case N4_NODE_FAILURE:
smf_app_inst->handle_itti_msg(
std::static_pointer_cast<itti_n4_node_failure>(shared_msg));
break;
case N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS:
if (itti_n11_n1n2_message_transfer_response_status* m =
dynamic_cast<itti_n11_n1n2_message_transfer_response_status*>(
......@@ -226,12 +237,6 @@ void smf_app_task(void*) {
}
break;
case N4_SESSION_REPORT_REQUEST:
smf_app_inst->handle_itti_msg(
std::static_pointer_cast<itti_n4_session_report_request>(
shared_msg));
break;
case N11_SESSION_CREATE_SM_CONTEXT_RESPONSE:
if (itti_n11_create_sm_context_response* m =
dynamic_cast<itti_n11_create_sm_context_response*>(msg)) {
......@@ -490,6 +495,22 @@ void smf_app::handle_itti_msg(
}
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(std::shared_ptr<itti_n4_node_failure> snf) {
pfcp::node_id_t node_id = snf->node_id;
for (auto it : scid2smf_context) {
if (it.second->upf_node_id == node_id) {
supi64_t supi64 = smf_supi_to_u64(it.second->supi);
Logger::smf_app().debug(
"Remove the associated PDU session (SUPI " SUPI_64_FMT
", PDU Sessin Id %d)",
supi64, it.second->pdu_session_id);
//TODO: remove the session
}
}
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(
itti_n11_n1n2_message_transfer_response_status& m) {
......@@ -826,6 +847,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
return;
}
// TODO:
// If no DNN information from UE, set to default value
std::string dnn = smreq->req.get_dnn();
if (dnn.length() == 0) {
......
......@@ -321,6 +321,13 @@ class smf_app {
*/
void handle_itti_msg(itti_n4_association_setup_request& sna);
/*
* Handle ITTI message (N4 Node Failure)
* @param [itti_n4_node_failure&] snf
* @return void
*/
void handle_itti_msg(std::shared_ptr<itti_n4_node_failure> snf);
/*
* Handle ITTI message from N11 to update PDU session status
* @param [itti_n11_update_pdu_session_status&] snu
......
......@@ -94,6 +94,7 @@ bool pfcp_associations::add_association(
sa->recovery_time_stamp = recovery_time_stamp;
sa->function_features = {};
} else {
// Resolve FQDN to get UPF IP address if necessary
if (node_id.node_id_type == pfcp::NODE_ID_TYPE_FQDN) {
Logger::smf_app().info("Node ID Type FQDN: %s", node_id.fqdn.c_str());
}
......@@ -104,12 +105,20 @@ bool pfcp_associations::add_association(
node_id.fqdn.c_str());
return false;
}
if (record->h_addrtype == AF_INET) {
in_addr* address = (struct in_addr*) record->h_addr;
node_id.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
node_id.u1.ipv4_address = *address;
Logger::smf_app().info(
"Node ID Type FQDN: %s, IPv4 Addr: %s", node_id.fqdn.c_str(),
inet_ntoa(*address));
} else if (record->h_addrtype == AF_INET6) {
// TODO
Logger::smf_app().info(
"Node ID Type FQDN: %s. IPv6 Addr, this mode has not been supported "
"yet!",
node_id.fqdn.c_str());
return false;
} else {
return false;
......@@ -169,8 +178,15 @@ bool pfcp_associations::add_association(
in_addr* address = (struct in_addr*) record->h_addr;
node_id.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
node_id.u1.ipv4_address = *address;
Logger::smf_app().info(
"Node ID Type FQDN: %s, IPv4 Addr: %s", node_id.fqdn.c_str(),
inet_ntoa(*address));
} else if (record->h_addrtype == AF_INET6) {
// TODO
Logger::smf_app().info(
"Node ID Type FQDN: %s. IPv6 Addr, this mode has not been supported "
"yet!",
node_id.fqdn.c_str());
return false;
} else {
return false;
......@@ -292,8 +308,24 @@ void pfcp_associations::timeout_heartbeat_request(
smf_n4_inst->send_heartbeat_request(pit->second);
} else {
Logger::smf_n4().warn(
"PFCP HEARTBEAT PROCEDURE FAILED after %d retries! TODO",
"PFCP HEARTBEAT PROCEDURE FAILED after %d retries, remove the "
"association with this UPF",
PFCP_ASSOCIATION_HEARTBEAT_MAX_RETRIES);
// Related session contexts and PFCP associations become invalid and may
// be deleted-> Send request to SMF App to remove all associated sessions
// and notify AMF accordingly
std::shared_ptr<itti_n4_node_failure> itti_msg =
std::make_shared<itti_n4_node_failure>(TASK_SMF_N4, TASK_SMF_APP);
itti_msg->node_id = pit->second->node_id;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_n4().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
itti_msg->get_msg_name());
}
// Remove UPF from the associations
remove_association(hash_node_id);
}
}
}
......@@ -455,3 +487,12 @@ bool pfcp_associations::remove_association(
// TODO
return true;
}
//------------------------------------------------------------------------------
bool pfcp_associations::remove_association(const int32_t& hash_node_id) {
if (associations.count(hash_node_id) > 0) {
associations.erase(hash_node_id);
return true;
}
return false;
}
......@@ -219,6 +219,7 @@ class pfcp_associations {
bool add_peer_candidate_node(
const pfcp::node_id_t& node_id, const upf_profile& profile);
bool remove_association(const std::string& node_instance_id);
bool remove_association(const int32_t& hash_node_id);
};
} // namespace smf
......
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