Lines Matching defs:entry

69  * The period in seconds after which an ADB name entry is regarded as stale
210 dns_adbentry_t *entry;
230 * An address entry. It holds quite a bit of information about addresses,
270 * A nonzero 'expires' field indicates that the entry should
349 static void log_quota(dns_adbentry_t *entry, const char *fmt, ...)
863 * Requires the adbname bucket be locked and that no entry buckets be locked.
928 dns_adbentry_t *entry;
930 entry = new_adbentry(adb);
931 if (entry == NULL) {
937 entry->sockaddr = sockaddr;
938 entry->refcnt = 1;
939 entry->nh = 1;
941 nh->entry = entry;
943 link_entry(adb, addr_bucket, entry);
948 if (anh->entry == foundentry)
953 nh->entry = foundentry;
1070 * Requires the name's bucket be locked and no entry buckets be locked.
1154 * Requires the entry's bucket be locked.
1157 link_entry(dns_adb_t *adb, int bucket, dns_adbentry_t *entry) {
1178 ISC_LIST_PREPEND(adb->entries[bucket], entry, plink);
1179 entry->lock_bucket = bucket;
1184 * Requires the entry's bucket be locked.
1187 unlink_entry(dns_adb_t *adb, dns_adbentry_t *entry) {
1191 bucket = entry->lock_bucket;
1194 if ((entry->flags & ENTRY_IS_DEAD) != 0)
1195 ISC_LIST_UNLINK(adb->deadentries[bucket], entry, plink);
1197 ISC_LIST_UNLINK(adb->entries[bucket], entry, plink);
1198 entry->lock_bucket = DNS_ADB_INVALIDBUCKET;
1268 dns_adbentry_t *entry;
1275 entry = ISC_LIST_HEAD(adb->entries[bucket]);
1280 * automatically triggered by an entry being unlinked.
1288 while (entry != NULL) {
1289 next_entry = ISC_LIST_NEXT(entry, plink);
1290 if (entry->refcnt == 0 &&
1291 entry->expires != 0) {
1292 result = unlink_entry(adb, entry);
1293 free_adbentry(adb, &entry);
1297 entry = next_entry;
1323 dns_adbentry_t *entry;
1335 * Clean up the entry if needed.
1337 entry = namehook->entry;
1338 if (entry != NULL) {
1339 INSIST(DNS_ADBENTRY_VALID(entry));
1341 if (addr_bucket != entry->lock_bucket) {
1344 addr_bucket = entry->lock_bucket;
1349 entry->nh--;
1350 result = dec_entry_refcnt(adb, overmem, entry,
1357 namehook->entry = NULL;
1612 inc_entry_refcnt(dns_adb_t *adb, dns_adbentry_t *entry, isc_boolean_t lock) {
1615 bucket = entry->lock_bucket;
1620 entry->refcnt++;
1627 dec_entry_refcnt(dns_adb_t *adb, isc_boolean_t overmem, dns_adbentry_t *entry,
1634 bucket = entry->lock_bucket;
1639 INSIST(entry->refcnt > 0);
1640 entry->refcnt--;
1643 if (entry->refcnt == 0 &&
1644 (adb->entry_sd[bucket] || entry->expires == 0 || overmem ||
1645 (entry->flags & ENTRY_IS_DEAD) != 0)) {
1647 result = unlink_entry(adb, entry);
1656 entry->lock_bucket = DNS_ADB_INVALIDBUCKET;
1658 free_adbentry(adb, &entry);
1740 new_adbnamehook(dns_adb_t *adb, dns_adbentry_t *entry) {
1748 nh->entry = entry;
1762 INSIST(nh->entry == NULL);
1860 free_adbentry(dns_adb_t *adb, dns_adbentry_t **entry) {
1864 INSIST(entry != NULL && DNS_ADBENTRY_VALID(*entry));
1865 e = *entry;
1866 *entry = NULL;
1989 * Copy bits from the entry into the newly allocated addrinfo. The entry
1994 new_adbaddrinfo(dns_adb_t *adb, dns_adbentry_t *entry, in_port_t port) {
2002 ai->sockaddr = entry->sockaddr;
2004 ai->srtt = entry->srtt;
2005 ai->flags = entry->flags;
2006 ai->entry = entry;
2021 INSIST(ai->entry == NULL);
2082 dns_adbentry_t *entry, *entry_next;
2097 for (entry = ISC_LIST_HEAD(adb->entries[bucket]);
2098 entry != NULL;
2099 entry = entry_next) {
2100 entry_next = ISC_LIST_NEXT(entry, plink);
2101 (void)check_expire_entry(adb, &entry, now);
2102 if (entry != NULL &&
2103 (entry->expires == 0 || entry->expires > now) &&
2104 isc_sockaddr_equal(addr, &entry->sockaddr)) {
2105 ISC_LIST_UNLINK(adb->entries[bucket], entry, plink);
2106 ISC_LIST_PREPEND(adb->entries[bucket], entry, plink);
2107 return (entry);
2118 entry_is_lame(dns_adb_t *adb, dns_adbentry_t *entry, dns_name_t *qname,
2126 li = ISC_LIST_HEAD(entry->lameinfo);
2133 * Has the entry expired?
2136 ISC_LIST_UNLINK(entry->lameinfo, li, plink);
2157 log_quota(dns_adbentry_t *entry, const char *fmt, ...) {
2167 isc_netaddr_fromsockaddr(&netaddr, &entry->sockaddr);
2172 addrbuf, entry->active, entry->quota, msgbuf);
2182 dns_adbentry_t *entry;
2190 entry = namehook->entry;
2191 bucket = entry->lock_bucket;
2195 if (entry->quota != 0 &&
2196 entry->active >= entry->quota)
2205 && entry_is_lame(adb, entry, qname, qtype, now)) {
2209 addrinfo = new_adbaddrinfo(adb, entry, find->port);
2215 * Found a valid entry. Add it to the find's list.
2217 inc_entry_refcnt(adb, entry, ISC_FALSE);
2230 entry = namehook->entry;
2231 bucket = entry->lock_bucket;
2235 if (entry->quota != 0 &&
2236 entry->active >= entry->quota)
2245 && entry_is_lame(adb, entry, qname, qtype, now)) {
2249 addrinfo = new_adbaddrinfo(adb, entry, find->port);
2255 * Found a valid entry. Add it to the find's list.
2257 inc_entry_refcnt(adb, entry, ISC_FALSE);
2326 * Examine the tail entry of the LRU list to see if it expires or is stale
2327 * (unused for some period); if so, the name entry will be freed. If the ADB
2386 dns_adbentry_t *entry;
2390 entry = *entryp;
2392 if (entry->refcnt != 0)
2395 if (entry->expires == 0 || entry->expires > now)
2399 * The entry is not in use. Delete it.
2401 DP(DEF_LEVEL, "killing entry %p", entry);
2402 INSIST(ISC_LINK_LINKED(entry, plink));
2403 result = unlink_entry(adb, entry);
2404 free_adbentry(adb, &entry);
2446 dns_adbentry_t *entry, *next_entry;
2449 DP(CLEAN_LEVEL, "cleaning entry bucket %d", bucket);
2452 entry = ISC_LIST_HEAD(adb->entries[bucket]);
2453 while (entry != NULL) {
2454 next_entry = ISC_LIST_NEXT(entry, plink);
2456 result = check_expire_entry(adb, &entry, now);
2457 entry = next_entry;
3291 dns_adbentry_t *entry;
3324 entry = ai->entry;
3325 ai->entry = NULL;
3326 INSIST(DNS_ADBENTRY_VALID(entry));
3327 RUNTIME_CHECK(dec_entry_refcnt(adb, overmem, entry, ISC_TRUE) ==
3414 * the entry buckets. This should put the adb into a state where
3442 dns_adbentry_t *entry;
3507 entry = ISC_LIST_HEAD(adb->entries[i]);
3508 while (entry != NULL) {
3509 if (entry->nh == 0)
3510 dump_entry(f, adb, entry, debug, now);
3511 entry = ISC_LIST_NEXT(entry, plink);
3525 dump_entry(FILE *f, dns_adb_t *adb, dns_adbentry_t *entry,
3533 isc_netaddr_fromsockaddr(&netaddr, &entry->sockaddr);
3537 fprintf(f, ";\t%p: refcnt %u\n", entry, entry->refcnt);
3540 "[plain %u/%u]", addrbuf, entry->srtt, entry->flags,
3541 entry->edns, entry->to4096, entry->to1432, entry->to1232,
3542 entry->to512, entry->plain, entry->plainto);
3543 if (entry->udpsize != 0U)
3544 fprintf(f, " [udpsize %u]", entry->udpsize);
3545 if (entry->cookie != NULL) {
3548 for (i = 0; i < entry->cookielen; i++)
3549 fprintf(f, "%02x", entry->cookie[i]);
3552 if (entry->expires != 0)
3553 fprintf(f, " [ttl %d]", entry->expires - now);
3557 entry->atr, entry->quota);
3561 for (li = ISC_LIST_HEAD(entry->lameinfo);
3617 ai->entry, ai->flags, ai->srtt, tmpp);
3648 dump_entry(f, adb, nh->entry, debug, now);
3735 * Make up a negative cache entry so we don't ask again
3744 "adb name %p: Caching auth negative entry for A",
3752 "adb name %p: Caching auth negative entry for AAAA",
3764 * We found a negative cache entry. Pull the TTL from it
3775 "adb name %p: Caching negative entry for A (ttl %u)",
3779 "adb name %p: Caching negative entry for AAAA (ttl %u)",
3905 "caching negative entry for A (ttl %u)",
3916 "caching negative entry for AAAA (ttl %u)",
4094 bucket = addr->entry->lock_bucket;
4096 li = ISC_LIST_HEAD(addr->entry->lameinfo);
4113 ISC_LIST_PREPEND(addr->entry->lameinfo, li, plink);
4131 bucket = addr->entry->lock_bucket;
4134 if (addr->entry->expires == 0 || factor == DNS_ADB_RTTADJAGE)
4148 bucket = addr->entry->lock_bucket;
4163 if (addr->entry->lastage != now) {
4164 new_srtt = addr->entry->srtt;
4166 new_srtt -= addr->entry->srtt;
4168 addr->entry->lastage = now;
4170 new_srtt = addr->entry->srtt;
4172 new_srtt = ((isc_uint64_t)addr->entry->srtt / 10 * factor)
4175 addr->entry->srtt = (unsigned int) new_srtt;
4178 if (addr->entry->expires == 0)
4179 addr->entry->expires = now + ADB_ENTRY_WINDOW;
4195 bucket = addr->entry->lock_bucket;
4198 addr->entry->flags = (addr->entry->flags & ~mask) | (bits & mask);
4199 if (addr->entry->expires == 0) {
4201 addr->entry->expires = now + ADB_ENTRY_WINDOW;
4206 * the most recent values from addr->entry->flags.
4247 addr->entry->timeouts++;
4249 if (addr->entry->completed++ <= adb->atr_freq)
4257 tr = (double) addr->entry->timeouts / addr->entry->completed;
4258 addr->entry->timeouts = addr->entry->completed = 0;
4259 INSIST(addr->entry->atr >= 0.0);
4260 INSIST(addr->entry->atr <= 1.0);
4263 addr->entry->atr *= 1.0 - adb->atr_discount;
4264 addr->entry->atr += tr * adb->atr_discount;
4265 addr->entry->atr = ISC_CLAMP(addr->entry->atr, 0.0, 1.0);
4267 if (addr->entry->atr < adb->atr_low && addr->entry->mode > 0) {
4268 addr->entry->quota = adb->quota *
4269 quota_adj[--addr->entry->mode] / 10000;
4270 log_quota(addr->entry, "atr %0.2f, quota increased to %u",
4271 addr->entry->atr, addr->entry->quota);
4272 } else if (addr->entry->atr > adb->atr_high &&
4273 addr->entry->mode < (QUOTA_ADJ_SIZE - 1)) {
4274 addr->entry->quota = adb->quota *
4275 quota_adj[++addr->entry->mode] / 10000;
4276 log_quota(addr->entry, "atr %0.2f, quota decreased to %u",
4277 addr->entry->atr, addr->entry->quota);
4281 if (addr->entry->quota == 0)
4282 addr->entry->quota = 1;
4294 bucket = addr->entry->lock_bucket;
4297 if (addr->entry->edns == 0U &&
4298 (addr->entry->plain > EDNSTOS || addr->entry->to4096 > EDNSTOS)) {
4299 if (((addr->entry->plain + addr->entry->to4096) & 0x3f) != 0) {
4305 addr->entry->plain++;
4306 if (addr->entry->plain == 0xff) {
4307 addr->entry->edns >>= 1;
4308 addr->entry->to4096 >>= 1;
4309 addr->entry->to1432 >>= 1;
4310 addr->entry->to1232 >>= 1;
4311 addr->entry->to512 >>= 1;
4312 addr->entry->plain >>= 1;
4313 addr->entry->plainto >>= 1;
4328 bucket = addr->entry->lock_bucket;
4333 addr->entry->plain++;
4334 if (addr->entry->plain == 0xff) {
4335 addr->entry->edns >>= 1;
4336 addr->entry->to4096 >>= 1;
4337 addr->entry->to1432 >>= 1;
4338 addr->entry->to1232 >>= 1;
4339 addr->entry->to512 >>= 1;
4340 addr->entry->plain >>= 1;
4341 addr->entry->plainto >>= 1;
4353 bucket = addr->entry->lock_bucket;
4362 if (addr->entry->edns == 0 && addr->entry->plain == 0) {
4363 addr->entry->to512 = 0;
4364 addr->entry->to1232 = 0;
4365 addr->entry->to1432 = 0;
4366 addr->entry->to4096 = 0;
4368 addr->entry->to512 >>= 1;
4369 addr->entry->to1232 >>= 1;
4370 addr->entry->to1432 >>= 1;
4371 addr->entry->to4096 >>= 1;
4374 addr->entry->plainto++;
4375 if (addr->entry->plainto == 0xff) {
4376 addr->entry->edns >>= 1;
4377 addr->entry->plain >>= 1;
4378 addr->entry->plainto >>= 1;
4390 bucket = addr->entry->lock_bucket;
4396 if (addr->entry->to512 <= EDNSTOS) {
4397 addr->entry->to512++;
4398 addr->entry->to1232++;
4399 addr->entry->to1432++;
4400 addr->entry->to4096++;
4403 if (addr->entry->to1232 <= EDNSTOS) {
4404 addr->entry->to1232++;
4405 addr->entry->to1432++;
4406 addr->entry->to4096++;
4409 if (addr->entry->to1432 <= EDNSTOS) {
4410 addr->entry->to1432++;
4411 addr->entry->to4096++;
4414 if (addr->entry->to4096 <= EDNSTOS)
4415 addr->entry->to4096++;
4418 if (addr->entry->to4096 == 0xff) {
4419 addr->entry->edns >>= 1;
4420 addr->entry->to4096 >>= 1;
4421 addr->entry->to1432 >>= 1;
4422 addr->entry->to1232 >>= 1;
4423 addr->entry->to512 >>= 1;
4424 addr->entry->plain >>= 1;
4425 addr->entry->plainto >>= 1;
4437 bucket = addr->entry->lock_bucket;
4441 if (size > addr->entry->udpsize)
4442 addr->entry->udpsize = size;
4446 addr->entry->edns++;
4447 if (addr->entry->edns == 0xff) {
4448 addr->entry->edns >>= 1;
4449 addr->entry->to4096 >>= 1;
4450 addr->entry->to1432 >>= 1;
4451 addr->entry->to1232 >>= 1;
4452 addr->entry->to512 >>= 1;
4453 addr->entry->plain >>= 1;
4454 addr->entry->plainto >>= 1;
4467 bucket = addr->entry->lock_bucket;
4469 size = addr->entry->udpsize;
4488 bucket = addr->entry->lock_bucket;
4490 if (addr->entry->to1232 > EDNSTOS || lookups >= 2)
4492 else if (addr->entry->to1432 > EDNSTOS || lookups >= 1)
4494 else if (addr->entry->to4096 > EDNSTOS)
4503 size < addr->entry->udpsize && addr->entry->udpsize < 4096)
4504 size = addr->entry->udpsize;
4519 bucket = addr->entry->lock_bucket;
4522 if (addr->entry->cookie != NULL &&
4523 (cookie == NULL || len != addr->entry->cookielen)) {
4524 isc_mem_put(adb->mctx, addr->entry->cookie,
4525 addr->entry->cookielen);
4526 addr->entry->cookie = NULL;
4527 addr->entry->cookielen = 0;
4530 if (addr->entry->cookie == NULL && cookie != NULL && len != 0U) {
4531 addr->entry->cookie = isc_mem_get(adb->mctx, len);
4532 if (addr->entry->cookie != NULL)
4533 addr->entry->cookielen = (isc_uint16_t)len;
4536 if (addr->entry->cookie != NULL)
4537 memmove(addr->entry->cookie, cookie, len);
4550 bucket = addr->entry->lock_bucket;
4552 if (cookie != NULL && addr->entry->cookie != NULL &&
4553 len >= addr->entry->cookielen)
4555 memmove(cookie, addr->entry->cookie, addr->entry->cookielen);
4556 len = addr->entry->cookielen;
4569 dns_adbentry_t *entry;
4581 entry = find_entry_and_lock(adb, sa, &bucket, now);
4587 if (entry == NULL) {
4591 entry = new_adbentry(adb);
4592 if (entry == NULL) {
4596 entry->sockaddr = *sa;
4597 link_entry(adb, bucket, entry);
4598 DP(ENTER_LEVEL, "findaddrinfo: new entry %p", entry);
4600 DP(ENTER_LEVEL, "findaddrinfo: found entry %p", entry);
4603 addr = new_adbaddrinfo(adb, entry, port);
4607 inc_entry_refcnt(adb, entry, ISC_FALSE);
4620 dns_adbentry_t *entry;
4630 entry = addr->entry;
4631 REQUIRE(DNS_ADBENTRY_VALID(entry));
4636 bucket = addr->entry->lock_bucket;
4639 if (entry->expires == 0) {
4641 entry->expires = now + ADB_ENTRY_WINDOW;
4644 want_check_exit = dec_entry_refcnt(adb, overmem, entry, ISC_FALSE);
4648 addr->entry = NULL;
4788 dns_adbentry_overquota(dns_adbentry_t *entry) {
4790 REQUIRE(DNS_ADBENTRY_VALID(entry));
4791 block = ISC_TF(entry->quota != 0 && entry->active >= entry->quota);
4802 bucket = addr->entry->lock_bucket;
4805 addr->entry->active++;
4816 bucket = addr->entry->lock_bucket;
4819 if (addr->entry->active > 0)
4820 addr->entry->active--;