per flow stat bug fix (counting everything twice)
authorIdo Barnea <[email protected]>
Thu, 3 Mar 2016 11:46:30 +0000 (13:46 +0200)
committerIdo Barnea <[email protected]>
Thu, 3 Mar 2016 11:46:30 +0000 (13:46 +0200)
src/flow_stat.cpp
src/flow_stat.h

index 659de09..cb5c7e0 100644 (file)
@@ -576,7 +576,7 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
         // last stream associated with the entry stopped transmittig.
         // remove user_id <--> hw_id mapping
         uint8_t proto = m_user_id_map.l4_proto(stream->m_rx_check.m_user_id);
-        uint16_t hw_id = m_user_id_map.unmap(stream->m_rx_check.m_user_id);
+        uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_user_id);
         if (hw_id >= MAX_FLOW_STATS) {
             fprintf(stderr, "Error: %s got wrong hw_id %d from unmap\n", __func__, hw_id);
             return -1;
@@ -592,6 +592,7 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
                 p_user_id->set_rx_counter(port, rx_counter);
                 p_user_id->set_tx_counter(port, tx_counter);
             }
+            m_user_id_map.unmap(stream->m_rx_check.m_user_id);
             m_hw_id_map.unmap(hw_id);
         }
     }
@@ -606,7 +607,7 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
     Json::Value root;
     bool ret = false;
 
-    if (! m_api ) {
+    if (m_user_id_map.is_empty()) {
         return false;
     }
     root["name"] = "rx-stats";
index 4ea59a2..eed3b79 100644 (file)
@@ -138,6 +138,7 @@ class CFlowStatUserIdMap {
  public:
     CFlowStatUserIdMap();
     friend std::ostream& operator<<(std::ostream& os, const CFlowStatUserIdMap& cf);
+    bool is_empty() {return (m_map.empty() == true);};
     uint16_t get_hw_id(uint32_t user_id);
     class CFlowStatUserIdInfo * find_user_id(uint32_t user_id);
     class CFlowStatUserIdInfo * add_user_id(uint32_t user_id, uint8_t proto);