Move memset() out of PACKET_INITIALIZE()

The memset() inside PACKET_INITIALIZE() is redundant in some cases and
it is cleaner to do as part of the memory allocation. This simplifies
changes for integrating Tilera mPIPE support because the size of memory
cleared in that case is different from SIZE_OF_PACKET.

For the cases where Packets are directly allocated and then call
PACKET_INITIALIZE() without memset() first, this patch adds memset() calls.

A further change would use GetPacketFromAlloc() directly.
pull/358/merge
Ken Steele 12 years ago committed by Victor Julien
parent 71c22ddfee
commit 699d9e01f1

@ -1557,6 +1557,7 @@ int DecodeIPV4DefragTest01(void)
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
@ -1695,6 +1696,7 @@ int DecodeIPV4DefragTest02(void)
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);
@ -1824,6 +1826,7 @@ int DecodeIPV4DefragTest03(void)
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&pq, 0, sizeof(PacketQueue));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
FlowInitConfig(FLOW_QUIET);

@ -89,6 +89,7 @@ Packet *PacketGetFromAlloc(void)
return NULL;
}
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
p->flags |= PKT_ALLOC;

@ -612,7 +612,6 @@ typedef struct DecodeThreadVars_
*/
#ifndef __SC_CUDA_SUPPORT__
#define PACKET_INITIALIZE(p) { \
memset((p), 0x00, SIZE_OF_PACKET); \
SCMutexInit(&(p)->tunnel_mutex, NULL); \
PACKET_RESET_CHECKSUMS((p)); \
(p)->pkt = ((uint8_t *)(p)) + sizeof(Packet); \
@ -620,7 +619,6 @@ typedef struct DecodeThreadVars_
}
#else
#define PACKET_INITIALIZE(p) { \
memset((p), 0x00, SIZE_OF_PACKET); \
SCMutexInit(&(p)->tunnel_mutex, NULL); \
PACKET_RESET_CHECKSUMS((p)); \
SCMutexInit(&(p)->cuda_mutex, NULL); \

@ -9291,6 +9291,7 @@ static int StreamTcpTest40(void) {
DecodeThreadVars dtv;
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
SET_PKT_LEN(p, sizeof(raw_vlan));
@ -9350,6 +9351,7 @@ static int StreamTcpTest41(void) {
memset(&dtv, 0, sizeof(DecodeThreadVars));
memset(&tv, 0, sizeof(ThreadVars));
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
if (PacketCopyData(p, raw_ip, sizeof(raw_ip)) == -1) {

@ -122,6 +122,7 @@ void PacketPoolInit(intmax_t max_pending_packets) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered while allocating a packet. Exiting...");
exit(EXIT_FAILURE);
}
memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
PacketPoolStorePacket(p);

Loading…
Cancel
Save