From: Victor Julien Date: Fri, 22 Mar 2024 12:37:35 +0000 (+0100) Subject: flow: avoid direct IP header checks X-Git-Tag: suricata-8.0.0-beta1~1408 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d9ae62b6ebe6b89db6e58df9fbc2149330ad97c;p=thirdparty%2Fsuricata.git flow: avoid direct IP header checks To prepare future changes to the Packet header pointers. Ticket: #5517. --- diff --git a/src/flow-hash.c b/src/flow-hash.c index 57e3f99158..150a2f02a7 100644 --- a/src/flow-hash.c +++ b/src/flow-hash.c @@ -116,7 +116,7 @@ typedef struct FlowHashKey6_ { uint32_t FlowGetIpPairProtoHash(const Packet *p) { uint32_t hash = 0; - if (p->ip4h != NULL) { + if (PacketIsIPv4(p)) { FlowHashKey4 fhk = { .pad[0] = 0, }; @@ -137,7 +137,7 @@ uint32_t FlowGetIpPairProtoHash(const Packet *p) fhk.vlan_id[2] = p->vlan_id[2] & g_vlan_mask; hash = hashword(fhk.u32, ARRAY_SIZE(fhk.u32), flow_config.hash_rand); - } else if (p->ip6h != NULL) { + } else if (PacketIsIPv6(p)) { FlowHashKey6 fhk = { .pad[0] = 0, }; @@ -191,7 +191,7 @@ static inline uint32_t FlowGetHash(const Packet *p) { uint32_t hash = 0; - if (p->ip4h != NULL) { + if (PacketIsIPv4(p)) { if (p->tcph != NULL || p->udph != NULL) { FlowHashKey4 fhk = { .pad[0] = 0 }; @@ -257,7 +257,7 @@ static inline uint32_t FlowGetHash(const Packet *p) hash = hashword(fhk.u32, ARRAY_SIZE(fhk.u32), flow_config.hash_rand); } - } else if (p->ip6h != NULL) { + } else if (PacketIsIPv6(p)) { FlowHashKey6 fhk = { .pad[0] = 0 }; if (FlowHashRawAddressIPv6GtU32(p->src.addr_data32, p->dst.addr_data32)) { fhk.src[0] = p->src.addr_data32[0];