Go to the documentation of this file.
101 static void FlowWorkerFlowTimeout(
116 const int server = f->
ffr_tc;
117 const int client = f->
ffr_ts;
131 FlowWorkerFlowTimeout(
tv, p, fw, detect_thread);
143 FlowWorkerFlowTimeout(
tv, p, fw, detect_thread);
167 if (f->
proto == IPPROTO_TCP) {
172 int cnt = FlowFinish(
tv, f, fw, detect_thread);
184 FlowEndCountersUpdate(
tv, &fw->
fec, f);
202 if (max_work != 0 && ++i == max_work)
205 if (ret_queue.
len > 0) {
222 #ifdef CAPTURE_OFFLOAD
223 case FLOW_STATE_CAPTURE_BYPASSED: {
227 FlowDeReference(&p->
flow);
236 FlowDeReference(&p->
flow);
270 if (fw->
dtv == NULL) {
271 FlowWorkerThreadDeinit(
tv, fw);
277 FlowWorkerThreadDeinit(
tv, fw);
283 void *detect_thread = NULL;
285 FlowWorkerThreadDeinit(
tv, fw);
293 FlowWorkerThreadDeinit(
tv, fw);
297 SCLogError(
"initializing flow log API for thread failed");
298 FlowWorkerThreadDeinit(
tv, fw);
323 if (detect_thread != NULL) {
384 bool setting_nopayload =
390 if (setting_nopayload) {
391 FlowSetNoPayloadInspectionFlag(p->
flow);
403 if (det_ctx != NULL) {
419 FlowDeReference(&x->
flow);
436 static void FlowWorkerFlowTimeout(
446 FlowWorkerStreamTCPUpdate(
tv, fw, p, det_ctx,
true);
452 if (det_ctx != NULL) {
466 STREAM_TOSERVER : STREAM_TOCLIENT);
472 FlowDeReference(&p->
flow);
479 static inline void FlowWorkerProcessInjectedFlows(
487 if (injected.
len > 0) {
503 uint32_t max_work = 2;
511 UpdateCounters(
tv, fw, &counters);
519 static void PacketAppUpdate2FlowFlags(
Packet *p)
537 SCLogDebug(
"pcap_cnt %" PRIu64
", FLOW_TS_APP_UPDATED|FLOW_TC_APP_UPDATE_NEXT set",
541 SCLogDebug(
"pcap_cnt %" PRIu64
", FLOW_TC_APP_UPDATED|FLOW_TS_APP_UPDATE_NEXT set",
548 SCLogDebug(
"pcap_cnt %" PRIu64
", FLOW_TC_APP_UPDATED|FLOW_TS_APP_UPDATE_NEXT set",
552 SCLogDebug(
"pcap_cnt %" PRIu64
", FLOW_TS_APP_UPDATED|FLOW_TC_APP_UPDATE_NEXT set",
622 ": direction %s FLOW_TS_APP_UPDATE_NEXT %s FLOW_TC_APP_UPDATE_NEXT %s",
637 if (PacketIsTCP(p)) {
644 if (det_ctx == NULL &&
650 FlowWorkerStreamTCPUpdate(
tv, fw, p, det_ctx,
false);
651 PacketAppUpdate2FlowFlags(p);
658 PacketAppUpdate2FlowFlags(p);
667 if (det_ctx != NULL) {
678 if (p->
flow != NULL) {
681 if (FlowIsBypassed(p->
flow)) {
683 if (p->
proto == IPPROTO_TCP) {
694 STREAM_TOSERVER : STREAM_TOCLIENT);
696 }
else if (p->
proto == IPPROTO_UDP) {
718 SCLogDebug(
"not pseudo, no app update: skip");
722 SCLogDebug(
"flow drop in place: remove app update flags");
727 FlowDeReference(&p->
flow);
734 FlowWorkerProcessInjectedFlows(
tv, fw, p);
737 FlowWorkerProcessLocalFlows(
tv, fw, p);
787 return "flow-inject";
796 static bool FlowWorkerIsBusy(
ThreadVars *
tv,
void *flow_worker)
#define PKT_IS_TOCLIENT(p)
bool PacketCheckAction(const Packet *p, const uint8_t a)
FlowQueuePrivate work_queue
struct FlowQueue_ * flow_queue
TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f)
Run flow logger(s)
#define FLOW_TC_APP_UPDATE_NEXT
@ PKT_DROP_REASON_STREAM_PRE_HOOK
void StatsCounterMaxUpdateI64(StatsThreadContext *stats, StatsCounterMaxId id, int64_t x)
update the value of the localmax counter
uint16_t SCAppLayerParserStateIssetFlag(AppLayerParserState *pstate, uint16_t flag)
void FlowCleanupAppLayer(Flow *f)
@ PROFILE_FLOWWORKER_DETECT
TmEcode OutputFlowLogThreadInit(ThreadVars *tv, void **data)
thread init for the flow logger This will run the thread init functions for the individual registered...
@ PROFILE_FLOWWORKER_FLOW_INJECTED
struct FlowWorkerThreadData_ FlowWorkerThreadData
#define PKT_IS_PSEUDOPKT(p)
return 1 if the packet is a pseudo packet
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
#define FLOW_PKT_LAST_PSEUDO
#define SC_ATOMIC_SET(name, val)
Set the value for the atomic variable.
void AppLayerParserTransactionsCleanup(Flow *f, const uint8_t pkt_dir)
remove obsolete (inspected and logged) transactions
@ PROFILE_FLOWWORKER_FLOW_EVICTED
const char * ProfileFlowWorkerIdToString(enum ProfileFlowWorkerId fwi)
DetectPacketHookFunc PreFlowHook
StatsCounterId StatsRegisterCounter(const char *name, StatsThreadContext *stats)
Registers a normal, unqualified counter.
@ PROFILE_FLOWWORKER_TCPPRUNE
@ PKT_SRC_CAPTURE_TIMEOUT
DetectPacketHookFunc PreStreamHook
void SCAppLayerParserStateSetFlag(AppLayerParserState *pstate, uint16_t flag)
#define FLOW_TC_APP_UPDATED
@ PKT_DROP_REASON_FLOW_PRE_HOOK
uint32_t flows_aside_pkt_inject
void AppLayerRegisterThreadCounters(ThreadVars *tv)
Registers per flow counters for all protocols.
StatsCounterId local_bypass_pkts
TmEcode StreamTcpThreadInit(ThreadVars *tv, void *initdata, void **data)
#define SC_ATOMIC_CAS(name, cmpval, newval)
atomic Compare and Switch
#define FLOW_PKT_TOSERVER
Packet * FlowPseudoPacketGet(int direction, Flow *f, const TcpSession *ssn)
void FlowHandlePacket(ThreadVars *tv, FlowLookupStruct *fls, Packet *p)
Entry point for packet flow handling.
void FlowQueuePrivatePrependFlow(FlowQueuePrivate *fqc, Flow *f)
#define PKT_NOPAYLOAD_INSPECTION
StreamTcpThread * stream_thread
bool(* ThreadBusy)(ThreadVars *tv, void *thread_data)
#define PKT_IS_FLUSHPKT(p)
StatsCounterId flows_removed
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
@ PROFILE_FLOWWORKER_STREAM
#define APP_LAYER_PARSER_EOF_TS
TmEcode OutputLoggerThreadDeinit(ThreadVars *tv, void *thread_data)
void DisableDetectFlowFileFlags(Flow *f)
disable file features we don't need Called if we have no detection engine.
simple fifo queue for packets
void StatsCounterDecr(StatsThreadContext *stats, StatsCounterId id)
Decrements the local counter.
#define FLOW_TIMEOUT_REASSEMBLY_DONE
#define FLOWWORKER_PROFILING_START(p, id)
void FlowSparePoolReturnFlows(FlowQueuePrivate *fqp)
#define FLOWLOCK_UNLOCK(fb)
StatsCounterId both_bypass_pkts
TmEcode(* ThreadDeinit)(ThreadVars *, void *)
#define PKT_SET_SRC(p, src_val)
AppLayerParserState * alparser
void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
DetectEngineThreadCtx * DetectEngineThreadCtxPtr
struct FlowWorkerThreadData_::@120 cnt
@ FLOW_STATE_LOCAL_BYPASSED
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION
StatsCounterId flows_aside_needs_work
#define PKT_IS_TOSERVER(p)
Packet * PacketDequeueNoLock(PacketQueueNoLock *qnl)
struct FlowTimeoutCounters FlowTimeoutCounters
void FlowHandlePacketUpdate(Flow *f, Packet *p, ThreadVars *tv, DecodeThreadVars *dtv)
Update Packet and Flow.
#define FLOWLOCK_WRLOCK(fb)
#define STREAM_FLAGS_FOR_PACKET(p)
StatsCounterMaxId flows_injected_max
TmEcode StreamTcp(ThreadVars *, Packet *, void *, PacketQueueNoLock *pq)
Per thread variable structure.
int DetectEngineEnabled(void)
Check if detection is enabled.
StatsCounterId counter_flow_active
TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
initialize thread specific detection engine context
TmEcode(* Func)(ThreadVars *, Packet *, void *)
#define FLOW_PKT_TOCLIENT_FIRST
@ PROFILE_FLOWWORKER_APPLAYERUDP
Flow * FlowQueuePrivateGetFromTop(FlowQueuePrivate *fqc)
#define FLOWWORKER_PROFILING_END(p, id)
void StreamTcpPruneSession(Flow *f, uint8_t flags)
Remove idle TcpSegments from TcpSession.
TmEcode OutputLoggerThreadInit(ThreadVars *tv, const void *initdata, void **data)
bool FlowWorkerGetFlushAck(void *flow_worker)
TmModule tmm_modules[TMM_SIZE]
#define APP_LAYER_PARSER_EOF_TC
int AppLayerHandleUdp(ThreadVars *tv, AppLayerThreadCtx *tctx, Packet *p, Flow *f)
Handle a app layer UDP message.
#define DEBUG_ASSERT_FLOW_LOCKED(f)
int FlowClearMemory(Flow *f, uint8_t proto_map)
Function clear the flow memory before queueing it to spare flow queue.
void TmModuleFlowWorkerRegister(void)
void FlowQueuePrivateAppendPrivate(FlowQueuePrivate *dest, FlowQueuePrivate *src)
void TimeSetByThread(const int thread_id, SCTime_t tv)
StatsCounterId both_bypass_bytes
#define APP_LAYER_PARSER_NO_INSPECTION
FlowQueuePrivate spare_queue
void * FlowWorkerGetDetectCtxPtr(void *flow_worker)
FlowQueuePrivate FlowQueueExtractPrivate(FlowQueue *fq)
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NONE
void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
void FlowFree(Flow *f)
cleanup & free the memory of a flow
void * FlowWorkerGetThreadData(void *flow_worker)
@ PROFILE_FLOWWORKER_SIZE
TmEcode DetectEngineThreadCtxDeinit(ThreadVars *tv, void *data)
uint8_t app_update_direction
void FlowWorkerSetFlushAck(void *flow_worker)
#define FLOW_TS_APP_UPDATED
TmEcode(* ThreadInit)(ThreadVars *, const void *, void **)
void PacketUpdateEngineEventCounters(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p)
TmEcode Detect(ThreadVars *tv, Packet *p, void *data)
Detection engine thread wrapper.
void StreamTcpDetectLogFlush(ThreadVars *tv, StreamTcpThread *stt, Flow *f, Packet *p, PacketQueueNoLock *pq)
create packets in both directions to flush out logging and detection before switching protocols....
void * output_thread_flow
StatsCounterId flows_aside_pkt_inject
#define SCLogError(...)
Macro used to log ERROR messages.
TmEcode OutputFlowLogThreadDeinit(ThreadVars *tv, void *thread_data)
void FramesPrune(Flow *f, Packet *p)
TmEcode OutputLoggerLog(ThreadVars *tv, Packet *p, void *thread_data)
Structure to hold thread specific data for all decode modules.
TmEcode OutputLoggerFlush(ThreadVars *tv, Packet *p, void *thread_data)
void StreamTcpSessionCleanup(TcpSession *ssn)
Session cleanup function. Does not free the ssn.
StatsCounterMaxId StatsRegisterMaxCounter(const char *name, StatsThreadContext *stats)
Registers a counter, whose value holds the maximum of all the values assigned to it.
#define SC_ATOMIC_INITPTR(name)
StatsCounterId counter_tcp_active_sessions
DecodeThreadVars * DecodeThreadVarsAlloc(ThreadVars *tv)
Alloc and setup DecodeThreadVars.
@ PROFILE_FLOWWORKER_FLOW
TcpReassemblyThreadCtx * ra_ctx
void PacketDrop(Packet *p, const uint8_t action, enum PacketDropReason r)
issue drop action
StatsCounterId flows_injected
#define FLOW_END_FLAG_TIMEOUT
bool FlowNeedsReassembly(Flow *f)
Check if a flow needs forced reassembly, or any other processing.
int FlowChangeProto(Flow *f)
Check if change proto flag is set for flow.
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
void FlowEndCountersRegister(ThreadVars *t, FlowEndCounters *fec)
SC_ATOMIC_DECLARE(DetectEngineThreadCtxPtr, detect_thread)
#define FLOW_SPARE_POOL_BLOCK_SIZE
void StatsCounterAddI64(StatsThreadContext *stats, StatsCounterId id, int64_t x)
Adds a value of type uint64_t to the local counter.
#define FLOW_PKT_TOSERVER_FIRST
StatsCounterId local_bypass_bytes
#define DEBUG_VALIDATE_BUG_ON(exp)
@ PKT_DROP_REASON_FLOW_DROP
SC_ATOMIC_DECLARE(bool, flush_ack)
#define FLOW_TS_APP_UPDATE_NEXT
TmEcode StreamTcpThreadDeinit(ThreadVars *tv, void *data)
#define TM_FLAG_FLOWWORKER_TM
void FlowWorkerReplaceDetectCtx(void *flow_worker, void *detect_ctx)
uint32_t flows_aside_needs_work