summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/route.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/vom/route.cpp')
-rw-r--r--src/vpp-api/vom/route.cpp93
1 files changed, 80 insertions, 13 deletions
diff --git a/src/vpp-api/vom/route.cpp b/src/vpp-api/vom/route.cpp
index e59bfbaaf8c..0da2ebba749 100644
--- a/src/vpp-api/vom/route.cpp
+++ b/src/vpp-api/vom/route.cpp
@@ -102,16 +102,47 @@ path::operator<(const path& p) const
{
if (m_type < p.m_type)
return true;
+ if (m_rd && !p.m_rd)
+ return false;
+ if (!m_rd && p.m_rd)
+ return true;
if (m_rd->table_id() < p.m_rd->table_id())
return true;
if (m_nh < p.m_nh)
return true;
+ if (m_interface && !p.m_interface)
+ return false;
+ if (!m_interface && p.m_interface)
+ return true;
if (m_interface->handle() < p.m_interface->handle())
return true;
return (false);
}
+path::~path()
+{
+}
+
+bool
+path::operator==(const path& p) const
+{
+ bool result = true;
+ if (m_rd && !p.m_rd)
+ return false;
+ if (!m_rd && p.m_rd)
+ return false;
+ if (m_rd && p.m_rd)
+ result &= (*m_rd == *p.m_rd);
+ if (m_interface && !p.m_interface)
+ return false;
+ if (!m_interface && p.m_interface)
+ return false;
+ if (m_interface && p.m_interface)
+ result &= (*m_interface == *p.m_interface);
+ return (result && (m_type == p.m_type) && (m_nh == p.m_nh));
+}
+
std::string
path::to_string() const
{
@@ -174,6 +205,14 @@ path::preference() const
return m_preference;
}
+ip_route::ip_route(const prefix_t& prefix, const path& p)
+ : m_hw(false)
+ , m_rd(route_domain::get_default())
+ , m_prefix(prefix)
+ , m_paths({ p })
+{
+}
+
ip_route::ip_route(const prefix_t& prefix)
: m_hw(false)
, m_rd(route_domain::get_default())
@@ -198,12 +237,35 @@ ip_route::ip_route(const route_domain& rd, const prefix_t& prefix)
{
}
+ip_route::ip_route(const route_domain& rd,
+ const prefix_t& prefix,
+ const path& p)
+ : m_hw(false)
+ , m_rd(rd.singular())
+ , m_prefix(prefix)
+ , m_paths({ p })
+{
+}
+
ip_route::~ip_route()
{
sweep();
// not in the DB anymore.
- m_db.release(std::make_pair(m_rd->table_id(), m_prefix), this);
+ m_db.release(key(), this);
+ m_paths.clear();
+}
+
+const ip_route::key_t
+ip_route::key() const
+{
+ return (std::make_pair(m_rd->table_id(), m_prefix));
+}
+
+bool
+ip_route::operator==(const ip_route& i) const
+{
+ return ((key() == i.key()) && (m_paths == i.m_paths));
}
void
@@ -262,8 +324,13 @@ ip_route::update(const ip_route& r)
std::shared_ptr<ip_route>
ip_route::find_or_add(const ip_route& temp)
{
- return (m_db.find_or_add(std::make_pair(temp.m_rd->table_id(), temp.m_prefix),
- temp));
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<ip_route>
+ip_route::find(const key_t& k)
+{
+ return (m_db.find(k));
}
std::shared_ptr<ip_route>
@@ -308,8 +375,8 @@ ip_route::event_handler::handle_populate(const client_db::key_t& key)
prefix_t pfx(0, payload.address, payload.address_length);
/**
-* populating the route domain here
-*/
+ * populating the route domain here
+ */
route_domain rd_temp(payload.table_id);
std::shared_ptr<route_domain> rd = route_domain::find(rd_temp);
if (!rd) {
@@ -341,10 +408,10 @@ ip_route::event_handler::handle_populate(const client_db::key_t& key)
VOM_LOG(log_level_t::DEBUG) << "ip-route-dump: " << ip_r.to_string();
/*
-* Write each of the discovered interfaces into the OM,
-* but disable the HW Command q whilst we do, so that no
-* commands are sent to VPP
-*/
+ * Write each of the discovered interfaces into the OM,
+ * but disable the HW Command q whilst we do, so that no
+ * commands are sent to VPP
+ */
OM::commit(key, ip_r);
}
@@ -383,10 +450,10 @@ ip_route::event_handler::handle_populate(const client_db::key_t& key)
VOM_LOG(log_level_t::DEBUG) << "ip-route-dump: " << ip_r.to_string();
/*
-* Write each of the discovered interfaces into the OM,
-* but disable the HW Command q whilst we do, so that no
-* commands are sent to VPP
-*/
+ * Write each of the discovered interfaces into the OM,
+ * but disable the HW Command q whilst we do, so that no
+ * commands are sent to VPP
+ */
OM::commit(key, ip_r);
}
}