Skip to content

Commit

Permalink
decode: don't clear computed csums twice
Browse files Browse the repository at this point in the history
Already done in a generic way by PACKET_RESET_CHECKSUMS.
  • Loading branch information
victorjulien committed Apr 8, 2024
1 parent 40afbf5 commit 561b81d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/decode-icmpv4.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ typedef struct ICMPV4Timestamp_ {
uint32_t tx_ts;
} __attribute__((__packed__)) ICMPV4Timestamp;

#define CLEAR_ICMPV4_PACKET(p) do { \
(p)->level4_comp_csum = -1; \
PACKET_CLEAR_L4VARS((p)); \
(p)->icmpv4h = NULL; \
} while(0)
#define CLEAR_ICMPV4_PACKET(p) \
do { \
PACKET_CLEAR_L4VARS((p)); \
(p)->icmpv4h = NULL; \
} while (0)

#define ICMPV4_HEADER_PKT_OFFSET 8

Expand Down
11 changes: 5 additions & 6 deletions src/decode-icmpv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,11 @@ typedef struct ICMPV6Vars_ {

} ICMPV6Vars;


#define CLEAR_ICMPV6_PACKET(p) do { \
(p)->level4_comp_csum = -1; \
PACKET_CLEAR_L4VARS((p)); \
(p)->icmpv6h = NULL; \
} while(0)
#define CLEAR_ICMPV6_PACKET(p) \
do { \
PACKET_CLEAR_L4VARS((p)); \
(p)->icmpv6h = NULL; \
} while (0)

void DecodeICMPV6RegisterTests(void);

Expand Down
10 changes: 5 additions & 5 deletions src/decode-ipv4.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ typedef struct IPV4Hdr_
#define IPV4_GET_IPPROTO(p) \
IPV4_GET_RAW_IPPROTO((p)->ip4h)

#define CLEAR_IPV4_PACKET(p) do { \
(p)->ip4h = NULL; \
(p)->level3_comp_csum = -1; \
memset(&p->ip4vars, 0x00, sizeof(p->ip4vars)); \
} while (0)
#define CLEAR_IPV4_PACKET(p) \
do { \
(p)->ip4h = NULL; \
memset(&p->ip4vars, 0x00, sizeof(p->ip4vars)); \
} while (0)

enum IPV4OptionFlags {
IPV4_OPT_FLAG_EOL = 0,
Expand Down
10 changes: 5 additions & 5 deletions src/decode-tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ typedef struct TCPVars_
TCPOpt tfo; /* tcp fast open */
} TCPVars;

#define CLEAR_TCP_PACKET(p) { \
(p)->level4_comp_csum = -1; \
PACKET_CLEAR_L4VARS((p)); \
(p)->tcph = NULL; \
}
#define CLEAR_TCP_PACKET(p) \
{ \
PACKET_CLEAR_L4VARS((p)); \
(p)->tcph = NULL; \
}

void DecodeTCPRegisterTests(void);

Expand Down
8 changes: 4 additions & 4 deletions src/decode-udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ typedef struct UDPHdr_
uint16_t uh_sum; /* checksum */
} UDPHdr;

#define CLEAR_UDP_PACKET(p) do { \
(p)->level4_comp_csum = -1; \
(p)->udph = NULL; \
} while (0)
#define CLEAR_UDP_PACKET(p) \
do { \
(p)->udph = NULL; \
} while (0)

void DecodeUDPV4RegisterTests(void);

Expand Down

0 comments on commit 561b81d

Please sign in to comment.