GBP V2
[vpp.git] / src / vpp-api / vom / interface.cpp
index 435002a..6faf349 100644 (file)
@@ -22,6 +22,7 @@
 #include "vom/l3_binding_cmds.hpp"
 #include "vom/logger.hpp"
 #include "vom/prefix.hpp"
+#include "vom/singular_db_funcs.hpp"
 
 namespace VOM {
 /**
@@ -148,13 +149,13 @@ interface::l2_address() const
 interface::const_iterator_t
 interface::cbegin()
 {
-  return m_db.cbegin();
+  return m_db.begin();
 }
 
 interface::const_iterator_t
 interface::cend()
 {
-  return m_db.cend();
+  return m_db.end();
 }
 
 void
@@ -169,6 +170,10 @@ interface::sweep()
   }
 
   if (m_stats) {
+    if (stats_type_t::DETAILED == m_stats_type) {
+      HW::enqueue(new interface_cmds::collect_detail_stats_change_cmd(
+        m_stats_type, handle_i(), false));
+    }
     HW::enqueue(new interface_cmds::stats_disable_cmd(m_hdl.data()));
     m_stats.reset();
   }
@@ -198,6 +203,18 @@ interface::replay()
     HW::enqueue(new interface_cmds::state_change_cmd(m_state, m_hdl));
   }
 
+  if (m_stats) {
+    if (stats_type_t::DETAILED == m_stats_type) {
+      m_stats_type.set(rc_t::NOOP);
+      HW::enqueue(new interface_cmds::collect_detail_stats_change_cmd(
+        m_stats_type, handle_i(), true));
+    }
+    stat_listener& listener = m_stats->listener();
+    listener.status().set(rc_t::NOOP);
+    m_stats.reset(new interface_cmds::stats_enable_cmd(listener, handle_i()));
+    HW::enqueue(m_stats);
+  }
+
   if (m_table_id && (m_table_id.data() != route::DEFAULT_TABLE)) {
     HW::enqueue(
       new interface_cmds::set_table_cmd(m_table_id, l3_proto_t::IPV4, m_hdl));
@@ -258,9 +275,7 @@ interface::key() const
 std::queue<cmd*>&
 interface::mk_create_cmd(std::queue<cmd*>& q)
 {
-  if (type_t::LOOPBACK == m_type) {
-    q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
-  } else if (type_t::BVI == m_type) {
+  if ((type_t::LOOPBACK == m_type) || (type_t::BVI == m_type)) {
     q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
     q.push(new interface_cmds::set_tag(m_hdl, m_name));
     /*
@@ -469,7 +484,7 @@ interface::remove(const HW::item<handle_t>& item)
 void
 interface::dump(std::ostream& os)
 {
-  m_db.dump(os);
+  db_dump(m_db, os);
 }
 
 void
@@ -499,8 +514,12 @@ interface::event_handler::handle_populate(const client_db::key_t& key)
   HW::write();
 
   for (auto& itf_record : *cmd) {
-    std::shared_ptr<interface> itf =
-      interface_factory::new_interface(itf_record.get_payload());
+    auto payload = itf_record.get_payload();
+    VOM_LOG(log_level_t::DEBUG) << "dump: [" << payload.sw_if_index
+                                << " name:" << (char*)payload.interface_name
+                                << " tag:" << (char*)payload.tag << "]";
+
+    std::shared_ptr<interface> itf = interface_factory::new_interface(payload);
 
     if (itf && interface::type_t::LOCAL != itf->type()) {
       VOM_LOG(log_level_t::DEBUG) << "dump: " << itf->to_string();
@@ -610,7 +629,7 @@ interface::event_handler::order() const
 void
 interface::event_handler::show(std::ostream& os)
 {
-  m_db.dump(os);
+  db_dump(m_db, os);
 }
 
 } // namespace VOM