diff --git a/src/source-af-packet.c b/src/source-af-packet.c index f86617fc26..f91a39ce7f 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -648,15 +648,17 @@ TmEcode AFPReleaseDataFromRing(ThreadVars *t, Packet *p) } if (AFPDerefSocket(p->afp_v.mpeer) == 0) - return ret; + goto cleanup; if (p->afp_v.relptr) { union thdr h; h.raw = p->afp_v.relptr; h.h2->tp_status = TP_STATUS_KERNEL; - return ret; } - return TM_ECODE_FAILED; + +cleanup: + AFPV_CLEANUP(&p->afp_v); + return ret; } /** diff --git a/src/source-af-packet.h b/src/source-af-packet.h index 0fcd2cb863..e65a1f2a7a 100644 --- a/src/source-af-packet.h +++ b/src/source-af-packet.h @@ -93,7 +93,12 @@ typedef struct AFPPeer_ { TAILQ_ENTRY(AFPPeer_) next; } AFPPeer; -/* per packet AF_PACKET vars */ +/** + * \brief per packet AF_PACKET vars + * + * This structure is used y the release data system and is cleaned + * up by the AFPV_CLEANUP macro below. + */ typedef struct AFPPacketVars_ { void *relptr; @@ -105,6 +110,13 @@ typedef struct AFPPacketVars_ AFPPeer *mpeer; } AFPPacketVars; +#define AFPV_CLEANUP(afpv) do { \ + (afpv)->relptr = NULL; \ + (afpv)->copy_mode = 0; \ + (afpv)->peer = NULL; \ + (afpv)->mpeer = NULL; \ +} while(0) + /** * @} */