Commit 8f56bbf3 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Add debugging log

parent 5b856fa3
......@@ -390,7 +390,34 @@ typedef struct dnn_upf_info_item_s {
return std::hash<std::string>()(dnn);
}
} dnn_upf_info_item_t;
std::string to_string() const {
std::string s = {};
s.append("DNN = " + dnn + ", ");
if (dnai_list.size() > 0) {
s.append("DNAI list: {");
for (auto dnai : dnai_list) {
s.append("DNAI = " + dnai + ", ");
}
s.append("}, ");
}
if (dnai_nw_instance_list.size() > 0) {
s.append("DNAI NW Instance list: {");
for (auto dnai_nw : dnai_nw_instance_list) {
s.append("(" + dnai_nw.first + ", " + dnai_nw.second + "),");
}
s.append("}, ");
}
return s;
}
}
dnn_upf_info_item_t;
typedef struct snssai_upf_info_item_s {
snssai_t snssai;
......@@ -411,6 +438,22 @@ typedef struct snssai_upf_info_item_s {
return snssai.operator()(snssai);
}
std::string to_string() const {
std::string s = {};
s.append("SNSSAI Info: " + snssai.toString() + ",");
if (dnn_upf_info_list.size() > 0) {
s.append("DNN UPF Info list: {");
for (auto dnn_upf : dnn_upf_info_list) {
s.append(dnn_upf.to_string() + ", ");
}
s.append("}, ");
}
return s;
}
} snssai_upf_info_item_t;
typedef struct interface_upf_info_item_s {
......
......@@ -97,16 +97,27 @@ bool edge::serves_network(
const std::string& dnn, const snssai_t& snssai,
const std::unordered_set<std::string>& dnais,
std::string& matched_dnai) const {
Logger::smf_app().debug(
"Serves Network, DNN %s, S-NSSAI %s", dnn.c_str(),
snssai.toString().c_str());
// just create a snssai_upf_info_item for fast lookup
snssai_upf_info_item_s snssai_item;
snssai_item.snssai = snssai;
snssai_upf_info_item_s snssai_item = {};
snssai_item.snssai = snssai;
// For debuging purpose
if (!snssai_dnns.empty()) {
Logger::smf_app().debug("S-NSSAI UPF info list");
for (const auto& s : snssai_dnns) {
Logger::smf_app().debug(
"S-NSSAI UPF info item %s", s.to_string().c_str());
}
}
auto snssai_it = snssai_dnns.find(snssai_item);
if (snssai_it != snssai_dnns.end()) {
// create temp item for fast lookup
dnn_upf_info_item_s dnn_item;
dnn_item.dnn = dnn;
auto dnn_it = snssai_it->dnn_upf_info_list.find(dnn_item);
dnn_upf_info_item_s dnn_item = {};
dnn_item.dnn = dnn;
auto dnn_it = snssai_it->dnn_upf_info_list.find(dnn_item);
if (dnn_it != snssai_it->dnn_upf_info_list.end()) {
if (!dnais.empty()) {
// should be only 1 DNAI
......@@ -123,6 +134,8 @@ bool edge::serves_network(
}
}
}
Logger::smf_app().debug("Could not serve network, return false");
return false;
}
......@@ -287,7 +300,7 @@ bool pfcp_association::find_interface_edge(
if (!is_upf_profile_set()) {
return false;
}
upf_info_t upf_info;
upf_info_t upf_info = {};
upf_node_profile.get_upf_info(upf_info);
for (const auto& iface : upf_info.interface_upf_info_list) {
......@@ -1236,17 +1249,20 @@ void upf_graph::update_edge_info(
std::shared_ptr<upf_graph> upf_graph::select_upf_node(
const snssai_t& snssai, const std::string& dnn) {
Logger::smf_app().info("Select UPF Node");
std::shared_ptr<upf_graph> upf_graph_ptr = std::make_shared<upf_graph>();
std::shared_lock graph_lock(graph_mutex);
std::shared_ptr<pfcp_association> not_found;
std::shared_ptr<pfcp_association> not_found = {};
if (adjacency_list.empty()) {
Logger::smf_app().warn("No UPF available");
}
// First, only consider UPFs with profile ID set
for (const auto& it : adjacency_list) {
std::shared_ptr<pfcp_association> current_upf = it.first;
Logger::smf_app().debug("Current UPF info");
current_upf->display();
if (current_upf->is_upf_profile_set()) {
upf_info_t upf_info;
upf_info_t upf_info = {};
std::vector<snssai_t> snssais = {};
current_upf->get_upf_node_profile().get_upf_info(upf_info);
bool has_access = false;
......@@ -1254,6 +1270,7 @@ std::shared_ptr<upf_graph> upf_graph::select_upf_node(
edge access_edge;
edge exit_edge;
for (const auto& edge : it.second) {
Logger::smf_app().debug("Verify Slice/DNN support");
// verify that UPF belongs to the same slice and supports this dnn
if (edge.serves_network(dnn, snssai)) {
if (edge.type == iface_type::N3) {
......
......@@ -328,6 +328,13 @@ struct edge {
if (association && nw_instance.empty()) {
output.append("(").append(association->get_printable_name()).append(")");
}
if (!snssai_dnns.empty()) {
output.append("S-NSSAI UPF info list: { ");
for (const auto& s : snssai_dnns) {
output.append(" " + s.to_string() + ", ");
}
output.append("}");
}
return output;
}
};
......
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