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

Merge branch 'improve_smf_context_handling' into 'develop'

Improve smf context handling

See merge request oai/cn5g/oai-cn5g-smf!98
parents a809cd94 42e55035
......@@ -45,7 +45,7 @@ Based on document **3GPP TS 23.501 v16.0.0 (Section 6.2.2)**.
| 2 | UE IP address allocation & management​ | :heavy_check_mark: | IP Address pool is controlled by SMF |
| 3 | DHCPv4 (server and client) and DHCPv6 (server and client) function | :x: | |
| 4 | Respond to ARP requests and/or IPv6 Neighbour Solicitation requests | :x: | |
| 5 | Selection of UPF function​ | :heavy_check_mark: | Local configuration in SMF |
| 5 | Selection of UPF function​ | :heavy_check_mark: | Local configuration/UPF discovery via NRF |
| 6 | Configures traffic steering at UPF | :x: | |
| 7 | Termination of interfaces towards PCFs | :x: | |
| 8 | Lawful intercept | :x: | |
......
......@@ -1067,6 +1067,19 @@ struct node_id_s {
return false;
}
};
node_id_s& operator=(const struct node_id_s& i) {
node_id_type = i.node_id_type;
fqdn = i.fqdn;
u1.ipv4_address.s_addr = i.u1.ipv4_address.s_addr;
u1.ipv6_address.s6_addr32[0] = i.u1.ipv6_address.s6_addr32[0];
u1.ipv6_address.s6_addr32[1] = i.u1.ipv6_address.s6_addr32[1];
u1.ipv6_address.s6_addr32[2] = i.u1.ipv6_address.s6_addr32[2];
u1.ipv6_address.s6_addr32[3] = i.u1.ipv6_address.s6_addr32[3];
return *this;
}
std::string toString() const {
if (NODE_ID_TYPE_FQDN == this->node_id_type) {
return fqdn;
......
......@@ -73,6 +73,19 @@ typedef struct s_nssai // section 28.4, TS23.003
}
}
s_nssai& operator=(const struct s_nssai& s) {
sST = s.sST;
sD = s.sD;
return *this;
}
std::string toString() const {
std::string s = {};
s.append("SST=").append(std::to_string(sST));
s.append(", SD=").append(sD);
return s;
}
} snssai_t;
typedef uint8_t pdu_session_id;
......
This diff is collapsed.
......@@ -80,23 +80,11 @@ class smf_context_ref {
void clear() {
supi = {};
nssai = {};
dnn = {};
pdu_session_id = 0;
amf_status_uri = {};
amf_addr = {};
upf_node_id = {};
target_amf = "";
}
supi_t supi;
std::string dnn;
pdu_session_id_t pdu_session_id;
snssai_t nssai;
std::string amf_status_uri;
std::string amf_addr;
std::string target_amf; // targetServingNfId
pfcp::node_id_t upf_node_id;
};
class smf_app {
......@@ -212,7 +200,6 @@ class smf_app {
void operator=(smf_app const&) = delete;
void test_dns();
/*
* Set the association between Seid and SM Context
* @param [const seid_t &] seid: SessionID
......@@ -453,17 +440,14 @@ class smf_app {
bool is_scid_2_smf_context(const scid_t& scid) const;
/*
* Verify whether a SMF Context Reference with a given ID exist
* Verify whether a SMF Context Reference exist
* @param [const supi64_t &] supi64: Supi64
* @param [const std::string &] dnn: DNN
* @param [const snssai_t &] snssai: S-NSSAI
* @param [const pdu_session_id_t &] pid: PDU Session ID
*
* @return bool: True if a SMF Context Reference exist, otherwise return false
* @return bool: True if SMF Context Reference found, otherwise return false
*/
bool is_scid_2_smf_context(
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
const pdu_session_id_t& pid) const;
const supi64_t& supi, const pdu_session_id_t& pid) const;
/*
* Find SMF Context Reference by its ID
......
......@@ -344,11 +344,13 @@ class smf_config {
}
sbi_http2_port = 8080;
sbi_api_version = "v1";
http_version = 1;
use_local_subscription_info = false;
register_nrf = false;
discover_upf = false;
use_fqdn_dns = false;
use_nwi = false;
};
~smf_config();
void lock() { m_rw_lock.lock(); };
......
This diff is collapsed.
This diff is collapsed.
......@@ -416,7 +416,6 @@ bool smf_n1::create_n1_pdu_session_modification_command(
// Get the SMF_PDU_Session
std::shared_ptr<smf_context> sc = {};
std::shared_ptr<dnn_context> sd = {};
std::shared_ptr<smf_pdu_session> sp = {};
supi_t supi = sm_context_res.get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
......@@ -430,16 +429,21 @@ bool smf_n1::create_n1_pdu_session_modification_command(
return false;
}
bool find_dnn = sc.get()->find_dnn_context(
sm_context_res.get_snssai(), sm_context_res.get_dnn(), sd);
bool find_pdu = false;
if (find_dnn) {
find_pdu =
sd.get()->find_pdu_session(sm_context_res.get_pdu_session_id(), sp);
if (!sc.get()->find_pdu_session(sm_context_res.get_pdu_session_id(), sp)) {
Logger::smf_n1().warn("PDU session context does not exist!");
return false;
}
std::string dnn = sp.get()->get_dnn();
if (dnn.compare(sm_context_res.get_dnn()) != 0) {
// error
Logger::smf_n1().warn("DNN doesn't matched with this session!");
return false;
}
if (!find_dnn or !find_pdu) {
if (!(sp.get()->get_snssai() == sm_context_res.get_snssai())) {
// error
Logger::smf_n1().warn("DNN or PDU session context does not exist!");
Logger::smf_n1().warn("SNSSAI doesn't matched with this session!");
return false;
}
......@@ -554,7 +558,6 @@ bool smf_n1::create_n1_pdu_session_modification_command(
// Get the SMF_PDU_Session
std::shared_ptr<smf_context> sc = {};
std::shared_ptr<dnn_context> sd = {};
std::shared_ptr<smf_pdu_session> sp = {};
supi_t supi = msg.get_supi();
supi64_t supi64 = smf_supi_to_u64(supi);
......@@ -568,17 +571,24 @@ bool smf_n1::create_n1_pdu_session_modification_command(
return false;
}
bool find_dnn =
sc.get()->find_dnn_context(msg.get_snssai(), msg.get_dnn(), sd);
bool find_pdu = false;
if (find_dnn) {
find_pdu = sd.get()->find_pdu_session(msg.get_pdu_session_id(), sp);
if (!sc.get()->find_pdu_session(msg.get_pdu_session_id(), sp)) {
Logger::smf_n1().warn("PDU session context does not exist!");
return false;
}
if (!find_dnn or !find_pdu) {
std::string dnn = sp.get()->get_dnn();
if (dnn.compare(msg.get_dnn()) != 0) {
// error
Logger::smf_n1().warn("DNN or PDU session context does not exist!");
Logger::smf_n1().warn("DNN doesn't matched with this session!");
return false;
}
/*
if (!(sp.get()->get_snssai() == msg.get_snssai())){
// error
Logger::smf_n1().warn("SNSSAI doesn't matched with this
session!"); return false;
}
*/
sm_msg->header.procedure_transaction_identity =
msg.get_pti().procedure_transaction_id;
......
......@@ -102,9 +102,10 @@ int session_create_sm_context_procedure::run(
std::shared_ptr<smf::smf_context> sc) {
Logger::smf_app().info("Perform a procedure - Create SM Context Request");
// TODO check if compatible with ongoing procedures if any
pfcp::node_id_t up_node_id = {};
snssai_t snssai = sm_context_req->req.get_snssai();
std::string dnn = sm_context_req->req.get_dnn();
pfcp::node_id_t up_node_id = {};
snssai_t snssai = sm_context_req->req.get_snssai();
std::string dnn = sm_context_req->req.get_dnn();
pdu_session_id_t pdu_session_id = sm_context_req->req.get_pdu_session_id();
if (not pfcp_associations::get_instance().select_up_node(
up_node_id, snssai, dnn)) {
......@@ -116,7 +117,16 @@ int session_create_sm_context_procedure::run(
std::shared_ptr<smf_context_ref> scf = {};
if (smf_app_inst->is_scid_2_smf_context(sm_context_req->scid)) {
scf = smf_app_inst->scid_2_smf_context(sm_context_req->scid);
scf.get()->upf_node_id = up_node_id;
// scf.get()->upf_node_id = up_node_id;
std::shared_ptr<smf_pdu_session> sp = {};
if (!sc.get()->find_pdu_session(scf.get()->pdu_session_id, sp)) {
Logger::smf_app().warn("PDU session context does not exist!");
sm_context_resp->res.set_cause(
PDU_SESSION_APPLICATION_ERROR_CONTEXT_NOT_FOUND);
return RETURNerror;
}
sp.get()->set_upf_node_id(up_node_id);
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!",
......@@ -466,7 +476,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
std::string supi_str = n11_triggered_pending->res.get_supi_prefix() + "-" +
smf_supi_to_string(supi);
std::string url =
"http://" + sps.get()->get_amf_addr() + NAMF_COMMUNICATION_BASE +
"http://" + sc.get()->get_amf_addr() + NAMF_COMMUNICATION_BASE +
smf_cfg.amf_addr.api_version +
fmt::format(
NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL, supi_str.c_str());
......@@ -499,7 +509,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
// N1N2MsgTxfrFailureNotification
std::string callback_uri =
sps.get()->get_amf_addr() + NSMF_PDU_SESSION_BASE +
sc.get()->get_amf_addr() + NSMF_PDU_SESSION_BASE +
smf_cfg.sbi_api_version +
fmt::format(
NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE, supi_str.c_str());
......@@ -550,14 +560,22 @@ int session_update_sm_context_procedure::run(
sm_context_req->scid);
}
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
up_node_id = scf.get()->upf_node_id;
scf = smf_app_inst->scid_2_smf_context(scid);
// up_node_id = scf.get()->upf_node_id;
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!", scid);
// TODO:
return RETURNerror;
}
std::shared_ptr<smf_pdu_session> sp = {};
if (!sc.get()->find_pdu_session(scf.get()->pdu_session_id, sp)) {
Logger::smf_app().warn("PDU session context does not exist!");
return RETURNerror;
}
sp.get()->get_upf_node_id(up_node_id);
// TODO: UPF insertion in case of Handover
/* if (not pfcp_associations::get_instance().select_up_node(
......@@ -1445,14 +1463,23 @@ int session_release_sm_context_procedure::run(
sm_context_req->scid);
}
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
up_node_id = scf.get()->upf_node_id;
scf = smf_app_inst->scid_2_smf_context(scid);
// up_node_id = scf.get()->upf_node_id;
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!", scid);
// TODO:
return RETURNerror;
}
std::shared_ptr<smf_pdu_session> sp = {};
if (!sc.get()->find_pdu_session(scf.get()->pdu_session_id, sp)) {
Logger::smf_app().warn("PDU session context does not exist!");
return RETURNerror;
}
sp.get()->get_upf_node_id(up_node_id);
/* if (not pfcp_associations::get_instance().select_up_node(
up_node_id, NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS)) {
sm_context_res->res.set_cause(
......
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