client.c File Reference

#include <config.h>
#include <isc/formatcheck.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/platform.h>
#include <isc/print.h>
#include <isc/queue.h>
#include <isc/random.h>
#include <isc/serial.h>
#include <isc/stats.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>
#include <isc/hmacsha.h>
#include <dns/badcache.h>
#include <dns/db.h>
#include <dns/dispatch.h>
#include <dns/edns.h>
#include <dns/events.h>
#include <dns/message.h>
#include <dns/peer.h>
#include <dns/rcode.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/resolver.h>
#include <dns/stats.h>
#include <dns/tsig.h>
#include <dns/view.h>
#include <dns/zone.h>
#include <named/interfacemgr.h>
#include <named/log.h>
#include <named/notify.h>
#include <named/os.h>
#include <named/server.h>
#include <named/update.h>

Go to the source code of this file.

Data Structures

struct  ns_clientmgr
 nameserver client manager structure More...

Defines

#define NS_CLIENT_TRACE
#define CTRACE(m)
#define MTRACE(m)
#define TCP_CLIENT(c)   (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
#define TCP_BUFFER_SIZE   (65535 + 2)
#define SEND_BUFFER_SIZE   4096
#define RECV_BUFFER_SIZE   4096
#define NMCTXS   0
 If named with built without thread, simply share manager's context. Using a separate context in this case would simply waste memory.
#define SIT_SIZE   24U
#define ECS_SIZE   20U
#define MANAGER_MAGIC   ISC_MAGIC('N', 'S', 'C', 'm')
#define VALID_MANAGER(m)   ISC_MAGIC_VALID(m, MANAGER_MAGIC)
#define NS_CLIENTSTATE_FREED   0
 The client object no longer exists.
#define NS_CLIENTSTATE_INACTIVE   1
 The client object exists and has a task and timer. Its "query" struct and sendbuf are initialized. It is on the client manager's list of inactive clients. It has a message and OPT, both in the reset state.
#define NS_CLIENTSTATE_READY   2
 The client object is either a TCP or a UDP one, and it is associated with a network interface. It is on the client manager's list of active clients.
#define NS_CLIENTSTATE_READING   3
 The client object is a TCP client object that has received a connection. It has a tcpsocket, tcpmsg, TCP quota, and an outstanding TCP read request. This state is not used for UDP client objects.
#define NS_CLIENTSTATE_WORKING   4
 The client object has received a request and is working on it. It has a view, and it may have any of a non-reset OPT, recursion quota, and an outstanding write request.
#define NS_CLIENTSTATE_RECURSING   5
 The client object is recursing. It will be on the 'recursing' list.
#define NS_CLIENTSTATE_MAX   9
 Sentinel value used to indicate "no state". When client->newstate has this value, we are not attempting to exit the current state. Must be greater than any valid state.
#define NS_CLIENT_DROPPORT   1
#define DROPPORT_NO   0
#define DROPPORT_REQUEST   1
#define DROPPORT_RESPONSE   2

Functions

static void client_read (ns_client_t *client)
static void client_accept (ns_client_t *client)
static void client_udprecv (ns_client_t *client)
static void clientmgr_destroy (ns_clientmgr_t *manager)
static isc_boolean_t exit_check (ns_client_t *client)
 Check for a deactivation or shutdown request and take appropriate action. Returns ISC_TRUE if either is in progress; in this case the caller must no longer use the client object as it may have been freed.
static void ns_client_endrequest (ns_client_t *client)
static void client_start (isc_task_t *task, isc_event_t *event)
 The client's task has received the client's control event as part of the startup process.
static void client_request (isc_task_t *task, isc_event_t *event)
static void ns_client_dumpmessage (ns_client_t *client, const char *reason)
static isc_result_t get_client (ns_clientmgr_t *manager, ns_interface_t *ifp, dns_dispatch_t *disp, isc_boolean_t tcp)
static isc_result_t get_worker (ns_clientmgr_t *manager, ns_interface_t *ifp, isc_socket_t *sock)
static isc_boolean_t allowed (isc_netaddr_t *addr, dns_name_t *signer, isc_netaddr_t *ecs_addr, isc_uint8_t ecs_addrlen, isc_uint8_t *ecs_scope, dns_acl_t *acl)
void ns_client_recursing (ns_client_t *client)
void ns_client_killoldestquery (ns_client_t *client)
 Add client to end of th recursing list.
void ns_client_settimeout (ns_client_t *client, unsigned int seconds)
 Try to replace the current client with a new one, so that the current one can go off and do some lengthy work without leaving the dispatch/socket without service.
static void client_shutdown (isc_task_t *task, isc_event_t *event)
 The client's task has received a shutdown event.
void ns_client_next (ns_client_t *client, isc_result_t result)
 Finish processing the current client request and return an error response to the client. The error response will have an RCODE determined by 'result'.
static void client_senddone (isc_task_t *task, isc_event_t *event)
static isc_result_t client_allocsendbuf (ns_client_t *client, isc_buffer_t *buffer, isc_buffer_t *tcpbuffer, isc_uint32_t length, unsigned char *sendbuf, unsigned char **datap)
 We only want to fail with ISC_R_NOSPACE when called from ns_client_sendraw() and not when called from ns_client_send(), tcpbuffer is NULL when called from ns_client_sendraw() and length != 0. tcpbuffer != NULL when called from ns_client_send() and length == 0.
static isc_result_t client_sendpkg (ns_client_t *client, isc_buffer_t *buffer)
void ns_client_sendraw (ns_client_t *client, dns_message_t *message)
 Finish processing the current client request and send client->message as a response.
static void client_send (ns_client_t *client)
static void client_delay (isc_task_t *task, isc_event_t *event)
void ns_client_send (ns_client_t *client)
 Note! These ns_client_ routines MUST be called ONLY from the client's task in order to ensure synchronization.
static int ns_client_dropport (in_port_t port)
 ns_client_dropport determines if certain requests / responses should be dropped based on the port number.
void ns_client_error (ns_client_t *client, isc_result_t result)
 Finish processing the current client request and send msg as a response using client->message->id for the id.
isc_result_t ns_client_addopt (ns_client_t *client, dns_message_t *message, dns_rdataset_t **opt)
isc_boolean_t ns_client_isself (dns_view_t *myview, dns_tsigkey_t *mykey, isc_sockaddr_t *srcaddr, isc_sockaddr_t *dstaddr, dns_rdataclass_t rdclass, void *arg)
 Replace the qname.
static isc_result_t process_ecs (ns_client_t *client, isc_buffer_t *buf, size_t optlen)
static isc_result_t process_opt (ns_client_t *client, dns_rdataset_t *opt)
static void client_timeout (isc_task_t *task, isc_event_t *event)
static isc_result_t get_clientmctx (ns_clientmgr_t *manager, isc_mem_t **mctxp)
static isc_result_t client_create (ns_clientmgr_t *manager, ns_client_t **clientp)
static void client_newconn (isc_task_t *task, isc_event_t *event)
void ns_client_attach (ns_client_t *source, ns_client_t **targetp)
 Return ISC_TRUE iff the client is currently shutting down.
void ns_client_detach (ns_client_t **clientp)
 Attach '*targetp' to 'source'.
isc_boolean_t ns_client_shuttingdown (ns_client_t *client)
 Finish processing the current client request, return no response to the client.
isc_result_t ns_client_replace (ns_client_t *client)
 Detach '*clientp' from its client.
isc_result_t ns_clientmgr_create (isc_mem_t *mctx, isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr, ns_clientmgr_t **managerp)
 Set a timer in the client to go off in the specified amount of time.
void ns_clientmgr_destroy (ns_clientmgr_t **managerp)
 Create a client manager.
isc_result_t ns_clientmgr_createclients (ns_clientmgr_t *manager, unsigned int n, ns_interface_t *ifp, isc_boolean_t tcp)
 Destroy a client manager and all ns_client_t objects managed by it.
