Skip to content
Snippets Groups Projects
Commit 3f07228a authored by Jonas Höglund's avatar Jonas Höglund
Browse files

Fix parsing several interfaces

parent b5d486fe
Branches
No related tags found
No related merge requests found
Pipeline #222 canceled
......@@ -246,6 +246,7 @@ private:
public:
inst_def_set();
bool insert(const std::shared_ptr<instance_definition>& id);
bool erase(const std::shared_ptr<instance_definition>& id);
const_iterator find(const std::string& instance_name) const {
return m_instance_def_set.find(std::make_shared<instance_definition>(instance_name));
......
......@@ -195,34 +195,47 @@ void configuration::initalize_interfaces()
HC_LOG_TRACE("");
unsigned int if_index;
for (auto & inst : m_inst_def_set) {
auto result = std::make_shared<interfaces>(get_addr_family(m_gmp), m_reset_reverse_path_filter);
auto add = [&](const std::shared_ptr<interface>& interf) {
if_index = interfaces::get_if_index(interf->get_if_name());
if (if_index == 0) {
HC_LOG_ERROR("interface " << interf->get_if_name() << " not found");
throw "unknown interface";
}
if (!result->add_interface(if_index)) {
throw "failed to add interface";
}
};
for (auto & downstream : inst->get_downstreams()) {
add(downstream);
}
for (auto & upstream : inst->get_upstreams()) {
add(upstream);
}
if (!m_interfaces_map.insert(std::pair<std::string, std::shared_ptr<interfaces>>(inst->get_instance_name(), result)).second) {
HC_LOG_ERROR("proxy instance " << inst->get_instance_name() << " already exists");
throw "failed to add instance";
}
auto def_set = m_inst_def_set;
auto result = std::make_shared<interfaces>(get_addr_family(m_gmp), m_reset_reverse_path_filter);
auto add = [&](const std::shared_ptr<interface>& interf) {
if_index = interfaces::get_if_index(interf->get_if_name());
if (if_index == 0) {
HC_LOG_ERROR("interface " << interf->get_if_name() << " not found");
throw "unknown interface";
}
if (!result->add_interface(if_index)) {
throw "failed to add interface";
}
};
for (auto & inst : def_set) {
try {
for (auto & downstream : inst->get_downstreams()) {
add(downstream);
}
for (auto & upstream : inst->get_upstreams()) {
add(upstream);
}
if (!m_interfaces_map.insert(std::pair<std::string, std::shared_ptr<interfaces>>(inst->get_instance_name(), result)).second) {
HC_LOG_ERROR("proxy instance " << inst->get_instance_name() << " already exists");
throw "failed to add instance";
}
} catch (const char *s) {
m_inst_def_set.erase(inst);
continue;
}
}
if (m_inst_def_set.size() == 0) {
throw "no valid interfaces found";
}
}
#ifdef DEBUG_MODE
......
......@@ -595,6 +595,12 @@ bool inst_def_set::insert(const std::shared_ptr<instance_definition>& id)
return m_instance_def_set.insert(id).second;
}
bool inst_def_set::erase(const std::shared_ptr<instance_definition>& id)
{
HC_LOG_TRACE("");
return m_instance_def_set.erase(id);
}
unsigned int inst_def_set::size() const
{
HC_LOG_TRACE("");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment