summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-03-14 02:22:24 -0700
committerDamjan Marion <dmarion@me.com>2019-03-14 13:05:46 +0000
commit2331e48ff981e83b46f82c661383f398c63c2bb7 (patch)
tree3253dfe16bb531880085b9994f33307869dc5be9 /extras
parent6348074be4a7efd30f7f6af4c4ec940076afe2fe (diff)
GBP: Endpoint flags
Change-Id: I4d70985ad078e84ec23ce704c8b76e2ac7809419 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/gbp_endpoint.cpp27
-rw-r--r--extras/vom/vom/gbp_endpoint.hpp26
-rw-r--r--extras/vom/vom/gbp_endpoint_cmds.cpp31
-rw-r--r--extras/vom/vom/gbp_endpoint_cmds.hpp4
4 files changed, 75 insertions, 13 deletions
diff --git a/extras/vom/vom/gbp_endpoint.cpp b/extras/vom/vom/gbp_endpoint.cpp
index 20f966cfb20..ef406b16565 100644
--- a/extras/vom/vom/gbp_endpoint.cpp
+++ b/extras/vom/vom/gbp_endpoint.cpp
@@ -24,16 +24,29 @@ singular_db<gbp_endpoint::key_t, gbp_endpoint> gbp_endpoint::m_db;
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(
const interface& itf,
const std::vector<boost::asio::ip::address>& ip_addrs,
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_itf(itf.singular())
, m_ips(ip_addrs)
, m_mac(mac)
, 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_mac(gbpe.m_mac)
, m_epg(gbpe.m_epg)
+ , m_flags(gbpe.m_flags)
{
}
@@ -61,7 +75,8 @@ gbp_endpoint::key() const
bool
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
@@ -77,8 +92,8 @@ void
gbp_endpoint::replay()
{
if (m_hdl) {
- HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hdl, m_itf->handle(), m_ips,
- m_mac, m_epg->sclass()));
+ HW::enqueue(new gbp_endpoint_cmds::create_cmd(
+ 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)
{
if (rc_t::OK != m_hdl.rc()) {
- HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hdl, m_itf->handle(), m_ips,
- m_mac, m_epg->sclass()));
+ HW::enqueue(new gbp_endpoint_cmds::create_cmd(
+ m_hdl, m_itf->handle(), m_ips, m_mac, m_epg->sclass(), m_flags));
}
}
diff --git a/extras/vom/vom/gbp_endpoint.hpp b/extras/vom/vom/gbp_endpoint.hpp
index d27ad90a4df..8008e3b1c67 100644
--- a/extras/vom/vom/gbp_endpoint.hpp
+++ b/extras/vom/vom/gbp_endpoint.hpp
@@ -31,6 +31,24 @@ class gbp_endpoint : public object_base
{
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
*/
typedef std::pair<interface::key_t, mac_address_t> key_t;
@@ -41,7 +59,8 @@ public:
gbp_endpoint(const interface& itf,
const std::vector<boost::asio::ip::address>& ip_addr,
const mac_address_t& mac,
- const gbp_endpoint_group& epg);
+ const gbp_endpoint_group& epg,
+ const flags_t& flags = flags_t::NONE);
/**
* Copy Construct
@@ -175,6 +194,11 @@ private:
std::shared_ptr<gbp_endpoint_group> m_epg;
/**
+ * Endpoint flags
+ */
+ flags_t m_flags;
+
+ /**
* A map of all bridge_domains
*/
static singular_db<key_t, gbp_endpoint> m_db;
diff --git a/extras/vom/vom/gbp_endpoint_cmds.cpp b/extras/vom/vom/gbp_endpoint_cmds.cpp
index 77c75488099..f0c55ebc4da 100644
--- a/extras/vom/vom/gbp_endpoint_cmds.cpp
+++ b/extras/vom/vom/gbp_endpoint_cmds.cpp
@@ -21,16 +21,35 @@ DEFINE_VAPI_MSG_IDS_GBP_API_JSON;
namespace VOM {
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,
const handle_t& itf,
const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac,
- sclass_t sclass)
+ sclass_t sclass,
+ const gbp_endpoint::flags_t& flags)
: rpc_cmd(item)
, m_itf(itf)
, m_ip_addrs(ip_addrs)
, m_mac(mac)
, m_sclass(sclass)
+ , m_flags(flags)
{
}
@@ -38,7 +57,8 @@ bool
create_cmd::operator==(const create_cmd& other) const
{
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
@@ -52,9 +72,10 @@ create_cmd::issue(connection& con)
payload.endpoint.sw_if_index = m_itf.value();
payload.endpoint.sclass = m_sclass;
payload.endpoint.n_ips = m_ip_addrs.size();
+ payload.endpoint.flags = to_api(m_flags);
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);
@@ -92,8 +113,8 @@ create_cmd::to_string() const
for (auto ip : m_ip_addrs)
s << ip.to_string();
- s << "] mac:" << m_mac;
- s << " slcass:" << m_sclass;
+ s << "] mac:" << m_mac << " slcass:" << m_sclass
+ << " flags:" << m_flags.to_string();
return (s.str());
}
diff --git a/extras/vom/vom/gbp_endpoint_cmds.hpp b/extras/vom/vom/gbp_endpoint_cmds.hpp
index 2aa56f8312e..4b9036aca00 100644
--- a/extras/vom/vom/gbp_endpoint_cmds.hpp
+++ b/extras/vom/vom/gbp_endpoint_cmds.hpp
@@ -37,7 +37,8 @@ public:
const handle_t& itf,
const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac,
- sclass_t sclass);
+ sclass_t sclass,
+ const gbp_endpoint::flags_t& flags);
/**
* Issue the command to VPP/HW
@@ -61,6 +62,7 @@ private:
const std::vector<boost::asio::ip::address> m_ip_addrs;
const mac_address_t m_mac;
const sclass_t m_sclass;
+ const gbp_endpoint::flags_t m_flags;
};
/**