From: Victor Julien Date: Wed, 3 Nov 2021 14:02:12 +0000 (+0100) Subject: af-packet: packet checks into debug validate check X-Git-Tag: suricata-7.0.0-beta1~1244 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f8e15f70cdb5f81909ebf43504f98e184a8e848;p=thirdparty%2Fsuricata.git af-packet: packet checks into debug validate check --- diff --git a/src/source-af-packet.c b/src/source-af-packet.c index b72b5b00df..c84c561057 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -57,6 +57,7 @@ #include "source-af-packet.h" #include "runmodes.h" #include "flow-storage.h" +#include "util-validate.h" #ifdef HAVE_AF_PACKET @@ -849,9 +850,11 @@ static TmEcode AFPWritePacket(Packet *p, int version) static void AFPReleaseDataFromRing(Packet *p) { + DEBUG_VALIDATE_BUG_ON(PKT_IS_PSEUDOPKT(p)); + /* Need to be in copy mode and need to detect early release where Ethernet header could not be set (and pseudo packet) */ - if ((p->afp_v.copy_mode != AFP_COPY_MODE_NONE) && !PKT_IS_PSEUDOPKT(p)) { + if (p->afp_v.copy_mode != AFP_COPY_MODE_NONE) { AFPWritePacket(p, TPACKET_V2); } @@ -871,9 +874,11 @@ cleanup: #ifdef HAVE_TPACKET_V3 static void AFPReleasePacketV3(Packet *p) { + DEBUG_VALIDATE_BUG_ON(PKT_IS_PSEUDOPKT(p)); + /* Need to be in copy mode and need to detect early release where Ethernet header could not be set (and pseudo packet) */ - if ((p->afp_v.copy_mode != AFP_COPY_MODE_NONE) && !PKT_IS_PSEUDOPKT(p)) { + if (p->afp_v.copy_mode != AFP_COPY_MODE_NONE) { AFPWritePacket(p, TPACKET_V3); } PacketFreeOrRelease(p); @@ -2910,7 +2915,7 @@ TmEcode DecodeAFP(ThreadVars *tv, Packet *p, void *data) SCEnter(); DecodeThreadVars *dtv = (DecodeThreadVars *)data; - BUG_ON(PKT_IS_PSEUDOPKT(p)); + DEBUG_VALIDATE_BUG_ON(PKT_IS_PSEUDOPKT(p)); /* update counters */ DecodeUpdatePacketCounters(tv, dtv, p);