*
* For ICMP we only consider UNREACHABLE errors atm.
*/
-static inline uint32_t FlowGetKey(const Packet *p)
+static inline uint32_t FlowGetHash(const Packet *p)
{
- uint32_t key;
+ uint32_t hash = 0;
if (p->ip4h != NULL) {
if (p->tcph != NULL || p->udph != NULL) {
fhk.vlan_id[0] = p->vlan_id[0];
fhk.vlan_id[1] = p->vlan_id[1];
- uint32_t hash = hashword(fhk.u32, 5, flow_config.hash_rand);
- key = hash % flow_config.hash_size;
+ hash = hashword(fhk.u32, 5, flow_config.hash_rand);
} else if (ICMPV4_DEST_UNREACH_IS_VALID(p)) {
uint32_t psrc = IPV4_GET_RAW_IPSRC_U32(ICMPV4_GET_EMB_IPV4(p));
fhk.vlan_id[0] = p->vlan_id[0];
fhk.vlan_id[1] = p->vlan_id[1];
- uint32_t hash = hashword(fhk.u32, 5, flow_config.hash_rand);
- key = hash % flow_config.hash_size;
+ hash = hashword(fhk.u32, 5, flow_config.hash_rand);
} else {
FlowHashKey4 fhk;
fhk.vlan_id[0] = p->vlan_id[0];
fhk.vlan_id[1] = p->vlan_id[1];
- uint32_t hash = hashword(fhk.u32, 5, flow_config.hash_rand);
- key = hash % flow_config.hash_size;
+ hash = hashword(fhk.u32, 5, flow_config.hash_rand);
}
} else if (p->ip6h != NULL) {
FlowHashKey6 fhk;
fhk.vlan_id[0] = p->vlan_id[0];
fhk.vlan_id[1] = p->vlan_id[1];
- uint32_t hash = hashword(fhk.u32, 11, flow_config.hash_rand);
- key = hash % flow_config.hash_size;
- } else
- key = 0;
+ hash = hashword(fhk.u32, 11, flow_config.hash_rand);
+ }
- return key;
+ return hash;
}
/* Since two or more flows can have the same hash key, we need to compare
Flow *f = NULL;
/* get the key to our bucket */
- uint32_t key = FlowGetKey(p);
+ uint32_t hash = FlowGetHash(p);
/* get our hash bucket and lock it */
- FlowBucket *fb = &flow_hash[key];
+ FlowBucket *fb = &flow_hash[hash % flow_config.hash_size];
FBLOCK_LOCK(fb);
SCLogDebug("fb %p fb->head %p", fb, fb->head);
/* got one, now lock, initialize and return */
FlowInit(f, p);
+ f->flow_hash = hash;
f->fb = fb;
/* update the last seen timestamp of this flow */
COPY_TIMESTAMP(&p->ts,&f->lastts);
Flow *f = NULL;
/* get the key to our bucket */
- uint32_t key = FlowGetKey(p);
+ uint32_t hash = FlowGetHash(p);
/* get our hash bucket and lock it */
- FlowBucket *fb = &flow_hash[key];
+ FlowBucket *fb = &flow_hash[hash % flow_config.hash_size];
FBLOCK_LOCK(fb);
SCLogDebug("fb %p fb->head %p", fb, fb->head);
FlowHashCountInit;
/* get the key to our bucket */
- uint32_t key = FlowGetKey(p);
+ uint32_t hash = FlowGetHash(p);
/* get our hash bucket and lock it */
- FlowBucket *fb = &flow_hash[key];
+ FlowBucket *fb = &flow_hash[hash % flow_config.hash_size];
FBLOCK_LOCK(fb);
SCLogDebug("fb %p fb->head %p", fb, fb->head);
/* got one, now lock, initialize and return */
FlowInit(f, p);
+ f->flow_hash = hash;
f->fb = fb;
/* update the last seen timestamp of this flow */
/* initialize and return */
FlowInit(f, p);
+ f->flow_hash = hash;
f->fb = fb;
/* update the last seen timestamp of this flow */