GBP: Endpoint flags

Change-Id: I4d70985ad078e84ec23ce704c8b76e2ac7809419
Signed-off-by: Neale Ranns <nranns@cisco.com>
This commit is contained in:
Neale Ranns
2019-03-14 02:22:24 -07:00
committed by Damjan Marion
parent 6348074be4
commit 2331e48ff9
4 changed files with 75 additions and 13 deletions

View File

@ -24,16 +24,29 @@ singular_db<gbp_endpoint::key_t, gbp_endpoint> gbp_endpoint::m_db;
gbp_endpoint::event_handler gbp_endpoint::m_evh; gbp_endpoint::event_handler gbp_endpoint::m_evh;
const gbp_endpoint::flags_t gbp_endpoint::flags_t::NONE(0, "none");
const gbp_endpoint::flags_t gbp_endpoint::flags_t::BOUNCE(1, "bounce");
const gbp_endpoint::flags_t gbp_endpoint::flags_t::LEARNT(2, "learnt");
const gbp_endpoint::flags_t gbp_endpoint::flags_t::REMOTE(4, "remote");
const gbp_endpoint::flags_t gbp_endpoint::flags_t::EXTERNAL(8, "external");
gbp_endpoint::flags_t::flags_t(int v, const std::string& s)
: enum_base<gbp_endpoint::flags_t>(v, s)
{
}
gbp_endpoint::gbp_endpoint( gbp_endpoint::gbp_endpoint(
const interface& itf, const interface& itf,
const std::vector<boost::asio::ip::address>& ip_addrs, const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac, const mac_address_t& mac,
const gbp_endpoint_group& epg) const gbp_endpoint_group& epg,
const flags_t& flags)
: m_hdl(handle_t::INVALID) : m_hdl(handle_t::INVALID)
, m_itf(itf.singular()) , m_itf(itf.singular())
, m_ips(ip_addrs) , m_ips(ip_addrs)
, m_mac(mac) , m_mac(mac)
, m_epg(epg.singular()) , m_epg(epg.singular())
, m_flags(flags)
{ {
} }
@ -43,6 +56,7 @@ gbp_endpoint::gbp_endpoint(const gbp_endpoint& gbpe)
, m_ips(gbpe.m_ips) , m_ips(gbpe.m_ips)
, m_mac(gbpe.m_mac) , m_mac(gbpe.m_mac)
, m_epg(gbpe.m_epg) , m_epg(gbpe.m_epg)
, m_flags(gbpe.m_flags)
{ {
} }
@ -61,7 +75,8 @@ gbp_endpoint::key() const
bool bool
gbp_endpoint::operator==(const gbp_endpoint& gbpe) const gbp_endpoint::operator==(const gbp_endpoint& gbpe) const
{ {
return ((key() == gbpe.key()) && (m_epg == gbpe.m_epg)); return ((key() == gbpe.key()) && (m_epg == gbpe.m_epg) &&
(m_flags == gbpe.m_flags));
} }
void void
@ -77,8 +92,8 @@ void
gbp_endpoint::replay() gbp_endpoint::replay()
{ {
if (m_hdl) { if (m_hdl) {
HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hdl, m_itf->handle(), m_ips, HW::enqueue(new gbp_endpoint_cmds::create_cmd(
m_mac, m_epg->sclass())); m_hdl, m_itf->handle(), m_ips, m_mac, m_epg->sclass(), m_flags));
} }
} }
@ -100,8 +115,8 @@ void
gbp_endpoint::update(const gbp_endpoint& r) gbp_endpoint::update(const gbp_endpoint& r)
{ {
if (rc_t::OK != m_hdl.rc()) { if (rc_t::OK != m_hdl.rc()) {
HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hdl, m_itf->handle(), m_ips, HW::enqueue(new gbp_endpoint_cmds::create_cmd(
m_mac, m_epg->sclass())); m_hdl, m_itf->handle(), m_ips, m_mac, m_epg->sclass(), m_flags));
} }
} }

View File

