aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-03-04 14:08:11 -0800
committerNeale Ranns <nranns@cisco.com>2019-03-06 10:31:38 +0000
commit8da9fc659badc016e409f772673002f021c0cc4a (patch)
tree0223180b7344b652ab8c45bb38f47f335bbed7c5 /extras/vom
parentdc8d93b02949f508d5eed312a51aa91102224b39 (diff)
GBP: learn from ARP and L2 packets
Change-Id: I8af7bca566ec7c9bd2b72529d49e04c6e649b44a Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/vom/gbp_vxlan.cpp36
-rw-r--r--extras/vom/vom/gbp_vxlan.hpp9
-rw-r--r--extras/vom/vom/gbp_vxlan_cmds.cpp4
-rw-r--r--extras/vom/vom/gbp_vxlan_cmds.hpp2
4 files changed, 36 insertions, 15 deletions
diff --git a/extras/vom/vom/gbp_vxlan.cpp b/extras/vom/vom/gbp_vxlan.cpp
index af4467abfbb..76826c2a3d6 100644
--- a/extras/vom/vom/gbp_vxlan.cpp
+++ b/extras/vom/vom/gbp_vxlan.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/gbp_vxlan.hpp"
+#include "vom/api_types.hpp"
#include "vom/gbp_vxlan_cmds.hpp"
#include "vom/interface.hpp"
#include "vom/singular_db_funcs.hpp"
@@ -29,22 +30,28 @@ singular_db<gbp_vxlan::key_t, gbp_vxlan> gbp_vxlan::m_db;
gbp_vxlan::event_handler gbp_vxlan::m_evh;
-gbp_vxlan::gbp_vxlan(uint32_t vni, const gbp_route_domain& grd)
+gbp_vxlan::gbp_vxlan(uint32_t vni,
+ const gbp_route_domain& grd,
+ const boost::asio::ip::address_v4& src)
: interface(mk_name(vni),
interface::type_t::UNKNOWN,
interface::admin_state_t::UP)
, m_vni(vni)
, m_gbd()
, m_grd(grd.singular())
+ , m_src(src)
{
}
-gbp_vxlan::gbp_vxlan(uint32_t vni, const gbp_bridge_domain& gbd)
+gbp_vxlan::gbp_vxlan(uint32_t vni,
+ const gbp_bridge_domain& gbd,
+ const boost::asio::ip::address_v4& src)
: interface(mk_name(vni),
interface::type_t::UNKNOWN,
interface::admin_state_t::UP)
, m_vni(vni)
, m_gbd(gbd.singular())
, m_grd()
+ , m_src(src)
{
}
@@ -53,6 +60,7 @@ gbp_vxlan::gbp_vxlan(const gbp_vxlan& vt)
, m_vni(vt.m_vni)
, m_gbd(vt.m_gbd)
, m_grd(vt.m_grd)
+ , m_src(vt.m_src)
{
}
@@ -75,7 +83,7 @@ gbp_vxlan::key() const
bool
gbp_vxlan::operator==(const gbp_vxlan& vt) const
{
- return (m_vni == vt.m_vni);
+ return (m_vni == vt.m_vni && m_src == vt.m_src);
}
void
@@ -92,11 +100,11 @@ gbp_vxlan::replay()
{
if (rc_t::OK == m_hdl) {
if (m_grd)
- HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_vni, false,
- m_grd->id()));
+ HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_src, m_vni,
+ false, m_grd->id()));
else if (m_gbd)
- HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_vni, true,
- m_gbd->id()));
+ HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_src, m_vni,
+ true, m_gbd->id()));
}
}
@@ -129,11 +137,11 @@ gbp_vxlan::update(const gbp_vxlan& desired)
*/
if (rc_t::OK != m_hdl) {
if (m_grd)
- HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_vni, false,
- m_grd->id()));
+ HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_src, m_vni,
+ false, m_grd->id()));
else if (m_gbd)
- HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_vni, true,
- m_gbd->id()));
+ HW::enqueue(new gbp_vxlan_cmds::create_cmd(m_hdl, name(), m_src, m_vni,
+ true, m_gbd->id()));
}
}
@@ -176,11 +184,13 @@ gbp_vxlan::event_handler::handle_populate(const client_db::key_t& key)
for (auto& record : *cmd) {
auto& payload = record.get_payload();
+ boost::asio::ip::address_v4 src = from_api(payload.tunnel.src);
+
if (GBP_VXLAN_TUNNEL_MODE_L3 == payload.tunnel.mode) {
auto rd = gbp_route_domain::find(payload.tunnel.bd_rd_id);
if (rd) {
- gbp_vxlan vt(payload.tunnel.vni, *rd);
+ gbp_vxlan vt(payload.tunnel.vni, *rd, src);
OM::commit(key, vt);
VOM_LOG(log_level_t::DEBUG) << "dump: " << vt.to_string();
}
@@ -188,7 +198,7 @@ gbp_vxlan::event_handler::handle_populate(const client_db::key_t& key)
auto bd = gbp_bridge_domain::find(payload.tunnel.bd_rd_id);
if (bd) {
- gbp_vxlan vt(payload.tunnel.vni, *bd);
+ gbp_vxlan vt(payload.tunnel.vni, *bd, src);
OM::commit(key, vt);
VOM_LOG(log_level_t::DEBUG) << "dump: " << vt.to_string();
}
diff --git a/extras/vom/vom/gbp_vxlan.hpp b/extras/vom/vom/gbp_vxlan.hpp
index cae67d8ad17..8aa4b6b6b6e 100644
--- a/extras/vom/vom/gbp_vxlan.hpp
+++ b/extras/vom/vom/gbp_vxlan.hpp
@@ -38,8 +38,12 @@ public:
/**
* Construct a new object matching the desried state
*/
- gbp_vxlan(uint32_t vni, const gbp_bridge_domain& gbd);
- gbp_vxlan(uint32_t vni, const gbp_route_domain& grd);
+ gbp_vxlan(uint32_t vni,
+ const gbp_bridge_domain& gbd,
+ const boost::asio::ip::address_v4& src);
+ gbp_vxlan(uint32_t vni,
+ const gbp_route_domain& grd,
+ const boost::asio::ip::address_v4& src);
/*
* Destructor
@@ -161,6 +165,7 @@ private:
uint32_t m_vni;
std::shared_ptr<gbp_bridge_domain> m_gbd;
std::shared_ptr<gbp_route_domain> m_grd;
+ boost::asio::ip::address_v4 m_src;
/**
* A map of all VLAN tunnela against thier key
diff --git a/extras/vom/vom/gbp_vxlan_cmds.cpp b/extras/vom/vom/gbp_vxlan_cmds.cpp
index a3565902b5d..86b61c14f06 100644
--- a/extras/vom/vom/gbp_vxlan_cmds.cpp
+++ b/extras/vom/vom/gbp_vxlan_cmds.cpp
@@ -14,15 +14,18 @@
*/
#include "vom/gbp_vxlan_cmds.hpp"
+#include "vom/api_types.hpp"
namespace VOM {
namespace gbp_vxlan_cmds {
create_cmd::create_cmd(HW::item<handle_t>& item,
const std::string& name,
+ const boost::asio::ip::address_v4& src,
uint32_t vni,
bool is_l2,
uint32_t bd_rd)
: interface::create_cmd<vapi::Gbp_vxlan_tunnel_add>(item, name)
+ , m_src(src)
, m_vni(vni)
, m_is_l2(is_l2)
, m_bd_rd(bd_rd)
@@ -42,6 +45,7 @@ create_cmd::issue(connection& con)
payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L2;
else
payload.tunnel.mode = GBP_VXLAN_TUNNEL_MODE_L3;
+ to_api(m_src, payload.tunnel.src);
VAPI_CALL(req.execute());
diff --git a/extras/vom/vom/gbp_vxlan_cmds.hpp b/extras/vom/vom/gbp_vxlan_cmds.hpp
index a42a6531f20..642235731bb 100644
--- a/extras/vom/vom/gbp_vxlan_cmds.hpp
+++ b/extras/vom/vom/gbp_vxlan_cmds.hpp
@@ -35,6 +35,7 @@ public:
*/
create_cmd(HW::item<handle_t>& item,
const std::string& name,
+ const boost::asio::ip::address_v4& src,
uint32_t vni,
bool is_l2,
uint32_t bd_rd);
@@ -54,6 +55,7 @@ public:
bool operator==(const create_cmd& i) const;
private:
+ boost::asio::ip::address_v4 m_src;
uint32_t m_vni;
bool m_is_l2;
uint32_t m_bd_rd;