isc_sockaddr_tns_client_getsockaddr (ns_client_t *client)
 Create up to 'n' clients listening on interface 'ifp'. If 'tcp' is ISC_TRUE, the clients will listen for TCP connections, otherwise for UDP requests.
isc_result_t ns_client_checkaclsilent (ns_client_t *client, isc_netaddr_t *netaddr, dns_acl_t *acl, isc_boolean_t default_allow)
 Get the socket address of the client whose request is currently being processed.
isc_result_t ns_client_checkacl (ns_client_t *client, isc_sockaddr_t *sockaddr, const char *opname, dns_acl_t *acl, isc_boolean_t default_allow, int log_level)
 Convenience function for client request ACL checking.
static void ns_client_name (ns_client_t *client, char *peerbuf, size_t len)
void ns_client_logv (ns_client_t *client, isc_logcategory_t *category, isc_logmodule_t *module, int level, const char *fmt, va_list ap)
void ns_client_log (ns_client_t *client, isc_logcategory_t *category, isc_logmodule_t *module, int level, const char *fmt,...)
void ns_client_aclmsg (const char *msg, dns_name_t *name, dns_rdatatype_t type, dns_rdataclass_t rdclass, char *buf, size_t len)
void ns_client_dumprecursing (FILE *f, ns_clientmgr_t *manager)
 Kill the oldest recursive query (recursing list head).
void ns_client_qnamereplace (ns_client_t *client, dns_name_t *name)
 Dump the outstanding recursive queries to 'f'.
isc_result_t ns_client_sourceip (dns_clientinfo_t *ci, isc_sockaddr_t **addrp)
 Isself callback.

Variables

unsigned int ns_client_requests


Detailed Description

Client Routines

Important note!

All client state changes, other than that from idle to listening, occur as a result of events. This guarantees serialization and avoids the need for locking.

If a routine is ever created that allows someone other than the client's task to change the client, then the client will have to be locked.

Definition in file client.c.


Define Documentation

#define NS_CLIENT_TRACE

Definition at line 83 of file client.c.

#define CTRACE (  ) 

Value:

Definition at line 85 of file client.c.

Referenced by client_accept(), client_create(), client_delay(), client_read(), client_request(), client_send(), client_senddone(), client_sendpkg(), client_shutdown(), client_timeout(), client_udprecv(), exit_check(), ns_client_endrequest(), ns_client_error(), ns_client_next(), ns_client_replace(), ns_client_sendraw(), ns_query_start(), query_addadditional(), query_addadditional2(), query_addbestns(), query_addds(), query_addnoqnameproof(), query_addns(), query_addrdataset(), query_addrrset(), query_addsoa(), query_addwildcardproof(), query_dns64(), query_filter64(), query_find(), query_getnamebuf(), query_isduplicate(), query_keepname(), query_newname(), query_newnamebuf(), query_newrdataset(), query_putrdataset(), query_releasename(), query_resume(), query_validatezonedb(), redirect(), redirect2(), rpz_find_p(), rpz_ready(), rpz_rewrite(), rpz_rewrite_ip_rrset(), and rpz_rrset_find().

#define MTRACE (  ) 

Value:

isc_log_write(ns_g_lctx, \
                                      NS_LOGCATEGORY_GENERAL, \
                                      NS_LOGMODULE_CLIENT, \
                                      ISC_LOG_DEBUG(3), \
                                      "clientmgr @%p: %s", manager, (m))

Definition at line 90 of file client.c.

Referenced by clientmgr_destroy(), get_client(), get_clientmctx(), get_worker(), ns_clientmgr_create(), ns_clientmgr_createclients(), and ns_clientmgr_destroy().

#define TCP_CLIENT (  )     (((c)->attributes & NS_CLIENTATTR_TCP) != 0)

Definition at line 99 of file client.c.

Referenced by client_allocsendbuf(), client_request(), client_send(), client_senddone(), client_sendpkg(), client_start(), exit_check(), ns_client_error(), ns_client_next(), and ns_client_replace().

#define TCP_BUFFER_SIZE   (65535 + 2)

Definition at line 101 of file client.c.

Referenced by client_allocsendbuf(), client_send(), client_senddone(), exit_check(), and ns_client_sendraw().

#define SEND_BUFFER_SIZE   4096

Definition at line 102 of file client.c.

#define RECV_BUFFER_SIZE   4096

Definition at line 103 of file client.c.

#define NMCTXS   0

If named with built without thread, simply share manager's context. Using a separate context in this case would simply waste memory.

Definition at line 115 of file client.c.

Referenced by clientmgr_destroy(), get_clientmctx(), and ns_clientmgr_create().

#define SIT_SIZE   24U

Definition at line 122 of file client.c.

Referenced by ns_client_addopt().

#define ECS_SIZE   20U

Definition at line 123 of file client.c.

Referenced by ns_client_addopt().

#define MANAGER_MAGIC   ISC_MAGIC('N', 'S', 'C', 'm')

Definition at line 156 of file client.c.

Referenced by ns_clientmgr_create().

#define VALID_MANAGER (  )     ISC_MAGIC_VALID(m, MANAGER_MAGIC)

Definition at line 157 of file client.c.

#define NS_CLIENTSTATE_FREED   0

The client object no longer exists.

Client object states. Ordering is significant: higher-numbered states are generally "more active", meaning that the client can have more dynamically allocated data, outstanding events, etc. In the list below, any such properties listed for state N also apply to any state > N.

To force the client into a less active state, set client->newstate to that state and call exit_check(). This will cause any activities defined for higher-numbered states to be aborted.

Definition at line 171 of file client.c.

Referenced by client_shutdown(), exit_check(), and ns_client_shuttingdown().

#define NS_CLIENTSTATE_INACTIVE   1

The client object exists and has a task and timer. Its "query" struct and sendbuf are initialized. It is on the client manager's list of inactive clients. It has a message and OPT, both in the reset state.

Definition at line 176 of file client.c.

Referenced by client_create(), and exit_check().

#define NS_CLIENTSTATE_READY   2

The client object is either a TCP or a UDP one, and it is associated with a network interface. It is on the client manager's list of active clients.

If it is a TCP client object, it has a TCP listener socket and an outstanding TCP listen request.

If it is a UDP client object, it has a UDP listener socket and an outstanding UDP receive request.

Definition at line 184 of file client.c.

Referenced by client_newconn(), client_request(), client_timeout(), exit_check(), get_client(), and ns_client_next().

#define NS_CLIENTSTATE_READING   3

The client object is a TCP client object that has received a connection. It has a tcpsocket, tcpmsg, TCP quota, and an outstanding TCP read request. This state is not used for UDP client objects.

Definition at line 197 of file client.c.

Referenced by client_newconn(), client_read(), client_request(), exit_check(), and ns_client_next().

#define NS_CLIENTSTATE_WORKING   4

The client object has received a request and is working on it. It has a view, and it may have any of a non-reset OPT, recursion quota, and an outstanding write request.

Definition at line 205 of file client.c.

Referenced by client_request(), exit_check(), get_worker(), ns_client_endrequest(), ns_client_next(), and ns_client_recursing().

#define NS_CLIENTSTATE_RECURSING   5

The client object is recursing. It will be on the 'recursing' list.

Definition at line 212 of file client.c.

Referenced by exit_check(), ns_client_dumprecursing(), ns_client_endrequest(), ns_client_next(), and ns_client_recursing().

#define NS_CLIENTSTATE_MAX   9

Sentinel value used to indicate "no state". When client->newstate has this value, we are not attempting to exit the current state. Must be greater than any valid state.

Definition at line 218 of file client.c.

Referenced by client_create(), and exit_check().

#define NS_CLIENT_DROPPORT   1

Definition at line 229 of file client.c.

#define DROPPORT_NO   0

Definition at line 1241 of file client.c.

Referenced by ns_client_dropport(), and ns_client_error().

