Skip to content

Commit

Permalink
decode/vxlan: Delay var init until needed
Browse files Browse the repository at this point in the history
This commit modifies the var initialization slightly until after
integrity checks have been performed.
  • Loading branch information
jlucovsky authored and victorjulien committed Jun 4, 2021
1 parent 415db83 commit 61fa748
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/decode-vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ void DecodeVXLANConfig(void)
int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
const uint8_t *pkt, uint32_t len)
{
EthernetHdr *ethh = (EthernetHdr *)(pkt + VXLAN_HEADER_LEN);

uint16_t eth_type;
int decode_tunnel_proto = DECODE_TUNNEL_UNSET;
DEBUG_VALIDATE_BUG_ON(pkt == NULL);

/* Initial packet validation */
if (unlikely(!g_vxlan_enabled))
Expand All @@ -153,8 +150,11 @@ int DecodeVXLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
/* Increment stats counter for VXLAN packets */
StatsIncr(tv, dtv->counter_vxlan);

EthernetHdr *ethh = (EthernetHdr *)(pkt + VXLAN_HEADER_LEN);
int decode_tunnel_proto = DECODE_TUNNEL_UNSET;

/* Look at encapsulated Ethernet frame to get next protocol */
eth_type = SCNtohs(ethh->eth_type);
uint16_t eth_type = SCNtohs(ethh->eth_type);
SCLogDebug("VXLAN ethertype 0x%04x", eth_type);

switch (eth_type) {
Expand Down

0 comments on commit 61fa748

Please sign in to comment.