From 10e7a9f8d8c8572be16f9b3f0395da6f8eff22ec Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Tue, 14 Nov 2017 08:40:43 -0800 Subject: VOM: bridge-domain learning mode and route help commands Change-Id: I2fa219d6530f1e7a3b8ae32d35a0c60ba57c5129 Signed-off-by: Neale Ranns --- src/vpp-api/vom/bridge_domain.cpp | 19 +++++++++++++++--- src/vpp-api/vom/bridge_domain.hpp | 25 ++++++++++++++++++++++- src/vpp-api/vom/bridge_domain_cmds.cpp | 6 ++++-- src/vpp-api/vom/bridge_domain_cmds.hpp | 9 ++++++++- src/vpp-api/vom/inspect.hpp | 2 ++ src/vpp-api/vom/route.cpp | 1 + src/vpp-api/vom/route_domain.cpp | 34 ++++++++++++++++++++++++++++++++ src/vpp-api/vom/route_domain.hpp | 36 ++++++++++++++++++++++++++++++++++ test/ext/vom_test.cpp | 6 +++--- 9 files changed, 128 insertions(+), 10 deletions(-) diff --git a/src/vpp-api/vom/bridge_domain.cpp b/src/vpp-api/vom/bridge_domain.cpp index 8e012b5d951..81d83621212 100644 --- a/src/vpp-api/vom/bridge_domain.cpp +++ b/src/vpp-api/vom/bridge_domain.cpp @@ -19,6 +19,17 @@ #include "vom/l2_binding.hpp" namespace VOM { + +const bridge_domain::learning_mode_t bridge_domain::learning_mode_t::ON(1, + "on"); +const bridge_domain::learning_mode_t bridge_domain::learning_mode_t::OFF(0, + "off"); + +bridge_domain::learning_mode_t::learning_mode_t(int v, const std::string& s) + : enum_base(v, s) +{ +} + /** * A DB of al the interfaces, key on the name */ @@ -29,13 +40,15 @@ bridge_domain::event_handler bridge_domain::m_evh; /** * Construct a new object matching the desried state */ -bridge_domain::bridge_domain(uint32_t id) +bridge_domain::bridge_domain(uint32_t id, const learning_mode_t& lmode) : m_id(id) + , m_learning_mode(lmode) { } bridge_domain::bridge_domain(const bridge_domain& o) : m_id(o.m_id) + , m_learning_mode(o.m_learning_mode) { } @@ -58,7 +71,7 @@ void bridge_domain::replay() { if (rc_t::OK == m_id.rc()) { - HW::enqueue(new bridge_domain_cmds::create_cmd(m_id)); + HW::enqueue(new bridge_domain_cmds::create_cmd(m_id, m_learning_mode)); } } @@ -116,7 +129,7 @@ bridge_domain::update(const bridge_domain& desired) * the desired state is always that the interface should be created */ if (rc_t::OK != m_id.rc()) { - HW::enqueue(new bridge_domain_cmds::create_cmd(m_id)); + HW::enqueue(new bridge_domain_cmds::create_cmd(m_id, m_learning_mode)); } } diff --git a/src/vpp-api/vom/bridge_domain.hpp b/src/vpp-api/vom/bridge_domain.hpp index b42f53fce7b..2c134f0740b 100644 --- a/src/vpp-api/vom/bridge_domain.hpp +++ b/src/vpp-api/vom/bridge_domain.hpp @@ -31,6 +31,21 @@ namespace VOM { class bridge_domain : public object_base { public: + /** + * Bridge Domain Learning mode + */ + struct learning_mode_t : enum_base + { + const static learning_mode_t ON; + const static learning_mode_t OFF; + + private: + /** + * Private constructor taking the value and the string name + */ + learning_mode_t(int v, const std::string& s); + }; + /** * The value of the defaultbridge domain */ @@ -39,11 +54,14 @@ public: /** * Construct a new object matching the desried state */ - bridge_domain(uint32_t id); + bridge_domain(uint32_t id, + const learning_mode_t& lmode = learning_mode_t::ON); + /** * Copy Constructor */ bridge_domain(const bridge_domain& o); + /** * Destructor */ @@ -145,6 +163,11 @@ private: */ HW::item m_id; + /** + * The leanring mode of the bridge + */ + learning_mode_t m_learning_mode; + /** * A map of all interfaces key against the interface's name */ diff --git a/src/vpp-api/vom/bridge_domain_cmds.cpp b/src/vpp-api/vom/bridge_domain_cmds.cpp index 1b9dc1cff99..498569f9fab 100644 --- a/src/vpp-api/vom/bridge_domain_cmds.cpp +++ b/src/vpp-api/vom/bridge_domain_cmds.cpp @@ -19,8 +19,10 @@ DEFINE_VAPI_MSG_IDS_L2_API_JSON; namespace VOM { namespace bridge_domain_cmds { -create_cmd::create_cmd(HW::item& item) +create_cmd::create_cmd(HW::item& item, + const bridge_domain::learning_mode_t& lmode) : rpc_cmd(item) + , m_learning_mode(lmode) { } @@ -40,7 +42,7 @@ create_cmd::issue(connection& con) payload.flood = 1; payload.uu_flood = 1; payload.forward = 1; - payload.learn = 1; + payload.learn = m_learning_mode.value(); payload.arp_term = 1; payload.mac_age = 0; payload.is_add = 1; diff --git a/src/vpp-api/vom/bridge_domain_cmds.hpp b/src/vpp-api/vom/bridge_domain_cmds.hpp index c6226fd339b..f263b323e41 100644 --- a/src/vpp-api/vom/bridge_domain_cmds.hpp +++ b/src/vpp-api/vom/bridge_domain_cmds.hpp @@ -34,7 +34,8 @@ public: /** * Constructor */ - create_cmd(HW::item& item); + create_cmd(HW::item& item, + const bridge_domain::learning_mode_t& lmode); /** * Issue the command to VPP/HW @@ -49,6 +50,12 @@ public: * Comparison operator - only used for UT */ bool operator==(const create_cmd& i) const; + +private: + /** + * the learning mode for the bridge + */ + bridge_domain::learning_mode_t m_learning_mode; }; /** diff --git a/src/vpp-api/vom/inspect.hpp b/src/vpp-api/vom/inspect.hpp index fb9528decc0..d5bca3040d2 100644 --- a/src/vpp-api/vom/inspect.hpp +++ b/src/vpp-api/vom/inspect.hpp @@ -18,8 +18,10 @@ #include #include +#include #include #include +#include namespace VOM { /** diff --git a/src/vpp-api/vom/route.cpp b/src/vpp-api/vom/route.cpp index ece0768e634..e59bfbaaf8c 100644 --- a/src/vpp-api/vom/route.cpp +++ b/src/vpp-api/vom/route.cpp @@ -19,6 +19,7 @@ namespace VOM { namespace route { +ip_route::event_handler ip_route::m_evh; singular_db ip_route::m_db; const path::special_t path::special_t::STANDARD(0, "standard"); diff --git a/src/vpp-api/vom/route_domain.cpp b/src/vpp-api/vom/route_domain.cpp index f173fd7a250..08357faa6c5 100644 --- a/src/vpp-api/vom/route_domain.cpp +++ b/src/vpp-api/vom/route_domain.cpp @@ -18,6 +18,9 @@ #include "vom/route_domain_cmds.hpp" namespace VOM { + +route_domain::event_handler route_domain::m_evh; + /** * A DB of al the interfaces, key on the name */ @@ -164,7 +167,38 @@ route_domain::dump(std::ostream& os) { m_db.dump(os); } + +void +route_domain::event_handler::handle_populate(const client_db::key_t& key) +{ +} + +route_domain::event_handler::event_handler() +{ + OM::register_listener(this); + inspect::register_handler({ "rd", "route-domain" }, "Route Domains", this); +} + +void +route_domain::event_handler::handle_replay() +{ + m_db.replay(); +} + +dependency_t +route_domain::event_handler::order() const +{ + return (dependency_t::TABLE); } + +void +route_domain::event_handler::show(std::ostream& os) +{ + m_db.dump(os); +} + +}; // namespace VOPM + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vpp-api/vom/route_domain.hpp b/src/vpp-api/vom/route_domain.hpp index 0639fb95925..516271f7f66 100644 --- a/src/vpp-api/vom/route_domain.hpp +++ b/src/vpp-api/vom/route_domain.hpp @@ -16,6 +16,7 @@ #ifndef __VOM_ROUTE_DOMAIN_H__ #define __VOM_ROUTE_DOMAIN_H__ +#include "vom/inspect.hpp" #include "vom/object_base.hpp" #include "vom/om.hpp" #include "vom/prefix.hpp" @@ -93,6 +94,41 @@ public: void replay(void); private: + /** + * Class definition for listeners to OM events + */ + class event_handler : public OM::listener, public inspect::command_handler + { + public: + event_handler(); + virtual ~event_handler() = default; + + /** + * Handle a populate event + */ + void handle_populate(const client_db::key_t& key); + + /** + * Handle a replay event + */ + void handle_replay(); + + /** + * Show the object in the Singular DB + */ + void show(std::ostream& os); + + /** + * Get the sortable Id of the listener + */ + dependency_t order() const; + }; + + /** + * Instance of the event handler to register with OM + */ + static event_handler m_evh; + /** * Commit the acculmulated changes into VPP. i.e. to a 'HW" write. */ diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp index 5bec3a49583..788208376ef 100644 --- a/test/ext/vom_test.cpp +++ b/test/ext/vom_test.cpp @@ -760,7 +760,7 @@ BOOST_AUTO_TEST_CASE(test_bridge) { bridge_domain bd1(33); HW::item hw_bd(33, rc_t::OK); - ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd)); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::ON)); TRY_CHECK_RC(OM::write(franz, bd1)); @@ -858,10 +858,10 @@ BOOST_AUTO_TEST_CASE(test_vxlan) { TRY_CHECK_RC(OM::write(franz, vxt)); // bridge-domain create - bridge_domain bd1(33); + bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF); HW::item hw_bd(33, rc_t::OK); - ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd)); + ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::OFF)); TRY_CHECK_RC(OM::write(franz, bd1)); -- cgit 1.2.3-korg