X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvpp-api%2Fvom%2Fbridge_domain_entry.cpp;h=241de9537717495e36d6ba9cc2a6cfffce839a18;hb=756cd9441752fc8f84104c9ee19099506ba89f85;hp=7a1245b0f4d248b31f14d60badb373c02681ac83;hpb=f29e85f9fa888e5544b19db78a752c03337ca14d;p=vpp.git diff --git a/src/vpp-api/vom/bridge_domain_entry.cpp b/src/vpp-api/vom/bridge_domain_entry.cpp index 7a1245b0f4d..241de953771 100644 --- a/src/vpp-api/vom/bridge_domain_entry.cpp +++ b/src/vpp-api/vom/bridge_domain_entry.cpp @@ -14,6 +14,8 @@ */ #include "vom/bridge_domain_entry.hpp" +#include "vom/bridge_domain_entry_cmds.hpp" +#include "vom/singular_db_funcs.hpp" namespace VOM { singular_db @@ -54,19 +56,32 @@ bridge_domain_entry::bridge_domain_entry(const bridge_domain_entry& bde) { } +const bridge_domain_entry::key_t +bridge_domain_entry::key() const +{ + return (std::make_pair(m_bd->key(), m_mac)); +} + +bool +bridge_domain_entry::operator==(const bridge_domain_entry& bde) const +{ + return ((key() == bde.key()) && (m_tx_itf == bde.m_tx_itf)); +} + bridge_domain_entry::~bridge_domain_entry() { sweep(); // not in the DB anymore. - m_db.release(std::make_pair(m_bd->id(), m_mac), this); + m_db.release(key(), this); } void bridge_domain_entry::sweep() { if (m_hw) { - HW::enqueue(new 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(); } @@ -75,7 +90,9 @@ void bridge_domain_entry::replay() { if (m_hw) { - HW::enqueue(new create_cmd(m_hw, m_mac, m_bd->id(), m_tx_itf->handle())); + HW::enqueue(new bridge_domain_entry_cmds::create_cmd( + m_hw, m_mac, m_bd->id(), m_tx_itf->handle(), + interface::type_t::BVI == m_tx_itf->type())); } } std::string @@ -95,14 +112,22 @@ bridge_domain_entry::update(const bridge_domain_entry& r) * create the table if it is not yet created */ if (rc_t::OK != m_hw.rc()) { - HW::enqueue(new create_cmd(m_hw, m_mac, m_bd->id(), m_tx_itf->handle())); + HW::enqueue(new bridge_domain_entry_cmds::create_cmd( + m_hw, m_mac, m_bd->id(), m_tx_itf->handle(), + interface::type_t::BVI == m_tx_itf->type())); } } std::shared_ptr bridge_domain_entry::find_or_add(const bridge_domain_entry& temp) { - return (m_db.find_or_add(std::make_pair(temp.m_bd->id(), temp.m_mac), temp)); + return (m_db.find_or_add(temp.key(), temp)); +} + +std::shared_ptr +bridge_domain_entry::find(const key_t& k) +{ + return (m_db.find(k)); } std::shared_ptr @@ -114,7 +139,7 @@ bridge_domain_entry::singular() const void bridge_domain_entry::dump(std::ostream& os) { - m_db.dump(os); + db_dump(m_db, os); } bridge_domain_entry::event_handler::event_handler() @@ -133,8 +158,8 @@ bridge_domain_entry::event_handler::handle_replay() void bridge_domain_entry::event_handler::handle_populate(const client_db::key_t& key) { - std::shared_ptr cmd( - new bridge_domain_entry::dump_cmd()); + std::shared_ptr cmd = + std::make_shared(); HW::enqueue(cmd); HW::write(); @@ -144,11 +169,21 @@ bridge_domain_entry::event_handler::handle_populate(const client_db::key_t& key) std::shared_ptr itf = interface::find(payload.sw_if_index); std::shared_ptr bd = bridge_domain::find(payload.bd_id); + + if (!bd || !itf) { + VOM_LOG(log_level_t::ERROR) << "bridge-domain-entry dump:" + << " itf:" << payload.sw_if_index + << " bd:" << payload.bd_id; + continue; + } + mac_address_t mac(payload.mac); bridge_domain_entry bd_e(*bd, mac, *itf); - VOM_LOG(log_level_t::DEBUG) << "bd-entry-dump: " << bd->to_string() - << mac.to_string() << itf->to_string(); + VOM_LOG(log_level_t::DEBUG) << "bridge-domain-entry dump:" + << " " << bd->to_string() << " " + << itf->to_string() << " mac:[" + << mac.to_string() << "]"; /* * Write each of the discovered interfaces into the OM, @@ -168,7 +203,7 @@ bridge_domain_entry::event_handler::order() const void bridge_domain_entry::event_handler::show(std::ostream& os) { - m_db.dump(os); + db_dump(m_db, os); } std::ostream&