#define DROPPORT_REQUEST   1

Definition at line 1242 of file client.c.

Referenced by client_request(), and ns_client_dropport().

#define DROPPORT_RESPONSE   2

Definition at line 1243 of file client.c.

Referenced by ns_client_dropport().


Function Documentation

static void client_read ( ns_client_t client  )  [static]

Definition at line 2795 of file client.c.

References client_request(), CTRACE, dns_tcpmsg_readmessage(), INSIST, ISC_R_SUCCESS, ns_client::newstate, ns_client::nreads, ns_client_next(), ns_client_settimeout(), NS_CLIENTSTATE_READING, ns_client::recursionquota, ns_client::state, ns_client::task, and ns_client::tcpmsg.

Referenced by client_newconn(), client_start(), and exit_check().

static void client_accept ( ns_client_t client  )  [static]

Definition at line 2935 of file client.c.

References client_newconn(), CTRACE, INSIST, ns_client::interface, ISC_R_SUCCESS, isc_result_totext(), isc_socket_accept(), ns_interface::lock, LOCK, ns_client::naccepts, ns_interface::ntcpcurrent, ns_client::task, ns_client::tcplistener, UNEXPECTED_ERROR, and UNLOCK.

Referenced by client_start(), and exit_check().

static void client_udprecv ( ns_client_t client  )  [static]

Definition at line 2963 of file client.c.

References isc_region::base, CTRACE, INSIST, ISC_R_SUCCESS, isc_result_totext(), isc_socket_recv2(), isc_region::length, ns_client::nrecvs, r, RECV_BUFFER_SIZE, ns_client::recvbuf, ns_client::recvevent, ns_client::task, ns_client::udpsocket, and UNEXPECTED_ERROR.

Referenced by client_start(), and exit_check().

static void clientmgr_destroy ( ns_clientmgr_t manager  )  [static]

Definition at line 3055 of file client.c.

References ns_clientmgr::clients, DESTROYLOCK, ns_clientmgr::inactive, ISC_LIST_EMPTY, isc_mem_detach(), isc_mem_put, ISC_QUEUE_DESTROY, ns_clientmgr::listlock, ns_clientmgr::lock, ns_clientmgr::magic, ns_clientmgr::mctx, MTRACE, NMCTXS, ns_clientmgr::reclock, and REQUIRE.

Referenced by exit_check(), and ns_clientmgr_destroy().

static isc_boolean_t exit_check ( ns_client_t client  )  [static]

Check for a deactivation or shutdown request and take appropriate action. Returns ISC_TRUE if either is in progress; in this case the caller must no longer use the client object as it may have been freed.

Definition at line 306 of file client.c.

References ns_client::attributes, client_accept(), client_read(), client_udprecv(), clientmgr_destroy(), ns_clientmgr::clients, CTRACE, ns_client::delaytimer, DESTROYLOCK, ns_client::dispatch, dns_dispatch_detach(), dns_message_destroy(), dns_message_puttemprdataset(), dns_rdataset_disassociate(), dns_rdataset_isassociated(), dns_tcpmsg_cancelread(), dns_tcpmsg_invalidate(), dns_view_detach(), ns_clientmgr::exiting, ns_query::fetchlock, ns_clientmgr::inactive, INSIST, ns_client::interface, isc_event_free(), ISC_FALSE, ISC_LINK_LINKED, ISC_LIST_EMPTY, ISC_LIST_UNLINK, isc_mem_put, isc_mem_putanddetach, isc_mem_references(), isc_mem_stats(), ISC_QLINK_LINKED, ISC_QUEUE_PUSH, isc_quota_detach(), ISC_SOCKCANCEL_ACCEPT, ISC_SOCKCANCEL_RECV, ISC_SOCKCANCEL_SEND, isc_socket_cancel(), isc_socket_detach(), isc_task_detach(), isc_task_shutdown(), isc_timer_detach(), isc_timer_reset(), isc_timertype_inactive, ISC_TRUE, ns_clientmgr::listlock, ns_clientmgr::lock, ns_interface::lock, LOCK, ns_client::magic, ns_client::manager, ns_client::mctx, ns_client::message, ns_client::mortal, ns_client::naccepts, ns_client::nctls, ns_client::needshutdown, ns_client::newstate, ns_client::nreads, ns_client::nrecvs, ns_client_endrequest(), NS_CLIENT_VALID, NS_CLIENTSTATE_FREED, NS_CLIENTSTATE_INACTIVE, NS_CLIENTSTATE_MAX, NS_CLIENTSTATE_READING, NS_CLIENTSTATE_READY, NS_CLIENTSTATE_RECURSING, NS_CLIENTSTATE_WORKING, ns_interface_detach(), ns_query_free(), ns_client::nsends, ns_interface::ntcpcurrent, ns_interface::ntcptarget, ns_client::nupdates, ns_client::opt, ns_client::peeraddr_valid, ns_client::pipelined, ns_client::query, ns_clientmgr::reclock, ns_clientmgr::recursing, ns_client::recursionquota, RECV_BUFFER_SIZE, ns_client::recvbuf, ns_client::recvevent, ns_client::references, REQUIRE, ns_client::sendevent, sock, ns_client::state, ns_client::task, TCP_BUFFER_SIZE, TCP_CLIENT, ns_client::tcpbuf, ns_client::tcplistener, ns_client::tcpmsg, ns_client::tcpmsg_valid, ns_client::tcpquota, ns_client::tcpsocket, ns_client::timer, ns_client::timerset, ns_client::udpsocket, UNLOCK, and ns_client::view.

static void ns_client_endrequest ( ns_client_t client  )  [static]

Definition at line 687 of file client.c.

References ns_client::attributes, CTRACE, DNS_MESSAGE_INTENTPARSE, dns_message_puttemprdataset(), dns_message_reset(), dns_nsstatscounter_recursclients, dns_rdataset_disassociate(), dns_rdataset_isassociated(), dns_view_detach(), ns_client::ednsversion, ns_client::extflags, INSIST, isc_quota_detach(), isc_stats_decrement(), ns_client::message, ns_client::naccepts, ns_client::next, ns_client::nreads, ns_client::nrecvs, NS_CLIENTATTR_TCP, NS_CLIENTSTATE_RECURSING, NS_CLIENTSTATE_WORKING, ns_client::nsends, ns_client::nupdates, ns_client::opt, ns_client::recursionquota, ns_client::signer, ns_client::state, ns_client::udpsize, and ns_client::view.

Referenced by exit_check().

static void client_start ( isc_task_t task,
isc_event_t event 
) [static]

The client's task has received the client's control event as part of the startup process.

Definition at line 628 of file client.c.

References client_accept(), client_read(), client_udprecv(), exit_check(), INSIST, ns_client::nctls, ns_client::pipelined, ns_client::task, TCP_CLIENT, and UNUSED.

Referenced by client_create().

static void client_request ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 1980 of file client.c.

