Skip to content

Commit

Permalink
exceptions: add stats counters for flow.memcap
Browse files Browse the repository at this point in the history
  • Loading branch information
jufajardini committed Mar 30, 2023
1 parent 7ae2233 commit a777f30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4877,6 +4877,9 @@
"memcap": {
"type": "integer"
},
"memcap_exception_policy": {
"type": "integer"
},
"memuse": {
"type": "integer"
},
Expand Down
1 change: 1 addition & 0 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv)
dtv->counter_erspan = StatsRegisterMaxCounter("decoder.erspan", tv);
dtv->counter_nsh = StatsRegisterMaxCounter("decoder.nsh", tv);
dtv->counter_flow_memcap = StatsRegisterCounter("flow.memcap", tv);
dtv->counter_flow_memcap_exc_policy = StatsRegisterCounter("flow.memcap_exception_policy", tv);

dtv->counter_tcp_active_sessions = StatsRegisterCounter("tcp.active_sessions", tv);
dtv->counter_flow_total = StatsRegisterCounter("flow.total", tv);
Expand Down
1 change: 1 addition & 0 deletions src/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ typedef struct DecodeThreadVars_
uint16_t counter_defrag_max_hit;

uint16_t counter_flow_memcap;
uint16_t counter_flow_memcap_exc_policy;

uint16_t counter_tcp_active_sessions;
uint16_t counter_flow_total;
Expand Down
11 changes: 11 additions & 0 deletions src/flow-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ static Flow *FlowGetNew(ThreadVars *tv, FlowLookupStruct *fls, Packet *p)
#ifdef DEBUG
if (g_eps_flow_memcap != UINT64_MAX && g_eps_flow_memcap == p->pcap_cnt) {
NoFlowHandleIPS(p);
StatsIncr(tv, fls->dtv->counter_flow_memcap);
// TODO increase exception policy stats ONLY if not set to ignore!!
StatsIncr(tv, fls->dtv->counter_flow_memcap_exc_policy);
SCLogNotice("flow memcap hit at packet %ld", p->pcap_cnt);
return NULL;
}
#endif
Expand All @@ -648,6 +652,10 @@ static Flow *FlowGetNew(ThreadVars *tv, FlowLookupStruct *fls, Packet *p)
f = FlowGetUsedFlow(tv, fls->dtv, p->ts);
if (f == NULL) {
NoFlowHandleIPS(p);
StatsIncr(tv, fls->dtv->counter_flow_memcap);
// TODO increase exception policy stats ONLY if not set to ignore!!
StatsIncr(tv, fls->dtv->counter_flow_memcap_exc_policy);
SCLogNotice("flow memcap hit at packet %ld", p->pcap_cnt);
return NULL;
}
#ifdef UNITTESTS
Expand All @@ -673,6 +681,9 @@ static Flow *FlowGetNew(ThreadVars *tv, FlowLookupStruct *fls, Packet *p)
}
#endif
NoFlowHandleIPS(p);
// TODO increase exception policy stats ONLY if not set to ignore!!
StatsIncr(tv, fls->dtv->counter_flow_memcap_exc_policy);
SCLogNotice("flow memcap hit at packet %ld", p->pcap_cnt);
return NULL;
}

Expand Down

0 comments on commit a777f30

Please sign in to comment.