VOM: bridge-domain learning mode and route help commands

Change-Id: I2fa219d6530f1e7a3b8ae32d35a0c60ba57c5129
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
This commit is contained in:
Neale Ranns
2017-11-14 08:40:43 -08:00
committed by Neale Ranns
parent a161a6dedb
commit 10e7a9f8d8
9 changed files with 128 additions and 10 deletions

View File

@ -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<bridge_domain::learning_mode_t>(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));
}
}

View File

@ -31,6 +31,21 @@ namespace VOM {
class bridge_domain : public object_base
{
public:
/**
* Bridge Domain Learning mode
*/
struct learning_mode_t : enum_base<learning_mode_t>
{
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<uint32_t> 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
*/

View File

@ -19,8 +19,10 @@ DEFINE_VAPI_MSG_IDS_L2_API_JSON;
namespace VOM {
namespace bridge_domain_cmds {
create_cmd::create_cmd(HW::item<uint32_t>& item)
create_cmd::create_cmd(HW::item<uint32_t>& 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;

View File

@ -34,7 +34,8 @@ public:
/**
* Constructor
*/
create_cmd(HW::item<uint32_t>& item);
create_cmd(HW::item<uint32_t>& 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;
};
/**

View File

@ -18,8 +18,10 @@
#include <deque>
#include <map>
#include <memory>
#include <ostream>
#include <string>
#include <vector>
namespace VOM {
/**

View File

@ -19,6 +19,7 @@
namespace VOM {
namespace route {
ip_route::event_handler ip_route::m_evh;
singular_db<ip_route::key_t, ip_route> ip_route::m_db;
const path::special_t path::special_t::STANDARD(0, "standard");

View File

@ -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
*

View File

@ -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.
*/

View File

@ -760,7 +760,7 @@ BOOST_AUTO_TEST_CASE(test_bridge) {
bridge_domain bd1(33);
HW::item<uint32_t> 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<uint32_t> 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));