References ns_interface::addr, isc_socketevent::address, AF_INET6, allowed(), ns_client::attributes, isc_socketevent::attributes, isc_region::base, dns_tcpmsg::buffer, buffer, dns_view::cacheacl, dns_view::cacheonacl, cleanup(), dns_tsigkey::creator, CTRACE, ns_client::destaddr, ns_client::dispatch, dns_acl_match(), dns_dispatch_importrecv(), DNS_EVENT_TCPMSG, DNS_LOGCATEGORY_SECURITY, dns_message_getopt(), dns_message_getrawmessage(), dns_message_gettsig(), dns_message_parse(), dns_message_peekheader(), dns_message_rechecksig(), dns_message_resetsig(), dns_message_signer(), DNS_MESSAGEFLAG_QR, DNS_MESSAGEFLAG_RD, dns_name_format(), DNS_NAME_FORMATSIZE, dns_name_init(), dns_nsstatscounter_invalidsig, dns_nsstatscounter_requesttcp, dns_nsstatscounter_requestv4, dns_nsstatscounter_requestv6, dns_nsstatscounter_sig0in, dns_nsstatscounter_tsigin, dns_opcode_iquery, dns_opcode_notify, dns_opcode_query, dns_opcode_update, dns_opcodestats_increment(), dns_peer_getmaxudp(), dns_peerlist_peerbyaddr(), DNS_R_FORMERR, DNS_R_NOIDENTITY, DNS_R_NOTIMP, DNS_R_REFUSED, dns_rcode_noerror, dns_rdataclass_format(), DNS_RDATACLASS_FORMATSIZE, dns_tsig_verify(), dns_tsigerror_badkey, dns_tsigkey_identity, dns_tsigrcode_totext(), dns_view_attach(), DROPPORT_REQUEST, ns_client::dscp, isc_socketevent::dscp, ns_client::ecs_addr, ns_client::ecs_addrlen, ns_client::ecs_scope, exit_check(), ns_interface::flags, dns_message::flags, dns_tsigkey::generated, IN6_IS_ADDR_LINKLOCAL, INSIST, ns_client::interface, in6_pktinfo::ipi6_addr, in6_pktinfo::ipi6_ifindex, isc_buffer_add, isc_buffer_init, isc_buffer_usedlength, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LOG_DEBUG, ISC_LOG_ERROR, ISC_LOG_WARNING, isc_log_write(), isc_netaddr_fromin6(), isc_netaddr_fromsockaddr(), isc_netaddr_setzone(), isc_quota_reserve(), ISC_R_CANCELED, ISC_R_FAILURE, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_getport(), isc_sockaddr_pf(), isc_socket_getsockname(), ISC_SOCKEVENT_RECVDONE, ISC_SOCKEVENTATTR_DSCP, ISC_SOCKEVENTATTR_MULTICAST, ISC_SOCKEVENTATTR_PKTINFO, isc_stats_increment(), isc_task_getcurrenttime(), isc_task_shutdown(), isc_time_set(), ISC_TRUE, isc_region::length, match(), dns_view::matchclients, dns_view::matchdestinations, dns_view::matchrecursiveonly, dns_view::maxudp, ns_client::message, isc_socketevent::n, dns_view::name, namebuf, ns_client::newstate, ns_client::now, ns_client::nreads, ns_client::nrecvs, ns_client_checkaclsilent(), ns_client_dropport(), ns_client_dumpmessage(), ns_client_error(), ns_client_log(), ns_client_next(), ns_client_replace(), ns_client_requests, ns_client_settimeout(), NS_CLIENT_VALID, NS_CLIENTATTR_HAVEECS, NS_CLIENTATTR_MULTICAST, NS_CLIENTATTR_PKTINFO, NS_CLIENTATTR_RA, NS_CLIENTSTATE_READING, NS_CLIENTSTATE_READY, NS_CLIENTSTATE_WORKING, NS_INTERFACEFLAG_ANYADDR, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, ns_notify_start(), ns_query_start(), ns_update_start(), dns_message::opcode, ns_client::peeraddr, ns_client::peeraddr_valid, dns_view::peers, ns_client::pipelined, isc_socketevent::pktinfo, ns_client::pktinfo, process_opt(), r, dns_message::rcode, dns_view::rdclass, dns_message::rdclass, dns_view::recursion, dns_view::recursionacl, dns_view::recursiononacl, ns_client::recursionquota, ns_client::recvevent, isc_socketevent::region, ns_client::requesttime, REQUIRE, dns_view::resolver, dns_tcpmsg::result, isc_socketevent::result, isc_sockaddr::sa, dns_message::sig0status, ns_client::signer, ns_client::signername, ns_client::state, ns_client::task, TCP_CLIENT, ns_client::tcpmsg, ns_client::tcpsocket, ns_client::tnow, dns_message::tsigkey, tsigkey, dns_message::tsigstatus, isc_sockaddr::type, ns_client::udpsize, UNEXPECTED_ERROR, and ns_client::view.

Referenced by client_create(), and client_read().

static void ns_client_dumpmessage ( ns_client_t client,
const char *  reason 
) [static]

Definition at line 3487 of file client.c.

References buffer, dns_master_style_debug, dns_message_totext(), isc_buffer_init, isc_buffer_usedlength, ISC_LOG_DEBUG, isc_log_wouldlog(), isc_mem_get, isc_mem_put, ISC_R_NOSPACE, ISC_R_SUCCESS, ns_client::mctx, ns_client::message, ns_client_log(), NS_LOGCATEGORY_UNMATCHED, and NS_LOGMODULE_CLIENT.

Referenced by client_request().

static isc_result_t get_client ( ns_clientmgr_t manager,
ns_interface_t ifp,
dns_dispatch_t disp,
isc_boolean_t  tcp 
) [static]

Definition at line 3179 of file client.c.

References ns_client::attributes, client_create(), ns_clientmgr::clients, ns_client::ctlevent, ns_client::dispatch, dns_dispatch_attach(), dns_dispatch_getsocket(), ns_interface::dscp, ns_client::dscp, ns_clientmgr::exiting, ns_clientmgr::inactive, INSIST, ns_client::interface, ISC_LIST_APPEND, ISC_QUEUE_POP, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, isc_socket_attach(), isc_task_send(), ns_clientmgr::listlock, ns_clientmgr::lock, LOCK, ns_client::manager, MTRACE, ns_client::nctls, NS_CLIENTATTR_TCP, NS_CLIENTSTATE_READY, ns_interface_attach(), ns_client::recursionquota, REQUIRE, sock, ns_client::state, ns_client::task, ns_client::tcplistener, ns_interface::tcpsocket, ns_client::udpsocket, and UNLOCK.

Referenced by ns_client_replace(), and ns_clientmgr_createclients().

static isc_result_t get_worker ( ns_clientmgr_t manager,
ns_interface_t ifp,
isc_socket_t sock 
) [static]

Definition at line 3244 of file client.c.

References ns_client::attributes, client_create(), ns_clientmgr::clients, ns_client::ctlevent, dns_tcpmsg_init(), ns_interface::dscp, ns_client::dscp, ns_clientmgr::exiting, ns_clientmgr::inactive, INSIST, ns_client::interface, ISC_FALSE, ISC_LIST_APPEND, ISC_QUEUE_POP, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, isc_socket_attach(), isc_socket_getpeername(), isc_socket_setname(), isc_task_send(), ISC_TRUE, ns_clientmgr::listlock, ns_clientmgr::lock, LOCK, ns_client::manager, ns_client::mctx, MTRACE, ns_client::nctls, ns_client::newstate, NS_CLIENTATTR_TCP, NS_CLIENTSTATE_WORKING, ns_interface_attach(), ns_client::peeraddr, ns_client::peeraddr_valid, ns_client::pipelined, ns_client::recursionquota, REQUIRE, ns_client::state, ns_client::task, ns_client::tcplistener, ns_client::tcpmsg, ns_client::tcpmsg_valid, ns_client::tcpquota, ns_client::tcpsocket, ns_interface::tcpsocket, and UNLOCK.

Referenced by ns_client_replace().

static isc_boolean_t allowed ( isc_netaddr_t addr,
dns_name_t signer,
isc_netaddr_t ecs_addr,
isc_uint8_t  ecs_addrlen,
isc_uint8_t ecs_scope,
dns_acl_t acl 
) [inline, static]

Definition at line 1548 of file client.c.

References dns_acl_match2(), ISC_FALSE, ISC_R_SUCCESS, ISC_TRUE, and match().

Referenced by check_zoneconf(), client_newconn(), client_request(), client_send(), ns_client_isself(), and rpz_rewrite().

void ns_client_recursing ( ns_client_t client  ) 

Definition at line 256 of file client.c.

References ISC_LIST_APPEND, LOCK, ns_client::manager, ns_client::newstate, NS_CLIENT_VALID, NS_CLIENTSTATE_RECURSING, NS_CLIENTSTATE_WORKING, ns_clientmgr::reclock, ns_clientmgr::recursing, REQUIRE, ns_client::state, and UNLOCK.

