}
const itf_flags_t itf_flags_t::NONE(0, "none");
-const itf_flags_t itf_flags_t::ACCEPT((1 << 2), "accept");
-const itf_flags_t itf_flags_t::FORWARD((1 << 3), "forward");
+const itf_flags_t itf_flags_t::ACCEPT((1 << 1), "accept");
+const itf_flags_t itf_flags_t::FORWARD((1 << 2), "forward");
itf_flags_t::itf_flags_t(int v, const std::string& s)
: enum_base<itf_flags_t>(v, s)
return itf_flags_t::FORWARD;
}
-path::path(special_t special)
+path::path(special_t special, const nh_proto_t& proto)
: m_type(special)
- , m_nh_proto(nh_proto_t::IPV4)
+ , m_nh_proto(proto)
, m_flags(flags_t::NONE)
, m_nh()
, m_rd(nullptr)
ip_route::sweep()
{
if (m_hw) {
- HW::enqueue(
- new ip_route_cmds::delete_cmd(m_hw, m_rd->table_id(), m_prefix));
+ for (auto& p : m_paths)
+ HW::enqueue(
+ new ip_route_cmds::delete_cmd(m_hw, m_rd->table_id(), m_prefix, p));
}
HW::write();
}
ip_route::replay()
{
if (m_hw) {
- HW::enqueue(
- new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, m_paths));
+ for (auto& p : m_paths)
+ HW::enqueue(
+ new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, p));
}
}
std::string
void
ip_route::update(const ip_route& r)
{
- /*
-* create the table if it is not yet created
-*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(
- new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, m_paths));
+ /*
+ * route not yet installed. install each of the desired paths
+ */
+ m_paths = r.m_paths;
+
+ for (auto& p : m_paths)
+ HW::enqueue(
+ new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, p));
+ } else {
+ /*
+ * add each path that is not installed yet and remove each that is no longer
+ * wanted
+ */
+ path_list_t to_add;
+ set_difference(r.m_paths.begin(), r.m_paths.end(), m_paths.begin(),
+ m_paths.end(), std::inserter(to_add, to_add.begin()));
+
+ for (auto& p : to_add)
+ HW::enqueue(
+ new ip_route_cmds::update_cmd(m_hw, m_rd->table_id(), m_prefix, p));
+
+ path_list_t to_del;
+ set_difference(m_paths.begin(), m_paths.end(), r.m_paths.begin(),
+ r.m_paths.end(), std::inserter(to_del, to_del.begin()));
+
+ for (auto& p : to_del)
+ HW::enqueue(
+ new ip_route_cmds::delete_cmd(m_hw, m_rd->table_id(), m_prefix, p));
+
+ m_paths = r.m_paths;
}
}
ip_mroute::event_handler::event_handler()
{
OM::register_listener(this);
- inspect::register_handler({ "ip-route" }, "ip route configurations", this);
+ inspect::register_handler({ "ip-mroute" },
+ "ip multicast route configurations", this);
}
void
ip_r.add(from_vpp(p.path, nh_proto_t::IPV4),
itf_flags_t::from_vpp(p.itf_flags));
}
- VOM_LOG(log_level_t::INFO) << "ip-mroute-dump: " << ip_r.to_string();
+ VOM_LOG(log_level_t::DEBUG) << "ip-mroute-dump: " << ip_r.to_string();
/*
* Write each of the discovered interfaces into the OM,
ip_r.add(from_vpp(p.path, nh_proto_t::IPV6),
itf_flags_t::from_vpp(p.itf_flags));
}
- VOM_LOG(log_level_t::INFO) << "ip-mroute-dump: " << ip_r.to_string();
+ VOM_LOG(log_level_t::DEBUG) << "ip-mroute-dump: " << ip_r.to_string();
/*
* Write each of the discovered interfaces into the OM,