Commit 5272d86b authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_upf_selection_09_11' into 'develop'

Fix for UPF selection - change priority order FQDN/IP addr

See merge request oai/cn5g/oai-cn5g-smf!103
parents a9728f43 74e79f24
...@@ -130,13 +130,12 @@ check_supported_distribution() { ...@@ -130,13 +130,12 @@ check_supported_distribution() {
"ubuntu18.04") return 0 ;; "ubuntu18.04") return 0 ;;
"ubuntu20.04") return 0 ;; "ubuntu20.04") return 0 ;;
"rhel8") return 0 ;; "rhel8") return 0 ;;
"rhel8.2") return 0 ;; "rhel8.2") return 0 ;;
"rhel8.3") return 0 ;; "rhel8.3") return 0 ;;
"rhel8.4") return 0 ;; "rhel8.4") return 0 ;;
"rhel8.5") return 0 ;; "rhel8.5") return 0 ;;
"rhel8.6") return 0 ;; "rhel8.6") return 0 ;;
"rhel8.7") return 0 ;; "rhel8.7") return 0 ;;
#"centos7") return 0 ;;
esac esac
return 1 return 1
} }
......
...@@ -1323,32 +1323,8 @@ bool smf_app::handle_nf_status_notification( ...@@ -1323,32 +1323,8 @@ bool smf_app::handle_nf_status_notification(
std::vector<struct in_addr> ipv4_addrs = {}; std::vector<struct in_addr> ipv4_addrs = {};
profile.get()->get_nf_ipv4_addresses(ipv4_addrs); profile.get()->get_nf_ipv4_addresses(ipv4_addrs);
// Use IPv4 addr first if available // Use FQDN if available
if (ipv4_addrs.size() >= 1) { if (!upf_fqdn.empty()) {
bool found = false;
for (auto node : smf_cfg.upfs) {
if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) {
found = true;
break;
}
}
if (!found) {
// Add a new UPF node
Logger::smf_app().debug(
"Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0]));
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr;
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
} else {
Logger::smf_app().debug(
"UPF node already exist (%s)", inet_ntoa(ipv4_addrs[0]));
}
} else if (!upf_fqdn.empty()) { // use FQDN
uint8_t addr_type = {0}; uint8_t addr_type = {0};
std::string address = {}; std::string address = {};
uint32_t upf_port = {0}; uint32_t upf_port = {0};
...@@ -1394,6 +1370,31 @@ bool smf_app::handle_nf_status_notification( ...@@ -1394,6 +1370,31 @@ bool smf_app::handle_nf_status_notification(
Logger::smf_app().debug( Logger::smf_app().debug(
"UPF node already exist (%s)", address.c_str()); "UPF node already exist (%s)", address.c_str());
} }
} else if (ipv4_addrs.size() >= 1) { // If FQDN isn't available, check
// IP address
bool found = false;
for (auto node : smf_cfg.upfs) {
if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) {
found = true;
break;
}
}
if (!found) {
// Add a new UPF node
Logger::smf_app().debug(
"Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0]));
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr;
smf_cfg.upfs.push_back(n);
upf_profile* upf_node_profile =
dynamic_cast<upf_profile*>(profile.get());
start_upf_association(n, std::ref(*upf_node_profile));
} else {
Logger::smf_app().debug(
"UPF node already exist (%s)", inet_ntoa(ipv4_addrs[0]));
}
} else { } else {
Logger::smf_app().debug("No IP Addr/FQDN found"); Logger::smf_app().debug("No IP Addr/FQDN found");
return false; return false;
......
...@@ -107,8 +107,8 @@ bool pfcp_associations::add_association( ...@@ -107,8 +107,8 @@ bool pfcp_associations::add_association(
} }
if (record->h_addrtype == AF_INET) { if (record->h_addrtype == AF_INET) {
in_addr* address = (struct in_addr*) record->h_addr; in_addr* address = (struct in_addr*) record->h_addr;
node_id.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS; // node_id.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
node_id.u1.ipv4_address = *address; node_id.u1.ipv4_address = *address;
Logger::smf_app().info( Logger::smf_app().info(
"Node ID Type FQDN: %s, IPv4 Addr: %s", node_id.fqdn.c_str(), "Node ID Type FQDN: %s, IPv4 Addr: %s", node_id.fqdn.c_str(),
...@@ -173,8 +173,8 @@ bool pfcp_associations::add_association( ...@@ -173,8 +173,8 @@ bool pfcp_associations::add_association(
return false; return false;
} }
if (record->h_addrtype == AF_INET) { if (record->h_addrtype == AF_INET) {
in_addr* address = (struct in_addr*) record->h_addr; in_addr* address = (struct in_addr*) record->h_addr;
node_id.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS; // node_id.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
node_id.u1.ipv4_address = *address; node_id.u1.ipv4_address = *address;
Logger::smf_app().info( Logger::smf_app().info(
"Node ID Type FQDN: %s, IPv4 Addr: %s", node_id.fqdn.c_str(), "Node ID Type FQDN: %s, IPv4 Addr: %s", node_id.fqdn.c_str(),
...@@ -451,7 +451,7 @@ bool pfcp_associations::select_up_node( ...@@ -451,7 +451,7 @@ bool pfcp_associations::select_up_node(
Logger::smf_app().info( Logger::smf_app().info(
"Select the UPF for the corresponding DNN %s, NSSSAI (SD: %s, " "Select the UPF for the corresponding DNN %s, NSSSAI (SD: %s, "
"SST: %d) ", "SST: %d) ",
d.dnn.c_str(), snssai.sD, snssai.sST); d.dnn.c_str(), snssai.sD.c_str(), snssai.sST);
return true; return true;
} }
} }
......
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