Referenced by query_recurse().

void ns_client_killoldestquery ( ns_client_t client  ) 

Add client to end of th recursing list.

Definition at line 267 of file client.c.

References ISC_LIST_HEAD, ISC_LIST_UNLINK, LOCK, ns_client::manager, NS_CLIENT_VALID, ns_query_cancel(), ns_clientmgr::reclock, ns_clientmgr::recursing, REQUIRE, and UNLOCK.

Referenced by query_recurse().

void ns_client_settimeout ( ns_client_t client,
unsigned int  seconds 
)

Try to replace the current client with a new one, so that the current one can go off and do some lengthy work without leaving the dispatch/socket without service.

Definition at line 282 of file client.c.

References ISC_FALSE, isc_interval_set(), ISC_LOG_ERROR, ISC_R_SUCCESS, isc_result_totext(), isc_timer_reset(), isc_timertype_once, ISC_TRUE, ns_client_log(), NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, ns_client::timer, and ns_client::timerset.

Referenced by client_read(), client_request(), and query_recurse().

static void client_shutdown ( isc_task_t task,
isc_event_t event 
) [static]

The client's task has received a shutdown event.

Definition at line 657 of file client.c.

References CTRACE, exit_check(), ns_clientmgr::inactive, isc_event_free(), ISC_FALSE, ISC_QLINK_LINKED, ISC_QUEUE_UNLINK, ISC_R_SHUTTINGDOWN, ISC_TASKEVENT_SHUTDOWN, ns_client::manager, ns_client::needshutdown, ns_client::newstate, NS_CLIENT_VALID, NS_CLIENTSTATE_FREED, REQUIRE, ns_client::shutdown, ns_client::shutdown_arg, ns_client::task, and UNUSED.

Referenced by client_create().

void ns_client_next ( ns_client_t client,
isc_result_t  result 
)

Finish processing the current client request and return an error response to the client. The error response will have an RCODE determined by 'result'.

Definition at line 731 of file client.c.

References CTRACE, DNS_LOGCATEGORY_SECURITY, exit_check(), ISC_LOG_DEBUG, ISC_R_SUCCESS, isc_result_totext(), ns_client::newstate, ns_client_log(), NS_CLIENT_VALID, NS_CLIENTSTATE_READING, NS_CLIENTSTATE_READY, NS_CLIENTSTATE_RECURSING, NS_CLIENTSTATE_WORKING, NS_LOGMODULE_CLIENT, REQUIRE, ns_client::state, and TCP_CLIENT.

Referenced by client_read(), client_request(), client_send(), client_senddone(), ns_client_error(), ns_client_sendraw(), query_next(), respond(), xfrout_maybe_destroy(), and xfrout_senddone().

static void client_senddone ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 763 of file client.c.

References CTRACE, INSIST, ISC_LOG_WARNING, isc_mem_put, ISC_R_SUCCESS, isc_result_totext(), ISC_SOCKEVENT_SENDDONE, ns_client::mctx, ns_client_log(), ns_client_next(), NS_CLIENT_VALID, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, ns_client::nsends, REQUIRE, isc_socketevent::result, ns_client::sendevent, ns_client::task, TCP_BUFFER_SIZE, TCP_CLIENT, ns_client::tcpbuf, and UNUSED.

Referenced by client_create(), and client_sendpkg().

static isc_result_t client_allocsendbuf ( ns_client_t client,
isc_buffer_t buffer,
isc_buffer_t tcpbuffer,
isc_uint32_t  length,
unsigned char *  sendbuf,
unsigned char **  datap 
) [static]

We only want to fail with ISC_R_NOSPACE when called from ns_client_sendraw() and not when called from ns_client_send(), tcpbuffer is NULL when called from ns_client_sendraw() and length != 0. tcpbuffer != NULL when called from ns_client_send() and length == 0.

Definition at line 805 of file client.c.

References ns_client::attributes, INSIST, isc_buffer_init, isc_buffer_putuint16, isc_mem_get, ISC_R_NOMEMORY, ISC_R_NOSPACE, ISC_R_SUCCESS, ns_client::mctx, NS_CLIENTATTR_HAVESIT, SEND_BUFFER_SIZE, dns_view::situdp, TCP_BUFFER_SIZE, TCP_CLIENT, ns_client::tcpbuf, ns_client::udpsize, and ns_client::view.

Referenced by client_send(), and ns_client_sendraw().

static isc_result_t client_sendpkg ( ns_client_t client,
isc_buffer_t buffer 
) [static]

Definition at line 871 of file client.c.

References isc_socketevent::attributes, ns_client::attributes, client_senddone(), CTRACE, ns_client::dispatch, dns_acl_match(), dns_dispatch_getdscp(), DNS_R_BLACKHOLED, isc_socketevent::dscp, ns_client::dscp, isc_buffer_usedregion, isc_netaddr_fromsockaddr(), ISC_R_INPROGRESS, ISC_R_SUCCESS, isc_socket_sendto2(), ISC_SOCKEVENTATTR_DSCP, ISC_SOCKFLAG_IMMEDIATE, ISC_SOCKFLAG_NORETRY, match(), NS_CLIENTATTR_MULTICAST, NS_CLIENTATTR_PKTINFO, ns_client::nsends, ns_client::peeraddr, ns_client::pktinfo, r, ns_client::sendevent, sock, ns_client::task, TCP_CLIENT, ns_client::tcpsocket, and ns_client::udpsocket.

Referenced by client_send(), and ns_client_sendraw().

void ns_client_sendraw ( ns_client_t client,
dns_message_t msg 
)

Finish processing the current client request and send client->message as a response.

Note! These ns_client_ routines MUST be called ONLY from the client's task in order to ensure synchronization.

Definition at line 938 of file client.c.

References isc_region::base, buffer, client_allocsendbuf(), client_sendpkg(), CTRACE, dns_message_getrawmessage(), dns_message::id, isc_buffer_availableregion, isc_buffer_copyregion(), isc_mem_put, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, isc_region::length, ns_client::mctx, ns_client::message, ns_client_next(), NS_CLIENT_VALID, r, REQUIRE, SEND_BUFFER_SIZE, TCP_BUFFER_SIZE, and ns_client::tcpbuf.

Referenced by forward_done().

static void client_send ( ns_client_t client  )  [static]

Definition at line 984 of file client.c.

References allowed(), ns_client::attributes, buffer, client_allocsendbuf(), client_sendpkg(), CTRACE, dns_compress_init(), dns_compress_invalidate(), dns_compress_setsensitive(), dns_message_renderbegin(), dns_message_renderend(), dns_message_rendersection(), dns_message_setopt(), DNS_MESSAGEFLAG_RA, DNS_MESSAGEFLAG_TC, DNS_MESSAGERENDER_OMITDNSSEC, DNS_MESSAGERENDER_PARTIAL, DNS_MESSAGERENDER_PREFER_A, DNS_MESSAGERENDER_PREFER_AAAA, dns_nsstatscounter_edns0out, dns_nsstatscounter_response, dns_nsstatscounter_sig0out, dns_nsstatscounter_truncatedresp, dns_nsstatscounter_tsigout, DNS_SECTION_ADDITIONAL, DNS_SECTION_ANSWER, DNS_SECTION_AUTHORITY, DNS_SECTION_QUESTION, dns_message::flags, isc_buffer_add, isc_buffer_putuint16, isc_buffer_usedregion, ISC_FALSE, isc_mem_put, isc_netaddr_fromsockaddr(), ISC_R_NOSPACE, ISC_R_SUCCESS, isc_stats_increment(), ISC_TRUE, isc_region::length, ns_client::mctx, ns_client::message, dns_tsigkey::name, name, dns_view::nocasecompress, ns_client_addopt(), ns_client_next(), NS_CLIENT_VALID, NS_CLIENTATTR_RA, NS_CLIENTATTR_WANTDNSSEC, NS_CLIENTATTR_WANTOPT, ns_client::opt, ns_client::peeraddr, ns_client::peeraddr_valid, dns_view::preferred_glue, r, REQUIRE, SEND_BUFFER_SIZE, dns_message::sig0key, TCP_BUFFER_SIZE, TCP_CLIENT, ns_client::tcpbuf, dns_message::tsigkey, and ns_client::view.

