X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fvom%2Fvom%2Froute_cmds.cpp;h=78676c225befa60b1957a57e0f012c46ecc4bd34;hb=7c0eb56f4;hp=83d44ccc01d388ee7aa9d658b84f218eb2c8177c;hpb=164e5f8c63652028ecb9c3570e1ea8618b163071;p=vpp.git diff --git a/extras/vom/vom/route_cmds.cpp b/extras/vom/vom/route_cmds.cpp index 83d44ccc01d..78676c225be 100644 --- a/extras/vom/vom/route_cmds.cpp +++ b/extras/vom/vom/route_cmds.cpp @@ -15,94 +15,53 @@ #include -#include "vom/route_cmds.hpp" +#include +#include +#include namespace VOM { namespace route { namespace ip_route_cmds { -static void -to_vpp(const route::path& p, vapi_payload_ip_add_del_route& payload) -{ - payload.is_drop = 0; - payload.is_unreach = 0; - payload.is_prohibit = 0; - payload.is_local = 0; - payload.is_classify = 0; - payload.is_multipath = 0; - payload.is_resolve_host = 0; - payload.is_resolve_attached = 0; - - if (route::path::flags_t::DVR & p.flags()) { - payload.is_dvr = 1; - } - - if (route::path::special_t::STANDARD == p.type()) { - uint8_t path_v6; - to_bytes(p.nh(), &path_v6, payload.next_hop_address); - - if (p.rd()) { - payload.next_hop_table_id = p.rd()->table_id(); - } - if (p.itf()) { - payload.next_hop_sw_if_index = p.itf()->handle().value(); - } - } else if (route::path::special_t::DROP == p.type()) { - payload.is_drop = 1; - } else if (route::path::special_t::UNREACH == p.type()) { - payload.is_unreach = 1; - } else if (route::path::special_t::PROHIBIT == p.type()) { - payload.is_prohibit = 1; - } else if (route::path::special_t::LOCAL == p.type()) { - payload.is_local = 1; - } - payload.next_hop_weight = p.weight(); - payload.next_hop_preference = p.preference(); - payload.next_hop_via_label = 0; - payload.classify_table_index = 0; -} - -update_cmd::update_cmd(HW::item& item, +update_cmd::update_cmd(HW::item& item, table_id_t id, const prefix_t& prefix, - const path_list_t& paths) - : rpc_cmd(item) + const path_list_t& pl) + : srpc_cmd(item) , m_id(id) , m_prefix(prefix) - , m_paths(paths) + , m_pl(pl) { - // no multipath yet. - assert(paths.size() == 1); } bool update_cmd::operator==(const update_cmd& other) const { - return ((m_prefix == other.m_prefix) && (m_id == other.m_id)); + return ((m_prefix == other.m_prefix) && (m_id == other.m_id) && + (m_pl == other.m_pl)); } rc_t update_cmd::issue(connection& con) { - msg_t req(con.ctx(), 0, std::ref(*this)); + msg_t req(con.ctx(), m_pl.size(), std::ref(*this)); auto& payload = req.get_request().get_payload(); - payload.table_id = m_id; + payload.route.table_id = m_id; payload.is_add = 1; - payload.is_multipath = 0; + payload.is_multipath = 1; - m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address, - &payload.dst_address_length); + payload.route.table_id = m_id; + payload.route.prefix = to_api(m_prefix); - for (auto& p : m_paths) - to_vpp(p, payload); + uint32_t ii = 0; + for (auto& p : m_pl) + to_api(p, payload.route.paths[ii++]); VAPI_CALL(req.execute()); - m_hw_item.set(wait()); - - return rc_t::OK; + return (wait()); } std::string @@ -110,12 +69,14 @@ update_cmd::to_string() const { std::ostringstream s; s << "ip-route-create: " << m_hw_item.to_string() << " table-id:" << m_id - << " prefix:" << m_prefix.to_string() << " paths:" << m_paths; + << " prefix:" << m_prefix.to_string() << " paths:"; + for (auto p : m_pl) + s << p.to_string() << " "; return (s.str()); } -delete_cmd::delete_cmd(HW::item& item, +delete_cmd::delete_cmd(HW::item& item, table_id_t id, const prefix_t& prefix) : rpc_cmd(item) @@ -136,11 +97,13 @@ delete_cmd::issue(connection& con) msg_t req(con.ctx(), 0, std::ref(*this)); auto& payload = req.get_request().get_payload(); - payload.table_id = m_id; payload.is_add = 0; + payload.is_multipath = 0; - m_prefix.to_vpp(&payload.is_ipv6, payload.dst_address, - &payload.dst_address_length); + payload.route.table_id = m_id; + payload.route.n_paths = 0; + payload.route.table_id = m_id; + payload.route.prefix = to_api(m_prefix); VAPI_CALL(req.execute()); @@ -160,48 +123,27 @@ delete_cmd::to_string() const return (s.str()); } -dump_v4_cmd::dump_v4_cmd() +dump_cmd::dump_cmd(route::table_id_t id, const l3_proto_t& proto) + : m_id(id) + , m_proto(proto) { } bool -dump_v4_cmd::operator==(const dump_v4_cmd& other) const +dump_cmd::operator==(const dump_cmd& other) const { return (true); } rc_t -dump_v4_cmd::issue(connection& con) +dump_cmd::issue(connection& con) { m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); - VAPI_CALL(m_dump->execute()); + auto& payload = m_dump->get_request().get_payload(); - wait(); - - return rc_t::OK; -} - -std::string -dump_v4_cmd::to_string() const -{ - return ("ip-route-v4-dump"); -} - -dump_v6_cmd::dump_v6_cmd() -{ -} - -bool -dump_v6_cmd::operator==(const dump_v6_cmd& other) const -{ - return (true); -} - -rc_t -dump_v6_cmd::issue(connection& con) -{ - m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); + payload.table.table_id = m_id; + payload.table.is_ip6 = m_proto.is_ipv6(); VAPI_CALL(m_dump->execute()); @@ -211,17 +153,19 @@ dump_v6_cmd::issue(connection& con) } std::string -dump_v6_cmd::to_string() const +dump_cmd::to_string() const { - return ("ip-route-v6-dump"); + return ("ip-route-v4-dump"); } + } // namespace ip_route_cmds } // namespace route } // namespace vom - /* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "mozilla") - * End: - */ + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */