]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
neater API for unbound-control lookup.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 26 Oct 2010 13:43:28 +0000 (13:43 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 26 Oct 2010 13:43:28 +0000 (13:43 +0000)
git-svn-id: file:///svn/unbound/trunk@2310 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/cachedump.c
services/cache/infra.c
services/cache/infra.h

index 2db2268c5439a637165f3a331fb37f2554fd6ad3..43c1a9a23305e9ce3aa6a4fa15229cce73a4ebaa 100644 (file)
@@ -802,8 +802,9 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
 {
        char buf[257];
        struct delegpt_addr* a;
-       int lame, dlame, rlame, rtt, edns_vs, to;
-       int entry_ttl, clean_rtt;
+       int lame, dlame, rlame, rto, edns_vs, to;
+       int entry_ttl;
+       struct rtt_info ri;
        uint8_t edns_lame_known;
        for(a = dp->target_list; a; a = a->next_target) {
                addr_to_str(&a->addr, a->addrlen, buf, sizeof(buf));
@@ -815,37 +816,30 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
                }
                /* lookup in infra cache */
                entry_ttl = infra_get_host_rto(worker->env.infra_cache,
-                       &a->addr, a->addrlen, &clean_rtt, &rtt,
-                       *worker->env.now);
+                       &a->addr, a->addrlen, &ri, *worker->env.now);
                if(entry_ttl == -1) {
                        if(!ssl_printf(ssl, "not in infra cache.\n"))
                                return;
                        continue; /* skip stuff not in infra cache */
-               } else if(entry_ttl == -2) {
-                       if(!ssl_printf(ssl, "not in infra cache.\n"))
-                               return;
-                       continue; /* skip stuff not in infra cache */
                }
 
                /* uses type_A because most often looked up, but other
                 * lameness won't be reported then */
                if(!infra_get_lame_rtt(worker->env.infra_cache, 
                        &a->addr, a->addrlen, dp->name, dp->namelen,
-                       LDNS_RR_TYPE_A, &lame, &dlame, &rlame, &rtt,
+                       LDNS_RR_TYPE_A, &lame, &dlame, &rlame, &rto,
                        *worker->env.now)) {
                        if(!ssl_printf(ssl, "not in infra cache.\n"))
                                return;
                        continue; /* skip stuff not in infra cache */
                }
-               if(!ssl_printf(ssl, "%s%s%s%srtt %d msec, ttl %d",
+               if(!ssl_printf(ssl, "%s%s%s%srto %d msec, ttl %d, ping %d "
+                       "var %d rtt %d",
                        lame?"LAME ":"", dlame?"NoDNSSEC ":"",
                        a->lame?"AddrWasParentSide ":"",
-                       rlame?"NoAuthButRecursive ":"", rtt, entry_ttl))
+                       rlame?"NoAuthButRecursive ":"", rto, entry_ttl,
+                       ri.srtt, ri.rttvar, rtt_notimeout(&ri)))
                        return;
-               if(rtt != clean_rtt && clean_rtt != 376 /* unknown */) {
-                       if(!ssl_printf(ssl, ", ping %d", clean_rtt))
-                               return;
-               }
                if(infra_host(worker->env.infra_cache, &a->addr, a->addrlen,
                        *worker->env.now, &edns_vs, &edns_lame_known, &to)) {
                        if(edns_vs == -1) {
index 5c21f7555f86684d7805959f4f3ed658e89e7199..4ac51f69b3818bc8c4920a86e0248d58b7c2085a 100644 (file)
@@ -510,18 +510,17 @@ infra_rtt_update(struct infra_cache* infra,
 
 int infra_get_host_rto(struct infra_cache* infra,
         struct sockaddr_storage* addr, socklen_t addrlen,
-       int* rtt, int* rto, uint32_t timenow)
+       struct rtt_info* rtt, uint32_t timenow)
 {
        struct lruhash_entry* e = infra_lookup_host_nottl(infra, addr, 
                addrlen, 0);
        struct infra_host_data* data;
-       int ttl = -2;
+       int ttl = -1;
        if(!e) return -1;
        data = (struct infra_host_data*)e->data;
        if(data->ttl >= timenow) {
                ttl = (int)(data->ttl - timenow);
-               *rtt = rtt_notimeout(&data->rtt);
-               *rto = rtt_unclamped(&data->rtt);
+               memmove(rtt, &data->rtt, sizeof(*rtt));
        }
        lock_rw_unlock(&e->lock);
        return ttl;
index a5ce396f83416a0dafcab199778e1521d766790b..9c203ee4d4471e15d29b6fb919eadf41357a8586 100644 (file)
@@ -290,15 +290,13 @@ int infra_get_lame_rtt(struct infra_cache* infra,
  * @param infra: infra cache.
  * @param addr: host address.
  * @param addrlen: length of addr.
- * @param rtt: the clean rtt time (of working replies).
- * @param rto: the rtt with timeouts applied. (rtt as returned by other funcs).
+ * @param rtt: the rtt_info is copied into here (caller alloced return struct).
  * @param timenow: what time it is now.
  * @return TTL the infra host element is valid for. If -1: not found in cache.
- *     If -2: found in cache, but TTL was not valid.
  */
 int infra_get_host_rto(struct infra_cache* infra,
         struct sockaddr_storage* addr, socklen_t addrlen, 
-       int* rtt, int* rto, uint32_t timenow);
+       struct rtt_info* rtt, uint32_t timenow);
 
 /**
  * Get memory used by the infra cache.