Referenced by client_delay(), and ns_client_send().

static void client_delay ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 1178 of file client.c.

References client_send(), CTRACE, ns_client::delaytimer, isc_event_free(), isc_timer_detach(), ISC_TIMEREVENT_IDLE, ISC_TIMEREVENT_LIFE, ns_client_detach(), NS_CLIENT_VALID, REQUIRE, ns_client::task, and UNUSED.

Referenced by ns_client_send().

void ns_client_send ( ns_client_t client  ) 

Note! These ns_client_ routines MUST be called ONLY from the client's task in order to ensure synchronization.

Definition at line 1201 of file client.c.

References client_delay(), client_send(), ns_client::delaytimer, dummy, isc_interval_set(), ISC_R_SUCCESS, isc_timer_create(), isc_timertype_once, ns_client::manager, ns_client::mortal, ns_client_attach(), ns_client_detach(), ns_client_replace(), ns_client::task, and ns_clientmgr::timermgr.

Referenced by ns_client_error(), query_send(), respond(), and sendstream().

static int ns_client_dropport ( in_port_t  port  )  [static]

ns_client_dropport determines if certain requests / responses should be dropped based on the port number.

Returns:

Definition at line 1254 of file client.c.

References DROPPORT_NO, DROPPORT_REQUEST, and DROPPORT_RESPONSE.

Referenced by client_request(), and ns_client_error().

void ns_client_error ( ns_client_t client,
isc_result_t  result 
)

Finish processing the current client request and send msg as a response using client->message->id for the id.

Definition at line 1269 of file client.c.

References ns_client::addr, ns_client::attributes, CTRACE, dns_badcache_add(), DNS_LOGCATEGORY_SECURITY, dns_message_reply(), DNS_MESSAGEFLAG_AA, DNS_MESSAGEFLAG_AD, DNS_MESSAGEFLAG_CD, DNS_MESSAGEFLAG_QR, dns_nsstatscounter_dropped, dns_nsstatscounter_ratedropped, DNS_R_DROP, dns_rcode_formerr, dns_rcode_noerror, dns_rcode_nxdomain, dns_rcode_servfail, dns_rcode_totext(), dns_result_torcode(), dns_rrl(), DNS_RRL_LOG_BUF_LEN, DNS_RRL_LOG_DROP, DNS_RRL_RESULT_OK, DROPPORT_NO, dns_view::fail_ttl, dns_view::failcache, dns_message::flags, ns_client::formerrcache, ns_client::id, dns_message::id, INSIST, isc_buffer_init, isc_buffer_putstr, isc_buffer_usedlength, ISC_FALSE, isc_interval_set(), ISC_LOG_DEBUG, isc_log_wouldlog(), ISC_R_SUCCESS, isc_sockaddr_equal(), isc_sockaddr_getport(), isc_stats_increment(), isc_time_nowplusinterval(), ISC_TRUE, dns_rrl::log_only, ns_client::message, ns_client::now, ns_client_dropport(), ns_client_log(), ns_client_next(), ns_client_send(), NS_CLIENT_VALID, NS_CLIENTATTR_NOSETFC, NS_FAILCACHE_CD, NS_LOGCATEGORY_CLIENT, NS_LOGCATEGORY_QUERY_EERRORS, NS_LOGMODULE_CLIENT, ns_client::peeraddr, ns_query::qname, ns_query::qtype, ns_client::query, dns_message::rcode, ns_client::requesttime, REQUIRE, dns_view::rrl, TCP_CLIENT, ns_client::time, and ns_client::view.

Referenced by client_request(), ns_xfr_start(), process_opt(), and query_error().

isc_result_t ns_client_addopt ( ns_client_t client,
dns_message_t message,
dns_rdataset_t **  opt 
)

Definition at line 1428 of file client.c.

References AF_INET6, ns_client::attributes, dns_ednsopt::code, DNS_EDNSOPTIONS, dns_message_buildopt(), DNS_MESSAGEEXTFLAG_REPLYPRESERVE, DNS_OPT_CLIENT_SUBNET, DNS_OPT_EXPIRE, DNS_OPT_NSID, DNS_OPT_SIT, dns_resolver_getudpsize(), ns_client::ecs_addr, ns_client::ecs_addrlen, ns_client::ecs_scope, ECS_SIZE, ednsopts, ns_client::expire, ns_client::extflags, isc_netaddr::family, INSIST, isc_buffer_init, isc_buffer_putuint16, isc_buffer_putuint32, isc_buffer_putuint8, ISC_R_SUCCESS, isc_random_get(), isc_stdtime_get(), dns_ednsopt::length, now, NS_CLIENT_VALID, NS_CLIENTATTR_HAVEECS, NS_CLIENTATTR_HAVEEXPIRE, NS_CLIENTATTR_WANTNSID, NS_CLIENTATTR_WANTSIT, ns_os_gethostname(), REQUIRE, dns_view::resolver, SIT_SIZE, isc_netaddr::type, dns_ednsopt::value, and ns_client::view.

Referenced by client_send(), process_opt(), and sendstream().

isc_boolean_t ns_client_isself ( dns_view_t myview,
dns_tsigkey_t mykey,
isc_sockaddr_t srcaddr,
isc_sockaddr_t dstaddr,
dns_rdataclass_t  rdclass,
void *  arg 
)

Replace the qname.

Definition at line 1573 of file client.c.

References allowed(), dns_tsigkey_detach(), dns_tsigkey_identity, dns_view_gettsig(), dst_key_compare(), ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_netaddr_fromsockaddr(), ISC_R_SUCCESS, ISC_TF, ISC_TRUE, dns_tsigkey::key, key, match(), dns_view::matchclients, dns_view::matchdestinations, dns_view::matchrecursiveonly, dns_tsigkey::name, ns_interfacemgr_listeningon(), dns_view::rdclass, and UNUSED.

Referenced by ns_zone_configure().

static isc_result_t process_ecs ( ns_client_t client,
isc_buffer_t buf,
size_t  optlen 
) [static]

Definition at line 1806 of file client.c.

References AF_INET6, ns_client::attributes, DNS_R_FORMERR, ns_client::ecs_addr, ns_client::ecs_addrlen, ns_client::ecs_scope, isc_netaddr::family, isc_buffer_forward, isc_buffer_getuint16(), isc_buffer_getuint8(), isc_buffer_remaininglength, ISC_LOG_DEBUG, ISC_R_SUCCESS, ns_client_log(), NS_CLIENTATTR_HAVEECS, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, and isc_netaddr::type.

Referenced by process_opt().

static isc_result_t process_opt ( ns_client_t client,
dns_rdataset_t opt 
) [static]

Definition at line 1881 of file client.c.

References ns_client::attributes, cleanup(), dns_rdata::data, DNS_EDNS_VERSION, dns_nsstatscounter_badednsver, dns_nsstatscounter_ecsopt, dns_nsstatscounter_edns0in, dns_nsstatscounter_expireopt, dns_nsstatscounter_nsidopt, dns_nsstatscounter_otheropt, DNS_OPT_CLIENT_SUBNET, DNS_OPT_EXPIRE, DNS_OPT_NSID, DNS_OPT_SIT, DNS_R_BADVERS, dns_rdata_init(), dns_rdataset_current(), dns_rdataset_first(), ns_client::ednsversion, ns_client::extflags, isc_buffer_add, isc_buffer_forward, isc_buffer_getuint16(), isc_buffer_init, isc_buffer_remaininglength, ISC_R_SUCCESS, isc_stats_increment(), dns_rdata::length, ns_client::message, ns_client_addopt(), ns_client_error(), NS_CLIENTATTR_WANTEXPIRE, NS_CLIENTATTR_WANTNSID, NS_CLIENTATTR_WANTOPT, ns_client::opt, process_ecs(), dns_rdataset::rdclass, dns_rdataset::ttl, and ns_client::udpsize.

