From b2b33063a8dffb9ebb65d6103a3f5dd0b0cc4b20 Mon Sep 17 00:00:00 2001 From: Juliana Fajardini Date: Thu, 30 Mar 2023 16:53:01 -0300 Subject: [PATCH] defrag: add defrag memcap stats counter Task #5816 --- etc/schema.json | 3 +++ src/decode.c | 2 ++ src/decode.h | 1 + src/defrag.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/etc/schema.json b/etc/schema.json index d86417e5fcd8..3936ce9668c9 100644 --- a/etc/schema.json +++ b/etc/schema.json @@ -4747,6 +4747,9 @@ "max_frag_hits": { "type": "integer" }, + "memcap_exception_policy": { + "type": "integer" + }, "ipv4": { "type": "object", "properties": { diff --git a/src/decode.c b/src/decode.c index 6e3f4c058fc4..81faaea845cc 100644 --- a/src/decode.c +++ b/src/decode.c @@ -593,6 +593,8 @@ void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv) dtv->counter_defrag_ipv6_reassembled = StatsRegisterCounter("defrag.ipv6.reassembled", tv); dtv->counter_defrag_max_hit = StatsRegisterCounter("defrag.max_frag_hits", tv); + dtv->counter_defrag_memcap_exc_policy = + StatsRegisterCounter("defrag.memcap_exception_policy", tv); for (int i = 0; i < DECODE_EVENT_MAX; i++) { BUG_ON(i != (int)DEvents[i].code); diff --git a/src/decode.h b/src/decode.h index ae3c8b13b624..5bc7ba948421 100644 --- a/src/decode.h +++ b/src/decode.h @@ -713,6 +713,7 @@ typedef struct DecodeThreadVars_ uint16_t counter_defrag_ipv6_fragments; uint16_t counter_defrag_ipv6_reassembled; uint16_t counter_defrag_max_hit; + uint16_t counter_defrag_memcap_exc_policy; uint16_t counter_flow_memcap; uint16_t counter_flow_memcap_exc_policy; diff --git a/src/defrag.c b/src/defrag.c index 2efcbfa7c81a..13bc71fdf36b 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -1043,6 +1043,8 @@ Defrag(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p) tracker = DefragGetTracker(tv, dtv, p); if (tracker == NULL) { StatsIncr(tv, dtv->counter_defrag_max_hit); + /* currently, whenever tracker is NULL, ExceptionPolicyApply has been called */ + StatsIncr(tv, dtv->counter_defrag_memcap_exc_policy); return NULL; }