Commit 5c7fbfd7 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'fix_nwi_without_nrf' into 'develop'

Use NWI from config file when no UPF profile is associated

See merge request oai/cn5g/oai-cn5g-smf!169
parents f7f6cfa3 d58209b6
...@@ -123,8 +123,6 @@ SMF = ...@@ -123,8 +123,6 @@ SMF =
USE_FQDN_DNS = "{{ env["USE_FQDN_DNS"] if "USE_FQDN_DNS" in env.keys() else 'no' }}"; USE_FQDN_DNS = "{{ env["USE_FQDN_DNS"] if "USE_FQDN_DNS" in env.keys() else 'no' }}";
# Default: 1 # Default: 1
HTTP_VERSION = {{ env["HTTP_VERSION"] if "HTTP_VERSION" in env.keys() else '1' }}; HTTP_VERSION = {{ env["HTTP_VERSION"] if "HTTP_VERSION" in env.keys() else '1' }};
# Set yes if network instance is to be used for given UPF
USE_NETWORK_INSTANCE = "{{ env["USE_NETWORK_INSTANCE"] if "USE_NETWORK_INSTANCE" in env.keys() else 'no' }}";
# Set yes if UE USAGE REPORTING is to be done at UPF # Set yes if UE USAGE REPORTING is to be done at UPF
ENABLE_USAGE_REPORTING = "{{ env["ENABLE_USAGE_REPORTING"] if "ENABLE_USAGE_REPORTING" in env.keys() else 'no' }}" ENABLE_USAGE_REPORTING = "{{ env["ENABLE_USAGE_REPORTING"] if "ENABLE_USAGE_REPORTING" in env.keys() else 'no' }}"
} }
......
...@@ -566,14 +566,6 @@ int smf_config::load(const string& config_file) { ...@@ -566,14 +566,6 @@ int smf_config::load(const string& config_file) {
SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION, httpVersion); SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION, httpVersion);
http_version = httpVersion; http_version = httpVersion;
support_features.lookupValue(
SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_NETWORK_INSTANCE, opt);
if (boost::iequals(opt, "yes")) {
use_nwi = true;
} else {
use_nwi = false;
}
support_features.lookupValue( support_features.lookupValue(
SMF_CONFIG_STRING_SUPPORT_FEATURES_ENABLE_USAGE_REPORTING, opt); SMF_CONFIG_STRING_SUPPORT_FEATURES_ENABLE_USAGE_REPORTING, opt);
if (boost::iequals(opt, "yes")) { if (boost::iequals(opt, "yes")) {
...@@ -787,7 +779,7 @@ int smf_config::load(const string& config_file) { ...@@ -787,7 +779,7 @@ int smf_config::load(const string& config_file) {
} }
} }
// Network Instance // Network Instance
if (upf_cfg.exists(SMF_CONFIG_STRING_NWI_LIST) & use_nwi) { if (upf_cfg.exists(SMF_CONFIG_STRING_NWI_LIST)) {
const Setting& nwi_cfg = upf_cfg[SMF_CONFIG_STRING_NWI_LIST]; const Setting& nwi_cfg = upf_cfg[SMF_CONFIG_STRING_NWI_LIST];
count = nwi_cfg.getLength(); count = nwi_cfg.getLength();
// Check if NWI list for given UPF is present // Check if NWI list for given UPF is present
...@@ -1076,8 +1068,6 @@ void smf_config::display() { ...@@ -1076,8 +1068,6 @@ void smf_config::display() {
Logger::smf_app().info( Logger::smf_app().info(
" Use FQDN ...........................: %s", " Use FQDN ...........................: %s",
use_fqdn_dns ? "Yes" : "No"); use_fqdn_dns ? "Yes" : "No");
Logger::smf_app().info(
" Use NWI ...........................: %s", use_nwi ? "Yes" : "No");
Logger::smf_app().info("- DNN configurations:"); Logger::smf_app().info("- DNN configurations:");
...@@ -1239,59 +1229,27 @@ std::string smf_config::get_default_dnn() { ...@@ -1239,59 +1229,27 @@ std::string smf_config::get_default_dnn() {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool smf_config::get_nwi_list_index( std::string smf_config::get_nwi(
bool nwi_enabled, uint8_t nwi_list_index, pfcp::node_id_t node_id) { const pfcp::node_id_t& node_id, const iface_type& type) {
if (node_id.node_id_type == pfcp::NODE_ID_TYPE_IPV4_ADDRESS) { // Note Stefan: In all cases, resolving should happen before this step and the
for (int i = 0; i < upf_nwi_list.size(); i++) { // IP address is set
if (node_id.u1.ipv4_address.s_addr == for (const auto& upf_nwi : upf_nwi_list) {
upf_nwi_list[i].upf_id.u1.ipv4_address.s_addr) { if (upf_nwi.upf_id.u1.ipv4_address.s_addr ==
nwi_list_index = i; node_id.u1.ipv4_address.s_addr) {
nwi_enabled = true; switch (type) {
return true; case iface_type::N3:
} return upf_nwi.domain_access;
} case iface_type::N6:
nwi_enabled = false; return upf_nwi.domain_core;
return false; case iface_type::N9:
} Logger::smf_app().warn(
if (node_id.node_id_type == pfcp::NODE_ID_TYPE_FQDN) { "N9 interface type not supported for locally configured NWI");
// Resove FQDN here because, node id type is always IPV4_ADDRESS in return "";
// upf_nwi_list default:
unsigned char buf_in_addr[sizeof(struct in_addr) + 1]; Logger::smf_app().error("Unsupported enum parameter in get_nwi");
unsigned int upf_port = {0}; return "";
uint8_t addr_type = {0};
std::string address = {};
struct in_addr ipv4_Address;
fqdn::resolve(node_id.fqdn, address, upf_port, addr_type, "");
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&ipv4_Address, buf_in_addr, sizeof(struct in_addr));
} else {
Logger::smf_app().error("FQDN resolve failed for get_nwi_list_index");
}
for (int i = 0; i < upf_nwi_list.size(); i++) {
if (ipv4_Address.s_addr ==
upf_nwi_list[i].upf_id.u1.ipv4_address.s_addr) {
nwi_list_index = i;
nwi_enabled = true;
return true;
} }
} }
nwi_enabled = false;
return false;
} }
return false; return "";
} }
\ No newline at end of file
//------------------------------------------------------------------------------
std::string smf_config::get_nwi(
const std::vector<interface_upf_info_item_t>& int_list,
const std::string& int_type) {
std::string nwi = {};
for (auto ui : int_list) {
if (!ui.interface_type.compare(int_type)) nwi = ui.network_instance;
}
Logger::smf_app().debug(
"Interface Type - %s, NWI - %s", int_type.c_str(), nwi.c_str());
return nwi;
}
//------------------------------------------------------------------------------
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "3gpp_29.244.h" #include "3gpp_29.244.h"
#include "pfcp.hpp" #include "pfcp.hpp"
#include "smf.h" #include "smf.h"
#include "smf_profile.hpp"
#define SMF_CONFIG_STRING_SMF_CONFIG "SMF" #define SMF_CONFIG_STRING_SMF_CONFIG "SMF"
#define SMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY" #define SMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
...@@ -157,8 +158,6 @@ ...@@ -157,8 +158,6 @@
"FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS" "FORCE_PUSH_PROTOCOL_CONFIGURATION_OPTIONS"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS" #define SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_FQDN_DNS "USE_FQDN_DNS"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION "HTTP_VERSION" #define SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION "HTTP_VERSION"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_NETWORK_INSTANCE \
"USE_NETWORK_INSTANCE"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_ENABLE_USAGE_REPORTING \ #define SMF_CONFIG_STRING_SUPPORT_FEATURES_ENABLE_USAGE_REPORTING \
"ENABLE_USAGE_REPORTING" "ENABLE_USAGE_REPORTING"
...@@ -245,7 +244,6 @@ class smf_config { ...@@ -245,7 +244,6 @@ class smf_config {
bool use_local_pcc_rules; bool use_local_pcc_rules;
bool use_fqdn_dns; bool use_fqdn_dns;
unsigned int http_version; unsigned int http_version;
bool use_nwi;
bool enable_ur; bool enable_ur;
std::vector<pfcp::node_id_t> upfs; std::vector<pfcp::node_id_t> upfs;
...@@ -340,7 +338,6 @@ class smf_config { ...@@ -340,7 +338,6 @@ class smf_config {
discover_upf = false; discover_upf = false;
discover_pcf = false; discover_pcf = false;
use_fqdn_dns = false; use_fqdn_dns = false;
use_nwi = false;
}; };
~smf_config(); ~smf_config();
void lock() { m_rw_lock.lock(); }; void lock() { m_rw_lock.lock(); };
...@@ -352,11 +349,14 @@ class smf_config { ...@@ -352,11 +349,14 @@ class smf_config {
bool is_dotted_dnn_handled( bool is_dotted_dnn_handled(
const std::string& dnn, const pdu_session_type_t& pdn_session_type); const std::string& dnn, const pdu_session_type_t& pdn_session_type);
std::string get_default_dnn(); std::string get_default_dnn();
bool get_nwi_list_index(
bool nwi_enabled, uint8_t nwi_list_index, pfcp::node_id_t node_id); /**
std::string get_nwi( * Returns network instance of iface_type typ. If not found, empty string is
const std::vector<interface_upf_info_item_t>& int_list, * returned
const std::string& int_type); * @param node_id IP address or FQDN to match against configuration
* @return NWI or empty string
*/
std::string get_nwi(const pfcp::node_id_t& node_id, const iface_type& type);
}; };
} // namespace smf } // namespace smf
......
...@@ -894,12 +894,14 @@ void upf_graph::insert_into_graph(const std::shared_ptr<pfcp_association>& sa) { ...@@ -894,12 +894,14 @@ void upf_graph::insert_into_graph(const std::shared_ptr<pfcp_association>& sa) {
"just add the node"); "just add the node");
Logger::smf_app().info("Assume that the UPF has a N3 and a N6 interface."); Logger::smf_app().info("Assume that the UPF has a N3 and a N6 interface.");
edge n3_edge = {}; edge n3_edge = {};
n3_edge.type = iface_type::N3; n3_edge.type = iface_type::N3;
n3_edge.uplink = false; n3_edge.nw_instance = smf_cfg.get_nwi(sa->node_id, iface_type::N3);
edge n6_edge = {}; n3_edge.uplink = false;
n6_edge.type = iface_type::N6; edge n6_edge = {};
n6_edge.uplink = true; n6_edge.type = iface_type::N6;
n6_edge.nw_instance = smf_cfg.get_nwi(sa->node_id, iface_type::N6);
n6_edge.uplink = true;
add_upf_graph_edge(sa, n3_edge); add_upf_graph_edge(sa, n3_edge);
add_upf_graph_edge(sa, n6_edge); add_upf_graph_edge(sa, n6_edge);
......
...@@ -47,8 +47,6 @@ namespace smf { ...@@ -47,8 +47,6 @@ namespace smf {
#define PFCP_ASSOCIATION_HEARTBEAT_MAX_RETRIES 2 #define PFCP_ASSOCIATION_HEARTBEAT_MAX_RETRIES 2
#define PFCP_ASSOCIATION_GRACEFUL_RELEASE_PERIOD 5 #define PFCP_ASSOCIATION_GRACEFUL_RELEASE_PERIOD 5
enum iface_type { N9, N6, N3 };
struct edge; struct edge;
class pfcp_association { class pfcp_association {
......
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
namespace smf { namespace smf {
enum class iface_type { N9, N6, N3 };
using namespace std; using namespace std;
class nf_profile : public std::enable_shared_from_this<nf_profile> { class nf_profile : public std::enable_shared_from_this<nf_profile> {
public: public:
......
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