diff --git a/include/ntop_typedefs.h b/include/ntop_typedefs.h index 41f1f81e1c..69121fbf0c 100644 --- a/include/ntop_typedefs.h +++ b/include/ntop_typedefs.h @@ -488,7 +488,7 @@ typedef enum { } FlowHashingEnum; typedef enum { - hash_entry_state_allocated, + hash_entry_state_allocated = 0, hash_entry_state_flow_notyetdetected, /* Flow only */ hash_entry_state_flow_protocoldetected, /* Flow only */ hash_entry_state_active, diff --git a/src/GenericHash.cpp b/src/GenericHash.cpp index 5937d48c4e..1a78fe9f2b 100644 --- a/src/GenericHash.cpp +++ b/src/GenericHash.cpp @@ -248,7 +248,7 @@ u_int GenericHash::purgeIdle(bool force_idle) { } else { switch(head_state) { case hash_entry_state_allocated: - ntop->getTrace()->traceEvent(TRACE_WARNING, "Unexpected state (%u)", head_state); + /* TCP flows with 3WH not yet completed fall here */ break; case hash_entry_state_flow_notyetdetected: @@ -262,7 +262,7 @@ u_int GenericHash::purgeIdle(bool force_idle) { break; case hash_entry_state_active: - if(head->is_hash_entry_state_idle_transition_ready() || force_idle) + if(force_idle || head->is_hash_entry_state_idle_transition_ready()) head->set_hash_entry_state_idle(); break; } diff --git a/src/GenericHashEntry.cpp b/src/GenericHashEntry.cpp index 63f9aeebc3..6447931279 100644 --- a/src/GenericHashEntry.cpp +++ b/src/GenericHashEntry.cpp @@ -82,7 +82,7 @@ bool GenericHashEntry::walkable() const { /* ***************************************** */ bool GenericHashEntry::idle() const { - return((get_state() == hash_entry_state_idle) ? true : false); + return((get_state() >= hash_entry_state_idle) ? true : false); }; /* ***************************************** */ diff --git a/src/Host.cpp b/src/Host.cpp index 734a2aa5b8..fadd7fa3f7 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -48,8 +48,9 @@ Host::Host(NetworkInterface *_iface, Mac *_mac, /* *************************************** */ Host::~Host() { - if(getUses() > 0 && (!iface->isView() - || !ntop->getGlobals()->isShutdownRequested() /* View hosts are not in sync with viewed flows so during shutdown it can be normal */)) + if((getUses() > 0) + /* View hosts are not in sync with viewed flows so during shutdown it can be normal */ + && (!iface->isView() || !ntop->getGlobals()->isShutdownRequested())) ntop->getTrace()->traceEvent(TRACE_WARNING, "Internal error: num_uses=%u", getUses()); // ntop->getTrace()->traceEvent(TRACE_NORMAL, "Deleting %s (%s)", k, localHost ? "local": "remote"); @@ -624,7 +625,7 @@ const char * Host::getOSDetail(char * const buf, ssize_t buf_len) { /* ***************************************** */ bool Host::is_hash_entry_state_idle_transition_ready() { - if(getUses() > 0 || !iface->is_purge_idle_interface()) + if((getUses() > 0) || (!iface->is_purge_idle_interface())) return(false); switch(ntop->getPrefs()->get_host_stickiness()) { @@ -1134,6 +1135,11 @@ void Host::updateStats(update_stats_user_data_t *update_hosts_stats_user_data) { Mac *cur_mac = getMac(); if(get_state() == hash_entry_state_idle) { + if((getUses() > 0) + /* View hosts are not in sync with viewed flows so during shutdown it can be normal */ + && (!iface->isView() || !ntop->getGlobals()->isShutdownRequested())) + ntop->getTrace()->traceEvent(TRACE_WARNING, "Internal error: num_uses=%u", getUses()); + set_hash_entry_state_ready_to_be_purged(); if(getNumTriggeredAlerts() diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index e4f854ae10..1cbdd37096 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -119,6 +119,7 @@ NetworkInterface::NetworkInterface(const char *name, #if !defined(__APPLE__) && !defined(WIN32) || (Utils::readIPv4((char*)name) == 0) #endif + || custom_interface_type ) ; /* Don't setup MDNS on ZC or RSS interfaces */ else {