aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-02-12 06:18:30 -0800
committerNeale Ranns <nranns@cisco.com>2019-02-13 09:06:44 +0000
commit6fef74ad3083f630648eae65545a0dd46af1102e (patch)
tree8b7ad67c063ae41ef7acfd15fa7f406198e6e7c7 /extras/vom
parent22ad815d654294d77ccbb2b7286a73b544bf3f52 (diff)
VOM: neighbour API flags
Change-Id: Ia664cd4c77f1c5b4bc46c5e191bb57704b3ccc46 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/vom/api_types.cpp28
-rw-r--r--extras/vom/vom/api_types.hpp4
-rw-r--r--extras/vom/vom/enum_base.hpp21
-rw-r--r--extras/vom/vom/neighbour.cpp47
-rw-r--r--extras/vom/vom/neighbour.hpp32
-rw-r--r--extras/vom/vom/neighbour_cmds.cpp14
-rw-r--r--extras/vom/vom/neighbour_cmds.hpp8
-rw-r--r--extras/vom/vom/route.cpp2
8 files changed, 131 insertions, 25 deletions
diff --git a/extras/vom/vom/api_types.cpp b/extras/vom/vom/api_types.cpp
index 486ebdacb6d..ea75d7fd8ee 100644
--- a/extras/vom/vom/api_types.cpp
+++ b/extras/vom/vom/api_types.cpp
@@ -17,6 +17,34 @@
namespace VOM {
+vapi_enum_ip_neighbor_flags
+to_api(const neighbour::flags_t& f)
+{
+ vapi_enum_ip_neighbor_flags out = IP_API_NEIGHBOR_FLAG_NONE;
+
+ if (f & neighbour::flags_t::STATIC)
+ out = static_cast<vapi_enum_ip_neighbor_flags>(out |
+ IP_API_NEIGHBOR_FLAG_STATIC);
+ if (f & neighbour::flags_t::NO_FIB_ENTRY)
+ out = static_cast<vapi_enum_ip_neighbor_flags>(
+ out | IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY);
+
+ return (out);
+}
+
+const neighbour::flags_t
+from_api(vapi_enum_ip_neighbor_flags f)
+{
+ neighbour::flags_t out = neighbour::flags_t::NONE;
+
+ if (f & IP_API_NEIGHBOR_FLAG_STATIC)
+ out |= neighbour::flags_t::STATIC;
+ if (f & IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY)
+ out |= neighbour::flags_t::NO_FIB_ENTRY;
+
+ return out;
+}
+
void
to_api(const boost::asio::ip::address_v4& a, vapi_type_ip4_address& v)
{
diff --git a/extras/vom/vom/api_types.hpp b/extras/vom/vom/api_types.hpp
index ac9a65e84af..789bbb19401 100644
--- a/extras/vom/vom/api_types.hpp
+++ b/extras/vom/vom/api_types.hpp
@@ -14,6 +14,7 @@
*/
#include <boost/asio/ip/address.hpp>
+#include <vom/neighbour.hpp>
#include <vom/prefix.hpp>
#include <vom/types.hpp>
@@ -23,6 +24,9 @@ namespace VOM {
typedef boost::asio::ip::address ip_address_t;
+vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t& f);
+const neighbour::flags_t from_api(vapi_enum_ip_neighbor_flags f);
+
void to_api(const ip_address_t& a, vapi_type_address& v);
void to_api(const boost::asio::ip::address_v4& a, vapi_type_ip4_address& v);
void to_api(const boost::asio::ip::address_v6& a, vapi_type_ip6_address& v);
diff --git a/extras/vom/vom/enum_base.hpp b/extras/vom/vom/enum_base.hpp
index 6756e2498de..015410a57c5 100644
--- a/extras/vom/vom/enum_base.hpp
+++ b/extras/vom/vom/enum_base.hpp
@@ -52,6 +52,27 @@ public:
}
/**
+ * bitwise or assignemnt
+ */
+ enum_base& operator|=(const enum_base& e)
+ {
+ m_value += e.m_value;
+ m_desc += ":" + e.m_desc;
+
+ return *this;
+ }
+
+ /**
+ * bitwise or
+ */
+ enum_base operator|(const enum_base& e1) const
+ {
+ enum_base e = *this;
+ e |= e1;
+ return e;
+ }
+
+ /**
* Comparison operator
*/
bool operator!=(const enum_base& e) const { return (e.m_value != m_value); }
diff --git a/extras/vom/vom/neighbour.cpp b/extras/vom/vom/neighbour.cpp
index cbcebd69f7d..a97892d7cdb 100644
--- a/extras/vom/vom/neighbour.cpp
+++ b/extras/vom/vom/neighbour.cpp
@@ -22,21 +22,33 @@ namespace VOM {
singular_db<neighbour::key_t, neighbour> neighbour::m_db;
neighbour::event_handler neighbour::m_evh;
+const neighbour::flags_t neighbour::flags_t::NONE(0, "");
+const neighbour::flags_t neighbour::flags_t::STATIC(1, "static");
+const neighbour::flags_t neighbour::flags_t::NO_FIB_ENTRY(2, "no-fib-entry");
+
+neighbour::flags_t::flags_t(int v, const std::string s)
+ : enum_base(v, s)
+{
+}
+
neighbour::neighbour(const interface& itf,
const boost::asio::ip::address& ip_addr,
- const mac_address_t& mac)
+ const mac_address_t& mac,
+ const flags_t flags)
: m_hw(false)
, m_itf(itf.singular())
, m_ip_addr(ip_addr)
, m_mac(mac)
+ , m_flags(flags)
{
}
-neighbour::neighbour(const neighbour& bde)
- : m_hw(bde.m_hw)
- , m_itf(bde.m_itf)
- , m_ip_addr(bde.m_ip_addr)
- , m_mac(bde.m_mac)
+neighbour::neighbour(const neighbour& n)
+ : m_hw(n.m_hw)
+ , m_itf(n.m_itf)
+ , m_ip_addr(n.m_ip_addr)
+ , m_mac(n.m_mac)
+ , m_flags(n.m_flags)
{
}
@@ -64,8 +76,8 @@ void
neighbour::sweep()
{
if (m_hw) {
- HW::enqueue(
- new neighbour_cmds::delete_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(new neighbour_cmds::delete_cmd(m_hw, m_itf->handle(), m_mac,
+ m_ip_addr, m_flags));
}
HW::write();
}
@@ -74,8 +86,8 @@ void
neighbour::replay()
{
if (m_hw) {
- HW::enqueue(
- new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac,
+ m_ip_addr, m_flags));
}
}
@@ -84,7 +96,7 @@ neighbour::to_string() const
{
std::ostringstream s;
s << "neighbour:[" << m_itf->to_string() << ", " << m_mac.to_string() << ", "
- << m_ip_addr.to_string() << "]";
+ << m_ip_addr.to_string() << " " << m_flags.to_string() << "]";
return (s.str());
}
@@ -96,8 +108,8 @@ neighbour::update(const neighbour& r)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(
- new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac, m_ip_addr));
+ HW::enqueue(new neighbour_cmds::create_cmd(m_hw, m_itf->handle(), m_mac,
+ m_ip_addr, m_flags));
}
}
@@ -168,10 +180,13 @@ neighbour::populate_i(const client_db::key_t& key,
mac_address_t mac = from_api(payload.neighbor.mac_address);
boost::asio::ip::address ip_addr = from_api(payload.neighbor.ip_address);
- neighbour n(*itf, ip_addr, mac);
+ neighbour::flags_t f = from_api(payload.neighbor.flags);
+ neighbour n(*itf, ip_addr, mac, f);
+ ;
- VOM_LOG(log_level_t::DEBUG) << "neighbour-dump: " << itf->to_string()
- << mac.to_string() << ip_addr.to_string();
+ VOM_LOG(log_level_t::DEBUG) << "neighbour-dump: " << itf->to_string() << " "
+ << mac.to_string() << " " << ip_addr.to_string()
+ << " " << f.to_string();
/*
* Write each of the discovered interfaces into the OM,
diff --git a/extras/vom/vom/neighbour.hpp b/extras/vom/vom/neighbour.hpp
index 500f03d0a61..4e074bf7f45 100644
--- a/extras/vom/vom/neighbour.hpp
+++ b/extras/vom/vom/neighbour.hpp
@@ -27,6 +27,30 @@ namespace VOM {
class neighbour : public object_base
{
public:
+ struct flags_t : public enum_base<flags_t>
+ {
+ /**
+ * Constructor
+ */
+ flags_t(int v, const std::string s);
+
+ /**
+ * Destructor
+ */
+ ~flags_t() = default;
+
+ flags_t operator|(const flags_t& e1) const
+ {
+ flags_t e = *this;
+ e |= e1;
+ return e;
+ }
+
+ const static flags_t NONE;
+ const static flags_t STATIC;
+ const static flags_t NO_FIB_ENTRY;
+ };
+
/**
* The key for a neighbour entry;
* the interface and IP address
@@ -38,7 +62,8 @@ public:
*/
neighbour(const interface& itf,
const boost::asio::ip::address& ip_addr,
- const mac_address_t& mac);
+ const mac_address_t& mac,
+ const flags_t flags = flags_t::STATIC);
/**
* Copy Construct
@@ -174,6 +199,11 @@ private:
mac_address_t m_mac;
/**
+ * flags on the entry
+ */
+ flags_t m_flags;
+
+ /**
* A map of all bridge_domains
*/
static singular_db<key_t, neighbour> m_db;
diff --git a/extras/vom/vom/neighbour_cmds.cpp b/extras/vom/vom/neighbour_cmds.cpp
index d43e508e1f5..5f9e180b01d 100644
--- a/extras/vom/vom/neighbour_cmds.cpp
+++ b/extras/vom/vom/neighbour_cmds.cpp
@@ -21,11 +21,13 @@ namespace neighbour_cmds {
create_cmd::create_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t& flags)
: rpc_cmd(item)
, m_itf(itf)
, m_mac(mac)
, m_ip_addr(ip_addr)
+ , m_flags(flags)
{
}
@@ -33,7 +35,7 @@ bool
create_cmd::operator==(const create_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_ip_addr == other.m_ip_addr) &&
- (m_itf == other.m_itf));
+ (m_itf == other.m_itf) && (m_flags == other.m_flags));
}
rc_t
@@ -44,10 +46,10 @@ create_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
payload.neighbor.sw_if_index = m_itf.value();
- payload.neighbor.flags = IP_API_NEIGHBOR_FLAG_STATIC;
to_api(m_mac, payload.neighbor.mac_address);
to_api(m_ip_addr, payload.neighbor.ip_address);
+ payload.neighbor.flags = to_api(m_flags);
VAPI_CALL(req.execute());
@@ -68,11 +70,13 @@ create_cmd::to_string() const
delete_cmd::delete_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t& flags)
: rpc_cmd(item)
, m_itf(itf)
, m_mac(mac)
, m_ip_addr(ip_addr)
+ , m_flags(flags)
{
}
@@ -91,10 +95,10 @@ delete_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
payload.neighbor.sw_if_index = m_itf.value();
- payload.neighbor.flags = IP_API_NEIGHBOR_FLAG_STATIC;
to_api(m_mac, payload.neighbor.mac_address);
to_api(m_ip_addr, payload.neighbor.ip_address);
+ payload.neighbor.flags = to_api(m_flags);
VAPI_CALL(req.execute());
diff --git a/extras/vom/vom/neighbour_cmds.hpp b/extras/vom/vom/neighbour_cmds.hpp
index 388dbf1b7ba..d43a6fe8f3b 100644
--- a/extras/vom/vom/neighbour_cmds.hpp
+++ b/extras/vom/vom/neighbour_cmds.hpp
@@ -37,7 +37,8 @@ public:
create_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t &flags);
/**
* Issue the command to VPP/HW
@@ -58,6 +59,7 @@ private:
handle_t m_itf;
mac_address_t m_mac;
boost::asio::ip::address m_ip_addr;
+ const neighbour::flags_t &m_flags;
};
/**
@@ -73,7 +75,8 @@ public:
delete_cmd(HW::item<bool>& item,
handle_t itf,
const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr);
+ const boost::asio::ip::address& ip_addr,
+ const neighbour::flags_t &flags);
/**
* Issue the command to VPP/HW
@@ -94,6 +97,7 @@ private:
handle_t m_itf;
mac_address_t m_mac;
boost::asio::ip::address m_ip_addr;
+ const neighbour::flags_t &m_flags;
};
/**
diff --git a/extras/vom/vom/route.cpp b/extras/vom/vom/route.cpp
index ae80fd9e55c..722628fee87 100644
--- a/extras/vom/vom/route.cpp
+++ b/extras/vom/vom/route.cpp
@@ -678,7 +678,7 @@ ip_mroute::event_handler::handle_populate(const client_db::key_t& key)
ip_r.add(from_vpp(p.path, nh_proto_t::IPV4),
itf_flags_t::from_vpp(p.itf_flags));
}
- VOM_LOG(log_level_t::INFO) << "ip-mroute-dump: " << ip_r.to_string();
+ VOM_LOG(log_level_t::DEBUG) << "ip-mroute-dump: " << ip_r.to_string();
/*
* Write each of the discovered interfaces into the OM,