dispatch.c File Reference

#include <config.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <isc/entropy.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/portset.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/socket.h>
#include <isc/stats.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/time.h>
#include <isc/util.h>
#include <dns/acl.h>
#include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/log.h>
#include <dns/message.h>
#include <dns/portlist.h>
#include <dns/stats.h>
#include <dns/tcpmsg.h>
#include <dns/types.h>

Go to the source code of this file.

Data Structures

struct  dns_dispatchmgr
struct  dns_dispentry
struct  dispsocket
struct  dispportentry
 A port table entry. We remember every port we first open in a table with a reference counter so that we can 'reuse' the same port (with different destination addresses) using the SO_REUSEADDR socket option. More...
struct  dns_dispatch

Defines

#define MGR_SHUTTINGDOWN   0x00000001U
#define MGR_IS_SHUTTINGDOWN(l)   (((l)->state & MGR_SHUTTINGDOWN) != 0)
#define IS_PRIVATE(d)   (((d)->attributes & DNS_DISPATCHATTR_PRIVATE) != 0)
#define DNS_DISPATCH_POOLSOCKS   2048
 Maximum number of dispatch sockets that can be pooled for reuse. The appropriate value may vary, but experiments have shown a busy caching server may need more than 1000 sockets concurrently opened. The maximum allowable number of dispatch sockets (per manager) will be set to the double of this value.
#define DNS_DISPATCH_SOCKSQUOTA   3072
 Quota to control the number of dispatch sockets. If a dispatch has more than the quota of sockets, new queries will purge oldest ones, so that a massive number of outstanding queries won't prevent subsequent queries (especially if the older ones take longer time and result in timeout).
#define DNS_DISPATCH_PORTTABLESIZE   1024
#define INVALID_BUCKET   (0xffffdead)
#define MAX_INTERNAL_TASKS   64
 Number of tasks for each dispatch that use separate sockets for different transactions. This must be a power of 2 as it will divide 32 bit numbers to get an uniformly random tasks selection. See get_dispsocket().
#define QID_MAGIC   ISC_MAGIC('Q', 'i', 'd', ' ')
#define VALID_QID(e)   ISC_MAGIC_VALID((e), QID_MAGIC)
#define RESPONSE_MAGIC   ISC_MAGIC('D', 'r', 's', 'p')
#define VALID_RESPONSE(e)   ISC_MAGIC_VALID((e), RESPONSE_MAGIC)
#define DISPSOCK_MAGIC   ISC_MAGIC('D', 's', 'o', 'c')
#define VALID_DISPSOCK(e)   ISC_MAGIC_VALID((e), DISPSOCK_MAGIC)
#define DISPATCH_MAGIC   ISC_MAGIC('D', 'i', 's', 'p')
#define VALID_DISPATCH(e)   ISC_MAGIC_VALID((e), DISPATCH_MAGIC)
#define DNS_DISPATCHMGR_MAGIC   ISC_MAGIC('D', 'M', 'g', 'r')
#define VALID_DISPATCHMGR(e)   ISC_MAGIC_VALID((e), DNS_DISPATCHMGR_MAGIC)
#define DNS_QID(disp)
#define DISP_RNGCTX(disp)
#define PORTBUFLOCK(mgr)   if ((mgr)->qid != NULL) LOCK(&((mgr)->qid->lock))
 Locking a query port buffer is a bit tricky. We access the buffer without locking until qid is created. Technically, there is a possibility of race between the creation of qid and access to the port buffer; in practice, however, this should be safe because qid isn't created until the first dispatch is created and there should be no contending situation until then.
#define PORTBUFUNLOCK(mgr)   if ((mgr)->qid != NULL) UNLOCK((&(mgr)->qid->lock))
#define LVL(x)   ISC_LOG_DEBUG(x)
#define ATTRMATCH(_a1, _a2, _mask)   (((_a1) & (_mask)) == ((_a2) & (_mask)))
#define DNS_DISPATCH_HELD   20U

Functions

typedef ISC_LIST (dns_dispentry_t)
static dns_dispentry_tentry_search (dns_qid_t *, isc_sockaddr_t *, dns_messageid_t, in_port_t, unsigned int)
static isc_boolean_t destroy_disp_ok (dns_dispatch_t *)
static void destroy_disp (isc_task_t *task, isc_event_t *event)
static void destroy_dispsocket (dns_dispatch_t *disp, dispsocket_t **dispsockp)
 Destroy a dedicated dispatch socket.
static void deactivate_dispsocket (dns_dispatch_t *disp, dispsocket_t *dispsock)
 Deactivate a dedicated dispatch socket. Move it to the inactive list for future reuse unless the total number of sockets are exceeding the maximum.
