Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move memset() out of PACKET_INITIALIZE() to prepare for porting Tilera mPIPE #358

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/decode-ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Packet *PacketGetFromAlloc(void)
return NULL;
}

memset(p, 0, SIZE_OF_PACKET);
PACKET_INITIALIZE(p);
p->flags |= PKT_ALLOC;

Expand Down
6 changes: 2 additions & 4 deletions src/decode.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2007-2012 Open Information Security Foundation
/* Copyright (C) 2007-2013 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
Expand Down Expand Up @@ -612,15 +612,13 @@ 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); \
(p)->livedev = NULL; \
}
#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); \
Expand All @@ -641,7 +639,7 @@ typedef struct DecodeThreadVars_
(p)->dp = 0; \
(p)->proto = 0; \
(p)->recursion_level = 0; \
(p)->flags = 0; \
(p)->flags = (p)->flags & PKT_ALLOC; \
(p)->flowflags = 0; \
(p)->pkt_src = 0; \
FlowDeReference(&((p)->flow)); \
Expand Down
2 changes: 2 additions & 0 deletions src/stream-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9085,6 +9085,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));
Expand Down Expand Up @@ -9144,6 +9145,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) {
Expand Down
1 change: 1 addition & 0 deletions src/tmqh-packetpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down