From cbe621fb09b837af3e4adaa0e45fed1607a5288d Mon Sep 17 00:00:00 2001 From: Juliana Fajardini Date: Wed, 11 Jun 2025 18:29:58 -0300 Subject: [PATCH] decode: add stats counters for ipv4/ipv6 over ipv4 These existed for ipv6 over ipv6, and ipv4 over ipv6, but not for the ipv4 counterpart. Task #7758 --- etc/schema.json | 6 ++++++ src/decode-ipv4.c | 2 ++ src/decode.c | 2 ++ src/decode.h | 2 ++ 4 files changed, 12 insertions(+) diff --git a/etc/schema.json b/etc/schema.json index 79071ef3f6..5149a7dd4c 100644 --- a/etc/schema.json +++ b/etc/schema.json @@ -6064,12 +6064,18 @@ "ipv4": { "type": "integer" }, + "ipv4_in_ipv4": { + "type": "integer" + }, "ipv4_in_ipv6": { "type": "integer" }, "ipv6": { "type": "integer" }, + "ipv6_in_ipv4": { + "type": "integer" + }, "ipv6_in_ipv6": { "type": "integer" }, diff --git a/src/decode-ipv4.c b/src/decode-ipv4.c index 2420f9c6ac..01979f8edd 100644 --- a/src/decode-ipv4.c +++ b/src/decode-ipv4.c @@ -591,6 +591,7 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, if (tp != NULL) { PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV4); PacketEnqueueNoLock(&tv->decode_pq, tp); + StatsIncr(tv, dtv->counter_ipv6inipv4); } FlowSetupPacket(p); break; @@ -601,6 +602,7 @@ int DecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, if (tp != NULL) { PKT_SET_SRC(tp, PKT_SRC_DECODER_IPV4); PacketEnqueueNoLock(&tv->decode_pq, tp); + StatsIncr(tv, dtv->counter_ipv4inipv4); } FlowSetupPacket(p); break; diff --git a/src/decode.c b/src/decode.c index ad4ea19bd8..6c225b0abc 100644 --- a/src/decode.c +++ b/src/decode.c @@ -664,6 +664,8 @@ void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv) dtv->counter_vntag = StatsRegisterCounter("decoder.vntag", tv); dtv->counter_ieee8021ah = StatsRegisterCounter("decoder.ieee8021ah", tv); dtv->counter_teredo = StatsRegisterCounter("decoder.teredo", tv); + dtv->counter_ipv4inipv4 = StatsRegisterCounter("decoder.ipv4_in_ipv4", tv); + dtv->counter_ipv6inipv4 = StatsRegisterCounter("decoder.ipv6_in_ipv4", tv); dtv->counter_ipv4inipv6 = StatsRegisterCounter("decoder.ipv4_in_ipv6", tv); dtv->counter_ipv6inipv6 = StatsRegisterCounter("decoder.ipv6_in_ipv6", tv); dtv->counter_mpls = StatsRegisterCounter("decoder.mpls", tv); diff --git a/src/decode.h b/src/decode.h index bd0fdb4cd9..62c699d7b2 100644 --- a/src/decode.h +++ b/src/decode.h @@ -1007,6 +1007,8 @@ typedef struct DecodeThreadVars_ uint16_t counter_pppoe; uint16_t counter_teredo; uint16_t counter_mpls; + uint16_t counter_ipv4inipv4; + uint16_t counter_ipv6inipv4; uint16_t counter_ipv4inipv6; uint16_t counter_ipv6inipv6; uint16_t counter_erspan;