@ -30,6 +30,24 @@ namespace VOM {
class gbp_endpoint : public object_base class gbp_endpoint : public object_base
{ {
public: public:
/**
* Endpoint flags
*/
struct flags_t : enum_base<flags_t>
{
const static flags_t NONE;
const static flags_t BOUNCE;
const static flags_t REMOTE;
const static flags_t LEARNT;
const static flags_t EXTERNAL;
private:
/**
* Private constructor taking the value and the string name
*/
flags_t(int v, const std::string& s);
};
/** /**
* The key for a GBP endpoint; interface and IP * The key for a GBP endpoint; interface and IP
*/ */
@ -41,7 +59,8 @@ public:
gbp_endpoint(const interface& itf, gbp_endpoint(const interface& itf,
const std::vector<boost::asio::ip::address>& ip_addr, const std::vector<boost::asio::ip::address>& ip_addr,
const mac_address_t& mac, const mac_address_t& mac,
const gbp_endpoint_group& epg); const gbp_endpoint_group& epg,
const flags_t& flags = flags_t::NONE);
/** /**
* Copy Construct * Copy Construct
@ -174,6 +193,11 @@ private:
*/ */
std::shared_ptr<gbp_endpoint_group> m_epg; std::shared_ptr<gbp_endpoint_group> m_epg;
/**
* Endpoint flags
*/
flags_t m_flags;
/** /**
* A map of all bridge_domains * A map of all bridge_domains
*/ */

View File

@ -21,16 +21,35 @@ DEFINE_VAPI_MSG_IDS_GBP_API_JSON;
namespace VOM { namespace VOM {
namespace gbp_endpoint_cmds { namespace gbp_endpoint_cmds {
static vapi_enum_gbp_endpoint_flags
to_api(const gbp_endpoint::flags_t& in)
{
vapi_enum_gbp_endpoint_flags out = GBP_API_ENDPOINT_FLAG_NONE;
if (in & gbp_endpoint::flags_t::REMOTE)
out = (vapi_enum_gbp_endpoint_flags)(out | GBP_API_ENDPOINT_FLAG_REMOTE);
if (in & gbp_endpoint::flags_t::BOUNCE)
out = (vapi_enum_gbp_endpoint_flags)(out | GBP_API_ENDPOINT_FLAG_BOUNCE);
if (in & gbp_endpoint::flags_t::LEARNT)
out = (vapi_enum_gbp_endpoint_flags)(out | GBP_API_ENDPOINT_FLAG_LEARNT);
if (in & gbp_endpoint::flags_t::EXTERNAL)
out = (vapi_enum_gbp_endpoint_flags)(out | GBP_API_ENDPOINT_FLAG_EXTERNAL);
return (out);
}
create_cmd::create_cmd(HW::item<handle_t>& item, create_cmd::create_cmd(HW::item<handle_t>& item,
const handle_t& itf, const handle_t& itf,
const std::vector<boost::asio::ip::address>& ip_addrs, const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac, const mac_address_t& mac,
sclass_t sclass) sclass_t sclass,
const gbp_endpoint::flags_t& flags)
: rpc_cmd(item) : rpc_cmd(item)
, m_itf(itf) , m_itf(itf)
, m_ip_addrs(ip_addrs) , m_ip_addrs(ip_addrs)
, m_mac(mac) , m_mac(mac)
, m_sclass(sclass) , m_sclass(sclass)
, m_flags(flags)
{ {
} }
@ -38,7 +57,8 @@ bool
create_cmd::operator==(const create_cmd& other) const create_cmd::operator==(const create_cmd& other) const
{ {
return ((m_itf == other.m_itf) && (m_ip_addrs == other.m_ip_addrs) && return ((m_itf == other.m_itf) && (m_ip_addrs == other.m_ip_addrs) &&
(m_mac == other.m_mac) && (m_sclass == other.m_sclass)); (m_mac == other.m_mac) && (m_sclass == other.m_sclass) &&
(m_flags == other.m_flags));
} }
rc_t rc_t
@ -52,9 +72,10 @@ create_cmd::issue(connection& con)
payload.endpoint.sw_if_index = m_itf.value(); payload.endpoint.sw_if_index = m_itf.value();
payload.endpoint.sclass = m_sclass; payload.endpoint.sclass = m_sclass;
payload.endpoint.n_ips = m_ip_addrs.size(); payload.endpoint.n_ips = m_ip_addrs.size();
payload.endpoint.flags = to_api(m_flags);
for (n = 0; n < payload.endpoint.n_ips; n++) { for (n = 0; n < payload.endpoint.n_ips; n++) {
to_api(m_ip_addrs[n], payload.endpoint.ips[n]); VOM::to_api(m_ip_addrs[n], payload.endpoint.ips[n]);
} }
to_api(m_mac, payload.endpoint.mac); to_api(m_mac, payload.endpoint.mac);
@ -92,8 +113,8 @@ create_cmd::to_string() const
for (auto ip : m_ip_addrs) for (auto ip : m_ip_addrs)
s << ip.to_string(); s << ip.to_string();
s << "] mac:" << m_mac; s << "] mac:" << m_mac << " slcass:" << m_sclass
s << " slcass:" << m_sclass; << " flags:" << m_flags.to_string();
return (s.str()); return (s.str());
} }

View File

@ -37,7 +37,8 @@ public:
const handle_t& itf, const handle_t& itf,
const std::vector<boost::asio::ip::address>& ip_addrs, const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac, const mac_address_t& mac,
sclass_t sclass); sclass_t sclass,
const gbp_endpoint::flags_t& flags);
/** /**
* Issue the command to VPP/HW * Issue the command to VPP/HW
@ -61,6 +62,7 @@ private:
const std::vector<boost::asio::ip::address> m_ip_addrs; const std::vector<boost::asio::ip::address> m_ip_addrs;
const mac_address_t m_mac; const mac_address_t m_mac;
const sclass_t m_sclass; const sclass_t m_sclass;
const gbp_endpoint::flags_t m_flags;
}; };
/** /**