Decode the reply from "named". */
| 1531 | |
| 1532 | /** Decode the reply from "named". */ |
| 1533 | static bool |
| 1534 | dns_process(DNSHandler *handler, HostEnt *buf, int len) |
| 1535 | { |
| 1536 | HEADER *h = reinterpret_cast<HEADER *>(buf->buf); |
| 1537 | DNSEntry *e = get_dns(handler, static_cast<uint16_t>(ntohs(h->id))); |
| 1538 | bool retry = false; |
| 1539 | bool tcp_retry = false; |
| 1540 | bool server_ok = true; |
| 1541 | uint32_t temp_ttl = 0; |
| 1542 | |
| 1543 | const char *RCODE_NAME[] = { |
| 1544 | "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED", "YXDOMAIN", "YXRRSET", "NXRRSET", "NOTAUTH", "NOTZONE", |
| 1545 | }; |
| 1546 | |
| 1547 | const char *RCODE_DESCRIPTION[] = { |
| 1548 | "No Error", |
| 1549 | "Format Error", |
| 1550 | "Server Failure", |
| 1551 | "Non-Existent Domain", |
| 1552 | "Not Implemented", |
| 1553 | "Query Refused", |
| 1554 | "Name Exists when it should not", |
| 1555 | "RR Set Exists when it should not", |
| 1556 | "RR Set that should exist does not", |
| 1557 | "Not Authorized", |
| 1558 | "Name not contained in zone", |
| 1559 | }; |
| 1560 | |
| 1561 | // |
| 1562 | // Do we have an entry for this id? |
| 1563 | // |
| 1564 | if (!e || !e->written_flag) { |
| 1565 | Dbg(dbg_ctl_dns, "unknown DNS id = %u", (uint16_t)ntohs(h->id)); |
| 1566 | return false; // cannot count this as a success |
| 1567 | } |
| 1568 | // |
| 1569 | // It is no longer in flight |
| 1570 | // |
| 1571 | e->written_flag = false; |
| 1572 | --(handler->in_flight); |
| 1573 | Metrics::Gauge::decrement(dns_rsb.in_flight); |
| 1574 | // These are rolling averages |
| 1575 | ink_hrtime diff = (ink_get_hrtime() - e->send_time) / HRTIME_MSECOND; |
| 1576 | |
| 1577 | Metrics::Counter::increment(dns_rsb.response_time, diff); |
| 1578 | |
| 1579 | // retrying over TCP when truncated is set |
| 1580 | if (dns_conn_mode == DNS_CONN_MODE::TCP_RETRY && h->tc == 1) { |
| 1581 | Dbg(dbg_ctl_dns, "Retrying DNS query over TCP for [%s]", e->qname); |
| 1582 | tcp_retry = true; |
| 1583 | Metrics::Counter::increment(dns_rsb.tcp_retries); |
| 1584 | goto Lerror; |
| 1585 | } |
| 1586 | |
| 1587 | // Logs using SiteThrottled* version is helpful for noisy logs, being used here |
| 1588 | // instead of print statements to help with the possible retries when a dns code occurs |
| 1589 | if (h->rcode != NOERROR || !h->ancount) { |
| 1590 | Dbg(dbg_ctl_dns, "received rcode = %d", h->rcode); |
no test coverage detected