delete bitop;
}
-void Flow::reset()
+void Flow::reset(bool do_cleanup)
{
if ( session )
- session->cleanup();
+ {
+ if ( do_cleanup )
+ session->cleanup();
+
+ else
+ session->clear();
+ }
free_application_data();
void init(PktType);
void term();
- void reset();
+ void reset(bool do_cleanup = true);
void restart(bool freeAppData = true);
void clear(bool freeAppData = true);
return flow;
}
-int FlowCache::release(Flow* flow, PruneReason reason)
+int FlowCache::release(Flow* flow, PruneReason reason, bool do_cleanup)
{
- flow->reset();
+ flow->reset(do_cleanup);
prune_stats.update(reason);
return remove(flow);
}
return pruned;
}
-bool FlowCache::prune_one(PruneReason reason)
+bool FlowCache::prune_one(PruneReason reason, bool do_cleanup)
{
// so we don't prune the current flow (assume current == MRU)
if ( hash_table->get_count() <= 1 )
assert(flow);
flow->ssn_state.session_flags |= SSNFLAG_PRUNED;
- release(flow, reason);
+ release(flow, reason, false);
return true;
}
Flow* find(const FlowKey*);
Flow* get(const FlowKey*);
- int release(Flow*, PruneReason = PruneReason::USER);
+ int release(Flow*, PruneReason = PruneReason::USER, bool do_cleanup = true);
unsigned prune_unis();
unsigned prune_stale(uint32_t thetime, const Flow* save_me);
unsigned prune_excess(const Flow* save_me);
- bool prune_one(PruneReason);
+ bool prune_one(PruneReason, bool do_cleanup);
unsigned timeout(unsigned num_flows, time_t cur_time);
unsigned purge();
}
// hole for memory manager/prune handler
-bool FlowControl::prune_one(PruneReason reason)
+bool FlowControl::prune_one(PruneReason reason, bool do_cleanup)
{
auto cache = get_cache(last_pkt_type);
- return cache ? cache->prune_one(reason) : false;
+ return cache ? cache->prune_one(reason, do_cleanup) : false;
}
void FlowControl::timeout_flows(uint32_t flowCount, time_t cur_time)
Active::resume();
}
+void FlowControl::preemptive_cleanup(const Packet* p)
+{
+ if ( !memory::MemoryCap::over_threshold() )
+ return;
+
+ DebugFormat(DEBUG_FLOW, "doing preemptive cleanup for packet of type %d",
+ static_cast<int>(p->type()));
+
+ // FIXIT-H J we want to associate this prune with an appropriate prune reason
+ // FIXIT-L J do we want to accumulate preemptive prune counts?
+ prune_flows(p->type(), p);
+}
+
//-------------------------------------------------------------------------
// packet foo
//-------------------------------------------------------------------------
return news;
}
-void FlowControl::preemptive_cleanup(const Packet* p)
-{
- if ( !memory::MemoryCap::over_threshold() )
- return;
-
- DebugFormat(DEBUG_FLOW, "doing preemptive cleanup for packet of type %d",
- static_cast<int>(p->type()));
-
- // FIXIT-H J we want to associate this prune with an appropriate prune reason
- // FIXIT-L J do we want to accumulate preemptive prune counts?
- prune_flows(p->type(), p);
-}
-
//-------------------------------------------------------------------------
// ip
//-------------------------------------------------------------------------
void delete_flow(Flow*, PruneReason);
void purge_flows(PktType);
void prune_flows(PktType, const Packet*);
- bool prune_one(PruneReason);
+ bool prune_one(PruneReason, bool do_cleanup);
void timeout_flows(uint32_t flowCount, time_t cur_time);
char expected_flow(Flow*, Packet*);
TIMEOUT,
EXCESS,
UNI,
+ PREEMPTIVE,
+ MEMCAP,
USER,
MAX
};
{
// assert(flow_con);
if ( flow_con )
- flow_con->prune_one(PruneReason::USER);
+ flow_con->prune_one(PruneReason::MEMCAP, false);
}
} // namespace memory
#include "main/snort_types.h"
#include "stream/stream_api.h"
-#include "normalize/norm.h"
+#include "network_inspectors/normalize/norm.h"
#include "flow/session.h"
#define STREAM_DEFAULT_SSN_TIMEOUT 30 /* seconds to timeout a session */