One DNSHandler is allocated to handle all DNS traffic by polling a UDP port. More...
#include <P_DNSProcessor.h>
Inherits Continuation.
Public Member Functions | |
void | received_one (int i) |
void | sent_one () |
bool | failover_now (int i) |
bool | failover_soon (int i) |
void | recv_dns (int event, Event *e) |
int | startEvent (int event, Event *e) |
Initial state of the DNSHandler. | |
int | startEvent_sdns (int event, Event *e) |
Initial state of the DSNHandler. | |
int | mainEvent (int event, Event *e) |
Main event for the DNSHandler. | |
void | open_con (sockaddr const *addr, bool failed=false, int icon=0) |
Open (and close) connections as necessary and also assures that the epoll fd struct is properly updated. | |
void | failover () |
Fail over to another name server. | |
void | rr_failure (int ndx) |
Mark one of the nameservers as down. | |
void | recover () |
void | retry_named (int ndx, ink_hrtime t, bool reopen=true) |
void | try_primary_named (bool reopen=true) |
void | switch_named (int ndx) |
uint16_t | get_query_id () |
void | release_query_id (uint16_t qid) |
void | set_query_id_in_use (uint16_t qid) |
bool | query_id_in_use (uint16_t qid) |
DNSHandler () | |
Data Fields | |
IpEndpoint | ip |
This is used as the target if round robin isn't set. | |
IpEndpoint | local_ipv6 |
Local V6 address if set. | |
IpEndpoint | local_ipv4 |
Local V4 address if set. | |
int | ifd [MAX_NAMED] |
int | n_con |
DNSConnection | con [MAX_NAMED] |
int | options |
Queue< DNSEntry > | entries |
Queue< DNSConnection > | triggered |
int | in_flight |
int | name_server |
int | in_write_dns |
HostEnt * | hostent_cache |
int | ns_down [MAX_NAMED] |
int | failover_number [MAX_NAMED] |
int | failover_soon_number [MAX_NAMED] |
ink_hrtime | crossed_failover_number [MAX_NAMED] |
ink_hrtime | last_primary_retry |
ink_hrtime | last_primary_reopen |
ink_res_state | m_res |
int | txn_lookup_timeout |
InkRand | generator |
uint64_t | qid_in_flight [(USHRT_MAX+1)/64] |
One DNSHandler is allocated to handle all DNS traffic by polling a UDP port.
Definition at line 203 of file P_DNSProcessor.h.
TS_INLINE DNSHandler::DNSHandler | ( | ) |
Definition at line 324 of file P_DNSProcessor.h.
References ats_ip_invalidate(), con, crossed_failover_number, Debug, failover_number, failover_soon_number, DNSConnection::handler, ifd, ip, ns_down, qid_in_flight, SET_HANDLER, and startEvent().
void DNSHandler::failover | ( | ) |
Fail over to another name server.
Definition at line 622 of file DNS.cc.
References ats_ip_copy(), ats_ip_ntop(), Debug, ip, IpEndpoint::isValid(), m_res, MAX_NAMED, n_con, name_server, ts_imp_res_state::nsaddr_list, ts_imp_res_state::nscount, open_con(), IpEndpoint::sa, IpEndpoint::setToLoopback(), switch_named(), and Warning.
Referenced by mainEvent(), open_con(), recv_dns(), and write_dns_event().
bool DNSHandler::failover_now | ( | int | i | ) | [inline] |
Definition at line 247 of file P_DNSProcessor.h.
References crossed_failover_number, Debug, dns_failover_period, HRTIME_SECONDS, ink_get_hrtime(), and is_debug_tag_set.
Referenced by mainEvent().
bool DNSHandler::failover_soon | ( | int | i | ) | [inline] |
Definition at line 258 of file P_DNSProcessor.h.
References crossed_failover_number, dns_failover_try_period, failover_soon_number, FAILOVER_SOON_RETRY, HRTIME_SECONDS, and ink_get_hrtime().
Referenced by mainEvent().
uint16_t DNSHandler::get_query_id | ( | ) |
Definition at line 917 of file DNS.cc.
References Error, generator, qid_in_flight, query_id_in_use(), InkRand::random(), and set_query_id_in_use().
Referenced by write_dns_event().
int DNSHandler::mainEvent | ( | int | event, | |
Event * | e | |||
) |
Main event for the DNSHandler.
Attempt to read from and write to named.
Definition at line 799 of file DNS.cc.
References Debug, dns_ns_rr, DNS_PRIMARY_RETRY_PERIOD, entries, failover(), failover_now(), failover_soon(), failover_soon_number, DLL< C, L >::head, ink_get_hrtime(), last_primary_retry, n_con, name_server, ns_down, recv_dns(), retry_named(), rr_failure(), try_primary_named(), and write_dns().
Referenced by startEvent(), and startEvent_sdns().
void DNSHandler::open_con | ( | sockaddr const * | addr, | |
bool | failed = false , |
|||
int | icon = 0 | |||
) |
Open (and close) connections as necessary and also assures that the epoll fd struct is properly updated.
Definition at line 412 of file DNS.cc.
References ats_ip_copy(), ats_ip_nptop(), DNSConnection::close(), con, Debug, dns_ns_rr, DNSConnection::eio, Error, failover(), get_PollDescriptor(), ip, local_ipv4, local_ipv6, NO_FD, ns_down, DNSConnection::num, rr_failure(), IpEndpoint::sa, EventIO::stop(), and DNSProcessor::thread.
Referenced by failover(), retry_named(), startEvent(), startEvent_sdns(), and try_primary_named().
bool DNSHandler::query_id_in_use | ( | uint16_t | qid | ) | [inline] |
Definition at line 286 of file P_DNSProcessor.h.
References qid_in_flight.
Referenced by get_query_id().
void DNSHandler::received_one | ( | int | i | ) | [inline] |
Definition at line 234 of file P_DNSProcessor.h.
References crossed_failover_number, failover_number, and failover_soon_number.
Referenced by recv_dns(), and switch_named().
void DNSHandler::recover | ( | ) |
Definition at line 549 of file DNS.cc.
References ats_ip_ntop(), ip, name_server, IpEndpoint::sa, switch_named(), and Warning.
Referenced by recv_dns().
void DNSHandler::recv_dns | ( | int | event, | |
Event * | e | |||
) |
Definition at line 728 of file DNS.cc.
References ats_ip_addr_eq(), ats_ip_ntop(), HostEnt::buf, Debug, Queue< C, L >::dequeue(), dns_ns_rr, dns_process(), dnsBufAllocator, failover(), DNSConnection::fd, get_rcode(), good_rcode(), hostent_cache, DNSConnection::ip, m_res, make_ptr(), MAX_DNS_PACKET_LEN, name_server, ns_down, ts_imp_res_state::nsaddr_list, DNSConnection::num, HostEnt::packet_size, received_one(), recover(), SocketManager::recvfrom(), rr_failure(), IpEndpoint::sa, socketManager, triggered, and Warning.
Referenced by mainEvent().
void DNSHandler::release_query_id | ( | uint16_t | qid | ) | [inline] |
Definition at line 278 of file P_DNSProcessor.h.
References qid_in_flight.
Referenced by dns_result(), and write_dns_event().
void DNSHandler::retry_named | ( | int | ndx, | |
ink_hrtime | t, | |||
bool | reopen = true | |||
) |
Definition at line 558 of file DNS.cc.
References _ink_res_mkquery(), DNSConnection::close(), con, countof, Debug, DNS_PRIMARY_REOPEN_PERIOD, ink_assert, last_primary_reopen, m_res, ts_imp_res_state::nsaddr_list, open_con(), IpEndpoint::sa, SocketManager::send(), socketManager, try_server_names, and try_servers.
Referenced by mainEvent().
void DNSHandler::rr_failure | ( | int | ndx | ) |
Mark one of the nameservers as down.
Definition at line 660 of file DNS.cc.
References ats_ip_ntop(), Debug, DNS_DECREMENT_DYN_STAT, dns_in_flight_stat, dns_ns_rr_init_down, dns_retries, entries, DLL< C, L >::head, in_flight, m_res, MAX_NAMED, ns_down, ts_imp_res_state::nsaddr_list, ts_imp_res_state::nscount, IpEndpoint::sa, and Warning.
Referenced by mainEvent(), open_con(), recv_dns(), and write_dns_event().
void DNSHandler::sent_one | ( | ) | [inline] |
Definition at line 239 of file P_DNSProcessor.h.
References crossed_failover_number, Debug, dns_failover_number, failover_number, ink_get_hrtime(), and name_server.
Referenced by write_dns_event().
void DNSHandler::set_query_id_in_use | ( | uint16_t | qid | ) | [inline] |
Definition at line 282 of file P_DNSProcessor.h.
References qid_in_flight.
Referenced by get_query_id().
int DNSHandler::startEvent | ( | int | event, | |
Event * | e | |||
) |
Initial state of the DNSHandler.
Can reinitialize the running DNS handler to a new nameserver.
Definition at line 475 of file DNS.cc.
References ats_ip_nptop(), ats_is_ip(), Debug, dns_handler_initialized, dns_ns_rr, dns_ns_rr_init_down, DNS_PERIOD, Event::ethread, EThread::id, ink_assert, m_res, mainEvent(), MAX_NAMED, n_con, ts_imp_res_state::nsaddr_list, ts_imp_res_state::nscount, open_con(), IpEndpoint::sa, EThread::schedule_every(), and SET_HANDLER.
Referenced by DNSHandler(), and DNSProcessor::open().
int DNSHandler::startEvent_sdns | ( | int | event, | |
Event * | e | |||
) |
Initial state of the DSNHandler.
Can reinitialize the running DNS hander to a new nameserver.
Definition at line 526 of file DNS.cc.
References Debug, DNS_PERIOD, Event::ethread, EThread::id, ip, mainEvent(), n_con, open_con(), IpEndpoint::sa, Event::schedule_every(), and SET_HANDLER.
void DNSHandler::switch_named | ( | int | ndx | ) |
Definition at line 609 of file DNS.cc.
References dns_retries, entries, DLL< C, L >::head, in_flight, and received_one().
Referenced by failover(), and recover().
void DNSHandler::try_primary_named | ( | bool | reopen = true |
) |
Definition at line 579 of file DNS.cc.
References _ink_res_mkquery(), con, countof, Debug, DEFAULT_NUM_TRY_SERVER, DNS_PRIMARY_REOPEN_PERIOD, DNS_PRIMARY_RETRY_PERIOD, ink_assert, ink_get_hrtime(), ip, last_primary_reopen, last_primary_retry, local_num_entries, m_res, open_con(), IpEndpoint::sa, SocketManager::send(), socketManager, try_server_names, and try_servers.
Referenced by mainEvent().
DNSConnection DNSHandler::con[MAX_NAMED] |
Definition at line 211 of file P_DNSProcessor.h.
Referenced by DNSHandler(), open_con(), retry_named(), try_primary_named(), and write_dns_event().
ink_hrtime DNSHandler::crossed_failover_number[MAX_NAMED] |
Definition at line 223 of file P_DNSProcessor.h.
Referenced by DNSHandler(), failover_now(), failover_soon(), received_one(), and sent_one().
Definition at line 213 of file P_DNSProcessor.h.
Referenced by dns_result(), get_dns(), get_entry(), DNSEntry::mainEvent(), mainEvent(), rr_failure(), switch_named(), and write_dns().
int DNSHandler::failover_number[MAX_NAMED] |
Definition at line 221 of file P_DNSProcessor.h.
Referenced by DNSHandler(), received_one(), and sent_one().
int DNSHandler::failover_soon_number[MAX_NAMED] |
Definition at line 222 of file P_DNSProcessor.h.
Referenced by DNSHandler(), failover_soon(), mainEvent(), and received_one().
Definition at line 230 of file P_DNSProcessor.h.
Referenced by get_query_id().
Definition at line 218 of file P_DNSProcessor.h.
Referenced by recv_dns().
int DNSHandler::ifd[MAX_NAMED] |
Definition at line 209 of file P_DNSProcessor.h.
Referenced by DNSHandler().
Definition at line 215 of file P_DNSProcessor.h.
Referenced by dns_process(), DNSEntry::mainEvent(), rr_failure(), switch_named(), write_dns(), and write_dns_event().
Definition at line 217 of file P_DNSProcessor.h.
Referenced by write_dns().
This is used as the target if round robin isn't set.
Definition at line 206 of file P_DNSProcessor.h.
Referenced by DNSHandler(), failover(), DNSProcessor::open(), open_con(), recover(), startEvent_sdns(), and try_primary_named().
Definition at line 225 of file P_DNSProcessor.h.
Referenced by retry_named(), and try_primary_named().
Definition at line 224 of file P_DNSProcessor.h.
Referenced by mainEvent(), and try_primary_named().
Local V4 address if set.
Definition at line 208 of file P_DNSProcessor.h.
Referenced by DNSProcessor::open(), and open_con().
Local V6 address if set.
Definition at line 207 of file P_DNSProcessor.h.
Referenced by DNSProcessor::open(), and open_con().
Definition at line 227 of file P_DNSProcessor.h.
Referenced by failover(), DNSEntry::mainEvent(), DNSProcessor::open(), recv_dns(), retry_named(), rr_failure(), startEvent(), try_primary_named(), write_dns(), and write_dns_event().
Definition at line 210 of file P_DNSProcessor.h.
Referenced by failover(), mainEvent(), startEvent(), and startEvent_sdns().
Definition at line 216 of file P_DNSProcessor.h.
Referenced by failover(), mainEvent(), recover(), recv_dns(), sent_one(), write_dns(), and write_dns_event().
int DNSHandler::ns_down[MAX_NAMED] |
Definition at line 220 of file P_DNSProcessor.h.
Referenced by DNSHandler(), mainEvent(), open_con(), recv_dns(), rr_failure(), and write_dns().
Definition at line 212 of file P_DNSProcessor.h.
Referenced by DNSProcessor::open().
uint64_t DNSHandler::qid_in_flight[(USHRT_MAX+1)/64] |
Definition at line 232 of file P_DNSProcessor.h.
Referenced by DNSHandler(), get_query_id(), query_id_in_use(), release_query_id(), and set_query_id_in_use().
Definition at line 214 of file P_DNSProcessor.h.
Referenced by recv_dns(), and DNSConnection::trigger().
Definition at line 228 of file P_DNSProcessor.h.
Referenced by DNSEntry::init(), DNSEntry::mainEvent(), and write_dns_event().