VOM: l2fib: Add bvi flag support
Change-Id: I03d7508649e80a538fcf9541815e2c29224bc87a
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vpp-api/vom/bridge_domain_entry.cpp b/src/vpp-api/vom/bridge_domain_entry.cpp
index 9723bde..9ac5cea 100644
--- a/src/vpp-api/vom/bridge_domain_entry.cpp
+++ b/src/vpp-api/vom/bridge_domain_entry.cpp
@@ -79,8 +79,8 @@
bridge_domain_entry::sweep()
{
if (m_hw) {
- HW::enqueue(
- new bridge_domain_entry_cmds::delete_cmd(m_hw, m_mac, m_bd->id()));
+ HW::enqueue(new bridge_domain_entry_cmds::delete_cmd(
+ m_hw, m_mac, m_bd->id(), interface::type_t::BVI == m_tx_itf->type()));
}
HW::write();
}
@@ -90,7 +90,8 @@
{
if (m_hw) {
HW::enqueue(new bridge_domain_entry_cmds::create_cmd(
- m_hw, m_mac, m_bd->id(), m_tx_itf->handle()));
+ m_hw, m_mac, m_bd->id(), m_tx_itf->handle(),
+ interface::type_t::BVI == m_tx_itf->type()));
}
}
std::string
@@ -111,7 +112,8 @@
*/
if (rc_t::OK != m_hw.rc()) {
HW::enqueue(new bridge_domain_entry_cmds::create_cmd(
- m_hw, m_mac, m_bd->id(), m_tx_itf->handle()));
+ m_hw, m_mac, m_bd->id(), m_tx_itf->handle(),
+ interface::type_t::BVI == m_tx_itf->type()));
}
}
diff --git a/src/vpp-api/vom/bridge_domain_entry_cmds.cpp b/src/vpp-api/vom/bridge_domain_entry_cmds.cpp
index ddb8bf1..f2a3ed9 100644
--- a/src/vpp-api/vom/bridge_domain_entry_cmds.cpp
+++ b/src/vpp-api/vom/bridge_domain_entry_cmds.cpp
@@ -20,11 +20,13 @@
create_cmd::create_cmd(HW::item<bool>& item,
const mac_address_t& mac,
uint32_t bd,
- handle_t tx_itf)
+ handle_t tx_itf,
+ bool is_bvi)
: rpc_cmd(item)
, m_mac(mac)
, m_bd(bd)
, m_tx_itf(tx_itf)
+ , m_is_bvi(is_bvi)
{
}
@@ -32,7 +34,7 @@
create_cmd::operator==(const create_cmd& other) const
{
return ((m_mac == other.m_mac) && (m_tx_itf == other.m_tx_itf) &&
- (m_bd == other.m_bd));
+ (m_bd == other.m_bd) && (m_is_bvi == other.m_is_bvi));
}
rc_t
@@ -45,6 +47,7 @@
payload.is_add = 1;
m_mac.to_bytes(payload.mac, 6);
payload.sw_if_index = m_tx_itf.value();
+ payload.bvi_mac = m_is_bvi;
VAPI_CALL(req.execute());
@@ -58,24 +61,28 @@
{
std::ostringstream s;
s << "bridge-domain-entry-create: " << m_hw_item.to_string() << " bd:" << m_bd
- << " mac:" << m_mac.to_string() << " tx:" << m_tx_itf;
+ << " mac:" << m_mac.to_string() << " tx:" << m_tx_itf
+ << " bvi:" << m_is_bvi;
return (s.str());
}
delete_cmd::delete_cmd(HW::item<bool>& item,
const mac_address_t& mac,
- uint32_t bd)
+ uint32_t bd,
+ bool is_bvi)
: rpc_cmd(item)
, m_mac(mac)
, m_bd(bd)
+ , m_is_bvi(is_bvi)
{
}
bool
delete_cmd::operator==(const delete_cmd& other) const
{
- return ((m_mac == other.m_mac) && (m_bd == other.m_bd));
+ return ((m_mac == other.m_mac) && (m_bd == other.m_bd) &&
+ (m_is_bvi == other.m_is_bvi));
}
rc_t
@@ -85,9 +92,10 @@
auto& payload = req.get_request().get_payload();
payload.bd_id = m_bd;
- payload.is_add = 1;
+ payload.is_add = 0;
m_mac.to_bytes(payload.mac, 6);
payload.sw_if_index = ~0;
+ payload.bvi_mac = m_is_bvi;
VAPI_CALL(req.execute());
@@ -102,7 +110,7 @@
{
std::ostringstream s;
s << "bridge-domain-entry-delete: " << m_hw_item.to_string() << " bd:" << m_bd
- << " mac:" << m_mac.to_string();
+ << " mac:" << m_mac.to_string() << " bvi:" << m_is_bvi;
return (s.str());
}
diff --git a/src/vpp-api/vom/bridge_domain_entry_cmds.hpp b/src/vpp-api/vom/bridge_domain_entry_cmds.hpp
index 780c376..dc46719 100644
--- a/src/vpp-api/vom/bridge_domain_entry_cmds.hpp
+++ b/src/vpp-api/vom/bridge_domain_entry_cmds.hpp
@@ -37,7 +37,8 @@
create_cmd(HW::item<bool>& item,
const mac_address_t& mac,
uint32_t id,
- handle_t tx_intf);
+ handle_t tx_intf,
+ bool is_bvi);
/**
* Issue the command to VPP/HW
@@ -58,6 +59,7 @@
mac_address_t m_mac;
uint32_t m_bd;
handle_t m_tx_itf;
+ bool m_is_bvi;
};
/**
@@ -69,7 +71,10 @@
/**
* Constructor
*/
- delete_cmd(HW::item<bool>& item, const mac_address_t& mac, uint32_t id);
+ delete_cmd(HW::item<bool>& item,
+ const mac_address_t& mac,
+ uint32_t id,
+ bool is_bvi);
/**
* Issue the command to VPP/HW
@@ -89,6 +94,7 @@
private:
mac_address_t m_mac;
uint32_t m_bd;
+ bool m_is_bvi;
};
/**
diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp
index 9176915..f12f871 100644
--- a/test/ext/vom_test.cpp
+++ b/test/ext/vom_test.cpp
@@ -736,6 +736,7 @@
VppInit vi;
const std::string franz = "FranzKafka";
const std::string dante = "Dante";
+ const std::string jkr = "jkrowling";
rc_t rc = rc_t::OK;
/*
@@ -801,7 +802,8 @@
HW::item<bool> hw_be1(true, rc_t::OK);
mac_address_t mac1({0,1,2,3,4,5});
bridge_domain_entry *be1 = new bridge_domain_entry(bd1, mac1, itf2);
- ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data()));
+ ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be1, mac1, bd1.id(), hw_ifh2.data(),
+ false));
TRY_CHECK_RC(OM::write(dante, *be1));
// Add some entries to the bridge-domain ARP termination table
@@ -827,13 +829,53 @@
delete be1;
delete bea1;
STRICT_ORDER_OFF();
+ ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
+ ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id(), false));
ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh2.data(), hw_bd.data(), false));
+
+ ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2));
ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name));
- ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be1, mac1, bd1.id()));
- ADD_EXPECT(bridge_domain_arp_entry_cmds::delete_cmd(hw_be1, bd1.id(), mac1, ip1));
- ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
TRY_CHECK(OM::remove(dante));
+
+ // test the BVI entry in l2fib
+ bridge_domain bd2(99);
+
+ HW::item<uint32_t> hw_bd2(99, rc_t::OK);
+ ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd2, bridge_domain::learning_mode_t::ON));
+
+ TRY_CHECK_RC(OM::write(jkr, bd2));
+
+ std::string itf3_name = "bvi";
+ interface itf3(itf3_name,
+ interface::type_t::BVI,
+ interface::admin_state_t::UP);
+
+ HW::item<handle_t> hw_ifh3(5, rc_t::OK);
+ ADD_EXPECT(interface_cmds::loopback_create_cmd(hw_ifh3, itf3_name));
+ ADD_EXPECT(interface_cmds::set_tag(hw_ifh3, itf3_name));
+ ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh3));
+ TRY_CHECK_RC(OM::write(jkr, itf3));
+
+ l2_binding *l2itf3 = new l2_binding(itf3, bd2);
+ ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true));
+ TRY_CHECK_RC(OM::write(jkr, *l2itf3));
+
+ HW::item<bool> hw_be2(true, rc_t::OK);
+ mac_address_t mac2({0,1,2,3,4,5});
+ bridge_domain_entry *be2 = new bridge_domain_entry(bd2, mac2, itf3);
+ ADD_EXPECT(bridge_domain_entry_cmds::create_cmd(hw_be2, mac2, bd2.id(), hw_ifh3.data(), true));
+ TRY_CHECK_RC(OM::write(jkr, *be2));
+
+ delete l2itf3;
+ delete be2;
+ STRICT_ORDER_OFF();
+ ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_bind, hw_ifh3.data(), hw_bd2.data(), true));
+ ADD_EXPECT(bridge_domain_entry_cmds::delete_cmd(hw_be2, mac2, bd2.id(), true));
+ ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh3));
+ ADD_EXPECT(interface_cmds::loopback_delete_cmd(hw_ifh3));
+ ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd2));
+ TRY_CHECK(OM::remove(jkr));
}
BOOST_AUTO_TEST_CASE(test_vxlan) {