summaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-06-19 06:25:56 -0700
committerDamjan Marion <dmarion@me.com>2019-07-01 08:37:53 +0000
commit160c923f99c2adc103495fab1bfcefe965fe7fb8 (patch)
treea3b33e764c9ec138d519a5a2b4001bdf63eb8dba /extras/vom
parent5770c916c0cf110ced690ff128b065bbb2c827ca (diff)
gbp: VRF scoped contracts
Type: feature Change-Id: I01772cfc3a0118a5c49bf346339788824e6931b2 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/CMakeLists.txt1
-rw-r--r--extras/vom/vom/CMakeLists.txt2
-rw-r--r--extras/vom/vom/gbp_bridge_domain.cpp25
-rw-r--r--extras/vom/vom/gbp_bridge_domain.hpp7
-rw-r--r--extras/vom/vom/gbp_bridge_domain_cmds.cpp8
-rw-r--r--extras/vom/vom/gbp_bridge_domain_cmds.hpp2
-rw-r--r--extras/vom/vom/gbp_contract.cpp35
-rw-r--r--extras/vom/vom/gbp_contract.hpp12
-rw-r--r--extras/vom/vom/gbp_contract_cmds.cpp11
-rw-r--r--extras/vom/vom/gbp_contract_cmds.hpp8
-rw-r--r--extras/vom/vom/gbp_endpoint_group.hpp7
-rw-r--r--extras/vom/vom/gbp_route_domain.cpp32
-rw-r--r--extras/vom/vom/gbp_route_domain.hpp6
-rw-r--r--extras/vom/vom/gbp_route_domain_cmds.cpp7
-rw-r--r--extras/vom/vom/gbp_route_domain_cmds.hpp2
-rw-r--r--extras/vom/vom/gbp_types.hpp40
16 files changed, 152 insertions, 53 deletions
diff --git a/extras/vom/CMakeLists.txt b/extras/vom/CMakeLists.txt
index 4853196b5fe..3a32117882a 100644
--- a/extras/vom/CMakeLists.txt
+++ b/extras/vom/CMakeLists.txt
@@ -26,6 +26,7 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_MESSAGE NEVER)
diff --git a/extras/vom/vom/CMakeLists.txt b/extras/vom/vom/CMakeLists.txt
index 26dd3e46574..144749968d5 100644
--- a/extras/vom/vom/CMakeLists.txt
+++ b/extras/vom/vom/CMakeLists.txt
@@ -94,6 +94,7 @@ if(GBP_FILE)
gbp_rule.cpp
gbp_subnet_cmds.cpp
gbp_subnet.cpp
+ gbp_types.hpp
gbp_vxlan.cpp
gbp_vxlan_cmds.cpp
)
@@ -220,6 +221,7 @@ if(GBP_FILE)
gbp_route_domain.hpp
gbp_rule.hpp
gbp_subnet.hpp
+ gbp_types.hpp
gbp_vxlan.hpp
)
endif()
diff --git a/extras/vom/vom/gbp_bridge_domain.cpp b/extras/vom/vom/gbp_bridge_domain.cpp
index cfa07681545..3e015c379c2 100644
--- a/extras/vom/vom/gbp_bridge_domain.cpp
+++ b/extras/vom/vom/gbp_bridge_domain.cpp
@@ -51,10 +51,12 @@ gbp_bridge_domain::event_handler gbp_bridge_domain::m_evh;
* Construct a new object matching the desried state
*/
gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const interface& bvi,
const flags_t& flags)
: m_id(bd.id())
, m_bd(bd.singular())
+ , m_rd(rd.singular())
, m_bvi(bvi.singular())
, m_uu_fwd()
, m_bm_flood()
@@ -63,12 +65,14 @@ gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
}
gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const interface& bvi,
const interface& uu_fwd,
const interface& bm_flood,
const flags_t& flags)
: m_id(bd.id())
, m_bd(bd.singular())
+ , m_rd(rd.singular())
, m_bvi(bvi.singular())
, m_uu_fwd(uu_fwd.singular())
, m_bm_flood(bm_flood.singular())
@@ -77,12 +81,14 @@ gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
}
gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const std::shared_ptr<interface> bvi,
const std::shared_ptr<interface> uu_fwd,
const std::shared_ptr<interface> bm_flood,
const flags_t& flags)
: m_id(bd.id())
, m_bd(bd.singular())
+ , m_rd(rd.singular())
, m_bvi(bvi)
, m_uu_fwd(uu_fwd)
, m_bm_flood(bm_flood)
@@ -97,12 +103,14 @@ gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
}
gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const interface& bvi,
const std::shared_ptr<interface> uu_fwd,
const std::shared_ptr<interface> bm_flood,
const flags_t& flags)
: m_id(bd.id())
, m_bd(bd.singular())
+ , m_rd(rd.singular())
, m_bvi(bvi.singular())
, m_uu_fwd(uu_fwd)
, m_bm_flood(bm_flood)
@@ -117,6 +125,7 @@ gbp_bridge_domain::gbp_bridge_domain(const bridge_domain& bd,
gbp_bridge_domain::gbp_bridge_domain(const gbp_bridge_domain& bd)
: m_id(bd.id())
, m_bd(bd.m_bd)
+ , m_rd(bd.m_rd)
, m_bvi(bd.m_bvi)
, m_uu_fwd(bd.m_uu_fwd)
, m_bm_flood(bd.m_bm_flood)
@@ -191,7 +200,7 @@ gbp_bridge_domain::replay()
{
if (rc_t::OK == m_id.rc()) {
HW::enqueue(new gbp_bridge_domain_cmds::create_cmd(
- m_id, (m_bvi ? m_bvi->handle() : handle_t::INVALID),
+ m_id, m_rd->id(), (m_bvi ? m_bvi->handle() : handle_t::INVALID),
(m_uu_fwd ? m_uu_fwd->handle() : handle_t::INVALID),
(m_bm_flood ? m_bm_flood->handle() : handle_t::INVALID), m_flags));
}
@@ -236,7 +245,7 @@ gbp_bridge_domain::update(const gbp_bridge_domain& desired)
*/
if (rc_t::OK != m_id.rc()) {
HW::enqueue(new gbp_bridge_domain_cmds::create_cmd(
- m_id, (m_bvi ? m_bvi->handle() : handle_t::INVALID),
+ m_id, m_rd->id(), (m_bvi ? m_bvi->handle() : handle_t::INVALID),
(m_uu_fwd ? m_uu_fwd->handle() : handle_t::INVALID),
(m_bm_flood ? m_bm_flood->handle() : handle_t::INVALID), m_flags));
}
@@ -281,6 +290,8 @@ gbp_bridge_domain::event_handler::handle_populate(const client_db::key_t& key)
interface::find(payload.bd.bm_flood_sw_if_index);
std::shared_ptr<interface> bvi =
interface::find(payload.bd.bvi_sw_if_index);
+ std::shared_ptr<gbp_route_domain> grd =
+ gbp_route_domain::find(payload.bd.rd_id);
flags_t flags = gbp_bridge_domain::flags_t::NONE;
if (payload.bd.flags & GBP_BD_API_FLAG_DO_NOT_LEARN)
@@ -292,12 +303,13 @@ gbp_bridge_domain::event_handler::handle_populate(const client_db::key_t& key)
if (payload.bd.flags & GBP_BD_API_FLAG_UCAST_ARP)
flags |= gbp_bridge_domain::flags_t::UCAST_ARP;
- if (uu_fwd && bm_flood && bvi) {
- gbp_bridge_domain bd(payload.bd.bd_id, bvi, uu_fwd, bm_flood, flags);
+ if (uu_fwd && bm_flood && bvi && grd) {
+ gbp_bridge_domain bd(payload.bd.bd_id, *grd, bvi, uu_fwd, bm_flood,
+ flags);
OM::commit(key, bd);
VOM_LOG(log_level_t::DEBUG) << "dump: " << bd.to_string();
} else if (bvi) {
- gbp_bridge_domain bd(payload.bd.bd_id, *bvi, flags);
+ gbp_bridge_domain bd(payload.bd.bd_id, *grd, *bvi, flags);
OM::commit(key, bd);
VOM_LOG(log_level_t::DEBUG) << "dump: " << bd.to_string();
} else {
@@ -323,7 +335,8 @@ gbp_bridge_domain::event_handler::handle_replay()
dependency_t
gbp_bridge_domain::event_handler::order() const
{
- return (dependency_t::VIRTUAL_TABLE);
+ /* order after gbp-route-domains */
+ return (dependency_t::ACL);
}
void
diff --git a/extras/vom/vom/gbp_bridge_domain.hpp b/extras/vom/vom/gbp_bridge_domain.hpp
index 44cf29956ef..264f8b3c031 100644
--- a/extras/vom/vom/gbp_bridge_domain.hpp
+++ b/extras/vom/vom/gbp_bridge_domain.hpp
@@ -17,9 +17,9 @@
#define __VOM_GBP_BRIDGE_DOMAIN_H__
#include "vom/bridge_domain.hpp"
+#include "vom/gbp_route_domain.hpp"
#include "vom/interface.hpp"
#include "vom/singular_db.hpp"
-#include "vom/types.hpp"
namespace VOM {
@@ -53,19 +53,23 @@ public:
* Construct a GBP bridge_domain
*/
gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const interface& bvi,
const flags_t& flags = flags_t::NONE);
gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const interface& bvi,
const interface& uu_fwd,
const interface& bm_flood,
const flags_t& flags = flags_t::NONE);
gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const std::shared_ptr<interface> bvi,
const std::shared_ptr<interface> uu_fwd,
const std::shared_ptr<interface> bm_flood,
const flags_t& flags = flags_t::NONE);
gbp_bridge_domain(const bridge_domain& bd,
+ const gbp_route_domain& rd,
const interface& bvi,
const std::shared_ptr<interface> uu_fwd,
const std::shared_ptr<interface> bm_flood,
@@ -192,6 +196,7 @@ private:
HW::item<uint32_t> m_id;
std::shared_ptr<bridge_domain> m_bd;
+ std::shared_ptr<gbp_route_domain> m_rd;
std::shared_ptr<interface> m_bvi;
std::shared_ptr<interface> m_uu_fwd;
std::shared_ptr<interface> m_bm_flood;
diff --git a/extras/vom/vom/gbp_bridge_domain_cmds.cpp b/extras/vom/vom/gbp_bridge_domain_cmds.cpp
index 082bd4bb48d..05064df6269 100644
--- a/extras/vom/vom/gbp_bridge_domain_cmds.cpp
+++ b/extras/vom/vom/gbp_bridge_domain_cmds.cpp
@@ -19,11 +19,13 @@ namespace VOM {
namespace gbp_bridge_domain_cmds {
create_cmd::create_cmd(HW::item<uint32_t>& item,
+ u32 rd_id,
const handle_t bvi,
const handle_t uu_fwd,
const handle_t bm_flood,
const gbp_bridge_domain::flags_t& flags)
: rpc_cmd(item)
+ , m_rd_id(rd_id)
, m_bvi(bvi)
, m_uu_fwd(uu_fwd)
, m_bm_flood(bm_flood)
@@ -35,8 +37,9 @@ bool
create_cmd::operator==(const create_cmd& other) const
{
return ((m_hw_item.data() == other.m_hw_item.data()) &&
- (m_bvi == other.m_bvi) && (m_uu_fwd == other.m_uu_fwd) &&
- (m_bm_flood == other.m_bm_flood) && (m_flags == other.m_flags));
+ (m_rd_id == other.m_rd_id) && (m_bvi == other.m_bvi) &&
+ (m_uu_fwd == other.m_uu_fwd) && (m_bm_flood == other.m_bm_flood) &&
+ (m_flags == other.m_flags));
}
rc_t
@@ -47,6 +50,7 @@ create_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.bd.bd_id = m_hw_item.data();
+ payload.bd.rd_id = m_rd_id;
payload.bd.bvi_sw_if_index = m_bvi.value();
payload.bd.uu_fwd_sw_if_index = m_uu_fwd.value();
payload.bd.bm_flood_sw_if_index = m_bm_flood.value();
diff --git a/extras/vom/vom/gbp_bridge_domain_cmds.hpp b/extras/vom/vom/gbp_bridge_domain_cmds.hpp
index a4fd0d51b45..6dbe6dcdfed 100644
--- a/extras/vom/vom/gbp_bridge_domain_cmds.hpp
+++ b/extras/vom/vom/gbp_bridge_domain_cmds.hpp
@@ -35,6 +35,7 @@ public:
* Constructor
*/
create_cmd(HW::item<uint32_t>& item,
+ u32 rd_id,
const handle_t bvi,
const handle_t uu_fwd,
const handle_t bm_flood,
@@ -55,6 +56,7 @@ public:
bool operator==(const create_cmd& i) const;
private:
+ u32 m_rd_id;
const handle_t m_bvi;
const handle_t m_uu_fwd;
const handle_t m_bm_flood;
diff --git a/extras/vom/vom/gbp_contract.cpp b/extras/vom/vom/gbp_contract.cpp
index c95c2e8008e..8fcef02da24 100644
--- a/extras/vom/vom/gbp_contract.cpp
+++ b/extras/vom/vom/gbp_contract.cpp
@@ -24,12 +24,14 @@ singular_db<gbp_contract::key_t, gbp_contract> gbp_contract::m_db;
gbp_contract::event_handler gbp_contract::m_evh;
-gbp_contract::gbp_contract(sclass_t sclass,
+gbp_contract::gbp_contract(scope_t scope,
+ sclass_t sclass,
sclass_t dclass,
const ACL::l3_list& acl,
const gbp_rules_t& rules,
const ethertype_set_t& allowed_ethertypes)
: m_hw(false)
+ , m_scope(scope)
, m_sclass(sclass)
, m_dclass(dclass)
, m_acl(acl.singular())
@@ -40,6 +42,7 @@ gbp_contract::gbp_contract(sclass_t sclass,
gbp_contract::gbp_contract(const gbp_contract& gbpc)
: m_hw(gbpc.m_hw)
+ , m_scope(gbpc.m_scope)
, m_sclass(gbpc.m_sclass)
, m_dclass(gbpc.m_dclass)
, m_acl(gbpc.m_acl)
@@ -59,7 +62,7 @@ gbp_contract::~gbp_contract()
const gbp_contract::key_t
gbp_contract::key() const
{
- return (std::make_pair(m_sclass, m_dclass));
+ return (std::make_tuple(m_scope, m_sclass, m_dclass));
}
bool
@@ -72,7 +75,8 @@ void
gbp_contract::sweep()
{
if (m_hw) {
- HW::enqueue(new gbp_contract_cmds::delete_cmd(m_hw, m_sclass, m_dclass));
+ HW::enqueue(
+ new gbp_contract_cmds::delete_cmd(m_hw, m_scope, m_sclass, m_dclass));
}
HW::write();
}
@@ -81,9 +85,9 @@ void
gbp_contract::replay()
{
if (m_hw) {
- HW::enqueue(new gbp_contract_cmds::create_cmd(m_hw, m_sclass, m_dclass,
- m_acl->handle(), m_gbp_rules,
- m_allowed_ethertypes));
+ HW::enqueue(new gbp_contract_cmds::create_cmd(
+ m_hw, m_scope, m_sclass, m_dclass, m_acl->handle(), m_gbp_rules,
+ m_allowed_ethertypes));
}
}
@@ -91,8 +95,8 @@ std::string
gbp_contract::to_string() const
{
std::ostringstream s;
- s << "gbp-contract:[{" << m_sclass << ", " << m_dclass << "}, "
- << m_acl->to_string();
+ s << "gbp-contract:[{" << m_scope << ", " << m_sclass << ", " << m_dclass
+ << "}, " << m_acl->to_string();
if (m_gbp_rules.size()) {
auto it = m_gbp_rules.cbegin();
while (it != m_gbp_rules.cend()) {
@@ -115,9 +119,9 @@ gbp_contract::update(const gbp_contract& r)
* create the table if it is not yet created
*/
if (rc_t::OK != m_hw.rc()) {
- HW::enqueue(new gbp_contract_cmds::create_cmd(m_hw, m_sclass, m_dclass,
- m_acl->handle(), m_gbp_rules,
- m_allowed_ethertypes));
+ HW::enqueue(new gbp_contract_cmds::create_cmd(
+ m_hw, m_scope, m_sclass, m_dclass, m_acl->handle(), m_gbp_rules,
+ m_allowed_ethertypes));
}
}
@@ -207,10 +211,10 @@ gbp_contract::event_handler::handle_populate(const client_db::key_t& key)
allowed_ethertypes.insert(ethertype_t::from_numeric_val(et[i]));
}
- gbp_contract gbpc(payload.contract.sclass, payload.contract.dclass, *acl,
- rules, allowed_ethertypes);
+ gbp_contract gbpc(payload.contract.scope, payload.contract.sclass,
+ payload.contract.dclass, *acl, rules,
+ allowed_ethertypes);
OM::commit(key, gbpc);
-
VOM_LOG(log_level_t::DEBUG) << "read: " << gbpc.to_string();
} else {
VOM_LOG(log_level_t::ERROR) << " no ACL:" << payload.contract.acl_index;
@@ -233,7 +237,8 @@ gbp_contract::event_handler::show(std::ostream& os)
std::ostream&
operator<<(std::ostream& os, const gbp_contract::key_t& key)
{
- os << "{ " << key.first << "," << key.second << "}";
+ os << "{ " << std::get<0>(key) << "," << std::get<1>(key) << ", "
+ << std::get<2>(key) << "}";
return (os);
}
diff --git a/extras/vom/vom/gbp_contract.hpp b/extras/vom/vom/gbp_contract.hpp
index 2e8f9d0bc26..caf5a3c5a0e 100644
--- a/extras/vom/vom/gbp_contract.hpp
+++ b/extras/vom/vom/gbp_contract.hpp
@@ -17,8 +17,8 @@
#define __VOM_GBP_CONTRACT_H__
#include "vom/acl_l3_list.hpp"
-#include "vom/gbp_endpoint.hpp"
#include "vom/gbp_rule.hpp"
+#include "vom/gbp_types.hpp"
#include "vom/interface.hpp"
#include "vom/singular_db.hpp"
#include "vom/types.hpp"
@@ -39,7 +39,7 @@ public:
/**
* The key for a contract is the pair of EPG-IDs
*/
- typedef std::pair<sclass_t, sclass_t> key_t;
+ typedef std::tuple<scope_t, sclass_t, sclass_t> key_t;
/**
* A set of allowed ethertypes
@@ -49,7 +49,8 @@ public:
/**
* Construct a GBP contract
*/
- gbp_contract(sclass_t sclass,
+ gbp_contract(scope_t scope,
+ sclass_t sclass,
sclass_t dclass,
const ACL::l3_list& acl,
const gbp_rules_t& gpb_rules,
@@ -166,6 +167,11 @@ private:
*/
HW::item<uint32_t> m_hw;
+ /*
+ * The scope of the contract
+ */
+ scope_t m_scope;
+
/**
* The source EPG ID
*/
diff --git a/extras/vom/vom/gbp_contract_cmds.cpp b/extras/vom/vom/gbp_contract_cmds.cpp
index 6aed9998e1e..1bb06bdaa69 100644
--- a/extras/vom/vom/gbp_contract_cmds.cpp
+++ b/extras/vom/vom/gbp_contract_cmds.cpp
@@ -20,12 +20,14 @@ namespace VOM {
namespace gbp_contract_cmds {
create_cmd::create_cmd(HW::item<uint32_t>& item,
+ scope_t scope,
sclass_t sclass,
sclass_t dclass,
const handle_t& acl,
const gbp_contract::gbp_rules_t& gbp_rules,
const gbp_contract::ethertype_set_t& allowed_ethertypes)
: rpc_cmd(item)
+ , m_scope(scope)
, m_sclass(sclass)
, m_dclass(dclass)
, m_acl(acl)
@@ -38,7 +40,8 @@ bool
create_cmd::operator==(const create_cmd& other) const
{
return ((m_acl == other.m_acl) && (m_sclass == other.m_sclass) &&
- (m_dclass == other.m_dclass) && (m_gbp_rules == other.m_gbp_rules) &&
+ (m_scope == other.m_scope) && (m_dclass == other.m_dclass) &&
+ (m_gbp_rules == other.m_gbp_rules) &&
(m_allowed_ethertypes == other.m_allowed_ethertypes));
}
@@ -55,6 +58,7 @@ create_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 1;
payload.contract.acl_index = m_acl.value();
+ payload.contract.scope = m_scope;
payload.contract.sclass = m_sclass;
payload.contract.dclass = m_dclass;
payload.contract.n_rules = n_rules;
@@ -117,9 +121,11 @@ create_cmd::to_string() const
}
delete_cmd::delete_cmd(HW::item<uint32_t>& item,
+ scope_t scope,
sclass_t sclass,
sclass_t dclass)
: rpc_cmd(item)
+ , m_scope(scope)
, m_sclass(sclass)
, m_dclass(dclass)
{
@@ -139,6 +145,7 @@ delete_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.is_add = 0;
payload.contract.acl_index = ~0;
+ payload.contract.scope = m_scope;
payload.contract.sclass = m_sclass;
payload.contract.dclass = m_dclass;
@@ -151,7 +158,7 @@ std::string
delete_cmd::to_string() const
{
std::ostringstream s;
- s << "gbp-contract-delete: " << m_hw_item.to_string()
+ s << "gbp-contract-delete: " << m_hw_item.to_string() << " scope: " << m_scope
<< " sclass:" << m_sclass << " dclass:" << m_dclass;
return (s.str());
diff --git a/extras/vom/vom/gbp_contract_cmds.hpp b/extras/vom/vom/gbp_contract_cmds.hpp
index 3b3fab97a70..d9fe1d74e37 100644
--- a/extras/vom/vom/gbp_contract_cmds.hpp
+++ b/extras/vom/vom/gbp_contract_cmds.hpp
@@ -35,6 +35,7 @@ public:
* Constructor
*/
create_cmd(HW::item<uint32_t>& item,
+ scope_t scope,
sclass_t sclass,
sclass_t dclass,
const handle_t& acl,
@@ -57,6 +58,7 @@ public:
bool operator==(const create_cmd& i) const;
private:
+ const scope_t m_scope;
const sclass_t m_sclass;
const sclass_t m_dclass;
const handle_t m_acl;
@@ -74,7 +76,10 @@ public:
/**
* Constructor
*/
- delete_cmd(HW::item<uint32_t>& item, sclass_t sclass, sclass_t dclass);
+ delete_cmd(HW::item<uint32_t>& item,
+ scope_t scope,
+ sclass_t sclass,
+ sclass_t dclass);
/**
* Issue the command to VPP/HW
@@ -92,6 +97,7 @@ public:
bool operator==(const delete_cmd& i) const;
private:
+ const scope_t m_scope;
const sclass_t m_sclass;
const sclass_t m_dclass;
};
diff --git a/extras/vom/vom/gbp_endpoint_group.hpp b/extras/vom/vom/gbp_endpoint_group.hpp
index 5c061a900b3..e15a1885317 100644
--- a/extras/vom/vom/gbp_endpoint_group.hpp
+++ b/extras/vom/vom/gbp_endpoint_group.hpp
@@ -22,16 +22,11 @@
#include "vom/gbp_bridge_domain.hpp"
#include "vom/gbp_route_domain.hpp"
+#include "vom/gbp_types.hpp"
namespace VOM {
/**
- * EPG IDs are 32 bit integers
- */
-typedef uint32_t vnid_t;
-typedef uint16_t sclass_t;
-
-/**
* A entry in the ARP termination table of a Bridge Domain
*/
class gbp_endpoint_group : public object_base
diff --git a/extras/vom/vom/gbp_route_domain.cpp b/extras/vom/vom/gbp_route_domain.cpp
index 8f0eae3b3aa..54b51cf88a3 100644
--- a/extras/vom/vom/gbp_route_domain.cpp
+++ b/extras/vom/vom/gbp_route_domain.cpp
@@ -34,26 +34,31 @@ gbp_route_domain::event_handler gbp_route_domain::m_evh;
gbp_route_domain::gbp_route_domain(const gbp_route_domain& rd)
: m_id(rd.id())
, m_rd(rd.m_rd)
+ , m_scope(rd.m_scope)
, m_ip4_uu_fwd(rd.m_ip4_uu_fwd)
, m_ip6_uu_fwd(rd.m_ip6_uu_fwd)
{
}
gbp_route_domain::gbp_route_domain(const route_domain& rd,
+ scope_t scope,
const interface& ip4_uu_fwd,
const interface& ip6_uu_fwd)
: m_id(rd.table_id())
, m_rd(rd.singular())
+ , m_scope(scope)
, m_ip4_uu_fwd(ip4_uu_fwd.singular())
, m_ip6_uu_fwd(ip6_uu_fwd.singular())
{
}
gbp_route_domain::gbp_route_domain(const route_domain& rd,
+ scope_t scope,
const std::shared_ptr<interface> ip4_uu_fwd,
const std::shared_ptr<interface> ip6_uu_fwd)
: m_id(rd.table_id())
, m_rd(rd.singular())
+ , m_scope(scope)
, m_ip4_uu_fwd(ip4_uu_fwd)
, m_ip6_uu_fwd(ip6_uu_fwd)
{
@@ -63,9 +68,10 @@ gbp_route_domain::gbp_route_domain(const route_domain& rd,
m_ip6_uu_fwd = m_ip6_uu_fwd->singular();
}
-gbp_route_domain::gbp_route_domain(const route_domain& rd)
+gbp_route_domain::gbp_route_domain(const route_domain& rd, scope_t scope)
: m_id(rd.table_id())
, m_rd(rd.singular())
+ , m_scope(scope)
, m_ip4_uu_fwd()
, m_ip6_uu_fwd()
{
@@ -120,7 +126,7 @@ gbp_route_domain::operator==(const gbp_route_domain& b) const
else
equal = false;
- return ((m_rd->key() == b.m_rd->key()) && equal);
+ return ((m_rd->key() == b.m_rd->key()) && m_scope == b.m_scope && equal);
}
void
@@ -138,10 +144,10 @@ gbp_route_domain::replay()
if (rc_t::OK == m_id.rc()) {
if (m_ip4_uu_fwd && m_ip6_uu_fwd)
HW::enqueue(new gbp_route_domain_cmds::create_cmd(
- m_id, m_ip4_uu_fwd->handle(), m_ip6_uu_fwd->handle()));
+ m_id, m_scope, m_ip4_uu_fwd->handle(), m_ip6_uu_fwd->handle()));
else
- HW::enqueue(new gbp_route_domain_cmds::create_cmd(m_id, handle_t::INVALID,
- handle_t::INVALID));
+ HW::enqueue(new gbp_route_domain_cmds::create_cmd(
+ m_id, m_scope, handle_t::INVALID, handle_t::INVALID));
}
}
@@ -157,7 +163,7 @@ std::string
gbp_route_domain::to_string() const
{
std::ostringstream s;
- s << "gbp-route-domain:[" << m_rd->to_string();
+ s << "gbp-route-domain:[" << m_rd->to_string() << "scope:" << m_scope;
if (m_ip4_uu_fwd)
s << " v4-uu:[" << m_ip4_uu_fwd->to_string() << "]";
@@ -178,16 +184,13 @@ gbp_route_domain::find(const key_t& key)
void
gbp_route_domain::update(const gbp_route_domain& desired)
{
- /*
- * the desired state is always that the interface should be created
- */
if (rc_t::OK != m_id.rc()) {
if (m_ip4_uu_fwd && m_ip6_uu_fwd)
HW::enqueue(new gbp_route_domain_cmds::create_cmd(
- m_id, m_ip4_uu_fwd->handle(), m_ip6_uu_fwd->handle()));
+ m_id, m_scope, m_ip4_uu_fwd->handle(), m_ip6_uu_fwd->handle()));
else
- HW::enqueue(new gbp_route_domain_cmds::create_cmd(m_id, handle_t::INVALID,
- handle_t::INVALID));
+ HW::enqueue(new gbp_route_domain_cmds::create_cmd(
+ m_id, m_scope, handle_t::INVALID, handle_t::INVALID));
}
}
@@ -230,11 +233,12 @@ gbp_route_domain::event_handler::handle_populate(const client_db::key_t& key)
interface::find(payload.rd.ip4_uu_sw_if_index);
if (ip6_uu_fwd && ip4_uu_fwd) {
- gbp_route_domain rd(payload.rd.rd_id, *ip4_uu_fwd, *ip6_uu_fwd);
+ gbp_route_domain rd(payload.rd.rd_id, payload.rd.scope, *ip4_uu_fwd,
+ *ip6_uu_fwd);
OM::commit(key, rd);
VOM_LOG(log_level_t::DEBUG) << "dump: " << rd.to_string();
} else {
- gbp_route_domain rd(payload.rd.rd_id);
+ gbp_route_domain rd(payload.rd.rd_id, payload.rd.scope);
OM::commit(key, rd);
VOM_LOG(log_level_t::DEBUG) << "dump: " << rd.to_string();
}
diff --git a/extras/vom/vom/gbp_route_domain.hpp b/extras/vom/vom/gbp_route_domain.hpp
index d2dc049deff..dd096738297 100644
--- a/extras/vom/vom/gbp_route_domain.hpp
+++ b/extras/vom/vom/gbp_route_domain.hpp
@@ -16,6 +16,7 @@
#ifndef __VOM_GBP_ROUTE_DOMAIN_H__
#define __VOM_GBP_ROUTE_DOMAIN_H__
+#include "vom/gbp_types.hpp"
#include "vom/interface.hpp"
#include "vom/route_domain.hpp"
#include "vom/singular_db.hpp"
@@ -37,12 +38,14 @@ public:
/**
* Construct a GBP route_domain
*/
- gbp_route_domain(const route_domain& rd);
+ gbp_route_domain(const route_domain& rd, scope_t scope);
gbp_route_domain(const route_domain& rd,
+ scope_t scope,
const interface& ip4_uu_fwd,
const interface& ip6_uu_fwd);
gbp_route_domain(const route_domain& rd,
+ scope_t scope,
const std::shared_ptr<interface> ip4_uu_fwd,
const std::shared_ptr<interface> ip6_uu_fwd);
@@ -171,6 +174,7 @@ private:
HW::item<uint32_t> m_id;
std::shared_ptr<route_domain> m_rd;
+ scope_t m_scope;
std::shared_ptr<interface> m_ip4_uu_fwd;
std::shared_ptr<interface> m_ip6_uu_fwd;
diff --git a/extras/vom/vom/gbp_route_domain_cmds.cpp b/extras/vom/vom/gbp_route_domain_cmds.cpp
index 9b8b4bee3fd..90e81f338e3 100644
--- a/extras/vom/vom/gbp_route_domain_cmds.cpp
+++ b/extras/vom/vom/gbp_route_domain_cmds.cpp
@@ -19,9 +19,11 @@ namespace VOM {
namespace gbp_route_domain_cmds {
create_cmd::create_cmd(HW::item<uint32_t>& item,
+ scope_t scope,
const handle_t ip4_uu_fwd,
const handle_t ip6_uu_fwd)
: rpc_cmd(item)
+ , m_scope(scope)
, m_ip4_uu_fwd(ip4_uu_fwd)
, m_ip6_uu_fwd(ip6_uu_fwd)
{
@@ -31,7 +33,7 @@ bool
create_cmd::operator==(const create_cmd& other) const
{
return ((m_hw_item.data() == other.m_hw_item.data()) &&
- (m_ip4_uu_fwd == other.m_ip4_uu_fwd) &&
+ (m_scope == other.m_scope) && (m_ip4_uu_fwd == other.m_ip4_uu_fwd) &&
(m_ip6_uu_fwd == other.m_ip6_uu_fwd));
}
@@ -43,6 +45,7 @@ create_cmd::issue(connection& con)
auto& payload = req.get_request().get_payload();
payload.rd.rd_id = m_hw_item.data();
+ payload.rd.scope = m_scope;
payload.rd.ip4_table_id = m_hw_item.data();
payload.rd.ip6_table_id = m_hw_item.data();
payload.rd.ip4_uu_sw_if_index = m_ip4_uu_fwd.value();
@@ -57,7 +60,7 @@ std::string
create_cmd::to_string() const
{
std::ostringstream s;
- s << "gbp-route-domain: " << m_hw_item.to_string()
+ s << "gbp-route-domain: " << m_hw_item.to_string() << " scope:" << m_scope
<< " ip4-uu-fwd:" << m_ip4_uu_fwd.to_string()
<< " ip6-uu-fwd:" << m_ip6_uu_fwd.to_string();
diff --git a/extras/vom/vom/gbp_route_domain_cmds.hpp b/extras/vom/vom/gbp_route_domain_cmds.hpp
index 249ba901329..6ef9fcd3ce9 100644
--- a/extras/vom/vom/gbp_route_domain_cmds.hpp
+++ b/extras/vom/vom/gbp_route_domain_cmds.hpp
@@ -35,6 +35,7 @@ public:
* Constructor
*/
create_cmd(HW::item<uint32_t>& item,
+ scope_t scope,
const handle_t ip4_uu_fwd,
const handle_t ip6_uu_fwd);
@@ -53,6 +54,7 @@ public:
bool operator==(const create_cmd& i) const;
private:
+ const scope_t m_scope;
const handle_t m_ip4_uu_fwd;
const handle_t m_ip6_uu_fwd;
};
diff --git a/extras/vom/vom/gbp_types.hpp b/extras/vom/vom/gbp_types.hpp
new file mode 100644
index 00000000000..5b46e08f513
--- /dev/null
+++ b/extras/vom/vom/gbp_types.hpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __VOM_GBP_TYPES_H__
+#define __VOM_GBP_TYPES_H__
+
+#include <stdint.h>
+
+namespace VOM {
+
+/**
+ * EPG IDs are 32 bit integers
+ */
+typedef uint32_t vnid_t;
+typedef uint16_t sclass_t;
+typedef uint16_t scope_t;
+
+}; // namespace
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
+
+#endif