static void client_timeout ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 2545 of file client.c.

References CTRACE, exit_check(), isc_event_free(), ISC_R_TIMEDOUT, ISC_TIMEREVENT_IDLE, ISC_TIMEREVENT_LIFE, ns_client::newstate, NS_CLIENT_VALID, NS_CLIENTSTATE_READY, REQUIRE, ns_client::shutdown, ns_client::shutdown_arg, ns_client::task, ns_client::timer, and UNUSED.

Referenced by client_create().

static isc_result_t get_clientmctx ( ns_clientmgr_t manager,
isc_mem_t **  mctxp 
) [static]

Definition at line 2574 of file client.c.

References INSIST, isc_mem_attach(), isc_mem_create(), isc_mem_setname(), ISC_R_SUCCESS, ns_clientmgr::mctx, MTRACE, and NMCTXS.

Referenced by client_create().

static isc_result_t client_create ( ns_clientmgr_t manager,
ns_client_t **  clientp 
) [static]

Definition at line 2618 of file client.c.

References ns_client::addr, ns_client::attributes, client_request(), client_senddone(), client_shutdown(), client_start(), client_timeout(), ns_client::ctlevent, CTRACE, ns_client::delaytimer, ns_client::dispatch, dns_aaaa_ok, dns_message_create(), dns_message_destroy(), DNS_MESSAGE_INTENTPARSE, dns_name_init(), ns_client::dscp, ns_client::ecs_addrlen, ns_client::ecs_scope, ns_client::ednsversion, ns_client::extflags, ns_client::formerrcache, get_clientmctx(), ns_client::id, ns_client::interface, isc_event_free(), ISC_EVENT_INIT, ISC_FALSE, ISC_LINK_INIT, isc_mem_detach(), isc_mem_get, isc_mem_put, isc_mem_putanddetach, ISC_QLINK_INIT, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_sockaddr_any(), isc_socket_socketevent(), ISC_SOCKEVENT_RECVDONE, ISC_SOCKEVENT_SENDDONE, isc_task_create(), isc_task_detach(), isc_task_onshutdown(), isc_task_setname(), isc_timer_create(), isc_timer_detach(), isc_timertype_inactive, ns_client::magic, ns_client::manager, ns_client::mctx, mctx, ns_client::message, ns_client::mortal, ns_client::naccepts, ns_client::nctls, ns_client::needshutdown, ns_client::newstate, ns_client::next, ns_client::nreads, ns_client::nrecvs, NS_CLIENT_MAGIC, NS_CLIENTSTATE_INACTIVE, NS_CLIENTSTATE_MAX, NS_EVENT_CLIENTCONTROL, ns_query_free(), ns_query_init(), ns_client::nsends, ns_client::nupdates, ns_client::opt, ns_client::peeraddr_valid, ns_client::pipelined, ns_client::recursionquota, RECV_BUFFER_SIZE, ns_client::recvbuf, ns_client::recvevent, ns_client::references, REQUIRE, ns_client::sendevent, ns_client::shutdown, ns_client::shutdown_arg, ns_client::signer, ns_client::signername, ns_client::state, ns_client::task, ns_clientmgr::taskmgr, ns_client::tcpbuf, ns_client::tcplistener, ns_client::tcpmsg_valid, ns_client::tcpquota, ns_client::tcpsocket, ns_client::time, ns_client::timer, ns_clientmgr::timermgr, ns_client::timerset, ns_client::udpsize, ns_client::udpsocket, and ns_client::view.

Referenced by get_client(), and get_worker().

static void client_newconn ( isc_task_t task,
isc_event_t event 
) [static]

Definition at line 2822 of file client.c.

References allowed(), client_read(), dns_acl_match(), DNS_LOGCATEGORY_SECURITY, dns_tcpmsg_init(), exit_check(), INSIST, ns_client::interface, isc_event_free(), ISC_FALSE, ISC_LOG_DEBUG, ISC_LOG_WARNING, isc_netaddr_fromsockaddr(), isc_quota_attach(), ISC_R_SUCCESS, isc_result_totext(), isc_socket_getpeername(), isc_socket_setname(), ISC_SOCKEVENT_NEWCONN, ISC_TRUE, ns_interface::lock, LOCK, match(), ns_client::mctx, ns_client::naccepts, isc_socket_newconnev::newsocket, ns_client::newstate, ns_client_log(), ns_client_replace(), NS_CLIENT_VALID, NS_CLIENTSTATE_READING, NS_CLIENTSTATE_READY, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, ns_interface::ntcpcurrent, ns_client::peeraddr, ns_client::peeraddr_valid, ns_client::pipelined, ns_client::recursionquota, REQUIRE, isc_socket_newconnev::result, ns_client::state, ns_client::task, ns_client::tcpmsg, ns_client::tcpmsg_valid, ns_client::tcpquota, ns_client::tcpsocket, UNLOCK, and UNUSED.

Referenced by client_accept().

void ns_client_attach ( ns_client_t source,
ns_client_t **  targetp 
)

Return ISC_TRUE iff the client is currently shutting down.

Definition at line 2990 of file client.c.

References ISC_LOG_DEBUG, ns_client_log(), NS_CLIENT_VALID, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, ns_client::references, and REQUIRE.

Referenced by ns_client_send(), ns_query_start(), query_prefetch(), send_forward_event(), send_update_event(), xfrout_ctx_create(), and xfrout_ctx_destroy().

void ns_client_detach ( ns_client_t **  clientp  ) 

Attach '*targetp' to 'source'.

Definition at line 3002 of file client.c.

References exit_check(), INSIST, ISC_LOG_DEBUG, ns_client_log(), NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, and ns_client::references.

Referenced by client_delay(), forward_done(), forward_fail(), ns_client_send(), prefetch_done(), query_find(), query_prefetch(), query_resume(), updatedone_action(), and xfrout_ctx_destroy().

isc_boolean_t ns_client_shuttingdown ( ns_client_t client  ) 

Finish processing the current client request, return no response to the client.

Definition at line 3015 of file client.c.

References ISC_TF, ns_client::newstate, and NS_CLIENTSTATE_FREED.

Referenced by query_resume().

isc_result_t ns_client_replace ( ns_client_t client  ) 

Detach '*clientp' from its client.

Definition at line 3020 of file client.c.

References CTRACE, ns_client::dispatch, get_client(), get_worker(), ns_client::interface, ISC_R_SUCCESS, ISC_TRUE, ns_client::manager, ns_client::mortal, ns_client::pipelined, REQUIRE, TCP_CLIENT, and ns_client::tcpsocket.

Referenced by client_newconn(), client_request(), ns_client_send(), ns_query_start(), query_recurse(), and send_forward_event().

isc_result_t ns_clientmgr_create ( isc_mem_t mctx,
isc_taskmgr_t taskmgr,
isc_timermgr_t timermgr,
ns_clientmgr_t **  managerp 
)

Set a timer in the client to go off in the specified amount of time.

Definition at line 3080 of file client.c.

References ns_clientmgr::clients, ns_clientmgr::exiting, ns_clientmgr::inactive, ISC_FALSE, ISC_LIST_INIT, isc_mem_get, isc_mem_put, isc_mutex_destroy, isc_mutex_init, ISC_QUEUE_INIT, ISC_R_NOMEMORY, ISC_R_SUCCESS, ns_clientmgr::listlock, ns_clientmgr::lock, ns_clientmgr::magic, MANAGER_MAGIC, ns_clientmgr::mctx, MTRACE, NMCTXS, ns_clientmgr::reclock, ns_clientmgr::recursing, ns_clientmgr::taskmgr, and ns_clientmgr::timermgr.

