/**
* \internal
- * \brief Pseudo packet setup for flow forced reassembly.
+ * \brief Pseudo packet setup to finish a flow when needed.
*
+ * \param p a dummy pseudo packet from packet pool. Not all pseudo
+ * packets need to force reassembly, in which case we just
+ * set dummy ack/seq values.
* \param direction Direction of the packet. 0 indicates toserver and 1
* indicates toclient.
* \param f Pointer to the flow.
* \param ssn Pointer to the tcp session.
- * \param dummy Indicates to create a dummy pseudo packet. Not all pseudo
- * packets need to force reassembly, in which case we just
- * set dummy ack/seq values.
+ * \retval pseudo packet with everything set up
*/
-static inline Packet *FlowForceReassemblyPseudoPacketSetup(
+static inline Packet *FlowPseudoPacketSetup(
Packet *p, int direction, Flow *f, const TcpSession *ssn)
{
const int orig_dir = direction;
return NULL;
}
-Packet *FlowForceReassemblyPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn)
+Packet *FlowPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn)
{
PacketPoolWait();
Packet *p = PacketPoolGetPacket();
PACKET_PROFILING_START(p);
- return FlowForceReassemblyPseudoPacketSetup(p, direction, f, ssn);
+ return FlowPseudoPacketSetup(p, direction, f, ssn);
}
/**
* \retval false no
* \retval true yes
*/
-bool FlowForceReassemblyNeedReassembly(Flow *f)
+bool FlowNeedsReassembly(Flow *f)
{
if (f == NULL || f->protoctx == NULL) {
/**
* \internal
- * \brief Forces reassembly for flow if it needs it.
+ * \brief Sends the flow to its respective thread's flow queue.
*
* The function requires flow to be locked beforehand.
*
* flag is set, choose the second thread_id (to client/source).
*
* \param f Pointer to the flow.
- *
- * \retval 0 This flow doesn't need any reassembly processing; 1 otherwise.
*/
-void FlowForceReassemblyForFlow(Flow *f)
+void FlowSendToLocalThread(Flow *f)
{
// Choose the thread_id based on whether the flow has been
// reversed.
/**
* \internal
- * \brief Forces reassembly for flows that need it.
+ * \brief Remove flows from the hash bucket as they have more work to be done in
+ * in the detection engine.
*
* When this function is called we're running in virtually dead engine,
* so locking the flows is not strictly required. The reasons it is still
* - allow us to aggressively check using debug validation assertions
* - be robust in case of future changes
* - locking overhead is negligible when no other thread fights us
- *
- * \param q The queue to process flows from.
*/
-static inline void FlowForceReassemblyForHash(void)
+static inline void FlowRemoveHash(void)
{
for (uint32_t idx = 0; idx < flow_config.hash_size; idx++) {
FlowBucket *fb = &flow_hash[idx];
/* in case of additional work, we pull the flow out of the
* hash and xfer ownership to the injected packet(s) */
- if (FlowForceReassemblyNeedReassembly(f)) {
+ if (FlowNeedsReassembly(f)) {
RemoveFromHash(f, prev_f);
f->flow_end_flags |= FLOW_END_FLAG_SHUTDOWN;
- FlowForceReassemblyForFlow(f);
+ FlowSendToLocalThread(f);
FLOWLOCK_UNLOCK(f);
f = next_f;
continue;
}
/**
- * \brief Force reassembly for all the flows that have unprocessed segments.
+ * \brief Clean up all the flows that have unprocessed segments and have
+ * some work to do in the detection engine.
*/
-void FlowForceReassembly(void)
+void FlowWorkToDoCleanup(void)
{
- /* Carry out flow reassembly for unattended flows */
- FlowForceReassemblyForHash();
+ /* Carry out cleanup of unattended flows */
+ FlowRemoveHash();
}
/* insert a pseudo packet in the toserver direction */
if (client == STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION) {
- Packet *p = FlowForceReassemblyPseudoPacketGet(0, f, ssn);
+ Packet *p = FlowPseudoPacketGet(0, f, ssn);
if (p != NULL) {
PKT_SET_SRC(p, PKT_SRC_FFR);
if (server == STREAM_HAS_UNPROCESSED_SEGMENTS_NONE) {
/* handle toclient */
if (server == STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION) {
- Packet *p = FlowForceReassemblyPseudoPacketGet(1, f, ssn);
+ Packet *p = FlowPseudoPacketGet(1, f, ssn);
if (p != NULL) {
PKT_SET_SRC(p, PKT_SRC_FFR);
p->flowflags |= FLOW_PKT_LAST_PSEUDO;
if (f->proto == IPPROTO_TCP) {
if (!(f->flags & (FLOW_TIMEOUT_REASSEMBLY_DONE | FLOW_ACTION_DROP)) &&
- !FlowIsBypassed(f) && FlowForceReassemblyNeedReassembly(f) && f->ffr != 0) {
+ !FlowIsBypassed(f) && FlowNeedsReassembly(f) && f->ffr != 0) {
/* read detect thread in case we're doing a reload */
void *detect_thread = SC_ATOMIC_GET(fw->detect_thread);
int cnt = FlowFinish(tv, f, fw, detect_thread);