From 1bdf2b2b6a9ad9624738e42491076b8445a7d6f4 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 18 Dec 2008 14:11:34 +0000 Subject: [PATCH] Fixup BSD port. git-svn-id: file:///svn/unbound/trunk@1401 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 1 + services/cache/infra.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index b04cb8588..e5a47d35a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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. diff --git a/services/cache/infra.c b/services/cache/infra.c index 29fca3280..75a39bc75 100644 --- a/services/cache/infra.c +++ b/services/cache/infra.c @@ -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; } -- 2.47.3