Referenced by ns_interface_create().

void ns_clientmgr_destroy ( ns_clientmgr_t **  managerp  ) 

Create a client manager.

Definition at line 3138 of file client.c.

References clientmgr_destroy(), ns_clientmgr::clients, ns_clientmgr::exiting, ISC_FALSE, ISC_LIST_EMPTY, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_SUCCESS, isc_task_beginexclusive(), isc_task_endexclusive(), isc_task_shutdown(), ISC_TRUE, MTRACE, REQUIRE, ns_client::task, and VALID_MANAGER.

Referenced by ns_interface_shutdown().

isc_result_t ns_clientmgr_createclients ( ns_clientmgr_t manager,
unsigned int  n,
ns_interface_t ifp,
isc_boolean_t  tcp 
)

Destroy a client manager and all ns_client_t objects managed by it.

Definition at line 3310 of file client.c.

References get_client(), ISC_R_SUCCESS, MTRACE, REQUIRE, ns_interface::udpdispatch, and VALID_MANAGER.

Referenced by ns_interface_accepttcp(), and ns_interface_listenudp().

isc_sockaddr_t* ns_client_getsockaddr ( ns_client_t client  ) 

Create up to 'n' clients listening on interface 'ifp'. If 'tcp' is ISC_TRUE, the clients will listen for TCP connections, otherwise for UDP requests.

Definition at line 3331 of file client.c.

References ns_client::peeraddr.

Referenced by ns_notify_start().

isc_result_t ns_client_checkaclsilent ( ns_client_t client,
isc_netaddr_t netaddr,
dns_acl_t acl,
isc_boolean_t  default_allow 
)

Get the socket address of the client whose request is currently being processed.

Definition at line 3336 of file client.c.

References ns_client::attributes, dns_acl_match2(), DNS_R_REFUSED, ns_client::ecs_addr, ns_client::ecs_addrlen, isc_netaddr_fromsockaddr(), ISC_R_SUCCESS, match(), NS_CLIENTATTR_HAVEECS, ns_client::peeraddr, and ns_client::signer.

Referenced by checkqueryacl(), checkupdateacl(), client_request(), ns_client_checkacl(), query_find(), query_getcachedb(), query_validatezonedb(), and redirect().

isc_result_t ns_client_checkacl ( ns_client_t client,
isc_sockaddr_t sockaddr,
const char *  opname,
dns_acl_t acl,
isc_boolean_t  default_allow,
int  log_level 
)

Convenience function for client request ACL checking.

Check the current client request against 'acl'. If 'acl' is NULL, allow the request iff 'default_allow' is ISC_TRUE. If netaddr is NULL, check the ACL against client->peeraddr; otherwise check it against netaddr.

Notes:

Requires: Returns:

Definition at line 3381 of file client.c.

References DNS_LOGCATEGORY_SECURITY, ISC_LOG_DEBUG, isc_netaddr_fromsockaddr(), ISC_R_SUCCESS, ns_client_checkaclsilent(), ns_client_log(), and NS_LOGMODULE_CLIENT.

Referenced by ns_xfr_start().

static void ns_client_name ( ns_client_t client,
char *  peerbuf,
size_t  len 
) [static]

Definition at line 3406 of file client.c.

References isc_sockaddr_format(), ns_client::peeraddr, and ns_client::peeraddr_valid.

Referenced by ns_client_dumprecursing(), and ns_client_logv().

void ns_client_logv ( ns_client_t client,
isc_logcategory_t category,
isc_logmodule_t module,
int  level,
const char *  fmt,
va_list  ap 
)

Definition at line 3415 of file client.c.

References dns_name_format(), DNS_NAME_FORMATSIZE, isc_log_write(), ISC_SOCKADDR_FORMATSIZE, dns_view::name, ns_client_name(), ns_query::origqname, ns_query::qname, ns_client::query, ns_client::signer, and ns_client::view.

Referenced by notify_log(), and ns_client_log().

void ns_client_log ( ns_client_t client,
isc_logcategory_t category,
isc_logmodule_t module,
int  level,
const char *  fmt,
  ... 
)

Definition at line 3458 of file client.c.

References isc_log_wouldlog(), and ns_client_logv().

Referenced by checkqueryacl(), checkupdateacl(), client_newconn(), client_request(), client_senddone(), log_query(), log_queryerror(), ns_client_attach(), ns_client_checkacl(), ns_client_detach(), ns_client_dumpmessage(), ns_client_error(), ns_client_next(), ns_client_settimeout(), ns_xfr_start(), process_ecs(), query_find(), query_findclosestnsec3(), query_getcachedb(), query_recurse(), query_validatezonedb(), rpz_getdb(), rpz_log_fail(), rpz_log_rewrite(), send_forward_event(), update_log(), warn_rfc1918(), and xfrout_logv().

void ns_client_aclmsg ( const char *  msg,
dns_name_t name,
dns_rdatatype_t  type,
dns_rdataclass_t  rdclass,
char *  buf,
size_t  len 
)

Definition at line 3472 of file client.c.

References dns_name_format(), DNS_NAME_FORMATSIZE, dns_rdataclass_format(), DNS_RDATACLASS_FORMATSIZE, dns_rdatatype_format(), DNS_RDATATYPE_FORMATSIZE, and namebuf.

Referenced by ns_xfr_start(), query_getcachedb(), and query_validatezonedb().

void ns_client_dumprecursing ( FILE *  f,
ns_clientmgr_t manager 
)

Kill the oldest recursive query (recursing list head).

Definition at line 3525 of file client.c.

References dns_name_format(), DNS_NAME_FORMATSIZE, dns_rdataclass_format(), DNS_RDATACLASS_FORMATSIZE, dns_rdatatype_format(), DNS_RDATATYPE_FORMATSIZE, ns_query::fetchlock, dns_message::id, INSIST, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_SOCKADDR_FORMATSIZE, LOCK, ns_client::message, dns_view::name, name, namebuf, ns_client_name(), NS_CLIENTSTATE_RECURSING, ns_query::origqname, ns_query::qname, ns_client::query, dns_rdataset::rdclass, ns_clientmgr::reclock, ns_clientmgr::recursing, ns_client::requesttime, REQUIRE, ns_client::state, dns_rdataset::type, UNLOCK, VALID_MANAGER, and ns_client::view.

Referenced by ns_interfacemgr_dumprecursing().

void ns_client_qnamereplace ( ns_client_t client,
dns_name_t name 
)

Dump the outstanding recursive queries to 'f'.

Definition at line 3590 of file client.c.

References ns_query::attributes, dns_message_puttempname(), ns_query::fetchlock, LOCK, ns_client::message, NS_QUERYATTR_REDIRECT, ns_query::qname, ns_client::query, ns_query::restarts, and UNLOCK.

Referenced by query_find(), and rpz_add_cname().

isc_result_t ns_client_sourceip ( dns_clientinfo_t ci,
isc_sockaddr_t **  addrp 
)

Isself callback.

Definition at line 3605 of file client.c.

References dns_clientinfo::data, ISC_R_SUCCESS, NS_CLIENT_VALID, ns_client::peeraddr, and REQUIRE.

Referenced by foreach_rr(), foreach_rrset(), get_key(), mark_secure(), query_addadditional(), query_addadditional2(), query_addbestns(), query_addns(), query_addsoa(), query_addwildcardproof(), query_find(), query_findclosestnsec3(), query_getdb(), redirect(), redirect2(), rpz_find_p(), and rpz_rrset_find().


Variable Documentation

unsigned int ns_client_requests

Definition at line 232 of file client.c.

Referenced by client_request(), and pps_timer_tick().


Generated on Tue Apr 28 17:41:08 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha