diff options
Diffstat (limited to 'extras/vom')
-rw-r--r-- | extras/vom/vom/interface.cpp | 26 | ||||
-rw-r--r-- | extras/vom/vom/interface.hpp | 7 | ||||
-rw-r--r-- | extras/vom/vom/interface_factory.cpp | 20 | ||||
-rw-r--r-- | extras/vom/vom/interface_factory.hpp | 3 | ||||
-rw-r--r-- | extras/vom/vom/interface_types.cpp | 13 | ||||
-rw-r--r-- | extras/vom/vom/ip_punt_redirect.cpp | 66 | ||||
-rw-r--r-- | extras/vom/vom/ip_punt_redirect.hpp | 16 | ||||
-rw-r--r-- | extras/vom/vom/ip_punt_redirect_cmds.cpp | 34 | ||||
-rw-r--r-- | extras/vom/vom/ip_punt_redirect_cmds.hpp | 49 | ||||
-rw-r--r-- | extras/vom/vom/tap_interface.cpp | 25 | ||||
-rw-r--r-- | extras/vom/vom/tap_interface.hpp | 15 | ||||
-rw-r--r-- | extras/vom/vom/tap_interface_cmds.cpp | 120 | ||||
-rw-r--r-- | extras/vom/vom/tap_interface_cmds.hpp | 77 |
13 files changed, 174 insertions, 297 deletions
diff --git a/extras/vom/vom/interface.cpp b/extras/vom/vom/interface.cpp index 4f26ac80313..371682333c7 100644 --- a/extras/vom/vom/interface.cpp +++ b/extras/vom/vom/interface.cpp @@ -287,7 +287,7 @@ interface::mk_create_cmd(std::queue<cmd*>& q) q.push(new interface_cmds::af_packet_create_cmd(m_hdl, m_name)); if (!m_tag.empty()) q.push(new interface_cmds::set_tag(m_hdl, m_tag)); - } else if (type_t::TAP == m_type || type_t::TAPV2 == m_type) { + } else if (type_t::TAPV2 == m_type) { if (!m_tag.empty()) q.push(new interface_cmds::set_tag(m_hdl, m_tag)); } else if (type_t::VHOST == m_type) { @@ -523,28 +523,6 @@ interface::event_handler::handle_populate(const client_db::key_t& key) } /* - * dump VPP tap interfaces - */ - std::shared_ptr<tap_interface_cmds::tap_dump_cmd> tapcmd = - std::make_shared<tap_interface_cmds::tap_dump_cmd>(); - - HW::enqueue(tapcmd); - HW::write(); - - for (auto& tap_record : *tapcmd) { - std::shared_ptr<tap_interface> tapitf = - interface_factory::new_tap_interface(tap_record.get_payload()); - VOM_LOG(log_level_t::DEBUG) << "tap-dump: " << tapitf->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 - */ - OM::commit(key, *tapitf); - } - - /* * dump VPP tapv2 interfaces */ std::shared_ptr<tap_interface_cmds::tapv2_dump_cmd> tapv2cmd = @@ -555,7 +533,7 @@ interface::event_handler::handle_populate(const client_db::key_t& key) for (auto& tapv2_record : *tapv2cmd) { std::shared_ptr<tap_interface> tapv2itf = - interface_factory::new_tap_v2_interface(tapv2_record.get_payload()); + interface_factory::new_tap_interface(tapv2_record.get_payload()); VOM_LOG(log_level_t::DEBUG) << "tapv2-dump: " << tapv2itf->to_string(); /* diff --git a/extras/vom/vom/interface.hpp b/extras/vom/vom/interface.hpp index a46b114833e..1096bcb332c 100644 --- a/extras/vom/vom/interface.hpp +++ b/extras/vom/vom/interface.hpp @@ -94,10 +94,6 @@ public: * Local interface type (specific to VPP) */ const static type_t LOCAL; - /** - * TAP interface type - */ - const static type_t TAP; /** * TAPv2 interface type @@ -322,7 +318,8 @@ public: int sw_if_index = reply.get_response().get_payload().sw_if_index; int retval = reply.get_response().get_payload().retval; - VOM_LOG(log_level_t::DEBUG) << this->to_string() << " " << retval; + VOM_LOG(log_level_t::DEBUG) << this->to_string() << " res:" << retval + << " sw-if-index:" << sw_if_index; rc_t rc = rc_t::from_vpp_retval(retval); handle_t handle = handle_t::INVALID; diff --git a/extras/vom/vom/interface_factory.cpp b/extras/vom/vom/interface_factory.cpp index fd135f5820e..abb26f84a6f 100644 --- a/extras/vom/vom/interface_factory.cpp +++ b/extras/vom/vom/interface_factory.cpp @@ -76,7 +76,7 @@ interface_factory::new_interface(const vapi_payload_sw_interface_details& vd) /* * pull out the other special cases */ - if (interface::type_t::TAP == type || interface::type_t::TAPV2 == type) { + if (interface::type_t::TAPV2 == type) { /* * TAP interfaces */ @@ -165,21 +165,6 @@ interface_factory::new_af_packet_interface( std::shared_ptr<tap_interface> interface_factory::new_tap_interface( - const vapi_payload_sw_interface_tap_details& vd) -{ - std::shared_ptr<tap_interface> sp; - std::string name = reinterpret_cast<const char*>(vd.dev_name); - handle_t hdl(vd.sw_if_index); - - sp = tap_interface(name, interface::type_t::TAP, interface::admin_state_t::UP, - route::prefix_t::ZERO) - .singular(); - sp->set(hdl); - return (sp); -} - -std::shared_ptr<tap_interface> -interface_factory::new_tap_v2_interface( const vapi_payload_sw_interface_tap_v2_details& vd) { std::shared_ptr<tap_interface> sp; @@ -196,8 +181,7 @@ interface_factory::new_tap_v2_interface( route::prefix_t(1, (uint8_t*)vd.host_ip6_addr, vd.host_ip6_prefix_len); l2_address_t l2_address(vd.host_mac_addr, 6); - sp = tap_interface(name, interface::type_t::TAPV2, - interface::admin_state_t::UP, pfx, l2_address) + sp = tap_interface(name, interface::admin_state_t::UP, pfx, l2_address) .singular(); sp->set(hdl); diff --git a/extras/vom/vom/interface_factory.hpp b/extras/vom/vom/interface_factory.hpp index 120816bddba..c90c7942c52 100644 --- a/extras/vom/vom/interface_factory.hpp +++ b/extras/vom/vom/interface_factory.hpp @@ -50,9 +50,6 @@ public: const vapi_payload_af_packet_details& vd); static std::shared_ptr<tap_interface> new_tap_interface( - const vapi_payload_sw_interface_tap_details& vd); - - static std::shared_ptr<tap_interface> new_tap_v2_interface( const vapi_payload_sw_interface_tap_v2_details& vd); static std::shared_ptr<bond_interface> new_bond_interface( diff --git a/extras/vom/vom/interface_types.cpp b/extras/vom/vom/interface_types.cpp index 73400373743..b63e4633ff8 100644 --- a/extras/vom/vom/interface_types.cpp +++ b/extras/vom/vom/interface_types.cpp @@ -25,12 +25,11 @@ const interface::type_t interface::type_t::VXLAN(3, "VXLAN"); const interface::type_t interface::type_t::AFPACKET(4, "AFPACKET"); const interface::type_t interface::type_t::LOOPBACK(5, "LOOPBACK"); const interface::type_t interface::type_t::LOCAL(6, "LOCAL"); -const interface::type_t interface::type_t::TAP(7, "TAP"); -const interface::type_t interface::type_t::TAPV2(8, "TAPV2"); -const interface::type_t interface::type_t::VHOST(9, "VHOST"); -const interface::type_t interface::type_t::BOND(10, "Bond"); -const interface::type_t interface::type_t::PIPE(11, "Pipe"); -const interface::type_t interface::type_t::PIPE_END(12, "Pipe-end"); +const interface::type_t interface::type_t::TAPV2(7, "TAPV2"); +const interface::type_t interface::type_t::VHOST(8, "VHOST"); +const interface::type_t interface::type_t::BOND(9, "Bond"); +const interface::type_t interface::type_t::PIPE(10, "Pipe"); +const interface::type_t interface::type_t::PIPE_END(11, "Pipe-end"); const interface::oper_state_t interface::oper_state_t::DOWN(0, "down"); const interface::oper_state_t interface::oper_state_t::UP(1, "up"); @@ -63,7 +62,7 @@ interface::type_t::from_string(const std::string& str) return interface::type_t::LOCAL; } else if ((str.find("tapcli") != std::string::npos) || (str.find("tuntap") != std::string::npos)) { - return interface::type_t::TAP; + return interface::type_t::UNKNOWN; } else if (str.find("tap") != std::string::npos) { return interface::type_t::TAPV2; } else if (str.find("bvi") != std::string::npos) { diff --git a/extras/vom/vom/ip_punt_redirect.cpp b/extras/vom/vom/ip_punt_redirect.cpp index 195b5914884..853546fe397 100644 --- a/extras/vom/vom/ip_punt_redirect.cpp +++ b/extras/vom/vom/ip_punt_redirect.cpp @@ -14,6 +14,7 @@ */ #include "vom/ip_punt_redirect.hpp" +#include "vom/api_types.hpp" #include "vom/ip_punt_redirect_cmds.hpp" #include "vom/singular_db_funcs.hpp" @@ -34,6 +35,14 @@ ip_punt_redirect::ip_punt_redirect(const interface& rx_itf, { } +ip_punt_redirect::ip_punt_redirect(const interface& tx_itf, + const boost::asio::ip::address& addr) + : m_rx_itf(nullptr) + , m_tx_itf(tx_itf.singular()) + , m_addr(addr) +{ +} + ip_punt_redirect::ip_punt_redirect(const ip_punt_redirect& o) : m_rx_itf(o.m_rx_itf) , m_tx_itf(o.m_tx_itf) @@ -47,7 +56,16 @@ ip_punt_redirect::~ip_punt_redirect() sweep(); // not in the DB anymore. - m_db.release(m_rx_itf->key(), this); + m_db.release(key(), this); +} + +const ip_punt_redirect::key_t +ip_punt_redirect::key() const +{ + if (m_rx_itf) + return m_rx_itf->key(); + else + return ("ALL"); } void @@ -55,7 +73,8 @@ ip_punt_redirect::sweep() { if (m_config) { HW::enqueue(new ip_punt_redirect_cmds::unconfig_cmd( - m_config, m_rx_itf->handle(), m_tx_itf->handle(), m_addr)); + m_config, (m_rx_itf ? m_rx_itf->handle() : handle_t::INVALID), + m_tx_itf->handle(), m_addr)); } HW::write(); } @@ -71,7 +90,8 @@ ip_punt_redirect::replay() { if (m_config) { HW::enqueue(new ip_punt_redirect_cmds::config_cmd( - m_config, m_rx_itf->handle(), m_tx_itf->handle(), m_addr)); + m_config, (m_rx_itf ? m_rx_itf->handle() : handle_t::INVALID), + m_tx_itf->handle(), m_addr)); } } @@ -79,9 +99,9 @@ std::string ip_punt_redirect::to_string() const { std::ostringstream s; - s << "IP-punt-redirect-config:" - << " rx-itf:" << m_rx_itf->to_string() - << " tx-itf:" << m_tx_itf->to_string() << " next-hop:" << m_addr; + s << "IP-punt-redirect:" + << " rx-itf:" << key() << " tx-itf:" << m_tx_itf->to_string() + << " next-hop:" << m_addr; return (s.str()); } @@ -91,14 +111,15 @@ ip_punt_redirect::update(const ip_punt_redirect& desired) { if (!m_config) { HW::enqueue(new ip_punt_redirect_cmds::config_cmd( - m_config, m_rx_itf->handle(), m_tx_itf->handle(), m_addr)); + m_config, (m_rx_itf ? m_rx_itf->handle() : handle_t::INVALID), + m_tx_itf->handle(), m_addr)); } } std::shared_ptr<ip_punt_redirect> ip_punt_redirect::find_or_add(const ip_punt_redirect& temp) { - return (m_db.find_or_add(temp.m_rx_itf->key(), temp)); + return (m_db.find_or_add(temp.key(), temp)); } std::shared_ptr<ip_punt_redirect> @@ -123,6 +144,35 @@ ip_punt_redirect::event_handler::handle_replay() void ip_punt_redirect::event_handler::handle_populate(const client_db::key_t& key) { + std::shared_ptr<ip_punt_redirect_cmds::dump_cmd> cmd = + std::make_shared<ip_punt_redirect_cmds::dump_cmd>(); + + HW::enqueue(cmd); + HW::write(); + + for (auto& record : *cmd) { + auto& payload = record.get_payload(); + + std::shared_ptr<interface> tx_itf = + interface::find(payload.punt.tx_sw_if_index); + std::shared_ptr<interface> rx_itf = + interface::find(payload.punt.rx_sw_if_index); + boost::asio::ip::address nh = from_api(payload.punt.nh); + + VOM_LOG(log_level_t::DEBUG) << "data: [" << payload.punt.tx_sw_if_index + << ", " << payload.punt.rx_sw_if_index << ", " + << nh << "]"; + + if (rx_itf && tx_itf) { + ip_punt_redirect ipr(*rx_itf, *tx_itf, nh); + OM::commit(key, ipr); + VOM_LOG(log_level_t::DEBUG) << "read: " << ipr.to_string(); + } else if (tx_itf) { + ip_punt_redirect ipr(*tx_itf, nh); + OM::commit(key, ipr); + VOM_LOG(log_level_t::DEBUG) << "read: " << ipr.to_string(); + } + } } dependency_t diff --git a/extras/vom/vom/ip_punt_redirect.hpp b/extras/vom/vom/ip_punt_redirect.hpp index 6cda0d2b3ba..ed9cf34992c 100644 --- a/extras/vom/vom/ip_punt_redirect.hpp +++ b/extras/vom/vom/ip_punt_redirect.hpp @@ -42,6 +42,15 @@ public: const boost::asio::ip::address& addr); /** + * Construct a new object matching the desried state + * + * @param tx_itf - The interface to which traffic should be redirected. + * @param addr - The next hop ip address to redirect the traffic. + */ + ip_punt_redirect(const interface& tx_itf, + const boost::asio::ip::address& addr); + + /** * Copy Constructor */ ip_punt_redirect(const ip_punt_redirect& o); @@ -73,8 +82,13 @@ public: typedef interface::key_t key_t; /** - * Find an singular instance in the DB for the interface passed + * return the object's key */ + const key_t key() const; + + /** + * Find an singular instance in the DB for the interface passed + */ static std::shared_ptr<ip_punt_redirect> find(const interface& i); private: diff --git a/extras/vom/vom/ip_punt_redirect_cmds.cpp b/extras/vom/vom/ip_punt_redirect_cmds.cpp index eda6929e2d1..135ef6a4e64 100644 --- a/extras/vom/vom/ip_punt_redirect_cmds.cpp +++ b/extras/vom/vom/ip_punt_redirect_cmds.cpp @@ -20,8 +20,8 @@ namespace VOM { namespace ip_punt_redirect_cmds { config_cmd::config_cmd(HW::item<bool>& item, - const handle_t& rx_itf, - const handle_t& tx_itf, + const handle_t rx_itf, + const handle_t tx_itf, const boost::asio::ip::address& addr) : rpc_cmd(item) , m_rx_itf(rx_itf) @@ -58,7 +58,7 @@ std::string config_cmd::to_string() const { std::ostringstream s; - s << "IP-punt-redirect-config: " << m_hw_item.to_string() + s << "IP-punt-redirect: " << m_hw_item.to_string() << " rx-itf:" << m_rx_itf.to_string() << " tx-itf:" << m_tx_itf.to_string() << " next-hop:" << m_addr; @@ -66,8 +66,8 @@ config_cmd::to_string() const } unconfig_cmd::unconfig_cmd(HW::item<bool>& item, - const handle_t& rx_itf, - const handle_t& tx_itf, + const handle_t rx_itf, + const handle_t tx_itf, const boost::asio::ip::address& addr) : rpc_cmd(item) , m_rx_itf(rx_itf) @@ -114,6 +114,30 @@ unconfig_cmd::to_string() const return (s.str()); } +bool +dump_cmd::operator==(const dump_cmd& other) const +{ + return (true); +} + +rc_t +dump_cmd::issue(connection& con) +{ + m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); + + VAPI_CALL(m_dump->execute()); + + wait(); + + return rc_t::OK; +} + +std::string +dump_cmd::to_string() const +{ + return ("ip-punt-redirect-dump"); +} + }; // namespace ip_punt_redirect_cmds }; // namespace VOM diff --git a/extras/vom/vom/ip_punt_redirect_cmds.hpp b/extras/vom/vom/ip_punt_redirect_cmds.hpp index d7408af97ec..22e2a62a23c 100644 --- a/extras/vom/vom/ip_punt_redirect_cmds.hpp +++ b/extras/vom/vom/ip_punt_redirect_cmds.hpp @@ -16,6 +16,7 @@ #ifndef __VOM_IP_PUNT_REDIRECT_CMDS_H__ #define __VOM_IP_PUNT_REDIRECT_CMDS_H__ +#include "vom/dump_cmd.hpp" #include "vom/ip_punt_redirect.hpp" #include "vom/rpc_cmd.hpp" @@ -34,8 +35,8 @@ public: * Constructor */ config_cmd(HW::item<bool>& item, - const handle_t& rx_itf, - const handle_t& tx_itf, + const handle_t rx_itf, + const handle_t tx_itf, const boost::asio::ip::address& addr); /** @@ -56,11 +57,11 @@ private: /** * Reference to the interface from which traffic is coming */ - const handle_t& m_rx_itf; + const handle_t m_rx_itf; /** * Reference to the interface where traffic will be redirected */ - const handle_t& m_tx_itf; + const handle_t m_tx_itf; /** * Reference to nexh hop ip address @@ -78,8 +79,8 @@ public: * Constructor */ unconfig_cmd(HW::item<bool>& item, - const handle_t& rx_itf, - const handle_t& tx_itf, + const handle_t rx_itf, + const handle_t tx_itf, const boost::asio::ip::address& addr); /** @@ -100,11 +101,11 @@ private: /** * Reference to the interface from which traffic is coming */ - const handle_t& m_rx_itf; + const handle_t m_rx_itf; /** * Reference to the interface where traffic will be redirected */ - const handle_t& m_tx_itf; + const handle_t m_tx_itf; /** * Reference to nexh hop ip address @@ -112,6 +113,38 @@ private: const boost::asio::ip::address& m_addr; }; +/** + * A cmd class that Dumps all the IP punt redirect + */ +class dump_cmd : public VOM::dump_cmd<vapi::Ip_punt_redirect_dump> +{ +public: + /** + * Constructor + */ + dump_cmd() = default; + + /** + * Issue the command to VPP/HW + */ + rc_t issue(connection& con); + /** + * convert to string format for debug purposes + */ + std::string to_string() const; + + /** + * Comparison operator - only used for UT + */ + bool operator==(const dump_cmd& i) const; + +private: + /** + * HW reutrn code + */ + HW::item<bool> item; +}; + }; // namespace ip_punt_redirect_cmds }; // namespace VOM diff --git a/extras/vom/vom/tap_interface.cpp b/extras/vom/vom/tap_interface.cpp index 4054e26466c..6555aeae5ee 100644 --- a/extras/vom/vom/tap_interface.cpp +++ b/extras/vom/vom/tap_interface.cpp @@ -25,21 +25,19 @@ tap_interface::event_handler tap_interface::m_evh; * Construct a new object matching the desried state */ tap_interface::tap_interface(const std::string& name, - type_t type, - admin_state_t state, - route::prefix_t prefix) - : interface(name, type, state) + const admin_state_t& state, + const route::prefix_t& prefix) + : interface(name, type_t::TAPV2, state) , m_prefix(prefix) , m_l2_address(l2_address_t::ZERO) { } tap_interface::tap_interface(const std::string& name, - type_t type, - admin_state_t state, - route::prefix_t prefix, + const admin_state_t& state, + const route::prefix_t& prefix, const l2_address_t& l2_address) - : interface(name, type, state) + : interface(name, type_t::TAPV2, state) , m_prefix(prefix) , m_l2_address(l2_address) { @@ -61,11 +59,7 @@ tap_interface::tap_interface(const tap_interface& o) std::queue<cmd*>& tap_interface::mk_create_cmd(std::queue<cmd*>& q) { - if (type_t::TAPV2 == type()) - q.push(new tap_interface_cmds::tapv2_create_cmd(m_hdl, name(), m_prefix, - m_l2_address)); - else - q.push(new tap_interface_cmds::tap_create_cmd(m_hdl, name(), m_prefix, + q.push(new tap_interface_cmds::tapv2_create_cmd(m_hdl, name(), m_prefix, m_l2_address)); return (q); @@ -74,10 +68,7 @@ tap_interface::mk_create_cmd(std::queue<cmd*>& q) std::queue<cmd*>& tap_interface::mk_delete_cmd(std::queue<cmd*>& q) { - if (type_t::TAPV2 == type()) - q.push(new tap_interface_cmds::tapv2_delete_cmd(m_hdl)); - else - q.push(new tap_interface_cmds::tap_delete_cmd(m_hdl)); + q.push(new tap_interface_cmds::tapv2_delete_cmd(m_hdl)); return (q); } diff --git a/extras/vom/vom/tap_interface.hpp b/extras/vom/vom/tap_interface.hpp index 3b0072d4a7d..a29ad358b52 100644 --- a/extras/vom/vom/tap_interface.hpp +++ b/extras/vom/vom/tap_interface.hpp @@ -26,14 +26,12 @@ class tap_interface : public interface { public: tap_interface(const std::string& name, - type_t type, - admin_state_t state, - route::prefix_t prefix); + const admin_state_t& state, + const route::prefix_t& prefix); tap_interface(const std::string& name, - type_t type, - admin_state_t state, - route::prefix_t prefix, + const admin_state_t& state, + const route::prefix_t& prefix, const l2_address_t& l2_address); ~tap_interface(); @@ -87,11 +85,6 @@ private: l2_address_t m_l2_address; /** - * interface is a friend so it can construct with handles - */ - friend class interface; - - /** * Return the matching 'instance' of the sub-interface * over-ride from the base class */ diff --git a/extras/vom/vom/tap_interface_cmds.cpp b/extras/vom/vom/tap_interface_cmds.cpp index 4ebd2be4cf0..ffe3e97ba0c 100644 --- a/extras/vom/vom/tap_interface_cmds.cpp +++ b/extras/vom/vom/tap_interface_cmds.cpp @@ -23,127 +23,12 @@ DEFINE_VAPI_MSG_IDS_TAPV2_API_JSON; namespace VOM { namespace tap_interface_cmds { -tap_create_cmd::tap_create_cmd(HW::item<handle_t>& item, - const std::string& name, - route::prefix_t& prefix, - const l2_address_t& l2_address) - : interface::create_cmd<vapi::Tap_connect>(item, name) - , m_prefix(prefix) - , m_l2_address(l2_address) -{ -} - -rc_t -tap_create_cmd::issue(connection& con) -{ - msg_t req(con.ctx(), std::ref(*this)); - - auto& payload = req.get_request().get_payload(); - memset(payload.tap_name, 0, sizeof(payload.tap_name)); - memcpy(payload.tap_name, m_name.c_str(), - std::min(m_name.length(), sizeof(payload.tap_name))); - if (m_prefix != route::prefix_t::ZERO) { - if (m_prefix.address().is_v6()) { - m_prefix.to_vpp(&payload.ip6_address_set, payload.ip6_address, - &payload.ip6_mask_width); - } else { - m_prefix.to_vpp(&payload.ip4_address_set, payload.ip4_address, - &payload.ip4_mask_width); - payload.ip4_address_set = 1; - } - } - - if (m_l2_address != l2_address_t::ZERO) { - m_l2_address.to_bytes(payload.mac_address, 6); - } else { - payload.use_random_mac = 1; - } - - VAPI_CALL(req.execute()); - - wait(); - if (m_hw_item.rc() == rc_t::OK) { - insert_interface(); - } - - return (m_hw_item.rc()); -} - -std::string -tap_create_cmd::to_string() const -{ - std::ostringstream s; - s << "tap-intf-create: " << m_hw_item.to_string() - << " ip-prefix:" << m_prefix.to_string(); - - return (s.str()); -} - -tap_delete_cmd::tap_delete_cmd(HW::item<handle_t>& item) - : interface::delete_cmd<vapi::Tap_delete>(item) -{ -} - -rc_t -tap_delete_cmd::issue(connection& con) -{ - msg_t req(con.ctx(), std::ref(*this)); - - auto& payload = req.get_request().get_payload(); - payload.sw_if_index = m_hw_item.data().value(); - - VAPI_CALL(req.execute()); - - wait(); - m_hw_item.set(rc_t::NOOP); - - remove_interface(); - return rc_t::OK; -} - -std::string -tap_delete_cmd::to_string() const -{ - std::ostringstream s; - s << "tap-itf-delete: " << m_hw_item.to_string(); - - return (s.str()); -} - -tap_dump_cmd::tap_dump_cmd() -{ -} - -bool -tap_dump_cmd::operator==(const tap_dump_cmd& other) const -{ - return (true); -} - -rc_t -tap_dump_cmd::issue(connection& con) -{ - m_dump.reset(new msg_t(con.ctx(), std::ref(*this))); - - VAPI_CALL(m_dump->execute()); - - wait(); - - return rc_t::OK; -} - -std::string -tap_dump_cmd::to_string() const -{ - return ("tap-itf-dump"); -} - /* * TAPV2 */ tapv2_create_cmd::tapv2_create_cmd(HW::item<handle_t>& item, const std::string& name, - route::prefix_t& prefix, + const route::prefix_t& prefix, const l2_address_t& l2_address) : interface::create_cmd<vapi::Tap_create_v2>(item, name) , m_prefix(prefix) @@ -185,7 +70,8 @@ tapv2_create_cmd::issue(connection& con) VAPI_CALL(req.execute()); - m_hw_item = wait(); + wait(); + if (m_hw_item.rc() == rc_t::OK) { insert_interface(); } diff --git a/extras/vom/vom/tap_interface_cmds.hpp b/extras/vom/vom/tap_interface_cmds.hpp index 5651b7cf193..84720fa3f8e 100644 --- a/extras/vom/vom/tap_interface_cmds.hpp +++ b/extras/vom/vom/tap_interface_cmds.hpp @@ -31,82 +31,13 @@ namespace tap_interface_cmds { /** * A functor class that creates an interface */ -class tap_create_cmd : public interface::create_cmd<vapi::Tap_connect> -{ -public: - tap_create_cmd(HW::item<handle_t>& item, - const std::string& name, - route::prefix_t& prefix, - const l2_address_t& l2_address); - - /** - * Issue the command to VPP/HW - */ - rc_t issue(connection& con); - /** - * convert to string format for debug purposes - */ - std::string to_string() const; - -private: - route::prefix_t& m_prefix; - const l2_address_t& m_l2_address; -}; - -/** - * A functor class that deletes a Tap interface - */ -class tap_delete_cmd : public interface::delete_cmd<vapi::Tap_delete> -{ -public: - tap_delete_cmd(HW::item<handle_t>& item); - - /** - * Issue the command to VPP/HW - */ - rc_t issue(connection& con); - /** - * convert to string format for debug purposes - */ - std::string to_string() const; -}; - -/** - * A cmd class that Dumps all the Vpp Interfaces - */ -class tap_dump_cmd : public VOM::dump_cmd<vapi::Sw_interface_tap_dump> -{ -public: - /** - * Default Constructor - */ - tap_dump_cmd(); - - /** - * Issue the command to VPP/HW - */ - rc_t issue(connection& con); - /** - * convert to string format for debug purposes - */ - std::string to_string() const; - - /** - * Comparison operator - only used for UT - */ - bool operator==(const tap_dump_cmd& i) const; -}; - -/** - * A functor class that creates an interface - */ class tapv2_create_cmd : public interface::create_cmd<vapi::Tap_create_v2> { public: tapv2_create_cmd(HW::item<handle_t>& item, - const std::string& name, - route::prefix_t& prefix, - const l2_address_t& l2_address); + const std::string& name, + const route::prefix_t& prefix, + const l2_address_t& l2_address); /** * Issue the command to VPP/HW @@ -118,7 +49,7 @@ public: std::string to_string() const; private: - route::prefix_t& m_prefix; + const route::prefix_t& m_prefix; const l2_address_t& m_l2_address; }; |