]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixup BSD port.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 18 Dec 2008 14:11:34 +0000 (14:11 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 18 Dec 2008 14:11:34 +0000 (14:11 +0000)
git-svn-id: file:///svn/unbound/trunk@1401 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/cache/infra.c

index b04cb85887b913f68ca425092421fcfbead78c12..e5a47d35aeca39bc496794bdf87c230d041a5563 100644 (file)
@@ -4,6 +4,7 @@
        - follows -rc makedist from ldns changes (no _rc).
        - ldns tarball updated with 1.4.1rc for DLV unit test.
        - verbose prints about recursion lame detection and server selection.
+       - fixup BSD port for infra host storage. It hashed wrongly.
 
 17 December 2008: Wouter
        - follows ldns makedist.sh. -rc option. autom4te dir removed.
index 29fca32807506955410a82bdd66c990fc863170d..75a39bc755174268f74777ed674c8793be50a839 100644 (file)
@@ -136,8 +136,18 @@ static hashvalue_t
 hash_addr(struct sockaddr_storage* addr, socklen_t addrlen)
 {
        hashvalue_t h = 0xab;
-       h = hashlittle(&addrlen, sizeof(addrlen), h);
-       h = hashlittle(addr, addrlen, h);
+       /* select the pieces to hash, some OS have changing data inside */
+       if(addr_is_ip6(addr, addrlen)) {
+               struct sockaddr_in6* in6 = (struct sockaddr_in6*)addr;
+               h = hashlittle(&in6->sin6_family, sizeof(in6->sin6_family), h);
+               h = hashlittle(&in6->sin6_port, sizeof(in6->sin6_port), h);
+               h = hashlittle(&in6->sin6_addr, INET6_SIZE, h);
+       } else {
+               struct sockaddr_in* in = (struct sockaddr_in*)addr;
+               h = hashlittle(&in->sin_family, sizeof(in->sin_family), h);
+               h = hashlittle(&in->sin_port, sizeof(in->sin_port), h);
+               h = hashlittle(&in->sin_addr, INET_SIZE, h);
+       }
        return h;
 }