From f61d78fb42d2662643e7f0dbdcb97adbc2589dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Wed, 14 May 2014 18:43:20 +0000 Subject: import unbound 1.4.21 --- services/cache/dns.c | 40 ++++++++++++++++++++-------------------- services/cache/dns.h | 8 ++++---- services/cache/infra.c | 22 +++++++++++----------- services/cache/infra.h | 18 +++++++++--------- services/cache/rrset.c | 12 ++++++------ services/cache/rrset.h | 10 +++++----- services/listen_dnsport.c | 5 +++++ services/localzone.c | 10 +++++----- services/mesh.c | 22 ++++++++++++++++++---- services/mesh.h | 2 +- services/outside_network.c | 24 +++++++++++++++--------- services/outside_network.h | 2 +- 12 files changed, 100 insertions(+), 75 deletions(-) (limited to 'services') diff --git a/services/cache/dns.c b/services/cache/dns.c index 6e99b7fa4a88..7dadb5c39656 100644 --- a/services/cache/dns.c +++ b/services/cache/dns.c @@ -66,8 +66,8 @@ * @param region: for qrep allocs. */ static void -store_rrsets(struct module_env* env, struct reply_info* rep, uint32_t now, - uint32_t leeway, int pside, struct reply_info* qrep, +store_rrsets(struct module_env* env, struct reply_info* rep, time_t now, + time_t leeway, int pside, struct reply_info* qrep, struct regional* region) { size_t i; @@ -105,11 +105,11 @@ store_rrsets(struct module_env* env, struct reply_info* rep, uint32_t now, void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, - hashvalue_t hash, struct reply_info* rep, uint32_t leeway, int pside, + hashvalue_t hash, struct reply_info* rep, time_t leeway, int pside, struct reply_info* qrep, struct regional* region) { struct msgreply_entry* e; - uint32_t ttl = rep->ttl; + time_t ttl = rep->ttl; size_t i; /* store RRsets */ @@ -142,7 +142,7 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, /** find closest NS or DNAME and returns the rrset (locked) */ static struct ub_packed_rrset_key* find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen, - uint16_t qclass, uint32_t now, uint16_t searchtype, int stripfront) + uint16_t qclass, time_t now, uint16_t searchtype, int stripfront) { struct ub_packed_rrset_key *rrset; uint8_t lablen; @@ -171,7 +171,7 @@ find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen, /** add addr to additional section */ static void addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region, - struct dns_msg* msg, uint32_t now) + struct dns_msg* msg, time_t now) { if((msg->rep->rrsets[msg->rep->rrset_count] = packed_rrset_copy_region(rrset, region, now))) { @@ -183,7 +183,7 @@ addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region, /** lookup message in message cache */ static struct msgreply_entry* msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, - uint16_t qtype, uint16_t qclass, uint32_t now, int wr) + uint16_t qtype, uint16_t qclass, time_t now, int wr) { struct lruhash_entry* e; struct query_info k; @@ -207,7 +207,7 @@ msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen, /** find and add A and AAAA records for nameservers in delegpt */ static int find_add_addrs(struct module_env* env, uint16_t qclass, - struct regional* region, struct delegpt* dp, uint32_t now, + struct regional* region, struct delegpt* dp, time_t now, struct dns_msg** msg) { struct delegpt_ns* ns; @@ -262,12 +262,12 @@ cache_fill_missing(struct module_env* env, uint16_t qclass, struct delegpt_ns* ns; struct msgreply_entry* neg; struct ub_packed_rrset_key* akey; - uint32_t now = *env->now; + time_t now = *env->now; for(ns = dp->nslist; ns; ns = ns->next) { akey = rrset_cache_lookup(env->rrset_cache, ns->name, ns->namelen, LDNS_RR_TYPE_A, qclass, 0, now, 0); if(akey) { - if(!delegpt_add_rrset_A(dp, region, akey, (int)ns->lame)) { + if(!delegpt_add_rrset_A(dp, region, akey, ns->lame)) { lock_rw_unlock(&akey->entry.lock); return 0; } @@ -285,7 +285,7 @@ cache_fill_missing(struct module_env* env, uint16_t qclass, akey = rrset_cache_lookup(env->rrset_cache, ns->name, ns->namelen, LDNS_RR_TYPE_AAAA, qclass, 0, now, 0); if(akey) { - if(!delegpt_add_rrset_AAAA(dp, region, akey, (int)ns->lame)) { + if(!delegpt_add_rrset_AAAA(dp, region, akey, ns->lame)) { lock_rw_unlock(&akey->entry.lock); return 0; } @@ -307,7 +307,7 @@ cache_fill_missing(struct module_env* env, uint16_t qclass, /** find and add DS or NSEC to delegation msg */ static void find_add_ds(struct module_env* env, struct regional* region, - struct dns_msg* msg, struct delegpt* dp, uint32_t now) + struct dns_msg* msg, struct delegpt* dp, time_t now) { /* Lookup the DS or NSEC at the delegation point. */ struct ub_packed_rrset_key* rrset = rrset_cache_lookup( @@ -369,7 +369,7 @@ dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, int dns_msg_authadd(struct dns_msg* msg, struct regional* region, - struct ub_packed_rrset_key* rrset, uint32_t now) + struct ub_packed_rrset_key* rrset, time_t now) { if(!(msg->rep->rrsets[msg->rep->rrset_count++] = packed_rrset_copy_region(rrset, region, now))) @@ -381,7 +381,7 @@ dns_msg_authadd(struct dns_msg* msg, struct regional* region, struct delegpt* dns_cache_find_delegation(struct module_env* env, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, - struct regional* region, struct dns_msg** msg, uint32_t now) + struct regional* region, struct dns_msg** msg, time_t now) { /* try to find closest NS rrset */ struct ub_packed_rrset_key* nskey; @@ -455,7 +455,7 @@ gen_dns_msg(struct regional* region, struct query_info* q, size_t num) /** generate dns_msg from cached message */ static struct dns_msg* tomsg(struct module_env* env, struct query_info* q, struct reply_info* r, - struct regional* region, uint32_t now, struct regional* scratch) + struct regional* region, time_t now, struct regional* scratch) { struct dns_msg* msg; size_t i; @@ -506,7 +506,7 @@ tomsg(struct module_env* env, struct query_info* q, struct reply_info* r, /** synthesize RRset-only response from cached RRset item */ static struct dns_msg* rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region, - uint32_t now, struct query_info* q) + time_t now, struct query_info* q) { struct dns_msg* msg; struct packed_rrset_data* d = (struct packed_rrset_data*) @@ -535,7 +535,7 @@ rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region, /** synthesize DNAME+CNAME response from cached DNAME item */ static struct dns_msg* synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, - uint32_t now, struct query_info* q) + time_t now, struct query_info* q) { struct dns_msg* msg; struct ub_packed_rrset_key* ck; @@ -599,7 +599,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region, ck->entry.hash = rrset_key_hash(&ck->rk); newd = (struct packed_rrset_data*)regional_alloc_zero(region, sizeof(struct packed_rrset_data) + sizeof(size_t) + - sizeof(uint8_t*) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t*) + sizeof(time_t) + sizeof(uint16_t) + newlen); if(!newd) return NULL; @@ -630,7 +630,7 @@ dns_cache_lookup(struct module_env* env, struct lruhash_entry* e; struct query_info k; hashvalue_t h; - uint32_t now = *env->now; + time_t now = *env->now; struct ub_packed_rrset_key* rrset; /* lookup first, this has both NXdomains and ANSWER responses */ @@ -739,7 +739,7 @@ dns_cache_lookup(struct module_env* env, int dns_cache_store(struct module_env* env, struct query_info* msgqinf, - struct reply_info* msgrep, int is_referral, uint32_t leeway, int pside, + struct reply_info* msgrep, int is_referral, time_t leeway, int pside, struct regional* region) { struct reply_info* rep = NULL; diff --git a/services/cache/dns.h b/services/cache/dns.h index bc9f57c9c0d9..508f34441118 100644 --- a/services/cache/dns.h +++ b/services/cache/dns.h @@ -82,7 +82,7 @@ struct dns_msg { * @return 0 on alloc error (out of memory). */ int dns_cache_store(struct module_env* env, struct query_info* qinf, - struct reply_info* rep, int is_referral, uint32_t leeway, int pside, + struct reply_info* rep, int is_referral, time_t leeway, int pside, struct regional* region); /** @@ -105,7 +105,7 @@ int dns_cache_store(struct module_env* env, struct query_info* qinf, * @param region: to allocate into for qmsg. */ void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, - hashvalue_t hash, struct reply_info* rep, uint32_t leeway, int pside, + hashvalue_t hash, struct reply_info* rep, time_t leeway, int pside, struct reply_info* qrep, struct regional* region); /** @@ -123,7 +123,7 @@ void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo, */ struct delegpt* dns_cache_find_delegation(struct module_env* env, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, - struct regional* region, struct dns_msg** msg, uint32_t timenow); + struct regional* region, struct dns_msg** msg, time_t timenow); /** * Find cached message @@ -177,6 +177,6 @@ struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype, * @return true if worked, false on fail */ int dns_msg_authadd(struct dns_msg* msg, struct regional* region, - struct ub_packed_rrset_key* rrset, uint32_t now); + struct ub_packed_rrset_key* rrset, time_t now); #endif /* SERVICES_CACHE_DNS_H */ diff --git a/services/cache/infra.c b/services/cache/infra.c index c674aca66754..42d6acad1a22 100644 --- a/services/cache/infra.c +++ b/services/cache/infra.c @@ -189,7 +189,7 @@ infra_lookup_nottl(struct infra_cache* infra, struct sockaddr_storage* addr, /** init the data elements */ static void data_entry_init(struct infra_cache* infra, struct lruhash_entry* e, - uint32_t timenow) + time_t timenow) { struct infra_data* data = (struct infra_data*)e->data; data->ttl = timenow + infra->host_ttl; @@ -218,7 +218,7 @@ data_entry_init(struct infra_cache* infra, struct lruhash_entry* e, */ static struct lruhash_entry* new_entry(struct infra_cache* infra, struct sockaddr_storage* addr, - socklen_t addrlen, uint8_t* name, size_t namelen, uint32_t tm) + socklen_t addrlen, uint8_t* name, size_t namelen, time_t tm) { struct infra_data* data; struct infra_key* key = (struct infra_key*)malloc(sizeof(*key)); @@ -248,7 +248,7 @@ new_entry(struct infra_cache* infra, struct sockaddr_storage* addr, int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, - socklen_t addrlen, uint8_t* nm, size_t nmlen, uint32_t timenow, + socklen_t addrlen, uint8_t* nm, size_t nmlen, time_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to) { struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, @@ -317,7 +317,7 @@ infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, int infra_set_lame(struct infra_cache* infra, struct sockaddr_storage* addr, - socklen_t addrlen, uint8_t* nm, size_t nmlen, uint32_t timenow, + socklen_t addrlen, uint8_t* nm, size_t nmlen, time_t timenow, int dnsseclame, int reclame, uint16_t qtype) { struct infra_data* data; @@ -374,7 +374,7 @@ infra_update_tcp_works(struct infra_cache* infra, int infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen, int qtype, - int roundtrip, int orig_rtt, uint32_t timenow) + int roundtrip, int orig_rtt, time_t timenow) { struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, nm, nmlen, 1); @@ -425,19 +425,19 @@ infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr, return rto; } -int infra_get_host_rto(struct infra_cache* infra, +long long infra_get_host_rto(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, - size_t nmlen, struct rtt_info* rtt, int* delay, uint32_t timenow, + size_t nmlen, struct rtt_info* rtt, int* delay, time_t timenow, int* tA, int* tAAAA, int* tother) { struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, nm, nmlen, 0); struct infra_data* data; - int ttl = -2; + long long ttl = -2; if(!e) return -1; data = (struct infra_data*)e->data; if(data->ttl >= timenow) { - ttl = (int)(data->ttl - timenow); + ttl = (long long)(data->ttl - timenow); memmove(rtt, &data->rtt, sizeof(*rtt)); if(timenow < data->probedelay) *delay = (int)(data->probedelay - timenow); @@ -453,7 +453,7 @@ int infra_get_host_rto(struct infra_cache* infra, int infra_edns_update(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm, size_t nmlen, int edns_version, - uint32_t timenow) + time_t timenow) { struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, nm, nmlen, 1); @@ -485,7 +485,7 @@ int infra_get_lame_rtt(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, uint16_t qtype, - int* lame, int* dnsseclame, int* reclame, int* rtt, uint32_t timenow) + int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow) { struct infra_data* host; struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen, diff --git a/services/cache/infra.h b/services/cache/infra.h index 161f5ab4319e..d3976aed7113 100644 --- a/services/cache/infra.h +++ b/services/cache/infra.h @@ -68,10 +68,10 @@ struct infra_key { */ struct infra_data { /** TTL value for this entry. absolute time. */ - uint32_t ttl; + time_t ttl; /** time in seconds (absolute) when probing re-commences, 0 disabled */ - uint32_t probedelay; + time_t probedelay; /** round trip times for timeout calculation */ struct rtt_info rtt; @@ -173,7 +173,7 @@ struct lruhash_entry* infra_lookup_nottl(struct infra_cache* infra, */ int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, - uint32_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to); + time_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to); /** * Set a host to be lame for the given zone. @@ -192,7 +192,7 @@ int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr, */ int infra_set_lame(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, - uint8_t* name, size_t namelen, uint32_t timenow, int dnsseclame, + uint8_t* name, size_t namelen, time_t timenow, int dnsseclame, int reclame, uint16_t qtype); /** @@ -212,7 +212,7 @@ int infra_set_lame(struct infra_cache* infra, */ int infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, int qtype, - int roundtrip, int orig_rtt, uint32_t timenow); + int roundtrip, int orig_rtt, time_t timenow); /** * Update information for the host, store that a TCP transaction works. @@ -240,7 +240,7 @@ void infra_update_tcp_works(struct infra_cache* infra, */ int infra_edns_update(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, - uint8_t* name, size_t namelen, int edns_version, uint32_t timenow); + uint8_t* name, size_t namelen, int edns_version, time_t timenow); /** * Get Lameness information and average RTT if host is in the cache. @@ -263,7 +263,7 @@ int infra_edns_update(struct infra_cache* infra, int infra_get_lame_rtt(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, size_t namelen, uint16_t qtype, - int* lame, int* dnsseclame, int* reclame, int* rtt, uint32_t timenow); + int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow); /** * Get additional (debug) info on timing. @@ -281,9 +281,9 @@ int infra_get_lame_rtt(struct infra_cache* infra, * @return TTL the infra host element is valid for. If -1: not found in cache. * TTL -2: found but expired. */ -int infra_get_host_rto(struct infra_cache* infra, +long long infra_get_host_rto(struct infra_cache* infra, struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name, - size_t namelen, struct rtt_info* rtt, int* delay, uint32_t timenow, + size_t namelen, struct rtt_info* rtt, int* delay, time_t timenow, int* tA, int* tAAAA, int* tother); /** diff --git a/services/cache/rrset.c b/services/cache/rrset.c index b9d20db0e5db..642236231121 100644 --- a/services/cache/rrset.c +++ b/services/cache/rrset.c @@ -120,7 +120,7 @@ rrset_cache_touch(struct rrset_cache* r, struct ub_packed_rrset_key* key, /** see if rrset needs to be updated in the cache */ static int -need_to_update_rrset(void* nd, void* cd, uint32_t timenow, int equal, int ns) +need_to_update_rrset(void* nd, void* cd, time_t timenow, int equal, int ns) { struct packed_rrset_data* newd = (struct packed_rrset_data*)nd; struct packed_rrset_data* cached = (struct packed_rrset_data*)cd; @@ -181,7 +181,7 @@ rrset_update_id(struct rrset_ref* ref, struct alloc_cache* alloc) int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, - struct alloc_cache* alloc, uint32_t timenow) + struct alloc_cache* alloc, time_t timenow) { struct lruhash_entry* e; struct ub_packed_rrset_key* k = ref->key; @@ -237,7 +237,7 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, - uint16_t qtype, uint16_t qclass, uint32_t flags, uint32_t timenow, + uint16_t qtype, uint16_t qclass, uint32_t flags, time_t timenow, int wr) { struct lruhash_entry* e; @@ -268,7 +268,7 @@ rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, } int -rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow) +rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow) { size_t i; for(i=0; ientry.data; @@ -366,7 +366,7 @@ rrset_update_sec_status(struct rrset_cache* r, void rrset_check_sec_status(struct rrset_cache* r, - struct ub_packed_rrset_key* rrset, uint32_t now) + struct ub_packed_rrset_key* rrset, time_t now) { struct packed_rrset_data* updata = (struct packed_rrset_data*)rrset->entry.data; diff --git a/services/cache/rrset.h b/services/cache/rrset.h index 22d36719eafc..92ced928b304 100644 --- a/services/cache/rrset.h +++ b/services/cache/rrset.h @@ -131,7 +131,7 @@ void rrset_cache_touch(struct rrset_cache* r, struct ub_packed_rrset_key* key, * also the rdata is equal (but other parameters in cache are superior). */ int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, - struct alloc_cache* alloc, uint32_t timenow); + struct alloc_cache* alloc, time_t timenow); /** * Lookup rrset. You obtain read/write lock. You must unlock before lookup @@ -149,7 +149,7 @@ int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref, */ struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, - uint32_t flags, uint32_t timenow, int wr); + uint32_t flags, time_t timenow, int wr); /** * Obtain readlock on a (sorted) list of rrset references. @@ -163,7 +163,7 @@ struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r, * RRsets have been purged from the cache. * If true, you hold readlocks on all the ref items. */ -int rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow); +int rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow); /** * Unlock array (sorted) of rrset references. @@ -199,7 +199,7 @@ void rrset_array_unlock_touch(struct rrset_cache* r, struct regional* scratch, * @param now: current time. */ void rrset_update_sec_status(struct rrset_cache* r, - struct ub_packed_rrset_key* rrset, uint32_t now); + struct ub_packed_rrset_key* rrset, time_t now); /** * Looks up security status of an rrset. Looks up the rrset. @@ -211,7 +211,7 @@ void rrset_update_sec_status(struct rrset_cache* r, * @param now: current time. */ void rrset_check_sec_status(struct rrset_cache* r, - struct ub_packed_rrset_key* rrset, uint32_t now); + struct ub_packed_rrset_key* rrset, time_t now); /** * Remove an rrset from the cache, by name and type and flags diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 647cbe07ebd9..368faaea4211 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -328,6 +328,8 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, # else closesocket(s); # endif + *noproto = 0; + *inuse = 0; return -1; } # elif defined(IP_DONTFRAG) @@ -341,12 +343,15 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr, # else closesocket(s); # endif + *noproto = 0; + *inuse = 0; return -1; } # endif /* IPv4 MTU */ } if(bind(s, (struct sockaddr*)addr, addrlen) != 0) { *noproto = 0; + *inuse = 0; #ifndef USE_WINSOCK #ifdef EADDRINUSE *inuse = (errno == EADDRINUSE); diff --git a/services/localzone.c b/services/localzone.c index 9fdab51c1081..4a2187ec4f25 100644 --- a/services/localzone.c +++ b/services/localzone.c @@ -225,7 +225,7 @@ lz_enter_zone(struct local_zones* zones, const char* name, const char* type, /** return name and class and rdata of rr; parses string */ static int get_rr_content(const char* str, uint8_t** nm, uint16_t* type, - uint16_t* dclass, uint32_t* ttl, ldns_buffer* rdata) + uint16_t* dclass, time_t* ttl, ldns_buffer* rdata) { ldns_rr* rr = NULL; ldns_status status = ldns_rr_new_frm_str(&rr, str, 3600, NULL, NULL); @@ -244,7 +244,7 @@ get_rr_content(const char* str, uint8_t** nm, uint16_t* type, } *dclass = ldns_rr_get_class(rr); *type = ldns_rr_get_type(rr); - *ttl = (uint32_t)ldns_rr_ttl(rr); + *ttl = (time_t)ldns_rr_ttl(rr); ldns_buffer_clear(rdata); ldns_buffer_skip(rdata, 2); status = ldns_rr_rdata2buffer_wire(rdata, rr); @@ -356,10 +356,10 @@ new_local_rrset(struct regional* region, struct local_data* node, /** insert RR into RRset data structure; Wastes a couple of bytes */ static int insert_rr(struct regional* region, struct packed_rrset_data* pd, - ldns_buffer* buf, uint32_t ttl) + ldns_buffer* buf, time_t ttl) { size_t* oldlen = pd->rr_len; - uint32_t* oldttl = pd->rr_ttl; + time_t* oldttl = pd->rr_ttl; uint8_t** olddata = pd->rr_data; /* add RR to rrset */ @@ -450,7 +450,7 @@ lz_enter_rr_into_zone(struct local_zone* z, ldns_buffer* buf, struct local_rrset* rrset; struct packed_rrset_data* pd; uint16_t rrtype = 0, rrclass = 0; - uint32_t ttl = 0; + time_t ttl = 0; if(!get_rr_content(rrstr, &nm, &rrtype, &rrclass, &ttl, buf)) { log_err("bad local-data: %s", rrstr); return 0; diff --git a/services/mesh.c b/services/mesh.c index 5c66caf3236d..a8cb115ab935 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -321,6 +321,8 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo, } #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_insert(&mesh->all, &s->node); log_assert(n != NULL); @@ -390,6 +392,8 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo, } #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_insert(&mesh->all, &s->node); log_assert(n != NULL); @@ -422,7 +426,7 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo, } void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo, - uint16_t qflags, uint32_t leeway) + uint16_t qflags, time_t leeway) { struct mesh_state* s = mesh_area_find(mesh, qinfo, qflags&BIT_RD, 0); #ifdef UNBOUND_DEBUG @@ -450,6 +454,8 @@ void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo, } #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_insert(&mesh->all, &s->node); log_assert(n != NULL); @@ -657,6 +663,8 @@ void mesh_detach_subs(struct module_qstate* qstate) RBTREE_FOR(ref, struct mesh_state_ref*, &qstate->mesh_info->sub_set) { #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_delete(&ref->s->super_set, &lookup); log_assert(n != NULL); /* must have been present */ @@ -693,6 +701,8 @@ int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo, } #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_insert(&mesh->all, &sub->node); log_assert(n != NULL); @@ -701,6 +711,8 @@ int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo, /* set new query state to run */ #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_insert(&mesh->run, &sub->run_node); log_assert(n != NULL); @@ -749,6 +761,8 @@ int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub) } #ifdef UNBOUND_DEBUG n = +#else + (void) #endif rbtree_insert(&super->sub_set, &subref->node); log_assert(n != NULL); /* we checked above if statement, the reverse @@ -878,8 +892,8 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep, m->s.env->mesh->num_reply_addrs--; end_time = *m->s.env->now_tv; timeval_subtract(&duration, &end_time, &r->start_time); - verbose(VERB_ALGO, "query took %d.%6.6d sec", - (int)duration.tv_sec, (int)duration.tv_usec); + verbose(VERB_ALGO, "query took %lld.%6.6d sec", + (long long)duration.tv_sec, (int)duration.tv_usec); m->s.env->mesh->replies_sent++; timeval_add(&m->s.env->mesh->replies_sum_wait, &duration); timehist_insert(m->s.env->mesh->histogram, &duration); @@ -1124,7 +1138,7 @@ mesh_stats(struct mesh_area* mesh, const char* str) timeval_divide(&avg, &mesh->replies_sum_wait, mesh->replies_sent); log_info("average recursion processing time " - "%d.%6.6d sec", (int)avg.tv_sec, (int)avg.tv_usec); + "%lld.%6.6d sec", (long long)avg.tv_sec, (int)avg.tv_usec); log_info("histogram of recursion processing times"); timehist_log(mesh->histogram, "recursions"); } diff --git a/services/mesh.h b/services/mesh.h index 5f109779a4d2..54a3cafecc9e 100644 --- a/services/mesh.h +++ b/services/mesh.h @@ -307,7 +307,7 @@ int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo, * @param leeway: TTL leeway what to expire earlier for this update. */ void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo, - uint16_t qflags, uint32_t leeway); + uint16_t qflags, time_t leeway); /** * Handle new event from the wire. A serviced query has returned. diff --git a/services/outside_network.c b/services/outside_network.c index e1cd0fd3877f..373d8f353688 100644 --- a/services/outside_network.c +++ b/services/outside_network.c @@ -1210,6 +1210,8 @@ serviced_create(struct outside_network* outnet, ldns_buffer* buff, int dnssec, sq->to_be_deleted = 0; #ifdef UNBOUND_DEBUG ins = +#else + (void) #endif rbtree_insert(outnet->serviced, &sq->node); log_assert(ins != NULL); /* must not be already present */ @@ -1361,7 +1363,7 @@ serviced_udp_send(struct serviced_query* sq, ldns_buffer* buff) { int rtt, vs; uint8_t edns_lame_known; - uint32_t now = *sq->outnet->now_secs; + time_t now = *sq->outnet->now_secs; if(!infra_host(sq->outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, now, &vs, &edns_lame_known, &rtt)) @@ -1449,6 +1451,8 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c, size_t backlen = 0; #ifdef UNBOUND_DEBUG rbnode_t* rem = +#else + (void) #endif /* remove from tree, and schedule for deletion, so that callbacks * can safely deregister themselves and even create new serviced @@ -1567,7 +1571,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error, (now.tv_sec == sq->last_sent_time.tv_sec && now.tv_usec > sq->last_sent_time.tv_usec)) { /* convert from microseconds to milliseconds */ - int roundtime = ((int)now.tv_sec - (int)sq->last_sent_time.tv_sec)*1000 + int roundtime = ((int)(now.tv_sec - sq->last_sent_time.tv_sec))*1000 + ((int)now.tv_usec - (int)sq->last_sent_time.tv_usec)/1000; verbose(VERB_ALGO, "measured TCP-time at %d msec", roundtime); log_assert(roundtime >= 0); @@ -1576,7 +1580,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error, if(roundtime < TCP_AUTH_QUERY_TIMEOUT*1000) { if(!infra_rtt_update(sq->outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, sq->qtype, - roundtime, sq->last_rtt, (uint32_t)now.tv_sec)) + roundtime, sq->last_rtt, (time_t)now.tv_sec)) log_err("out of memory noting rtt."); } } @@ -1668,7 +1672,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, sq->retry++; if(!(rto=infra_rtt_update(outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, sq->qtype, -1, sq->last_rtt, - (uint32_t)now.tv_sec))) + (time_t)now.tv_sec))) log_err("out of memory in UDP exponential backoff"); if(sq->retry < OUTBOUND_UDP_RETRY) { log_name_addr(VERB_ALGO, "retry query", sq->qbuf+10, @@ -1712,7 +1716,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, /* only store noEDNS in cache if domain is noDNSSEC */ if(!sq->want_dnssec) if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen, - sq->zone, sq->zonelen, -1, (uint32_t)now.tv_sec)) { + sq->zone, sq->zonelen, -1, (time_t)now.tv_sec)) { log_err("Out of memory caching no edns for host"); } sq->status = serviced_query_UDP; @@ -1722,7 +1726,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, log_addr(VERB_ALGO, "serviced query: EDNS works for", &sq->addr, sq->addrlen); if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen, - sq->zone, sq->zonelen, 0, (uint32_t)now.tv_sec)) { + sq->zone, sq->zonelen, 0, (time_t)now.tv_sec)) { log_err("Out of memory caching edns works"); } sq->edns_lame_known = 1; @@ -1739,7 +1743,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, log_addr(VERB_ALGO, "serviced query: EDNS fails for", &sq->addr, sq->addrlen); if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen, - sq->zone, sq->zonelen, -1, (uint32_t)now.tv_sec)) { + sq->zone, sq->zonelen, -1, (time_t)now.tv_sec)) { log_err("Out of memory caching no edns for host"); } } else { @@ -1753,7 +1757,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, (now.tv_sec == sq->last_sent_time.tv_sec && now.tv_usec > sq->last_sent_time.tv_usec)) { /* convert from microseconds to milliseconds */ - int roundtime = ((int)now.tv_sec - (int)sq->last_sent_time.tv_sec)*1000 + int roundtime = ((int)(now.tv_sec - sq->last_sent_time.tv_sec))*1000 + ((int)now.tv_usec - (int)sq->last_sent_time.tv_usec)/1000; verbose(VERB_ALGO, "measured roundtrip at %d msec", roundtime); log_assert(roundtime >= 0); @@ -1762,7 +1766,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error, if(roundtime < 60000) { if(!infra_rtt_update(outnet->infra, &sq->addr, sq->addrlen, sq->zone, sq->zonelen, sq->qtype, roundtime, - sq->last_rtt, (uint32_t)now.tv_sec)) + sq->last_rtt, (time_t)now.tv_sec)) log_err("out of memory noting rtt."); } } @@ -1866,6 +1870,8 @@ void outnet_serviced_query_stop(struct serviced_query* sq, void* cb_arg) if(!sq->cblist && !sq->to_be_deleted) { #ifdef UNBOUND_DEBUG rbnode_t* rem = +#else + (void) #endif rbtree_delete(sq->outnet->serviced, sq); log_assert(rem); /* should be present */ diff --git a/services/outside_network.h b/services/outside_network.h index 9ec81f405e6d..87fe8ff108de 100644 --- a/services/outside_network.h +++ b/services/outside_network.h @@ -63,7 +63,7 @@ struct outside_network { /** Base for select calls */ struct comm_base* base; /** pointer to time in seconds */ - uint32_t* now_secs; + time_t* now_secs; /** pointer to time in microseconds */ struct timeval* now_tv; -- cgit v1.2.3