aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/gbp_endpoint.cpp59
-rw-r--r--extras/vom/vom/gbp_endpoint.hpp9
-rw-r--r--extras/vom/vom/gbp_endpoint_cmds.cpp65
-rw-r--r--extras/vom/vom/gbp_endpoint_cmds.hpp19
-rw-r--r--extras/vom/vom/gbp_subnet.cpp4
-rw-r--r--extras/vom/vom/gbp_subnet_cmds.cpp7
-rw-r--r--extras/vom/vom/prefix.hpp5
7 files changed, 104 insertions, 64 deletions
diff --git a/extras/vom/vom/gbp_endpoint.cpp b/extras/vom/vom/gbp_endpoint.cpp
index 9762a91429a..236a961ae20 100644
--- a/extras/vom/vom/gbp_endpoint.cpp
+++ b/extras/vom/vom/gbp_endpoint.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/gbp_endpoint.hpp"
+#include "vom/api_types.hpp"
#include "vom/gbp_endpoint_cmds.hpp"
#include "vom/singular_db_funcs.hpp"
@@ -23,22 +24,23 @@ singular_db<gbp_endpoint::key_t, gbp_endpoint> gbp_endpoint::m_db;
gbp_endpoint::event_handler gbp_endpoint::m_evh;
-gbp_endpoint::gbp_endpoint(const interface& itf,
- const boost::asio::ip::address& ip_addr,
- const mac_address_t& mac,
- const gbp_endpoint_group& epg)
- : m_hw(false)
+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)
+ : m_hdl(handle_t::INVALID)
, m_itf(itf.singular())
- , m_ip(ip_addr)
+ , m_ips(ip_addrs)
, m_mac(mac)
, m_epg(epg.singular())
{
}
gbp_endpoint::gbp_endpoint(const gbp_endpoint& gbpe)
- : m_hw(gbpe.m_hw)
+ : m_hdl(gbpe.m_hdl)
, m_itf(gbpe.m_itf)
- , m_ip(gbpe.m_ip)
+ , m_ips(gbpe.m_ips)
, m_mac(gbpe.m_mac)
, m_epg(gbpe.m_epg)
{
@@ -53,7 +55,7 @@ gbp_endpoint::~gbp_endpoint()
const gbp_endpoint::key_t
gbp_endpoint::key() const
{
- return (std::make_pair(m_itf->key(), m_ip));
+ return (std::make_pair(m_itf->key(), m_mac));
}
bool
@@ -65,8 +67,8 @@ gbp_endpoint::operator==(const gbp_endpoint& gbpe) const
void
gbp_endpoint::sweep()
{
- if (m_hw) {
- HW::enqueue(new gbp_endpoint_cmds::delete_cmd(m_hw, m_itf->handle(), m_ip));
+ if (m_hdl) {
+ HW::enqueue(new gbp_endpoint_cmds::delete_cmd(m_hdl));
}
HW::write();
}
@@ -74,8 +76,8 @@ gbp_endpoint::sweep()
void
gbp_endpoint::replay()
{
- if (m_hw) {
- HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hw, m_itf->handle(), m_ip,
+ if (m_hdl) {
+ HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hdl, m_itf->handle(), m_ips,
m_mac, m_epg->id()));
}
}
@@ -84,8 +86,12 @@ std::string
gbp_endpoint::to_string() const
{
std::ostringstream s;
- s << "gbp-endpoint:[" << m_itf->to_string() << ", " << m_ip.to_string()
- << ", " << m_mac.to_string() << ", epg:" << m_epg->to_string() << "]";
+ s << "gbp-endpoint:[" << m_itf->to_string() << ", ips:[";
+
+ for (auto ip : m_ips)
+ s << ip.to_string();
+
+ s << "], " << m_mac.to_string() << ", epg:" << m_epg->to_string() << "]";
return (s.str());
}
@@ -93,8 +99,8 @@ gbp_endpoint::to_string() const
void
gbp_endpoint::update(const gbp_endpoint& r)
{
- if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(new gbp_endpoint_cmds::create_cmd(m_hw, m_itf->handle(), m_ip,
+ 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->id()));
}
}
@@ -147,18 +153,20 @@ gbp_endpoint::event_handler::handle_populate(const client_db::key_t& key)
for (auto& record : *cmd) {
auto& payload = record.get_payload();
- boost::asio::ip::address address =
- from_bytes(payload.endpoint.is_ip6, payload.endpoint.address);
+ std::vector<boost::asio::ip::address> addresses;
+
+ for (uint8_t n = 0; n < payload.endpoint.n_ips; n++)
+ addresses.push_back(from_api(payload.endpoint.ips[n]));
std::shared_ptr<interface> itf =
interface::find(payload.endpoint.sw_if_index);
std::shared_ptr<gbp_endpoint_group> epg =
gbp_endpoint_group::find(payload.endpoint.epg_id);
- mac_address_t mac(payload.endpoint.mac);
+ mac_address_t mac = from_api(payload.endpoint.mac);
VOM_LOG(log_level_t::DEBUG) << "data: " << payload.endpoint.sw_if_index;
if (itf && epg) {
- gbp_endpoint gbpe(*itf, address, mac, *epg);
+ gbp_endpoint gbpe(*itf, addresses, mac, *epg);
OM::commit(key, gbpe);
VOM_LOG(log_level_t::DEBUG) << "read: " << gbpe.to_string();
@@ -177,6 +185,15 @@ gbp_endpoint::event_handler::show(std::ostream& os)
{
db_dump(m_db, os);
}
+
+std::ostream&
+operator<<(std::ostream& os, const gbp_endpoint::key_t& key)
+{
+ os << key.first << "," << key.second;
+
+ return os;
+}
+
} // namespace VOM
/*
diff --git a/extras/vom/vom/gbp_endpoint.hpp b/extras/vom/vom/gbp_endpoint.hpp
index f6466a6077d..d27ad90a4df 100644
--- a/extras/vom/vom/gbp_endpoint.hpp
+++ b/extras/vom/vom/gbp_endpoint.hpp
@@ -17,6 +17,7 @@
#define __VOM_GBP_ENDPOINT_H__
#include <ostream>
+#include <vector>
#include "vom/gbp_endpoint_group.hpp"
#include "vom/interface.hpp"
@@ -32,13 +33,13 @@ public:
/**
* The key for a GBP endpoint; interface and IP
*/
- typedef std::pair<interface::key_t, boost::asio::ip::address> key_t;
+ typedef std::pair<interface::key_t, mac_address_t> key_t;
/**
* Construct a GBP endpoint
*/
gbp_endpoint(const interface& itf,
- const boost::asio::ip::address& ip_addr,
+ const std::vector<boost::asio::ip::address>& ip_addr,
const mac_address_t& mac,
const gbp_endpoint_group& epg);
@@ -151,7 +152,7 @@ private:
/**
* HW configuration for the result of creating the endpoint
*/
- HW::item<bool> m_hw;
+ HW::item<handle_t> m_hdl;
/**
* The interface the endpoint is attached to.
@@ -161,7 +162,7 @@ private:
/**
* The IP address of the endpoint
*/
- boost::asio::ip::address m_ip;
+ std::vector<boost::asio::ip::address> m_ips;
/**
* The MAC address of the endpoint
diff --git a/extras/vom/vom/gbp_endpoint_cmds.cpp b/extras/vom/vom/gbp_endpoint_cmds.cpp
index 1f9078f9b7f..8d44c91ec61 100644
--- a/extras/vom/vom/gbp_endpoint_cmds.cpp
+++ b/extras/vom/vom/gbp_endpoint_cmds.cpp
@@ -14,20 +14,21 @@
*/
#include "vom/gbp_endpoint_cmds.hpp"
+#include "vom/api_types.hpp"
DEFINE_VAPI_MSG_IDS_GBP_API_JSON;
namespace VOM {
namespace gbp_endpoint_cmds {
-create_cmd::create_cmd(HW::item<bool>& item,
+create_cmd::create_cmd(HW::item<handle_t>& item,
const handle_t& itf,
- const boost::asio::ip::address& ip_addr,
+ const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac,
epg_id_t epg_id)
: rpc_cmd(item)
, m_itf(itf)
- , m_ip_addr(ip_addr)
+ , m_ip_addrs(ip_addrs)
, m_mac(mac)
, m_epg_id(epg_id)
{
@@ -36,50 +37,76 @@ create_cmd::create_cmd(HW::item<bool>& item,
bool
create_cmd::operator==(const create_cmd& other) const
{
- return ((m_itf == other.m_itf) && (m_ip_addr == other.m_ip_addr) &&
+ return ((m_itf == other.m_itf) && (m_ip_addrs == other.m_ip_addrs) &&
(m_mac == other.m_mac) && (m_epg_id == other.m_epg_id));
}
rc_t
create_cmd::issue(connection& con)
{
- msg_t req(con.ctx(), std::ref(*this));
+ msg_t req(con.ctx(), m_ip_addrs.size() * sizeof(vapi_type_address),
+ std::ref(*this));
+ uint8_t n;
auto& payload = req.get_request().get_payload();
- payload.is_add = 1;
payload.endpoint.sw_if_index = m_itf.value();
payload.endpoint.epg_id = m_epg_id;
- to_bytes(m_ip_addr, &payload.endpoint.is_ip6, payload.endpoint.address);
- m_mac.to_bytes(payload.endpoint.mac, 6);
+ payload.endpoint.n_ips = m_ip_addrs.size();
+
+ for (n = 0; n < payload.endpoint.n_ips; n++) {
+ payload.endpoint.ips[n] = to_api(m_ip_addrs[n]);
+ }
+ payload.endpoint.mac = to_api(m_mac);
VAPI_CALL(req.execute());
return (wait());
}
+vapi_error_e
+create_cmd::operator()(vapi::Gbp_endpoint_add& reply)
+{
+ int handle = reply.get_response().get_payload().handle;
+ int retval = reply.get_response().get_payload().retval;
+
+ VOM_LOG(log_level_t::DEBUG) << this->to_string() << " " << retval;
+
+ rc_t rc = rc_t::from_vpp_retval(retval);
+ handle_t hdl = handle_t::INVALID;
+
+ if (rc_t::OK == rc) {
+ hdl = handle;
+ }
+
+ this->fulfill(HW::item<handle_t>(hdl, rc));
+
+ return (VAPI_OK);
+}
+
std::string
create_cmd::to_string() const
{
std::ostringstream s;
s << "gbp-endpoint-create: " << m_hw_item.to_string() << " itf:" << m_itf
- << " ip:" << m_ip_addr.to_string() << " epg-id:" << m_epg_id;
+ << " ips:[";
+ for (auto ip : m_ip_addrs)
+ s << ip.to_string();
+
+ s << "] mac:" << m_mac;
+ s << " epg-id:" << m_epg_id;
return (s.str());
}
-delete_cmd::delete_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const boost::asio::ip::address& ip_addr)
+delete_cmd::delete_cmd(HW::item<handle_t>& item)
: rpc_cmd(item)
- , m_itf(itf)
- , m_ip_addr(ip_addr)
{
}
bool
delete_cmd::operator==(const delete_cmd& other) const
{
- return ((m_itf == other.m_itf) && (m_ip_addr == other.m_ip_addr));
+ return (m_hw_item == other.m_hw_item);
}
rc_t
@@ -88,10 +115,7 @@ delete_cmd::issue(connection& con)
msg_t req(con.ctx(), std::ref(*this));
auto& payload = req.get_request().get_payload();
- payload.is_add = 0;
- payload.endpoint.sw_if_index = m_itf.value();
- payload.endpoint.epg_id = ~0;
- to_bytes(m_ip_addr, &payload.endpoint.is_ip6, payload.endpoint.address);
+ payload.handle = m_hw_item.data().value();
VAPI_CALL(req.execute());
@@ -102,8 +126,7 @@ std::string
delete_cmd::to_string() const
{
std::ostringstream s;
- s << "gbp-endpoint-delete: " << m_hw_item.to_string() << " itf:" << m_itf
- << " ip:" << m_ip_addr.to_string();
+ s << "gbp-endpoint-delete: " << m_hw_item.to_string();
return (s.str());
}
diff --git a/extras/vom/vom/gbp_endpoint_cmds.hpp b/extras/vom/vom/gbp_endpoint_cmds.hpp
index dea4c2c5605..e90fb66f04a 100644
--- a/extras/vom/vom/gbp_endpoint_cmds.hpp
+++ b/extras/vom/vom/gbp_endpoint_cmds.hpp
@@ -27,15 +27,15 @@ namespace gbp_endpoint_cmds {
/**
* A command class that creates or updates the GBP endpoint
*/
-class create_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_endpoint_add_del>
+class create_cmd : public rpc_cmd<HW::item<handle_t>, vapi::Gbp_endpoint_add>
{
public:
/**
* Constructor
*/
- create_cmd(HW::item<bool>& item,
+ create_cmd(HW::item<handle_t>& item,
const handle_t& itf,
- const boost::asio::ip::address& ip_addr,
+ const std::vector<boost::asio::ip::address>& ip_addrs,
const mac_address_t& mac,
epg_id_t epg_id);
@@ -49,6 +49,8 @@ public:
*/
std::string to_string() const;
+ virtual vapi_error_e operator()(vapi::Gbp_endpoint_add& reply);
+
/**
* Comparison operator - only used for UT
*/
@@ -56,7 +58,7 @@ public:
private:
const handle_t m_itf;
- const boost::asio::ip::address m_ip_addr;
+ const std::vector<boost::asio::ip::address> m_ip_addrs;
const mac_address_t m_mac;
const epg_id_t m_epg_id;
};
@@ -64,15 +66,13 @@ private:
/**
* A cmd class that deletes a GBP endpoint
*/
-class delete_cmd : public rpc_cmd<HW::item<bool>, vapi::Gbp_endpoint_add_del>
+class delete_cmd : public rpc_cmd<HW::item<handle_t>, vapi::Gbp_endpoint_del>
{
public:
/**
* Constructor
*/
- delete_cmd(HW::item<bool>& item,
- const handle_t& itf,
- const boost::asio::ip::address& ip_addr);
+ delete_cmd(HW::item<handle_t>& item);
/**
* Issue the command to VPP/HW
@@ -90,8 +90,7 @@ public:
bool operator==(const delete_cmd& i) const;
private:
- const handle_t m_itf;
- const boost::asio::ip::address m_ip_addr;
+ const handle_t m_hdl;
};
/**
diff --git a/extras/vom/vom/gbp_subnet.cpp b/extras/vom/vom/gbp_subnet.cpp
index 1a9ee86e06b..1bc024da854 100644
--- a/extras/vom/vom/gbp_subnet.cpp
+++ b/extras/vom/vom/gbp_subnet.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/gbp_subnet.hpp"
+#include "vom/api_types.hpp"
#include "vom/gbp_subnet_cmds.hpp"
#include "vom/singular_db_funcs.hpp"
@@ -190,8 +191,7 @@ gbp_subnet::event_handler::handle_populate(const client_db::key_t& key)
for (auto& record : *cmd) {
auto& payload = record.get_payload();
- route::prefix_t pfx(payload.subnet.is_ip6, payload.subnet.address,
- payload.subnet.address_length);
+ route::prefix_t pfx = from_api(payload.subnet.prefix);
std::shared_ptr<route_domain> rd =
route_domain::find(payload.subnet.table_id);
diff --git a/extras/vom/vom/gbp_subnet_cmds.cpp b/extras/vom/vom/gbp_subnet_cmds.cpp
index 3816a596e6d..79fdf175ee1 100644
--- a/extras/vom/vom/gbp_subnet_cmds.cpp
+++ b/extras/vom/vom/gbp_subnet_cmds.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/gbp_subnet_cmds.hpp"
+#include "vom/api_types.hpp"
namespace VOM {
namespace gbp_subnet_cmds {
@@ -52,8 +53,7 @@ create_cmd::issue(connection& con)
payload.subnet.table_id = m_rd;
payload.subnet.sw_if_index = m_itf.value();
payload.subnet.epg_id = m_epg_id;
- m_prefix.to_vpp(&payload.subnet.is_ip6, payload.subnet.address,
- &payload.subnet.address_length);
+ payload.subnet.prefix = to_api(m_prefix);
VAPI_CALL(req.execute());
@@ -94,8 +94,7 @@ delete_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
payload.subnet.table_id = m_rd;
- m_prefix.to_vpp(&payload.subnet.is_ip6, payload.subnet.address,
- &payload.subnet.address_length);
+ payload.subnet.prefix = to_api(m_prefix);
payload.subnet.is_internal = 0;
payload.subnet.sw_if_index = ~0;
diff --git a/extras/vom/vom/prefix.hpp b/extras/vom/vom/prefix.hpp
index 3950f6fd036..836554123f5 100644
--- a/extras/vom/vom/prefix.hpp
+++ b/extras/vom/vom/prefix.hpp
@@ -16,9 +16,8 @@
#ifndef __VOM_PREFIX_H__
#define __VOM_PREFIX_H__
-#include <boost/asio/ip/address.hpp>
-
#include "vom/enum_base.hpp"
+#include <boost/asio/ip/address.hpp>
namespace VOM {
/**
@@ -111,10 +110,12 @@ public:
* Constructor with string and length
*/
prefix_t(const std::string& s, uint8_t len);
+
/**
* Copy Constructor
*/
prefix_t(const prefix_t&);
+
/**
* Constructor with VPP API prefix representation
*/