Commit a2a8402b authored by Stefan Spettel's avatar Stefan Spettel

fix(smf): do not rely on pre-existing upf interfaces and handle snssai/dnn/dnai correctly

Signed-off-by: default avatarStefan Spettel <stefan.spettel@eurecom.fr>
parent 0594e14b
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <unordered_set>
typedef uint64_t supi64_t; typedef uint64_t supi64_t;
#define SUPI_64_FMT "%" SCNu64 #define SUPI_64_FMT "%" SCNu64
...@@ -361,7 +362,7 @@ typedef struct nf_service_s { ...@@ -361,7 +362,7 @@ typedef struct nf_service_s {
typedef struct dnn_upf_info_item_s { typedef struct dnn_upf_info_item_s {
std::string dnn; std::string dnn;
std::vector<std::string> dnai_list; std::unordered_set<std::string> dnai_list;
// supported from R16.8 // supported from R16.8
std::map<std::string, std::string> dnai_nw_instance_list; std::map<std::string, std::string> dnai_nw_instance_list;
// std::vector<std::string> pdu_session_types // std::vector<std::string> pdu_session_types
...@@ -372,11 +373,19 @@ typedef struct dnn_upf_info_item_s { ...@@ -372,11 +373,19 @@ typedef struct dnn_upf_info_item_s {
dnai_nw_instance_list = d.dnai_nw_instance_list; dnai_nw_instance_list = d.dnai_nw_instance_list;
return *this; return *this;
} }
bool operator==(const dnn_upf_info_item_s& s) const { return dnn == s.dnn; }
size_t operator()(const dnn_upf_info_item_s&) const {
return std::hash<std::string>()(dnn);
}
} dnn_upf_info_item_t; } dnn_upf_info_item_t;
typedef struct snssai_upf_info_item_s { typedef struct snssai_upf_info_item_s {
snssai_t snssai; snssai_t snssai;
std::vector<dnn_upf_info_item_t> dnn_upf_info_list; std::unordered_set<dnn_upf_info_item_t, dnn_upf_info_item_t>
dnn_upf_info_list;
snssai_upf_info_item_s& operator=(const snssai_upf_info_item_s& s) { snssai_upf_info_item_s& operator=(const snssai_upf_info_item_s& s) {
snssai = s.snssai; snssai = s.snssai;
...@@ -384,6 +393,14 @@ typedef struct snssai_upf_info_item_s { ...@@ -384,6 +393,14 @@ typedef struct snssai_upf_info_item_s {
return *this; return *this;
} }
bool operator==(const snssai_upf_info_item_s& s) const {
return snssai == s.snssai;
}
size_t operator()(const snssai_upf_info_item_s&) const {
return snssai.operator()(snssai);
}
} snssai_upf_info_item_t; } snssai_upf_info_item_t;
typedef struct interface_upf_info_item_s { typedef struct interface_upf_info_item_s {
......
This diff is collapsed.
...@@ -264,9 +264,9 @@ const std::string DEFAULT_FLOW_DESCRIPTION = ...@@ -264,9 +264,9 @@ const std::string DEFAULT_FLOW_DESCRIPTION =
"permit out ip from any to assigned"; "permit out ip from any to assigned";
struct edge { struct edge {
std::string dnai;
// this might need to be replaced by FlowInformation model in the future, but // this might need to be replaced by FlowInformation model in the future, but
// for now we know this is always uplink // for now we know this is always uplink
std::string used_dnai;
std::string flow_description; std::string flow_description;
unsigned int precedence = 0; unsigned int precedence = 0;
std::string nw_instance; std::string nw_instance;
...@@ -275,22 +275,27 @@ struct edge { ...@@ -275,22 +275,27 @@ struct edge {
std::vector<smf_qos_flow> qos_flows; std::vector<smf_qos_flow> qos_flows;
bool n4_sent = false; bool n4_sent = false;
std::shared_ptr<pfcp_association> association; std::shared_ptr<pfcp_association> association;
std::unordered_set<std::string> dnns; // we use parts of the upf_interface here
std::unordered_set<snssai_t, snssai_t> snssais; // the reason why we do is that all the info is split up into several parts
// in the API. It is more time-efficient to have all in one place
std::unordered_set<snssai_upf_info_item_s, snssai_upf_info_item_s>
snssai_dnns;
static edge from_upf_info( static edge from_upf_info(
const upf_info_t& upf_info, const interface_upf_info_item_t& interface); const upf_info_t& upf_info, const interface_upf_info_item_t& interface);
static edge from_upf_info(const upf_info_t& upf_info);
bool serves_network(const std::string& dnn, const snssai_t& snssai) const; bool serves_network(const std::string& dnn, const snssai_t& snssai) const;
bool serves_network( bool serves_network(
const std::string& dnn, const snssai_t& snssai, const std::string& dnn, const snssai_t& snssai,
const std::string& dnai) const; const std::unordered_set<std::string>& dnais,
std::string& found_dnai) const;
bool operator==(const edge& other) const { bool operator==(const edge& other) const {
return dnai == other.dnai && nw_instance == other.nw_instance && return nw_instance == other.nw_instance && type == other.type &&
type == other.type && uplink == other.uplink && uplink == other.uplink && association == other.association;
association == other.association;
} }
[[nodiscard]] std::string to_string() const { [[nodiscard]] std::string to_string() const {
...@@ -330,7 +335,7 @@ class upf_graph { ...@@ -330,7 +335,7 @@ class upf_graph {
smf_qos_flow qos_flow_asynch; smf_qos_flow qos_flow_asynch;
// normal DFS temporary values // normal DFS temporary values
std::set<std::string> dfs_all_dnais; std::unordered_set<std::string> dfs_all_dnais;
std::string dfs_flow_description; std::string dfs_flow_description;
snssai_t dfs_snssai; snssai_t dfs_snssai;
std::string dfs_dnn; std::string dfs_dnn;
...@@ -376,7 +381,7 @@ class upf_graph { ...@@ -376,7 +381,7 @@ class upf_graph {
* @param dnn The DNN to match against * @param dnn The DNN to match against
*/ */
void set_dfs_selection_criteria( void set_dfs_selection_criteria(
const std::set<std::string>& all_dnais, const std::unordered_set<std::string>& all_dnais,
const std::string& flow_description, uint32_t precedence, const std::string& flow_description, uint32_t precedence,
const snssai_t& snssai, const std::string& dnn); const snssai_t& snssai, const std::string& dnn);
...@@ -409,7 +414,7 @@ class upf_graph { ...@@ -409,7 +414,7 @@ class upf_graph {
* @param dnais * @param dnais
* @return * @return
*/ */
static std::string get_dnai_list(const std::set<string>& dnais); static std::string get_dnai_list(const std::unordered_set<string>& dnais);
public: public:
upf_graph() : adjacency_list(), visited_asynch(){}; upf_graph() : adjacency_list(), visited_asynch(){};
......
...@@ -652,14 +652,14 @@ void upf_profile::from_json(const nlohmann::json& data) { ...@@ -652,14 +652,14 @@ void upf_profile::from_json(const nlohmann::json& data) {
} }
if (d.find("dnaiList") != d.end()) { if (d.find("dnaiList") != d.end()) {
dnn_item.dnai_list = dnn_item.dnai_list =
d["dnaiList"].get<std::vector<std::string>>(); d["dnaiList"].get<std::unordered_set<std::string>>();
} }
if (d.find("dnaiNwInstanceList") != d.end()) { if (d.find("dnaiNwInstanceList") != d.end()) {
dnn_item.dnai_nw_instance_list = dnn_item.dnai_nw_instance_list =
d["dnaiNwInstanceList"] d["dnaiNwInstanceList"]
.get<std::map<std::string, std::string>>(); .get<std::map<std::string, std::string>>();
} }
upf_info_item.dnn_upf_info_list.push_back(dnn_item); upf_info_item.dnn_upf_info_list.insert(dnn_item);
} }
} }
upf_info.snssai_upf_info_list.push_back(upf_info_item); upf_info.snssai_upf_info_list.push_back(upf_info_item);
......
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