]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
defrag: use IP ID in hash
authorEric Leblond <eric@regit.org>
Fri, 27 Jul 2012 09:22:03 +0000 (11:22 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 6 Aug 2012 14:11:19 +0000 (16:11 +0200)
This patch fixes the collision issue observed on an intensive network
trafic. When there is fragmentation it is the case for all data
exchanged between two hosts. Thus using a hash func only involving
IP addresses (and protocol) was leading to a collision for all
exchanges between the hosts. At a larger scale, it was resulting in
a packet loss. By using the IP ID instead of the protocol family, we
introduce a real difference between the trackers.

src/defrag.c

index 0aafe4b84f7f283aa94e0b71e94621d700c742f6..99a320a8489ae2211eb2020a933cbdadd2d2d393 100644 (file)
@@ -231,12 +231,12 @@ DefragHashFunc(HashListTable *ht, void *data, uint16_t datalen)
     uint32_t key;
 
     if (p->af == AF_INET) {
-        key = (defrag_hash_rand + p->af +
+        key = (defrag_hash_rand + p->id +
             p->src_addr.addr_data32[0] + p->dst_addr.addr_data32[0]) %
             defrag_hash_size;
     }
     else if (p->af == AF_INET6) {
-        key = (defrag_hash_rand + p->af +
+        key = (defrag_hash_rand + p->id +
             p->src_addr.addr_data32[0] + p->src_addr.addr_data32[1] +
             p->src_addr.addr_data32[2] + p->src_addr.addr_data32[3] +
             p->dst_addr.addr_data32[0] + p->dst_addr.addr_data32[1] +