static void udp_exrecv (isc_task_t *, isc_event_t *)
static void udp_shrecv (isc_task_t *, isc_event_t *)
static void udp_recv (isc_event_t *, dns_dispatch_t *, dispsocket_t *)
static void tcp_recv (isc_task_t *, isc_event_t *)
static isc_result_t startrecv (dns_dispatch_t *, dispsocket_t *)
static isc_uint32_t dns_hash (dns_qid_t *, isc_sockaddr_t *, dns_messageid_t, in_port_t)
static void free_buffer (dns_dispatch_t *disp, void *buf, unsigned int len)
static void * allocate_udp_buffer (dns_dispatch_t *disp)
static void free_devent (dns_dispatch_t *disp, dns_dispatchevent_t *ev)
static dns_dispatchevent_tallocate_devent (dns_dispatch_t *disp)
static void do_cancel (dns_dispatch_t *disp)
static dns_dispentry_tlinear_first (dns_qid_t *disp)
static dns_dispentry_tlinear_next (dns_qid_t *disp, dns_dispentry_t *resp)
static void dispatch_free (dns_dispatch_t **dispp)
static isc_result_t get_udpsocket (dns_dispatchmgr_t *mgr, dns_dispatch_t *disp, isc_socketmgr_t *sockmgr, isc_sockaddr_t *localaddr, isc_socket_t **sockp, isc_socket_t *dup_socket)
static isc_result_t dispatch_createudp (dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, unsigned int maxrequests, unsigned int attributes, dns_dispatch_t **dispp, isc_socket_t *dup_socket)
static isc_boolean_t destroy_mgr_ok (dns_dispatchmgr_t *mgr)
static void destroy_mgr (dns_dispatchmgr_t **mgrp)
static isc_result_t qid_allocate (dns_dispatchmgr_t *mgr, unsigned int buckets, unsigned int increment, dns_qid_t **qidp, isc_boolean_t needaddrtable)
static void qid_destroy (isc_mem_t *mctx, dns_qid_t **qidp)
static isc_result_t open_socket (isc_socketmgr_t *mgr, isc_sockaddr_t *local, unsigned int options, isc_socket_t **sockp, isc_socket_t *dup_socket)
static isc_boolean_t portavailable (dns_dispatchmgr_t *mgr, isc_socket_t *sock, isc_sockaddr_t *sockaddrp)
static void mgr_log (dns_dispatchmgr_t *mgr, int level, const char *fmt,...) ISC_FORMAT_PRINTF(3
static void inc_stats (dns_dispatchmgr_t *mgr, isc_statscounter_t counter)
static void dec_stats (dns_dispatchmgr_t *mgr, isc_statscounter_t counter)
static void dispatch_log (dns_dispatch_t *disp, int level, const char *fmt,...) ISC_FORMAT_PRINTF(3
static void request_log (dns_dispatch_t *disp, dns_dispentry_t *resp, int level, const char *fmt,...) ISC_FORMAT_PRINTF(4
static dispportentry_t * port_search (dns_dispatch_t *disp, in_port_t port)
 Manipulate port table per dispatch: find an entry for a given port number, create a new entry, and decrement a given entry with possible clean-up.
static dispportentry_t * new_portentry (dns_dispatch_t *disp, in_port_t port)
static void deref_portentry (dns_dispatch_t *disp, dispportentry_t **portentryp)
 The caller must not hold the qid->lock.
static dispsocket_t * socket_search (dns_qid_t *qid, isc_sockaddr_t *dest, in_port_t port, unsigned int bucket)
 Find a dispsocket for socket address 'dest', and port number 'port'. Return NULL if no such entry exists. Requires qid->lock to be held.
static isc_result_t get_dispsocket (dns_dispatch_t *disp, isc_sockaddr_t *dest, isc_socketmgr_t *sockmgr, dispsocket_t **dispsockp, in_port_t *portp)
 Make a new socket for a single dispatch with a random port number. The caller must hold the disp->lock.
static void free_sevent (isc_event_t *ev)
static isc_socketevent_tallocate_sevent (dns_dispatch_t *disp, isc_socket_t *sock, isc_eventtype_t type, isc_taskaction_t action, const void *arg)
static isc_result_t create_default_portset (isc_mem_t *mctx, isc_portset_t **portsetp)
 Create a temporary port list to set the initial default set of dispatch ports: [1024, 65535]. This is almost meaningless as the application will normally set the ports explicitly, but is provided to fill some minor corner cases.
isc_result_t dns_dispatchmgr_create (isc_mem_t *mctx, isc_entropy_t *entropy, dns_dispatchmgr_t **mgrp)
 Creates a new dispatchmgr object.
void dns_dispatchmgr_setblackhole (dns_dispatchmgr_t *mgr, dns_acl_t *blackhole)
 Sets the dispatcher's "blackhole list," a list of addresses that will be ignored by all dispatchers created by the dispatchmgr.
dns_acl_tdns_dispatchmgr_getblackhole (dns_dispatchmgr_t *mgr)
 Gets a pointer to the dispatcher's current blackhole list, without incrementing its reference count.
void dns_dispatchmgr_setblackportlist (dns_dispatchmgr_t *mgr, dns_portlist_t *portlist)
 This function is deprecated. Use dns_dispatchmgr_setavailports() instead.
dns_portlist_tdns_dispatchmgr_getblackportlist (dns_dispatchmgr_t *mgr)
 This function is deprecated and always returns NULL.
isc_result_t dns_dispatchmgr_setavailports (dns_dispatchmgr_t *mgr, isc_portset_t *v4portset, isc_portset_t *v6portset)
 Sets a list of UDP ports that can be used for outgoing UDP messages.
static isc_result_t dns_dispatchmgr_setudp (dns_dispatchmgr_t *mgr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment)
void dns_dispatchmgr_destroy (dns_dispatchmgr_t **mgrp)
 Destroys the dispatchmgr when it becomes empty. This could be immediately.
void dns_dispatchmgr_setstats (dns_dispatchmgr_t *mgr, isc_stats_t *stats)
 Sets statistics counter for the dispatchmgr. This function is expected to be called only on zone creation (when necessary). Once installed, it cannot be removed or replaced. Also, there is no interface to get the installed stats from the zone; the caller must keep the stats to reference (e.g. dump) it later.
static int port_cmp (const void *key, const void *ent)
static isc_boolean_t local_addr_match (dns_dispatch_t *disp, isc_sockaddr_t *addr)
static isc_result_t dispatch_find (dns_dispatchmgr_t *mgr, isc_sockaddr_t *local, unsigned int attributes, unsigned int mask, dns_dispatch_t **dispp)
static isc_result_t dispatch_allocate (dns_dispatchmgr_t *mgr, unsigned int maxrequests, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_createtcp (dns_dispatchmgr_t *mgr, isc_socket_t *sock, isc_taskmgr_t *taskmgr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_createtcp2 (dns_dispatchmgr_t *mgr, isc_socket_t *sock, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, isc_sockaddr_t *destaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, dns_dispatch_t **dispp)
 Create a new dns_dispatch and attach it to the provided isc_socket_t.
isc_result_t dns_dispatch_gettcp (dns_dispatchmgr_t *mgr, isc_sockaddr_t *destaddr, isc_sockaddr_t *localaddr, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_gettcp2 (dns_dispatchmgr_t *mgr, isc_sockaddr_t *destaddr, isc_sockaddr_t *localaddr, isc_boolean_t *connected, dns_dispatch_t **dispp)
isc_result_t dns_dispatch_getudp_dup (dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, unsigned int mask, dns_dispatch_t **dispp, dns_dispatch_t *dup_dispatch)
 Attach to existing dns_dispatch_t if one is found with dns_dispatchmgr_find, otherwise create a new UDP dispatch.
isc_result_t dns_dispatch_getudp (dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, isc_sockaddr_t *localaddr, unsigned int buffersize, unsigned int maxbuffers, unsigned int maxrequests, unsigned int buckets, unsigned int increment, unsigned int attributes, unsigned int mask, dns_dispatch_t **dispp)
void dns_dispatch_attach (dns_dispatch_t *disp, dns_dispatch_t **dispp)
 Attach to a dispatch handle.
void dns_dispatch_detach (dns_dispatch_t **dispp)
 Detaches from the dispatch.
isc_result_t dns_dispatch_addresponse2 (dns_dispatch_t *disp, isc_sockaddr_t *dest, isc_task_t *task, isc_taskaction_t action, void *arg, dns_messageid_t *idp, dns_dispentry_t **resp, isc_socketmgr_t *sockmgr)
isc_result_t dns_dispatch_addresponse3 (dns_dispatch_t *disp, unsigned int options, isc_sockaddr_t *dest, isc_task_t *task, isc_taskaction_t action, void *arg, dns_messageid_t *idp, dns_dispentry_t **resp, isc_socketmgr_t *sockmgr)
isc_result_t dns_dispatch_addresponse (dns_dispatch_t *disp, isc_sockaddr_t *dest, isc_task_t *task, isc_taskaction_t action, void *arg, dns_messageid_t *idp, dns_dispentry_t **resp)
void dns_dispatch_starttcp (dns_dispatch_t *disp)
 Start processing of a TCP dispatch once the socket connects.
void dns_dispatch_removeresponse (dns_dispentry_t **resp, dns_dispatchevent_t **sockevent)
 Stops the flow of responses for the provided id and destination. If "sockevent" is non-NULL, the dispatch event and associated buffer is also returned to the system.
isc_socket_tdns_dispatch_getsocket (dns_dispatch_t *disp)
 Return the socket associated with this dispatcher.
isc_socket_tdns_dispatch_getentrysocket (dns_dispentry_t *resp)
isc_result_t dns_dispatch_getlocaladdress (dns_dispatch_t *disp, isc_sockaddr_t *addrp)
 Return the local address for this dispatch. This currently only works for dispatches using UDP sockets.
void dns_dispatch_cancel (dns_dispatch_t *disp)
 cancel outstanding clients
unsigned int dns_dispatch_getattributes (dns_dispatch_t *disp)
 Return the attributes (DNS_DISPATCHATTR_xxx) of this dispatch. Only the non-changeable attributes are expected to be referenced by the caller.
void dns_dispatch_changeattributes (dns_dispatch_t *disp, unsigned int attributes, unsigned int mask)
 Set the bits described by "mask" to the corresponding values in "attributes".
void dns_dispatch_importrecv (dns_dispatch_t *disp, isc_event_t *event)
 Inform the dispatcher of a socket receive. This is used for sockets shared between dispatchers and clients. If the dispatcher fails to copy or send the event, nothing happens.
dns_dispatch_tdns_dispatchset_get (dns_dispatchset_t *dset)
 Retrieve the next dispatch from dispatch set 'dset', and increment the round-robin counter.
isc_result_t dns_dispatchset_create (isc_mem_t *mctx, isc_socketmgr_t *sockmgr, isc_taskmgr_t *taskmgr, dns_dispatch_t *source, dns_dispatchset_t **dsetp, int n)
 Given a valid dispatch 'source', create a dispatch set containing 'n' UDP dispatches, with the remainder filled out by clones of the source.
void dns_dispatchset_cancelall (dns_dispatchset_t *dset, isc_task_t *task)
 Cancel socket operations for the dispatches in 'dset'.
void dns_dispatchset_destroy (dns_dispatchset_t **dsetp)
 Dereference all the dispatches in '*dsetp', free the dispatchset memory, and set *dsetp to NULL.
void dns_dispatch_setdscp (dns_dispatch_t *disp, isc_dscp_t dscp)
isc_dscp_t dns_dispatch_getdscp (dns_dispatch_t *disp)
 Set/get the DSCP value to be used when sending responses to clients, as defined in the "listen-on" or "listen-on-v6" statements.

Variables

 dns_qid_t


Detailed Description

Definition in file dispatch.c.


Define Documentation

#define MGR_SHUTTINGDOWN   0x00000001U

Definition at line 125 of file dispatch.c.

Referenced by dns_dispatchmgr_destroy().

#define MGR_IS_SHUTTINGDOWN (  )     (((l)->state & MGR_SHUTTINGDOWN) != 0)

Definition at line 126 of file dispatch.c.

Referenced by destroy_mgr_ok().

#define IS_PRIVATE (  )     (((d)->attributes & DNS_DISPATCHATTR_PRIVATE) != 0)

Definition at line 128 of file dispatch.c.

#define DNS_DISPATCH_POOLSOCKS   2048

Maximum number of dispatch sockets that can be pooled for reuse. The appropriate value may vary, but experiments have shown a busy caching server may need more than 1000 sockets concurrently opened. The maximum allowable number of dispatch sockets (per manager) will be set to the double of this value.

Definition at line 154 of file dispatch.c.

Referenced by deactivate_dispsocket(), and dns_dispatchmgr_setudp().

#define DNS_DISPATCH_SOCKSQUOTA   3072

Quota to control the number of dispatch sockets. If a dispatch has more than the quota of sockets, new queries will purge oldest ones, so that a massive number of outstanding queries won't prevent subsequent queries (especially if the older ones take longer time and result in timeout).

Definition at line 164 of file dispatch.c.

Referenced by dns_dispatch_addresponse3().

#define DNS_DISPATCH_PORTTABLESIZE   1024

Definition at line 193 of file dispatch.c.

Referenced by deref_portentry(), dispatch_createudp(), dispatch_free(), new_portentry(), and port_search().

#define INVALID_BUCKET   (0xffffdead)

Definition at line 196 of file dispatch.c.

#define MAX_INTERNAL_TASKS   64

Number of tasks for each dispatch that use separate sockets for different transactions. This must be a power of 2 as it will divide 32 bit numbers to get an uniformly random tasks selection. See get_dispsocket().

Definition at line 203 of file dispatch.c.

Referenced by dispatch_createudp().

#define QID_MAGIC   ISC_MAGIC('Q', 'i', 'd', ' ')

Definition at line 254 of file dispatch.c.

Referenced by qid_allocate().

#define VALID_QID (  )     ISC_MAGIC_VALID((e), QID_MAGIC)

Definition at line 255 of file dispatch.c.

Referenced by entry_search(), qid_destroy(), and socket_search().

#define RESPONSE_MAGIC   ISC_MAGIC('D', 'r', 's', 'p')

Definition at line 257 of file dispatch.c.

Referenced by dns_dispatch_addresponse3().

#define VALID_RESPONSE (  )     ISC_MAGIC_VALID((e), RESPONSE_MAGIC)

Definition at line 258 of file dispatch.c.

Referenced by dns_dispatch_getentrysocket(), dns_dispatch_removeresponse(), and request_log().

#define DISPSOCK_MAGIC   ISC_MAGIC('D', 's', 'o', 'c')

Definition at line 260 of file dispatch.c.

Referenced by get_dispsocket().

#define VALID_DISPSOCK (  )     ISC_MAGIC_VALID((e), DISPSOCK_MAGIC)

Definition at line 261 of file dispatch.c.

Referenced by udp_exrecv().

#define DISPATCH_MAGIC   ISC_MAGIC('D', 'i', 's', 'p')

Definition at line 263 of file dispatch.c.

Referenced by dispatch_allocate().

#define VALID_DISPATCH (  )     ISC_MAGIC_VALID((e), DISPATCH_MAGIC)

Definition at line 264 of file dispatch.c.

Referenced by dispatch_free(), dns_dispatch_addresponse(), dns_dispatch_addresponse3(), dns_dispatch_attach(), dns_dispatch_cancel(), dns_dispatch_changeattributes(), dns_dispatch_detach(), dns_dispatch_getattributes(), dns_dispatch_getdscp(), dns_dispatch_getlocaladdress(), dns_dispatch_getsocket(), dns_dispatch_importrecv(), dns_dispatch_removeresponse(), dns_dispatch_setdscp(), dns_dispatch_starttcp(), dns_dispatchset_create(), tcp_recv(), and udp_shrecv().

#define DNS_DISPATCHMGR_MAGIC   ISC_MAGIC('D', 'M', 'g', 'r')

Definition at line 266 of file dispatch.c.

Referenced by dns_dispatchmgr_create().

#define VALID_DISPATCHMGR (  )     ISC_MAGIC_VALID((e), DNS_DISPATCHMGR_MAGIC)

Definition at line 267 of file dispatch.c.

Referenced by dispatch_allocate(), dispatch_free(), dns_dispatch_createtcp2(), dns_dispatch_gettcp(), dns_dispatch_gettcp2(), dns_dispatch_getudp_dup(), dns_dispatch_removeresponse(), dns_dispatchmgr_destroy(), dns_dispatchmgr_getblackhole(), dns_dispatchmgr_getblackportlist(), dns_dispatchmgr_setavailports(), dns_dispatchmgr_setblackhole(), dns_dispatchmgr_setblackportlist(), dns_dispatchmgr_setstats(), dns_dispatchmgr_setudp(), and qid_allocate().

#define DNS_QID ( disp   ) 

Value:

((disp)->socktype == isc_sockettype_tcp) ? \
                       (disp)->qid : (disp)->mgr->qid

Definition at line 269 of file dispatch.c.

Referenced by deactivate_dispsocket(), deref_portentry(), destroy_dispsocket(), dns_dispatch_addresponse3(), dns_dispatch_removeresponse(), do_cancel(), get_dispsocket(), and new_portentry().

#define DISP_RNGCTX ( disp   ) 

Value:

((disp)->socktype == isc_sockettype_udp) ? \
                        ((disp)->rngctx) : ((disp)->mgr->rngctx)

Definition at line 271 of file dispatch.c.

Referenced by dns_dispatch_addresponse3(), get_dispsocket(), and get_udpsocket().

#define PORTBUFLOCK ( mgr   )     if ((mgr)->qid != NULL) LOCK(&((mgr)->qid->lock))

Locking a query port buffer is a bit tricky. We access the buffer without locking until qid is created. Technically, there is a possibility of race between the creation of qid and access to the port buffer; in practice, however, this should be safe because qid isn't created until the first dispatch is created and there should be no contending situation until then.

Definition at line 281 of file dispatch.c.

Referenced by dns_dispatchmgr_setavailports(), and portavailable().

#define PORTBUFUNLOCK ( mgr   )     if ((mgr)->qid != NULL) UNLOCK((&(mgr)->qid->lock))

Definition at line 282 of file dispatch.c.

Referenced by dns_dispatchmgr_setavailports(), and portavailable().

#define LVL (  )     ISC_LOG_DEBUG(x)

Definition at line 335 of file dispatch.c.

Referenced by destroy_disp(), destroy_mgr_ok(), dispatch_createudp(), dns_dispatch_addresponse3(), dns_dispatch_createtcp2(), dns_dispatch_detach(), dns_dispatch_removeresponse(), dns_dispatch_starttcp(), dns_dispatchmgr_destroy(), do_cancel(), tcp_recv(), and udp_recv().

#define ATTRMATCH ( _a1,
_a2,
_mask   )     (((_a1) & (_mask)) == ((_a2) & (_mask)))

Definition at line 2198 of file dispatch.c.

Referenced by dispatch_find(), dns_dispatch_gettcp(), and dns_dispatch_gettcp2().

#define DNS_DISPATCH_HELD   20U

Definition at line 2861 of file dispatch.c.

Referenced by get_udpsocket().


Function Documentation

typedef ISC_LIST ( dns_dispentry_t   ) 

< hash table size

< id increment on collision

< the table itself

< socket table

Definition at line 50 of file dispatch.c.

static dns_dispentry_t * entry_search ( dns_qid_t qid,
isc_sockaddr_t dest,
dns_messageid_t  id,
in_port_t  port,
unsigned int  bucket 
) [static]

Definition at line 879 of file dispatch.c.

References dns_dispentry::host, dns_dispentry::id, ISC_LIST_HEAD, ISC_LIST_NEXT, isc_sockaddr_equal(), dns_dispentry::port, REQUIRE, and VALID_QID.

Referenced by dns_dispatch_addresponse3(), tcp_recv(), and udp_recv().

static isc_boolean_t destroy_disp_ok ( dns_dispatch_t disp  )  [static]

Definition at line 492 of file dispatch.c.

References ISC_FALSE, ISC_LIST_EMPTY, and ISC_TRUE.

Referenced by dns_dispatch_detach(), dns_dispatch_removeresponse(), tcp_recv(), and udp_recv().

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

Definition at line 516 of file dispatch.c.

References destroy_dispsocket(), destroy_mgr(), destroy_mgr_ok(), dispatch_free(), dispatch_log(), DNS_EVENT_DISPATCHCONTROL, INSIST, isc_event_free(), ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_mempool_destroy(), isc_mutex_destroy, isc_socket_detach(), isc_task_detach(), dns_dispatchmgr::lock, LOCK, LVL, dns_dispatch::mgr, dns_dispatch::ntasks, dns_dispatch::sepool, dns_dispatch::sepool_lock, dns_dispatch::socket, dns_dispatch::task, UNLOCK, and UNUSED.

Referenced by dispatch_createudp(), and dns_dispatch_createtcp2().

static void destroy_dispsocket ( dns_dispatch_t disp,
dispsocket_t **  dispsockp 
) [static]

Destroy a dedicated dispatch socket.

Definition at line 795 of file dispatch.c.

References deref_portentry(), DNS_QID, dns_qid_t, ISC_LINK_LINKED, ISC_LIST_UNLINK, isc_mempool_put, isc_socket_detach(), isc_task_detach(), LOCK, dns_dispatch::magic, dns_dispatch::mgr, REQUIRE, and UNLOCK.

Referenced by deactivate_dispsocket(), destroy_disp(), dns_dispatch_addresponse3(), and get_dispsocket().

static void deactivate_dispsocket ( dns_dispatch_t disp,
dispsocket_t *  dispsock 
) [static]

Deactivate a dedicated dispatch socket. Move it to the inactive list for future reuse unless the total number of sockets are exceeding the maximum.

Definition at line 832 of file dispatch.c.

References deref_portentry(), destroy_dispsocket(), DNS_DISPATCH_POOLSOCKS, DNS_QID, dns_qid_t, INSIST, ISC_LIST_APPEND, ISC_LIST_UNLINK, ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, isc_socket_close(), LOCK, and UNLOCK.

Referenced by udp_recv().

static void udp_exrecv ( isc_task_t task,
isc_event_t ev 
) [static]

Definition at line 1007 of file dispatch.c.

References REQUIRE, udp_recv(), UNUSED, and VALID_DISPSOCK.

Referenced by startrecv().

static void udp_shrecv ( isc_task_t task,
isc_event_t ev 
) [static]

Definition at line 1017 of file dispatch.c.

References REQUIRE, udp_recv(), UNUSED, and VALID_DISPATCH.

Referenced by dns_dispatch_importrecv(), and startrecv().

static void udp_recv ( isc_event_t ev_in,
dns_dispatch_t disp,
dispsocket_t *  dispsock 
) [static]

Definition at line 1041 of file dispatch.c.

References dns_dispentry::action, dns_dispatchevent::addr, isc_socketevent::address, allocate_devent(), dns_dispentry::arg, isc_socketevent::attributes, dns_dispatchevent::attributes, isc_buffer::base, isc_region::base, dns_dispatchmgr::blackhole, dns_dispatchevent::buffer, dns_dispatch::ctlevent, deactivate_dispsocket(), destroy_disp_ok(), dns_dispentry::disp, dispatch_log(), dns_acl_match(), DNS_DISPATCHATTR_EXCLUSIVE, DNS_EVENT_DISPATCH, dns_hash(), dns_lctx, dns_message_peekheader(), DNS_MESSAGEFLAG_QR, dns_qid_t, dns_resstatscounter_mismatch, entry_search(), free_buffer(), dns_dispentry::host, dns_dispatchevent::id, dns_dispentry::id, inc_stats(), INSIST, isc_buffer_add, isc_buffer_init, isc_event_free(), ISC_EVENT_INIT, ISC_EVENT_PTR, ISC_FALSE, ISC_LIST_APPEND, ISC_LOG_ERROR, isc_log_wouldlog(), isc_netaddr_format(), ISC_NETADDR_FORMATSIZE, isc_netaddr_fromsockaddr(), ISC_R_CANCELED, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_anyofpf(), isc_sockaddr_eqaddr(), isc_sockaddr_equal(), isc_sockaddr_getport(), isc_sockaddr_pf(), ISC_SOCKEVENT_RECVDONE, isc_task_send(), ISC_TRUE, dns_dispentry::item_out, isc_buffer::length, isc_region::length, dns_dispatch::local, dns_dispatch::localport, LOCK, LVL, match(), dns_dispatch::mgr, isc_socketevent::n, PF_INET6, isc_socketevent::pktinfo, dns_dispatchevent::pktinfo, isc_socketevent::region, request_log(), dns_dispatchevent::result, isc_socketevent::result, startrecv(), dns_dispentry::task, dns_dispatch::task, and UNLOCK.

Referenced by udp_exrecv(), and udp_shrecv().

static void tcp_recv ( isc_task_t task,
isc_event_t ev_in 
) [static]

Definition at line 1332 of file dispatch.c.

References dns_dispentry::action, dns_dispatchevent::addr, dns_tcpmsg::address, allocate_devent(), dns_dispentry::arg, isc_buffer::base, dns_dispatchevent::buffer, dns_tcpmsg::buffer, dns_dispatch::ctlevent, destroy_disp_ok(), dispatch_log(), DNS_EVENT_DISPATCH, dns_hash(), dns_message_peekheader(), DNS_MESSAGEFLAG_QR, dns_qid_t, dns_tcpmsg_keepbuffer(), do_cancel(), entry_search(), dns_dispatchevent::id, INSIST, isc_event_free(), ISC_EVENT_INIT, ISC_EVENT_PTR, ISC_LIST_APPEND, ISC_LOG_ERROR, ISC_LOG_INFO, ISC_R_CANCELED, ISC_R_CONNECTIONRESET, ISC_R_EOF, ISC_R_SUCCESS, isc_result_totext(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_task_send(), ISC_TRUE, dns_dispentry::item_out, isc_buffer::length, dns_dispatch::localport, LOCK, LVL, request_log(), REQUIRE, dns_dispatchevent::result, dns_tcpmsg::result, startrecv(), dns_dispentry::task, dns_dispatch::task, UNLOCK, UNUSED, and VALID_DISPATCH.

Referenced by startrecv().

static isc_result_t startrecv ( dns_dispatch_t disp,
dispsocket_t *  dispsock 
) [static]

Definition at line 1503 of file dispatch.c.

References allocate_sevent(), allocate_udp_buffer(), isc_region::base, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_NOLISTEN, dns_tcpmsg_readmessage(), do_cancel(), free_buffer(), INSIST, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_socket_recv2(), isc_sockettype_tcp, isc_sockettype_udp, ISC_SOCKEVENT_RECVDONE, isc_region::length, dns_dispatch::mgr, sock, dns_dispatch::socket, dns_dispatch::task, tcp_recv(), udp_exrecv(), and udp_shrecv().

Referenced by dns_dispatch_addresponse3(), dns_dispatch_changeattributes(), dns_dispatch_removeresponse(), dns_dispatch_starttcp(), tcp_recv(), and udp_recv().

static isc_uint32_t dns_hash ( dns_qid_t qid,
isc_sockaddr_t dest,
dns_messageid_t  id,
in_port_t  port 
) [static]

Definition at line 429 of file dispatch.c.

References INSIST, isc_sockaddr_hash(), and ISC_TRUE.

Referenced by dns_dispatch_addresponse3(), get_dispsocket(), tcp_recv(), and udp_recv().

static void free_buffer ( dns_dispatch_t disp,
void *  buf,
unsigned int  len 
) [static]

Definition at line 901 of file dispatch.c.

References INSIST, isc_mem_put, isc_mempool_put, isc_sockettype_tcp, isc_sockettype_udp, LOCK, dns_dispatchmgr::mctx, dns_dispatch::mgr, and UNLOCK.

Referenced by dns_dispatch_removeresponse(), startrecv(), and udp_recv().

static void * allocate_udp_buffer ( dns_dispatch_t disp  )  [static]

Definition at line 928 of file dispatch.c.

References isc_mempool_get, LOCK, dns_dispatch::mgr, and UNLOCK.

Referenced by dns_dispatch_importrecv(), and startrecv().

static void free_devent ( dns_dispatch_t disp,
dns_dispatchevent_t ev 
) [inline, static]

Definition at line 982 of file dispatch.c.

References INSIST, isc_mempool_put, and dns_dispatch::mgr.

Referenced by dns_dispatch_removeresponse().

static dns_dispatchevent_t * allocate_devent ( dns_dispatch_t disp  )  [inline, static]

Definition at line 994 of file dispatch.c.

References ISC_EVENT_INIT, isc_mempool_get, and dns_dispatch::mgr.

Referenced by dispatch_allocate(), dns_dispatch_addresponse3(), tcp_recv(), and udp_recv().

static void do_cancel ( dns_dispatch_t disp  )  [static]

Definition at line 3539 of file dispatch.c.

References dns_dispentry::action, dns_dispentry::arg, isc_buffer::base, dns_dispatchevent::buffer, DNS_EVENT_DISPATCH, DNS_QID, dns_qid_t, ISC_EVENT_INIT, ISC_EVENT_PTR, isc_task_send(), ISC_TRUE, dns_dispentry::item_out, isc_buffer::length, linear_first(), linear_next(), LOCK, LVL, request_log(), dns_dispatchevent::result, dns_dispentry::task, and UNLOCK.

Referenced by dns_dispatch_cancel(), dns_dispatch_removeresponse(), new_request(), startrecv(), and tcp_recv().

static dns_dispentry_t * linear_first ( dns_qid_t disp  )  [static]

Definition at line 447 of file dispatch.c.

References ISC_LIST_HEAD.

Referenced by do_cancel().

static dns_dispentry_t * linear_next ( dns_qid_t disp,
dns_dispentry_t resp 
) [static]

Definition at line 468 of file dispatch.c.

References dns_dispentry::bucket, ISC_LIST_HEAD, and ISC_LIST_NEXT.

Referenced by do_cancel().

static void dispatch_free ( dns_dispatch_t **  dispp  )  [static]

Definition at line 2453 of file dispatch.c.

References DESTROYLOCK, DNS_DISPATCH_PORTTABLESIZE, dns_tcpmsg_invalidate(), INSIST, ISC_LIST_EMPTY, isc_mem_put, isc_mempool_destroy(), isc_mempool_put, isc_rng_detach(), dns_dispatch::magic, dns_dispatchmgr::mctx, dns_dispatch::mgr, qid_destroy(), REQUIRE, VALID_DISPATCH, and VALID_DISPATCHMGR.

Referenced by destroy_disp(), dispatch_createudp(), and dns_dispatch_createtcp2().

static isc_result_t get_udpsocket ( dns_dispatchmgr_t mgr,
dns_dispatch_t disp,
isc_socketmgr_t sockmgr,
isc_sockaddr_t localaddr,
isc_socket_t **  sockp,
isc_socket_t dup_socket 
) [static]

Definition at line 2865 of file dispatch.c.

References DISP_RNGCTX, DNS_DISPATCH_HELD, INSIST, ISC_LOG_ERROR, ISC_R_ADDRINUSE, ISC_R_ADDRNOTAVAIL, ISC_R_FAILURE, ISC_R_NOPERM, ISC_R_SUCCESS, isc_rng_uniformrandom(), isc_sockaddr_getport(), isc_sockaddr_pf(), isc_sockaddr_setport(), isc_socket_detach(), ISC_SOCKET_REUSEADDRESS, ISC_TF, dns_dispatch::localport, dns_dispatch::mgr, mgr_log(), open_socket(), portavailable(), and sock.

Referenced by dispatch_createudp().

static isc_result_t dispatch_createudp ( dns_dispatchmgr_t mgr,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
unsigned int  maxrequests,
unsigned int  attributes,
dns_dispatch_t **  dispp,
isc_socket_t dup_socket 
) [static]

Definition at line 2971 of file dispatch.c.

References dns_dispatch::ctlevent, destroy_disp(), dispatch_allocate(), dispatch_free(), dispatch_log(), DNS_DISPATCH_PORTTABLESIZE, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_TCP, DNS_DISPATCHATTR_UDP, DNS_EVENT_DISPATCHCONTROL, dns_lctx, get_udpsocket(), isc_event_allocate(), isc_event_free(), ISC_LIST_APPEND, ISC_LIST_INIT, isc_log_wouldlog(), isc_mem_get, isc_mempool_associatelock(), isc_mempool_create(), isc_mempool_destroy(), isc_mempool_setfillcount(), isc_mempool_setfreemax(), isc_mempool_setmaxalloc(), isc_mempool_setname(), isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_sockaddr_anyofpf(), isc_sockaddr_eqaddr(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_sockaddr_pf(), isc_socket_detach(), isc_socket_getfd(), isc_sockettype_udp, isc_task_create(), isc_task_detach(), isc_task_setname(), isc_task_shutdown(), dns_dispatch::local, LVL, MAX_INTERNAL_TASKS, dns_dispatchmgr::mctx, mgr_log(), dns_dispatch::ntasks, open_socket(), dns_dispatch::sepool, dns_dispatch::sepool_lock, sock, dns_dispatch::socket, and dns_dispatch::task.

Referenced by dns_dispatch_getudp_dup(), and dns_dispatchset_create().

static isc_boolean_t destroy_mgr_ok ( dns_dispatchmgr_t mgr  )  [static]

Definition at line 1603 of file dispatch.c.

References ISC_FALSE, ISC_LIST_EMPTY, isc_mempool_getallocated(), ISC_TRUE, LVL, MGR_IS_SHUTTINGDOWN, and mgr_log().

Referenced by destroy_disp(), and dns_dispatchmgr_destroy().

static void destroy_mgr ( dns_dispatchmgr_t **  mgrp  )  [static]

Definition at line 1629 of file dispatch.c.

References dns_dispatchmgr::blackhole, DESTROYLOCK, dns_acl_detach(), dns_dispatchmgr::entropy, isc_entropy_detach(), isc_mem_detach(), isc_mem_put, isc_mempool_destroy(), isc_rng_detach(), isc_stats_detach(), dns_dispatchmgr::lock, dns_dispatchmgr::magic, dns_dispatchmgr::mctx, qid_destroy(), dns_dispatchmgr::state, and dns_dispatchmgr::stats.

Referenced by destroy_disp(), and dns_dispatchmgr_destroy().

static isc_result_t qid_allocate ( dns_dispatchmgr_t mgr,
unsigned int  buckets,
unsigned int  increment,
dns_qid_t **  qidp,
isc_boolean_t  needaddrtable 
) [static]

Definition at line 2289 of file dispatch.c.

References dns_qid_t, ISC_LIST_INIT, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_dispatchmgr::mctx, QID_MAGIC, REQUIRE, and VALID_DISPATCHMGR.

Referenced by dns_dispatch_createtcp2(), and dns_dispatchmgr_setudp().

static void qid_destroy ( isc_mem_t mctx,
dns_qid_t **  qidp 
) [static]

Definition at line 2351 of file dispatch.c.

References DESTROYLOCK, dns_qid_t, isc_mem_put, REQUIRE, and VALID_QID.

Referenced by destroy_mgr(), and dispatch_free().

static isc_result_t open_socket ( isc_socketmgr_t mgr,
isc_sockaddr_t local,
unsigned int  options,
isc_socket_t **  sockp,
isc_socket_t dup_socket 
) [static]

Definition at line 1687 of file dispatch.c.

References ISC_R_SUCCESS, isc_sockaddr_pf(), isc_socket_bind(), isc_socket_close(), isc_socket_create(), isc_socket_detach(), isc_socket_dup(), isc_socket_ipv6only(), isc_socket_open(), isc_socket_setname(), isc_sockettype_udp, ISC_TRUE, and sock.

Referenced by dispatch_createudp(), get_dispsocket(), and get_udpsocket().

static isc_boolean_t portavailable ( dns_dispatchmgr_t mgr,
isc_socket_t sock,
isc_sockaddr_t sockaddrp 
) [static]

Definition at line 2160 of file dispatch.c.

References ISC_FALSE, ISC_R_SUCCESS, isc_sockaddr_getport(), isc_sockaddr_pf(), isc_socket_getsockname(), ISC_TRUE, port_cmp(), PORTBUFLOCK, PORTBUFUNLOCK, and REQUIRE.

Referenced by get_udpsocket(), and local_addr_match().

static void static void mgr_log ( dns_dispatchmgr_t mgr,
int  level,
const char *  fmt,
  ... 
) [static]

Definition at line 342 of file dispatch.c.

References dns_lctx, DNS_LOGCATEGORY_DISPATCH, DNS_LOGMODULE_DISPATCH, isc_log_wouldlog(), and isc_log_write().

Referenced by destroy_mgr_ok(), dispatch_createudp(), dns_dispatch_createtcp2(), dns_dispatchmgr_destroy(), and get_udpsocket().

static void inc_stats ( dns_dispatchmgr_t mgr,
isc_statscounter_t  counter 
) [inline, static]

Definition at line 359 of file dispatch.c.

References isc_stats_increment(), and dns_dispatchmgr::stats.

static void dec_stats ( dns_dispatchmgr_t mgr,
isc_statscounter_t  counter 
) [inline, static]

Definition at line 365 of file dispatch.c.

References isc_stats_decrement(), and dns_dispatchmgr::stats.

static void static void dispatch_log ( dns_dispatch_t disp,
int  level,
const char *  fmt,
  ... 
) [static]

Definition at line 375 of file dispatch.c.

References dns_lctx, DNS_LOGCATEGORY_DISPATCH, DNS_LOGMODULE_DISPATCH, isc_log_wouldlog(), and isc_log_write().

Referenced by destroy_disp(), dispatch_createudp(), dns_dispatch_createtcp2(), dns_dispatch_detach(), dns_dispatch_starttcp(), get_dispsocket(), tcp_recv(), and udp_recv().

static void static void request_log ( dns_dispatch_t disp,
dns_dispentry_t resp,
int  level,
const char *  fmt,
  ... 
) [static]

Definition at line 397 of file dispatch.c.

References dns_lctx, DNS_LOGCATEGORY_DISPATCH, DNS_LOGMODULE_DISPATCH, isc_log_wouldlog(), isc_log_write(), isc_sockaddr_format(), and VALID_RESPONSE.

Referenced by dns_dispatch_addresponse3(), dns_dispatch_removeresponse(), do_cancel(), tcp_recv(), and udp_recv().

static dispportentry_t* port_search ( dns_dispatch_t disp,
in_port_t  port 
) [static]

Manipulate port table per dispatch: find an entry for a given port number, create a new entry, and decrement a given entry with possible clean-up.

Definition at line 565 of file dispatch.c.

References DNS_DISPATCH_PORTTABLESIZE, ISC_LIST_HEAD, ISC_LIST_NEXT, and REQUIRE.

Referenced by get_dispsocket().

static dispportentry_t* new_portentry ( dns_dispatch_t disp,
in_port_t  port 
) [static]

Definition at line 582 of file dispatch.c.

References DNS_DISPATCH_PORTTABLESIZE, DNS_QID, dns_qid_t, ISC_LINK_INIT, ISC_LIST_APPEND, isc_mempool_get, LOCK, REQUIRE, and UNLOCK.

Referenced by get_dispsocket().

static void deref_portentry ( dns_dispatch_t disp,
dispportentry_t **  portentryp 
) [static]

The caller must not hold the qid->lock.

Definition at line 608 of file dispatch.c.

References DNS_DISPATCH_PORTTABLESIZE, DNS_QID, dns_qid_t, ISC_LIST_UNLINK, isc_mempool_put, LOCK, REQUIRE, and UNLOCK.

Referenced by deactivate_dispsocket(), and destroy_dispsocket().

static dispsocket_t* socket_search ( dns_qid_t qid,
isc_sockaddr_t dest,
in_port_t  port,
unsigned int  bucket 
) [static]

Find a dispsocket for socket address 'dest', and port number 'port'. Return NULL if no such entry exists. Requires qid->lock to be held.

Definition at line 640 of file dispatch.c.

References ISC_LIST_HEAD, ISC_LIST_NEXT, isc_sockaddr_equal(), REQUIRE, and VALID_QID.

Referenced by get_dispsocket().

static isc_result_t get_dispsocket ( dns_dispatch_t disp,
isc_sockaddr_t dest,
isc_socketmgr_t sockmgr,
dispsocket_t **  dispsockp,
in_port_t *  portp 
) [static]

Make a new socket for a single dispatch with a random port number. The caller must hold the disp->lock.

Definition at line 666 of file dispatch.c.

References destroy_dispsocket(), DISP_RNGCTX, dispatch_log(), DISPSOCK_MAGIC, dns_hash(), DNS_QID, dns_qid_t, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_UNLINK, ISC_LOG_WARNING, isc_mempool_get, ISC_R_ADDRINUSE, ISC_R_ADDRNOTAVAIL, ISC_R_FAILURE, ISC_R_NOMEMORY, ISC_R_NOPERM, ISC_R_SUCCESS, isc_random_get(), isc_result_totext(), isc_rng_uniformrandom(), isc_sockaddr_format(), ISC_SOCKADDR_FORMATSIZE, isc_sockaddr_pf(), isc_sockaddr_setport(), isc_socket_detach(), ISC_SOCKET_REUSEADDRESS, isc_task_attach(), dns_dispatch::local, LOCK, dns_dispatch::mgr, new_portentry(), dns_dispatch::ntasks, open_socket(), port_search(), r, sock, dns_dispatch::socket, socket_search(), dns_dispatch::task, and UNLOCK.

Referenced by dns_dispatch_addresponse3().

static void free_sevent ( isc_event_t ev  )  [inline, static]

Definition at line 949 of file dispatch.c.

References isc_mempool_put.

Referenced by allocate_sevent().

static isc_socketevent_t* allocate_sevent ( dns_dispatch_t disp,
isc_socket_t sock,
isc_eventtype_t  type,
isc_taskaction_t  action,
const void *  arg 
) [inline, static]

Definition at line 956 of file dispatch.c.

References isc_socketevent::attributes, isc_region::base, isc_socketevent::bufferlist, DE_CONST, free_sevent(), ISC_EVENT_INIT, ISC_LINK_INIT, ISC_LIST_INIT, isc_mempool_get, ISC_R_UNSET, isc_socketevent::n, isc_socketevent::offset, isc_socketevent::region, isc_socketevent::result, and dns_dispatch::sepool.

Referenced by startrecv().

static isc_result_t create_default_portset ( isc_mem_t mctx,
isc_portset_t **  portsetp 
) [static]

Create a temporary port list to set the initial default set of dispatch ports: [1024, 65535]. This is almost meaningless as the application will normally set the ports explicitly, but is provided to fill some minor corner cases.

Definition at line 1740 of file dispatch.c.

References isc_portset_addrange(), isc_portset_create(), and ISC_R_SUCCESS.

Referenced by dns_dispatchmgr_create().

isc_result_t dns_dispatchmgr_create ( isc_mem_t mctx,
isc_entropy_t entropy,
dns_dispatchmgr_t **  mgrp 
)

Creates a new dispatchmgr object.

Requires:

Returns:

Definition at line 1756 of file dispatch.c.

References dns_dispatchmgr::blackhole, create_default_portset(), DESTROYLOCK, DNS_DISPATCHMGR_MAGIC, dns_dispatchmgr_setavailports(), dns_dispatchmgr::entropy, isc_entropy_attach(), ISC_LIST_INIT, isc_mem_attach(), isc_mem_detach(), isc_mem_get, isc_mem_put, isc_mempool_associatelock(), isc_mempool_create(), isc_mempool_destroy(), isc_mempool_setfillcount(), isc_mempool_setfreemax(), isc_mempool_setmaxalloc(), isc_mempool_setname(), isc_mutex_init, isc_portset_destroy(), ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_rng_create(), dns_dispatchmgr::lock, dns_dispatchmgr::magic, dns_dispatchmgr::mctx, REQUIRE, dns_dispatchmgr::state, and dns_dispatchmgr::stats.

Referenced by dns_client_createx2(), make_dispatchset(), run_server(), and setup_system().

void dns_dispatchmgr_setblackhole ( dns_dispatchmgr_t mgr,
dns_acl_t blackhole 
)

Sets the dispatcher's "blackhole list," a list of addresses that will be ignored by all dispatchers created by the dispatchmgr.

Requires:

Definition at line 1920 of file dispatch.c.

References dns_dispatchmgr::blackhole, dns_acl_attach(), dns_acl_detach(), REQUIRE, and VALID_DISPATCHMGR.

Referenced by load_configuration().

dns_acl_t* dns_dispatchmgr_getblackhole ( dns_dispatchmgr_t mgr  ) 

Gets a pointer to the dispatcher's current blackhole list, without incrementing its reference count.

Requires:

Definition at line 1928 of file dispatch.c.

References dns_dispatchmgr::blackhole, REQUIRE, and VALID_DISPATCHMGR.

Referenced by isblackholed(), and possibly_mark().

void dns_dispatchmgr_setblackportlist ( dns_dispatchmgr_t mgr,
dns_portlist_t portlist 
)

This function is deprecated. Use dns_dispatchmgr_setavailports() instead.

Requires:

Definition at line 1934 of file dispatch.c.

References REQUIRE, UNUSED, and VALID_DISPATCHMGR.

dns_portlist_t* dns_dispatchmgr_getblackportlist ( dns_dispatchmgr_t mgr  ) 

This function is deprecated and always returns NULL.

Requires:

Definition at line 1945 of file dispatch.c.

References REQUIRE, and VALID_DISPATCHMGR.

isc_result_t dns_dispatchmgr_setavailports ( dns_dispatchmgr_t mgr,
isc_portset_t v4portset,
isc_portset_t v6portset 
)

Sets a list of UDP ports that can be used for outgoing UDP messages.

Requires:

Definition at line 1951 of file dispatch.c.

References INSIST, isc_mem_get, isc_mem_put, isc_portset_isset(), isc_portset_nports(), ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_dispatchmgr::mctx, PORTBUFLOCK, PORTBUFUNLOCK, REQUIRE, and VALID_DISPATCHMGR.

Referenced by dns_dispatchmgr_create(), and load_configuration().

static isc_result_t dns_dispatchmgr_setudp ( dns_dispatchmgr_t mgr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment 
) [static]

Definition at line 2016 of file dispatch.c.

References cleanup(), DNS_DISPATCH_POOLSOCKS, isc_mempool_associatelock(), isc_mempool_create(), isc_mempool_destroy(), isc_mempool_setfillcount(), isc_mempool_setfreemax(), isc_mempool_setmaxalloc(), isc_mempool_setname(), ISC_R_SUCCESS, ISC_TRUE, LOCK, dns_dispatchmgr::mctx, qid_allocate(), REQUIRE, UNLOCK, and VALID_DISPATCHMGR.

Referenced by dns_dispatch_getudp_dup().

void dns_dispatchmgr_destroy ( dns_dispatchmgr_t **  mgrp  ) 

Destroys the dispatchmgr when it becomes empty. This could be immediately.

Requires:

Definition at line 2116 of file dispatch.c.

References destroy_mgr(), destroy_mgr_ok(), dns_dispatchmgr::lock, LOCK, LVL, mgr_log(), MGR_SHUTTINGDOWN, REQUIRE, dns_dispatchmgr::state, UNLOCK, and VALID_DISPATCHMGR.

Referenced by destroyclient(), dns_client_createx2(), doshutdown(), shutdown_server(), and teardown().

void dns_dispatchmgr_setstats ( dns_dispatchmgr_t mgr,
isc_stats_t stats 
)

Sets statistics counter for the dispatchmgr. This function is expected to be called only on zone creation (when necessary). Once installed, it cannot be removed or replaced. Also, there is no interface to get the installed stats from the zone; the caller must keep the stats to reference (e.g. dump) it later.

Requires:

Definition at line 2138 of file dispatch.c.

References ISC_LIST_EMPTY, isc_stats_attach(), REQUIRE, dns_dispatchmgr::stats, and VALID_DISPATCHMGR.

Referenced by run_server().

static int port_cmp ( const void *  key,
const void *  ent 
) [static]

Definition at line 2147 of file dispatch.c.

Referenced by portavailable().

static isc_boolean_t local_addr_match ( dns_dispatch_t disp,
isc_sockaddr_t addr 
) [static]

Definition at line 2201 of file dispatch.c.

References ISC_FALSE, ISC_R_SUCCESS, isc_sockaddr_eqaddr(), isc_sockaddr_equal(), isc_sockaddr_getport(), isc_socket_getsockname(), ISC_TRUE, dns_dispatch::local, dns_dispatch::mgr, portavailable(), REQUIRE, and dns_dispatch::socket.

Referenced by dispatch_find().

static isc_result_t dispatch_find ( dns_dispatchmgr_t mgr,
isc_sockaddr_t local,
unsigned int  attributes,
unsigned int  mask,
dns_dispatch_t **  dispp 
) [static]

Definition at line 2252 of file dispatch.c.

References ATTRMATCH, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_PRIVATE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOTFOUND, ISC_R_SUCCESS, local_addr_match(), LOCK, and UNLOCK.

Referenced by dns_dispatch_getudp_dup().

static isc_result_t dispatch_allocate ( dns_dispatchmgr_t mgr,
unsigned int  maxrequests,
dns_dispatch_t **  dispp 
) [static]

Definition at line 2375 of file dispatch.c.

References allocate_devent(), DESTROYLOCK, DISPATCH_MAGIC, dns_dispatch::dscp, ISC_LINK_INIT, ISC_LIST_INIT, isc_mempool_get, isc_mempool_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, ISC_R_UNEXPECTED, isc_rng_attach(), isc_rng_detach(), dns_dispatch::local, dns_dispatch::localport, dns_dispatch::magic, dns_dispatch::maxrequests, dns_dispatch::mgr, dns_dispatch::peer, REQUIRE, and VALID_DISPATCHMGR.

Referenced by dispatch_createudp(), and dns_dispatch_createtcp2().

isc_result_t dns_dispatch_createtcp ( dns_dispatchmgr_t mgr,
isc_socket_t sock,
isc_taskmgr_t taskmgr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
dns_dispatch_t **  dispp 
)

Definition at line 2503 of file dispatch.c.

References dns_dispatch_createtcp2(), and DNS_DISPATCHATTR_PRIVATE.

Referenced by resquery_connected().

isc_result_t dns_dispatch_createtcp2 ( dns_dispatchmgr_t mgr,
isc_socket_t sock,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
isc_sockaddr_t destaddr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
dns_dispatch_t **  dispp 
)

Create a new dns_dispatch and attach it to the provided isc_socket_t.

For all dispatches, "buffersize" is the maximum packet size we will accept.

"maxbuffers" and "maxrequests" control the number of buffers in the overall system and the number of buffers which can be allocated to requests.

"buckets" is the number of buckets to use, and should be prime.

"increment" is used in a collision avoidance function, and needs to be a prime > buckets, and not 2.

Requires:

Returns:

Definition at line 2519 of file dispatch.c.

References AF_INET6, dns_dispatch::ctlevent, destroy_disp(), dispatch_allocate(), dispatch_free(), dispatch_log(), DNS_DISPATCHATTR_PRIVATE, DNS_DISPATCHATTR_TCP, DNS_DISPATCHATTR_UDP, DNS_EVENT_DISPATCHCONTROL, dns_tcpmsg_init(), isc_event_allocate(), ISC_FALSE, ISC_LIST_APPEND, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_sockaddr_any(), isc_sockaddr_any6(), isc_sockaddr_pf(), isc_socket_attach(), isc_socket_detach(), isc_socket_gettype(), isc_sockettype_tcp, isc_task_create(), isc_task_detach(), isc_task_setname(), dns_dispatch::local, dns_dispatchmgr::lock, LOCK, LVL, dns_dispatchmgr::mctx, mgr_log(), dns_dispatch::ntasks, dns_dispatch::peer, qid_allocate(), REQUIRE, dns_dispatch::sepool, dns_dispatch::socket, dns_dispatch::task, UNLOCK, UNUSED, and VALID_DISPATCHMGR.

Referenced by create_tcp_dispatch(), and dns_dispatch_createtcp().

isc_result_t dns_dispatch_gettcp ( dns_dispatchmgr_t mgr,
isc_sockaddr_t destaddr,
isc_sockaddr_t localaddr,
dns_dispatch_t **  dispp 
)

Definition at line 2630 of file dispatch.c.

References ATTRMATCH, DNS_DISPATCHATTR_CONNECTED, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_PRIVATE, DNS_DISPATCHATTR_TCP, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_sockaddr_eqaddr(), isc_sockaddr_equal(), isc_socket_getpeername(), isc_socket_getsockname(), ISC_TRUE, dns_dispatch::local, dns_dispatchmgr::lock, LOCK, match(), REQUIRE, dns_dispatch::socket, UNLOCK, and VALID_DISPATCHMGR.

Referenced by create_tcp_dispatch().

isc_result_t dns_dispatch_gettcp2 ( dns_dispatchmgr_t mgr,
isc_sockaddr_t destaddr,
isc_sockaddr_t localaddr,
isc_boolean_t connected,
dns_dispatch_t **  dispp 
)

Definition at line 2679 of file dispatch.c.

References ATTRMATCH, DNS_DISPATCHATTR_CONNECTED, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_PRIVATE, DNS_DISPATCHATTR_TCP, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_sockaddr_eqaddr(), isc_sockaddr_equal(), isc_socket_getpeername(), isc_socket_getsockname(), ISC_TRUE, dns_dispatch::local, dns_dispatchmgr::lock, LOCK, match(), dns_dispatch::peer, REQUIRE, dns_dispatch::socket, UNLOCK, and VALID_DISPATCHMGR.

Referenced by create_tcp_dispatch().

isc_result_t dns_dispatch_getudp_dup ( dns_dispatchmgr_t mgr,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
unsigned int  mask,
dns_dispatch_t **  dispp,
dns_dispatch_t dup 
)

Attach to existing dns_dispatch_t if one is found with dns_dispatchmgr_find, otherwise create a new UDP dispatch.

Requires:

Returns:

Definition at line 2756 of file dispatch.c.

References dispatch_createudp(), dispatch_find(), DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_NOLISTEN, DNS_DISPATCHATTR_TCP, dns_dispatchmgr_setudp(), ISC_R_SUCCESS, isc_sockaddr_getport(), ISC_SOCKCANCEL_RECV, isc_socket_cancel(), dns_dispatchmgr::lock, LOCK, dns_dispatch::maxrequests, REQUIRE, dns_dispatch::socket, dns_dispatch::task, UNLOCK, and VALID_DISPATCHMGR.

Referenced by dns_dispatch_getudp(), and ns_interface_listenudp().

isc_result_t dns_dispatch_getudp ( dns_dispatchmgr_t mgr,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
isc_sockaddr_t localaddr,
unsigned int  buffersize,
unsigned int  maxbuffers,
unsigned int  maxrequests,
unsigned int  buckets,
unsigned int  increment,
unsigned int  attributes,
unsigned int  mask,
dns_dispatch_t **  dispp 
)

Definition at line 2842 of file dispatch.c.

References dns_dispatch_getudp_dup().

Referenced by fctx_query(), find_udp_dispatch(), get_view_querysource_dispatch(), getudpdispatch(), make_dispatchset(), ns_add_reserved_dispatch(), and setup_system().

void dns_dispatch_attach ( dns_dispatch_t disp,
dns_dispatch_t **  dispp 
)

Attach to a dispatch handle.

Requires:

Definition at line 3128 of file dispatch.c.

References LOCK, REQUIRE, UNLOCK, and VALID_DISPATCH.

Referenced by dns_dispatchset_create(), dns_requestmgr_create(), fctx_query(), find_udp_dispatch(), and get_client().

void dns_dispatch_detach ( dns_dispatch_t **  dispp  ) 

Detaches from the dispatch.

Requires:

Definition at line 3147 of file dispatch.c.

References dns_dispatch::ctlevent, destroy_disp_ok(), dispatch_log(), INSIST, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_SOCKCANCEL_RECV, isc_socket_cancel(), isc_task_send(), LOCK, LVL, REQUIRE, dns_dispatch::socket, dns_dispatch::task, UNLOCK, and VALID_DISPATCH.

Referenced by configure_view(), destroyclient(), dns_client_createx2(), dns_dispatchset_create(), dns_dispatchset_destroy(), dns_request_createraw4(), dns_request_createvia4(), doshutdown(), end_reserved_dispatches(), exit_check(), fctx_cancelquery(), fctx_query(), make_dispatchset(), mgr_destroy(), ns_interface_destroy(), ns_interface_listenudp(), req_cancel(), and req_destroy().

isc_result_t dns_dispatch_addresponse2 ( dns_dispatch_t disp,
isc_sockaddr_t dest,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
dns_messageid_t idp,
dns_dispentry_t **  resp,
isc_socketmgr_t sockmgr 
)

Definition at line 3183 of file dispatch.c.

References dns_dispatch_addresponse3().

Referenced by dns_request_createvia4(), and resquery_send().

isc_result_t dns_dispatch_addresponse3 ( dns_dispatch_t disp,
unsigned int  options,
isc_sockaddr_t dest,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
dns_messageid_t idp,
dns_dispentry_t **  resp,
isc_socketmgr_t sockmgr 
)

Definition at line 3193 of file dispatch.c.

References dns_dispentry::action, allocate_devent(), dns_dispentry::arg, isc_buffer::base, dns_dispentry::bucket, dns_dispatchevent::buffer, dec_stats(), destroy_dispsocket(), dns_dispentry::disp, DISP_RNGCTX, dns_dispentry::dispsocket, DNS_DISPATCH_SOCKSQUOTA, DNS_DISPATCHATTR_CONNECTED, DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_FIXEDID, DNS_DISPATCHATTR_UDP, DNS_DISPATCHOPT_FIXEDID, DNS_EVENT_DISPATCH, dns_hash(), DNS_QID, dns_qid_t, dns_resstatscounter_dispabort, dns_resstatscounter_dispreqtcp, dns_resstatscounter_disprequdp, dns_resstatscounter_dispsockfail, entry_search(), get_dispsocket(), dns_dispentry::host, dns_dispentry::id, dns_dispatchevent::id, inc_stats(), INSIST, ISC_EVENT_INIT, ISC_EVENT_PTR, ISC_FALSE, ISC_LINK_INIT, ISC_LIST_APPEND, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_UNLINK, isc_mempool_get, isc_mempool_put, ISC_R_CANCELED, ISC_R_NOMEMORY, ISC_R_NOMORE, ISC_R_QUOTA, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, isc_rng_random(), isc_task_attach(), isc_task_detach(), isc_task_send(), ISC_TRUE, dns_dispentry::item_out, dns_dispatch::localport, LOCK, LVL, dns_dispentry::magic, dns_dispatch::maxrequests, dns_dispatch::mgr, dns_dispentry::port, request_log(), REQUIRE, RESPONSE_MAGIC, dns_dispatchevent::result, startrecv(), dns_dispentry::task, UNLOCK, and VALID_DISPATCH.

Referenced by dns_dispatch_addresponse(), dns_dispatch_addresponse2(), and dns_request_createraw4().

isc_result_t dns_dispatch_addresponse ( dns_dispatch_t disp,
isc_sockaddr_t dest,
isc_task_t task,
isc_taskaction_t  action,
void *  arg,
dns_messageid_t idp,
dns_dispentry_t **  resp 
)

Definition at line 3392 of file dispatch.c.

References dns_dispatch_addresponse3(), DNS_DISPATCHATTR_EXCLUSIVE, REQUIRE, and VALID_DISPATCH.

void dns_dispatch_starttcp ( dns_dispatch_t disp  ) 

Start processing of a TCP dispatch once the socket connects.

Requires:

Definition at line 3404 of file dispatch.c.

References dispatch_log(), DNS_DISPATCHATTR_CONNECTED, LOCK, LVL, REQUIRE, startrecv(), dns_dispatch::task, UNLOCK, and VALID_DISPATCH.

Referenced by req_connected().

void dns_dispatch_removeresponse ( dns_dispentry_t **  resp,
dns_dispatchevent_t **  sockevent 
)

Stops the flow of responses for the provided id and destination. If "sockevent" is non-NULL, the dispatch event and associated buffer is also returned to the system.

Requires:

Definition at line 3419 of file dispatch.c.

References isc_buffer::base, dns_dispentry::bucket, dns_dispatchevent::buffer, dns_dispatch::ctlevent, dec_stats(), destroy_disp_ok(), dns_dispentry::disp, dns_dispentry::dispsocket, DNS_EVENT_DISPATCH, DNS_QID, dns_qid_t, dns_resstatscounter_dispreqtcp, dns_resstatscounter_disprequdp, do_cancel(), free_buffer(), free_devent(), INSIST, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_INIT, ISC_LIST_NEXT, ISC_LIST_UNLINK, isc_mempool_put, ISC_SOCKCANCEL_RECV, isc_socket_cancel(), isc_task_detach(), isc_task_send(), isc_task_unsend(), ISC_TRUE, dns_dispentry::item_out, isc_buffer::length, LOCK, LVL, dns_dispentry::magic, dns_dispatch::mgr, request_log(), REQUIRE, dns_dispatch::socket, startrecv(), dns_dispentry::task, dns_dispatch::task, UNLOCK, VALID_DISPATCH, VALID_DISPATCHMGR, and VALID_RESPONSE.

Referenced by dns_request_createvia4(), fctx_cancelquery(), req_cancel(), req_destroy(), req_response(), and resquery_send().

isc_socket_t* dns_dispatch_getsocket ( dns_dispatch_t disp  ) 

Return the socket associated with this dispatcher.

Requires:

Returns:

Definition at line 3585 of file dispatch.c.

References REQUIRE, dns_dispatch::socket, and VALID_DISPATCH.

Referenced by dns_dispatchset_cancelall(), fctx_cancelquery(), get_client(), req_cancel(), req_getsocket(), and resquery_send().

isc_socket_t* dns_dispatch_getentrysocket ( dns_dispentry_t resp  ) 

Definition at line 3592 of file dispatch.c.

References dns_dispentry::dispsocket, REQUIRE, and VALID_RESPONSE.

Referenced by fctx_cancelquery(), req_cancel(), req_getsocket(), and resquery_send().

isc_result_t dns_dispatch_getlocaladdress ( dns_dispatch_t disp,
isc_sockaddr_t addrp 
)

Return the local address for this dispatch. This currently only works for dispatches using UDP sockets.

Requires:

Returns:

Definition at line 3602 of file dispatch.c.

References ISC_R_NOTIMPLEMENTED, ISC_R_SUCCESS, isc_sockettype_udp, dns_dispatch::local, REQUIRE, and VALID_DISPATCH.

Referenced by adjust_interfaces(), and fctx_query().

void dns_dispatch_cancel ( dns_dispatch_t disp  ) 

cancel outstanding clients

Requires:

Definition at line 3615 of file dispatch.c.

References do_cancel(), ISC_R_CANCELED, LOCK, REQUIRE, UNLOCK, and VALID_DISPATCH.

unsigned int dns_dispatch_getattributes ( dns_dispatch_t disp  ) 

Return the attributes (DNS_DISPATCHATTR_xxx) of this dispatch. Only the non-changeable attributes are expected to be referenced by the caller.

Requires:

Definition at line 3635 of file dispatch.c.

References REQUIRE, and VALID_DISPATCH.

Referenced by dns_requestmgr_create(), dns_resolver_create(), req_cancel(), and req_getsocket().

void dns_dispatch_changeattributes ( dns_dispatch_t disp,
unsigned int  attributes,
unsigned int  mask 
)

Set the bits described by "mask" to the corresponding values in "attributes".

That is:

        new = (old & ~mask) | (attributes & mask)

This function has a side effect when DNS_DISPATCHATTR_NOLISTEN changes. When the flag becomes off, the dispatch will start receiving on the corresponding socket. When the flag becomes on, receive events on the corresponding socket will be canceled.

Requires:

Definition at line 3646 of file dispatch.c.

References DNS_DISPATCHATTR_EXCLUSIVE, DNS_DISPATCHATTR_NOLISTEN, ISC_SOCKCANCEL_RECV, isc_socket_cancel(), LOCK, REQUIRE, dns_dispatch::socket, startrecv(), dns_dispatch::task, UNLOCK, and VALID_DISPATCH.

Referenced by ns_interface_destroy(), and ns_interface_listenudp().

void dns_dispatch_importrecv ( dns_dispatch_t disp,
isc_event_t event 
)

Inform the dispatcher of a socket receive. This is used for sockets shared between dispatchers and clients. If the dispatcher fails to copy or send the event, nothing happens.

Requires:

Definition at line 3683 of file dispatch.c.

References isc_socketevent::address, allocate_udp_buffer(), isc_socketevent::attributes, isc_region::base, DNS_DISPATCHATTR_NOLISTEN, DNS_EVENT_IMPORTRECVDONE, INSIST, isc_event_allocate(), isc_event_free(), ISC_EVENT_PTR, isc_task_send(), isc_region::length, dns_dispatchmgr::mctx, dns_dispatch::mgr, isc_socketevent::n, isc_socketevent::pktinfo, isc_socketevent::region, REQUIRE, isc_socketevent::result, dns_dispatch::task, isc_socketevent::timestamp, udp_shrecv(), and VALID_DISPATCH.

Referenced by client_request().

dns_dispatch_t* dns_dispatchset_get ( dns_dispatchset_t dset  ) 

Retrieve the next dispatch from dispatch set 'dset', and increment the round-robin counter.

Requires:

Definition at line 3720 of file dispatch.c.

References dns_dispatchset::cur, dns_dispatchset::dispatches, dns_dispatchset::lock, LOCK, dns_dispatchset::ndisp, and UNLOCK.

Referenced by ATF_TC_BODY(), dns_resolver_dispatchv4(), and dns_resolver_dispatchv6().

isc_result_t dns_dispatchset_create ( isc_mem_t mctx,
isc_socketmgr_t sockmgr,
isc_taskmgr_t taskmgr,
dns_dispatch_t source,
dns_dispatchset_t **  dsetp,
int  n 
)

Given a valid dispatch 'source', create a dispatch set containing 'n' UDP dispatches, with the remainder filled out by clones of the source.

Requires:

Definition at line 3738 of file dispatch.c.

References dns_dispatchset::cur, DESTROYLOCK, dispatch_createudp(), dns_dispatchset::dispatches, dns_dispatch_attach(), dns_dispatch_detach(), DNS_DISPATCHATTR_UDP, dset, isc_mem_attach(), isc_mem_detach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, dns_dispatch::local, dns_dispatchmgr::lock, LOCK, dns_dispatchset::lock, dns_dispatch::maxrequests, dns_dispatchset::mctx, dns_dispatch::mgr, dns_dispatchset::ndisp, REQUIRE, dns_dispatch::socket, UNLOCK, and VALID_DISPATCH.

Referenced by dns_resolver_create(), and make_dispatchset().

void dns_dispatchset_cancelall ( dns_dispatchset_t dset,
isc_task_t task 
)

Cancel socket operations for the dispatches in 'dset'.

Definition at line 3811 of file dispatch.c.

References dns_dispatchset::dispatches, dns_dispatch_getsocket(), ISC_SOCKCANCEL_ALL, isc_socket_cancel(), dns_dispatchset::ndisp, REQUIRE, and sock.

Referenced by dns_resolver_shutdown().

void dns_dispatchset_destroy ( dns_dispatchset_t **  dsetp  ) 

Dereference all the dispatches in '*dsetp', free the dispatchset memory, and set *dsetp to NULL.

Requires:

Definition at line 3824 of file dispatch.c.

References DESTROYLOCK, dns_dispatchset::dispatches, dns_dispatch_detach(), dset, isc_mem_put, isc_mem_putanddetach, dns_dispatchset::lock, dns_dispatchset::mctx, dns_dispatchset::ndisp, and REQUIRE.

Referenced by destroy(), dns_resolver_create(), and teardown().

void dns_dispatch_setdscp ( dns_dispatch_t disp,
isc_dscp_t  dscp 
)

Definition at line 3842 of file dispatch.c.

References dns_dispatch::dscp, REQUIRE, and VALID_DISPATCH.

isc_dscp_t dns_dispatch_getdscp ( dns_dispatch_t disp  ) 

Set/get the DSCP value to be used when sending responses to clients, as defined in the "listen-on" or "listen-on-v6" statements.

Requires:

Definition at line 3848 of file dispatch.c.

References dns_dispatch::dscp, REQUIRE, and VALID_DISPATCH.

Referenced by client_sendpkg().


Variable Documentation

dns_qid_t

Definition at line 65 of file dispatch.c.

Referenced by deactivate_dispsocket(), deref_portentry(), destroy_dispsocket(), dns_dispatch_addresponse3(), dns_dispatch_removeresponse(), do_cancel(), get_dispsocket(), new_portentry(), qid_allocate(), qid_destroy(), tcp_recv(), and udp_recv().


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