Commit 4b6a5e0d authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_smf_selection_sd' into 'develop'

Fix SD mismatch when selecting SMF

See merge request oai/cn5g/oai-cn5g-amf!78
parents 3e5fee86 bf1c8866
...@@ -1038,7 +1038,7 @@ bool amf_n11::discover_smf( ...@@ -1038,7 +1038,7 @@ bool amf_n11::discover_smf(
const std::string& nrf_port, const std::string& nrf_api_version) { const std::string& nrf_port, const std::string& nrf_api_version) {
Logger::amf_n11().debug( Logger::amf_n11().debug(
"Send NFDiscovery to NRF to discover the available SMFs"); "Send NFDiscovery to NRF to discover the available SMFs");
bool result = true; bool result = false;
uint8_t http_version = 1; uint8_t http_version = 1;
if (amf_cfg.support_features.use_http2) http_version = 2; if (amf_cfg.support_features.use_http2) http_version = 2;
...@@ -1118,24 +1118,26 @@ bool amf_n11::discover_smf( ...@@ -1118,24 +1118,26 @@ bool amf_n11::discover_smf(
if (instance_json.find("sNssais") != instance_json.end()) { if (instance_json.find("sNssais") != instance_json.end()) {
for (auto& s : instance_json["sNssais"].items()) { for (auto& s : instance_json["sNssais"].items()) {
nlohmann::json Snssai = s.value(); nlohmann::json Snssai = s.value();
if (Snssai["sst"] == snssai.sST) { if (Snssai["sst"].get<int>() == snssai.sST) {
// Match SD (optional) only if it is provided // Match SD (optional) only if it is provided
if (!Snssai["sd"].empty() & Snssai["sd"] != snssai.sD) { if (Snssai["sd"].empty() or
Logger::amf_n11().debug("SD is not matched"); (snssai.sD.compare(Snssai["sd"].get<std::string>()) == 0)) {
result = false; Logger::amf_n11().debug(
"S-NSSAI [SST- %d, SD -%s] is matched for SMF profile",
snssai.sST, snssai.sD.c_str());
result = true;
break; // NSSAI is included in the list of supported slices
// from SMF
} }
Logger::amf_n11().debug(
"Snssai [SST- %s, SD -%s] is matched for SMF profile",
Snssai["sst"].dump().c_str(), Snssai["sd"].dump().c_str());
result = true;
break;
} else {
Logger::amf_n11().debug(
"Snssai is not matched for SMF profile");
result = false;
} }
} }
} }
if (!result) {
Logger::amf_n11().debug("S-NSSAI is not matched for SMF profile");
// continue;
}
// TODO: check DNN // TODO: check DNN
// TODO: PLMN (need to add plmnList into NRF profile, SMF profile) // TODO: PLMN (need to add plmnList into NRF profile, SMF profile)
// for now, just IP addr of SMF of the first NF instance // for now, just IP addr of SMF of the first NF instance
...@@ -1156,6 +1158,7 @@ bool amf_n11::discover_smf( ...@@ -1156,6 +1158,7 @@ bool amf_n11::discover_smf(
} }
} }
} }
// Break after first matching SMF instance for requested S-NSSAI // Break after first matching SMF instance for requested S-NSSAI
if (result) break; if (result) break;
} }
......
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