diff options
author | Neale Ranns <nranns@cisco.com> | 2018-05-22 08:40:52 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2018-05-25 11:45:48 +0000 |
commit | 0053de63ec4bf8b9bce7817f1b61c9791baf6c26 (patch) | |
tree | 17fe95628d3b9f5c3d226c3ff79fb2b3027a2b80 /extras/vom | |
parent | 096e6be4bda3b409aa6fc400d0ce507ea415f26b (diff) |
ARP proxy dumps
Change-Id: I8335ebf266becf2f42bb3f28a17dfed8d9b08f97
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras/vom')
-rw-r--r-- | extras/vom/vom/arp_proxy_binding.cpp | 27 | ||||
-rw-r--r-- | extras/vom/vom/arp_proxy_binding.hpp | 7 | ||||
-rw-r--r-- | extras/vom/vom/arp_proxy_binding_cmds.cpp | 24 | ||||
-rw-r--r-- | extras/vom/vom/arp_proxy_binding_cmds.hpp | 36 | ||||
-rw-r--r-- | extras/vom/vom/arp_proxy_config.cpp | 17 | ||||
-rw-r--r-- | extras/vom/vom/arp_proxy_config_cmds.cpp | 33 | ||||
-rw-r--r-- | extras/vom/vom/arp_proxy_config_cmds.hpp | 35 |
7 files changed, 159 insertions, 20 deletions
diff --git a/extras/vom/vom/arp_proxy_binding.cpp b/extras/vom/vom/arp_proxy_binding.cpp index 73d3d844f53..bbae9f683eb 100644 --- a/extras/vom/vom/arp_proxy_binding.cpp +++ b/extras/vom/vom/arp_proxy_binding.cpp @@ -26,17 +26,14 @@ singular_db<interface::key_t, arp_proxy_binding> arp_proxy_binding::m_db; arp_proxy_binding::event_handler arp_proxy_binding::m_evh; -arp_proxy_binding::arp_proxy_binding(const interface& itf, - const arp_proxy_config& proxy_cfg) +arp_proxy_binding::arp_proxy_binding(const interface& itf) : m_itf(itf.singular()) - , m_arp_proxy_cfg(proxy_cfg.singular()) , m_binding(true) { } arp_proxy_binding::arp_proxy_binding(const arp_proxy_binding& o) : m_itf(o.m_itf) - , m_arp_proxy_cfg(o.m_arp_proxy_cfg) , m_binding(o.m_binding) { } @@ -44,8 +41,6 @@ arp_proxy_binding::arp_proxy_binding(const arp_proxy_binding& o) arp_proxy_binding::~arp_proxy_binding() { sweep(); - - // not in the DB anymore. m_db.release(m_itf->key(), this); } @@ -123,7 +118,25 @@ arp_proxy_binding::event_handler::handle_replay() void arp_proxy_binding::event_handler::handle_populate(const client_db::key_t& key) { - // FIXME + std::shared_ptr<arp_proxy_binding_cmds::dump_cmd> cmd = + std::make_shared<arp_proxy_binding_cmds::dump_cmd>(); + + HW::enqueue(cmd); + HW::write(); + + for (auto& record : *cmd) { + auto& payload = record.get_payload(); + + std::shared_ptr<interface> itf = interface::find(payload.sw_if_index); + + if (itf) { + arp_proxy_binding ab(*itf); + OM::commit(key, ab); + } else { + VOM_LOG(log_level_t::ERROR) << "arp-proxy-binding dump:" + << " itf:" << payload.sw_if_index; + } + } } dependency_t diff --git a/extras/vom/vom/arp_proxy_binding.hpp b/extras/vom/vom/arp_proxy_binding.hpp index f57f6971991..284cf7371fa 100644 --- a/extras/vom/vom/arp_proxy_binding.hpp +++ b/extras/vom/vom/arp_proxy_binding.hpp @@ -34,7 +34,7 @@ public: /** * Construct a new object matching the desried state */ - arp_proxy_binding(const interface& itf, const arp_proxy_config& proxy_cfg); + arp_proxy_binding(const interface& itf); /** * Copy Constructor @@ -136,11 +136,6 @@ private: const std::shared_ptr<interface> m_itf; /** - * A reference counting pointer to the prxy config. - */ - const std::shared_ptr<arp_proxy_config> m_arp_proxy_cfg; - - /** * HW configuration for the binding. The bool representing the * do/don't bind. */ diff --git a/extras/vom/vom/arp_proxy_binding_cmds.cpp b/extras/vom/vom/arp_proxy_binding_cmds.cpp index 675feef9b8d..2314d531add 100644 --- a/extras/vom/vom/arp_proxy_binding_cmds.cpp +++ b/extras/vom/vom/arp_proxy_binding_cmds.cpp @@ -95,6 +95,30 @@ unbind_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 ("ARP-proxy-binding-dump"); +} + }; // namespace arp_proxy_binding_cmds }; // namespace VOM diff --git a/extras/vom/vom/arp_proxy_binding_cmds.hpp b/extras/vom/vom/arp_proxy_binding_cmds.hpp index c73bb13aee3..fcf0a4a2530 100644 --- a/extras/vom/vom/arp_proxy_binding_cmds.hpp +++ b/extras/vom/vom/arp_proxy_binding_cmds.hpp @@ -17,6 +17,7 @@ #define __VOM_ARP_PROXY_BINDING_CMDS_H__ #include "vom/arp_proxy_binding.hpp" +#include "vom/dump_cmd.hpp" #include <vapi/vpe.api.vapi.hpp> @@ -87,8 +88,41 @@ private: */ const handle_t& m_itf; }; + +/** + * A cmd class that Dumps all the Proxy ARP configs + */ +class dump_cmd : public VOM::dump_cmd<vapi::Proxy_arp_intfc_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 cmds +}; // namespace VOM /* * fd.io coding-style-patch-verification: ON diff --git a/extras/vom/vom/arp_proxy_config.cpp b/extras/vom/vom/arp_proxy_config.cpp index 3973eba55f9..275d9f9bf74 100644 --- a/extras/vom/vom/arp_proxy_config.cpp +++ b/extras/vom/vom/arp_proxy_config.cpp @@ -15,6 +15,7 @@ #include "vom/arp_proxy_config.hpp" #include "vom/arp_proxy_config_cmds.hpp" +#include "vom/prefix.hpp" #include "vom/singular_db_funcs.hpp" namespace VOM { @@ -115,7 +116,21 @@ arp_proxy_config::event_handler::handle_replay() void arp_proxy_config::event_handler::handle_populate(const client_db::key_t& key) { - // VPP provides no dump for ARP proxy. + std::shared_ptr<arp_proxy_config_cmds::dump_cmd> cmd = + std::make_shared<arp_proxy_config_cmds::dump_cmd>(); + + HW::enqueue(cmd); + HW::write(); + + for (auto& record : *cmd) { + auto& payload = record.get_payload(); + + boost::asio::ip::address lo = from_bytes(0, payload.proxy.low_address); + boost::asio::ip::address hi = from_bytes(0, payload.proxy.hi_address); + + arp_proxy_config ap(lo.to_v4(), hi.to_v4()); + OM::commit(key, ap); + } } dependency_t diff --git a/extras/vom/vom/arp_proxy_config_cmds.cpp b/extras/vom/vom/arp_proxy_config_cmds.cpp index cf7fad5d90d..122c51bdb95 100644 --- a/extras/vom/vom/arp_proxy_config_cmds.cpp +++ b/extras/vom/vom/arp_proxy_config_cmds.cpp @@ -42,9 +42,9 @@ config_cmd::issue(connection& con) payload.is_add = 1; std::copy_n(std::begin(m_low.to_bytes()), m_low.to_bytes().size(), - payload.low_address); + payload.proxy.low_address); std::copy_n(std::begin(m_high.to_bytes()), m_high.to_bytes().size(), - payload.hi_address); + payload.proxy.hi_address); VAPI_CALL(req.execute()); @@ -87,9 +87,9 @@ unconfig_cmd::issue(connection& con) payload.is_add = 0; std::copy_n(std::begin(m_low.to_bytes()), m_low.to_bytes().size(), - payload.low_address); + payload.proxy.low_address); std::copy_n(std::begin(m_high.to_bytes()), m_high.to_bytes().size(), - payload.hi_address); + payload.proxy.hi_address); VAPI_CALL(req.execute()); @@ -108,9 +108,34 @@ 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 ("ARP-proxy-dump"); +} + +}; // namesapce cmds +}; // namespace VOM + /* * fd.io coding-style-patch-verification: ON * diff --git a/extras/vom/vom/arp_proxy_config_cmds.hpp b/extras/vom/vom/arp_proxy_config_cmds.hpp index ac0e1fd1702..77abc74556b 100644 --- a/extras/vom/vom/arp_proxy_config_cmds.hpp +++ b/extras/vom/vom/arp_proxy_config_cmds.hpp @@ -94,8 +94,41 @@ private: const boost::asio::ip::address_v4 m_low; const boost::asio::ip::address_v4 m_high; }; + +/** + * A cmd class that Dumps all the Proxy ARP configs + */ +class dump_cmd : public VOM::dump_cmd<vapi::Proxy_arp_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 cmds +}; // namespace VOM /* * fd.io coding-style-patch-verification: ON |