From e14331cbb2732fe3e6376aa45892b513d3d255b5 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 1 Jul 2010 01:31:30 +0200 Subject: [PATCH] Fix PACKET_RECYCLE not cleaning all of the packet. --- src/decode.h | 125 ++++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 60 deletions(-) diff --git a/src/decode.h b/src/decode.h index 7c783e5096..fe3954cfe3 100644 --- a/src/decode.h +++ b/src/decode.h @@ -483,71 +483,76 @@ typedef struct DecodeThreadVars_ * \brief Recycle a packet structure for reuse. * \todo the mutex destroy & init is necessary because of the memset, reconsider */ -#define PACKET_DO_RECYCLE(p) do { \ - (p)->recursion_level = 0; \ - (p)->flags = 0; \ - (p)->flowflags = 0; \ - (p)->flow = NULL; \ - (p)->ts.tv_sec = 0; \ - (p)->ts.tv_usec = 0; \ - (p)->datalink = 0; \ - (p)->action = 0; \ +#define PACKET_DO_RECYCLE(p) do { \ + CLEAR_ADDR(&(p)->src); \ + CLEAR_ADDR(&(p)->dst); \ + (p)->sp = 0; \ + (p)->dp = 0; \ + (p)->proto = 0; \ + (p)->recursion_level = 0; \ + (p)->flags = 0; \ + (p)->flowflags = 0; \ + (p)->flow = NULL; \ + (p)->ts.tv_sec = 0; \ + (p)->ts.tv_usec = 0; \ + (p)->datalink = 0; \ + (p)->action = 0; \ if ((p)->pktvar != NULL) { \ PktVarFree((p)->pktvar); \ (p)->pktvar = NULL; \ } \ - (p)->ethh = NULL; \ - if ((p)->ip4h != NULL) { \ - CLEAR_IPV4_PACKET((p)); \ - } \ - if ((p)->ip6h != NULL) { \ - CLEAR_IPV6_PACKET((p)); \ - } \ - if ((p)->tcph != NULL) { \ - CLEAR_TCP_PACKET((p)); \ - } \ - if ((p)->udph != NULL) { \ - CLEAR_UDP_PACKET((p)); \ - } \ - if ((p)->icmpv4h != NULL) { \ - CLEAR_ICMPV4_PACKET((p)); \ - } \ - if ((p)->icmpv6h != NULL) { \ - CLEAR_ICMPV6_PACKET((p)); \ - } \ - (p)->ppph = NULL; \ - (p)->pppoesh = NULL; \ - (p)->pppoedh = NULL; \ - (p)->greh = NULL; \ - (p)->vlanh = NULL; \ - (p)->payload = NULL; \ - (p)->payload_len = 0; \ - (p)->pktlen = 0; \ - (p)->alerts.cnt = 0; \ - (p)->next = NULL; \ - (p)->prev = NULL; \ - (p)->rtv_cnt = 0; \ - (p)->tpr_cnt = 0; \ + (p)->ethh = NULL; \ + if ((p)->ip4h != NULL) { \ + CLEAR_IPV4_PACKET((p)); \ + } \ + if ((p)->ip6h != NULL) { \ + CLEAR_IPV6_PACKET((p)); \ + } \ + if ((p)->tcph != NULL) { \ + CLEAR_TCP_PACKET((p)); \ + } \ + if ((p)->udph != NULL) { \ + CLEAR_UDP_PACKET((p)); \ + } \ + if ((p)->icmpv4h != NULL) { \ + CLEAR_ICMPV4_PACKET((p)); \ + } \ + if ((p)->icmpv6h != NULL) { \ + CLEAR_ICMPV6_PACKET((p)); \ + } \ + (p)->ppph = NULL; \ + (p)->pppoesh = NULL; \ + (p)->pppoedh = NULL; \ + (p)->greh = NULL; \ + (p)->vlanh = NULL; \ + (p)->payload = NULL; \ + (p)->payload_len = 0; \ + (p)->pktlen = 0; \ + (p)->alerts.cnt = 0; \ + (p)->next = NULL; \ + (p)->prev = NULL; \ + (p)->rtv_cnt = 0; \ + (p)->tpr_cnt = 0; \ SCMutexDestroy(&(p)->mutex_rtv_cnt); \ SCMutexInit(&(p)->mutex_rtv_cnt, NULL); \ - (p)->tunnel_proto = 0; \ - (p)->tunnel_pkt = 0; \ - (p)->tunnel_verdicted = 0; \ - (p)->events.cnt = 0; \ - (p)->root = NULL; \ + (p)->tunnel_proto = 0; \ + (p)->tunnel_pkt = 0; \ + (p)->tunnel_verdicted = 0; \ + (p)->events.cnt = 0; \ + (p)->root = NULL; \ PACKET_RESET_CHECKSUMS((p)); \ } while (0) #ifndef __SC_CUDA_SUPPORT__ #define PACKET_RECYCLE(p) PACKET_DO_RECYCLE((p)) #else -#define PACKET_RECYCLE(p) do { \ - PACKET_DO_RECYCLE((p)); \ - SCMutexDestroy(&(p)->cuda_mutex); \ - SCCondDestroy(&(p)->cuda_cond); \ - SCMutexInit(&(p)->cuda_mutex, NULL); \ - SCCondInit(&(p)->cuda_cond, NULL); \ - PACKET_RESET_CHECKSUMS((p)); \ +#define PACKET_RECYCLE(p) do { \ + PACKET_DO_RECYCLE((p)); \ + SCMutexDestroy(&(p)->cuda_mutex); \ + SCCondDestroy(&(p)->cuda_cond); \ + SCMutexInit(&(p)->cuda_mutex, NULL); \ + SCCondInit(&(p)->cuda_cond, NULL); \ + PACKET_RESET_CHECKSUMS((p)); \ } while(0) #endif @@ -562,13 +567,13 @@ typedef struct DecodeThreadVars_ SCMutexDestroy(&(p)->mutex_rtv_cnt); \ } while (0) #else -#define PACKET_CLEANUP(p) do { \ - if ((p)->pktvar != NULL) { \ - PktVarFree((p)->pktvar); \ - } \ - SCMutexDestroy(&(p)->mutex_rtv_cnt); \ - SCMutexDestroy(&(p)->cuda_mutex); \ - SCCondDestroy(&(p)->cuda_cond); \ +#define PACKET_CLEANUP(p) do { \ + if ((p)->pktvar != NULL) { \ + PktVarFree((p)->pktvar); \ + } \ + SCMutexDestroy(&(p)->mutex_rtv_cnt); \ + SCMutexDestroy(&(p)->cuda_mutex); \ + SCCondDestroy(&(p)->cuda_cond); \ } while(0) #endif