From 9e2f91548b46ed9fb5fba4a7918eef7d93f9eab3 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Fri, 18 May 2018 02:27:10 -0700 Subject: IP unnumbered dump Change-Id: I4f245fd225bcc563fafee2696cd039477d661c57 Signed-off-by: Neale Ranns --- extras/vom/vom/bridge_domain_cmds.hpp | 2 +- extras/vom/vom/ip_unnumbered.cpp | 22 +++++++++++++++++++++- extras/vom/vom/ip_unnumbered_cmds.cpp | 27 +++++++++++++++++++++++++++ extras/vom/vom/ip_unnumbered_cmds.hpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) (limited to 'extras') diff --git a/extras/vom/vom/bridge_domain_cmds.hpp b/extras/vom/vom/bridge_domain_cmds.hpp index 0216236d42c..3257d83dc75 100644 --- a/extras/vom/vom/bridge_domain_cmds.hpp +++ b/extras/vom/vom/bridge_domain_cmds.hpp @@ -101,7 +101,7 @@ public: }; /** - * A cmd class that Dumps all the IPv4 L3 configs + * A cmd class that Dumps all the bridge domains */ class dump_cmd : public VOM::dump_cmd { diff --git a/extras/vom/vom/ip_unnumbered.cpp b/extras/vom/vom/ip_unnumbered.cpp index caeeb419993..74a6edeceeb 100644 --- a/extras/vom/vom/ip_unnumbered.cpp +++ b/extras/vom/vom/ip_unnumbered.cpp @@ -117,7 +117,27 @@ ip_unnumbered::event_handler::handle_replay() void ip_unnumbered::event_handler::handle_populate(const client_db::key_t& key) { - // VPP provides no dump for IP unnumbered + std::shared_ptr cmd = + std::make_shared(); + + HW::enqueue(cmd); + HW::write(); + + for (auto& ip_record : *cmd) { + auto& payload = ip_record.get_payload(); + + VOM_LOG(log_level_t::DEBUG) << "ip-unnumbered dump: " + << " itf: " << payload.sw_if_index + << " ip: " << payload.ip_sw_if_index; + + std::shared_ptr itf = interface::find(payload.sw_if_index); + std::shared_ptr ip_itf = interface::find(payload.ip_sw_if_index); + + if (itf && ip_itf) { + ip_unnumbered ipun(*itf, *ip_itf); + OM::commit(key, ipun); + } + } } dependency_t diff --git a/extras/vom/vom/ip_unnumbered_cmds.cpp b/extras/vom/vom/ip_unnumbered_cmds.cpp index 4c1fcf6d465..fa7a1150cc4 100644 --- a/extras/vom/vom/ip_unnumbered_cmds.cpp +++ b/extras/vom/vom/ip_unnumbered_cmds.cpp @@ -105,6 +105,33 @@ 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))); + + auto& payload = m_dump->get_request().get_payload(); + payload.sw_if_index = ~0; + + VAPI_CALL(m_dump->execute()); + + wait(); + + return rc_t::OK; +} + +std::string +dump_cmd::to_string() const +{ + return ("ip-unnumbered-dump"); +} + }; // namespace ip_unnumbered_cmds }; // namespace VOM diff --git a/extras/vom/vom/ip_unnumbered_cmds.hpp b/extras/vom/vom/ip_unnumbered_cmds.hpp index 0bb70276e45..40030139b8c 100644 --- a/extras/vom/vom/ip_unnumbered_cmds.hpp +++ b/extras/vom/vom/ip_unnumbered_cmds.hpp @@ -16,6 +16,7 @@ #ifndef __VOM_IP_UNNUMBERED_CMDS_H__ #define __VOM_IP_UNNUMBERED_CMDS_H__ +#include "vom/dump_cmd.hpp" #include "vom/ip_unnumbered.hpp" #include "vom/rpc_cmd.hpp" @@ -100,6 +101,37 @@ private: const handle_t& m_l3_itf; }; +/** + * A cmd class that Dumps all the IP unnumbered interfaces + */ +class dump_cmd : public VOM::dump_cmd +{ +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 item; +}; }; // namespace ip_unnumbered_cmds }; // namespace VOM -- cgit 1.2.3-korg