client.c revision 06430b1f6c10fed7aa079a02d1d24f2c366d952b
1d16cf8bb8596c3e4dc1123a5bdf360bf24a272bAutomatic Updater * Copyright (C) 1999, 2000 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence * Important note!
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * All client state changes, other than that from idle to listening, occur
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * as a result of events. This guarantees serialization and avoids the
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * need for locking.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * If a routine is ever created that allows someone other than the client's
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * task to change the client, then the client will have to be locked.
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington#define MTRACE(m) isc_log_write(ns_g_lctx, \
87983da955bf63128de85d180359bdc418516c3cDavid Lawrence#define CTRACE(m) ((void)(m))
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington#define MTRACE(m) ((void)(m))
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews#define TCP_CLIENT(c) (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington /* Unlocked. */
bfafdac0616107ff32389532e7040567cd84b8aaBrian Wellington /* Locked by lock. */
94b166ffa58ef0ff263563c0550d0b30eb9f7772David Lawrence * Client object states. Ordering is significant: higher-numbered
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * states are generally "more active", meaning that the client can
94b166ffa58ef0ff263563c0550d0b30eb9f7772David Lawrence * have more dynamically allocated data, outstanding events, etc.
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * In the list below, any such properties listed for state N
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * also apply to any state > N.
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * To force the client into a less active state, set client->newstate
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * to that state and call exit_check(). This will cause any
5fe21da364d4397c9a413fe689ce82dea36a7b29Mark Andrews * activities defined for higher-numbered states to be aborted.
7502c6600645f120434d84d0ce3df7c3585cfe43Mark Andrews * The client object no longer exists.
8b3fb4bded905d65153678f48a006eed5c13b27eAndreas Gustafsson * The client object exists and has a task and timer.
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * Its "query" struct and sendbuf are initialized.
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * It is on the client manager's list of inactive clients.
b326d7e3a3a50eb65dd06db007d2fddc62606bbfMark Andrews * It has a message and OPT, both in the reset state.
f7c21e46c4b5fdae516b91374c24a87671f83ea3Andreas Gustafsson * The client object is either a TCP or a UDP one, and
cf300e03de3df3ff422db922520bf07c686c86daMark Andrews * it is associated with a network interface. It is on the
cf300e03de3df3ff422db922520bf07c686c86daMark Andrews * client manager's list of active clients.
dfceef7e68b56f6970dd2e8eea9980ad16bcc653Brian Wellington * If it is a TCP client object, it has a TCP listener socket
9e560b59a722d06a62b5aed761e71fec72638a7cBrian Wellington * and an outstading TCP listen request.
5455f30a7532738d750252c00e649890c694ee30Brian Wellington * If it is a UDP client object, it is associated with a
60213f2815a7e6584a2285546d05633fa7b6f5b4Mark Andrews * dispatch and has an outstanding dispatch request.
d2ef84e07b67e72a4bd9c729c6b8228067d17584Mark Andrews * The client object is a TCP client object that has received
94b166ffa58ef0ff263563c0550d0b30eb9f7772David Lawrence * a connection. It has a tcpsocket, tcpmsg, TCP quota, and an
94b166ffa58ef0ff263563c0550d0b30eb9f7772David Lawrence * outstanding TCP read request. This state is not used for
87983da955bf63128de85d180359bdc418516c3cDavid Lawrence * UDP client objects.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * The client object has received a request and is working
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * on it. It has a view, and it may have any of a non-reset OPT,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * recursion quota, and an outstanding write request. If it
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington * is a UDP client object, it has a dispatch event.
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews * Sentinel value used to indicate "no state". When client->newstate
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews * has this value, we are not attempting to exit the current state.
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews * Must be greater than any valid state.
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrewsstatic void clientmgr_destroy(ns_clientmgr_t *manager);
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrewsstatic isc_boolean_t exit_check(ns_client_t *client);
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrewsstatic void ns_client_endrequest(ns_client_t *client);
b493dfe8bce94b05efc0f161238d32f1234c5670Brian Wellingtonstatic void ns_client_checkactive(ns_client_t *client);
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington * Enter the inactive state.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * No requests are outstanding.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington dns_dispatch_removerequest(&client->dispentry, deventp);
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence ISC_LIST_UNLINK(client->manager->active, client, link);
e1d05d323526e7e65df13a6d3dfbec30f6ddb500Brian Wellington ISC_LIST_APPEND(client->manager->inactive, client, link);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews * Clean up a client object and free its memory.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * The client is in the inactive state.
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence isc_boolean_t need_clientmgr_destroy = ISC_FALSE;
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * When "shuttingdown" is true, either the task has received
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * its shutdown event or no shutdown event has ever been
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * set up. Thus, we have no outstanding shutdown
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * event at this point.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington REQUIRE(client->state == NS_CLIENTSTATE_INACTIVE);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington isc_mem_put(client->mctx, client->sendbuf, SEND_BUFFER_SIZE);
e4cd5a1e5d0358abeee7618b02b4592c055d957fBrian Wellington isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE);
e4cd5a1e5d0358abeee7618b02b4592c055d957fBrian Wellington INSIST(dns_rdataset_isassociated(client->opt));
e4cd5a1e5d0358abeee7618b02b4592c055d957fBrian Wellington dns_message_puttemprdataset(client->message, &client->opt);
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington ISC_LIST_UNLINK(*client->list, client, link);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews isc_mem_put(client->mctx, client, sizeof *client);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrewsset_timeout(ns_client_t *client, unsigned int seconds) {
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews result = isc_timer_reset(client->timer, isc_timertype_once, NULL,
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews "setting timouet: %s",
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews /* Continue anyway. */
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * Check for a deactivation or shutdown request and take appropriate
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * action. Returns ISC_TRUE if either is in progress; in this case
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * the caller must no longer use the client object as it may have been
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews INSIST(client->newstate < NS_CLIENTSTATE_WORKING);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * We need to detach from the view early when shutting down
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * the server to break the following vicious circle:
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * - The resolver will not shut down until the view refcount is zero
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * - The view refcount does not go to zero until all clients detach
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * - The client does not detach from the view until references is zero
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * - references does not go to zero until the resolver has shut down
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews if (client->newstate == NS_CLIENTSTATE_FREED && client->view != NULL)
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews INSIST(client->newstate <= NS_CLIENTSTATE_READING);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * We are trying to abort request processing.
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews if (! (client->nsends == 0 && client->references == 0)) {
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * Still waiting for I/O cancel completion.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * or lingering references.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * I/O cancel is complete. Burn down all state
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * related to the current request.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington if (NS_CLIENTSTATE_READING == client->newstate) {
420e5e1022ff5ca4697ed5286462eeaf03614e53Brian Wellington if (client->state == NS_CLIENTSTATE_READING) {
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington * We are trying to abort the current TCP connection,
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington INSIST(client->newstate <= NS_CLIENTSTATE_READY);
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington /* Still waiting for read cancel completion. */
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington (void) isc_timer_reset(client->timer, isc_timertype_inactive,
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * Now the client is ready to accept a new TCP connection
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * or UDP request, but we may have enough clients doing
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews * that already. Check whether this client needs to remain
71ca6e64b4d208a090d255eb64c24f945e615ea0Brian Wellington * active and force it to go inactive if not.
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington if (NS_CLIENTSTATE_READY == client->newstate) {
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington * Give the processed dispatch event back to
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews * the dispatch. This tells the dispatch
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews * that we are ready to receive the next event.
4423c99613db1399dbb5c51e86ef0d351a1418c2Mark Andrews INSIST(client->newstate <= NS_CLIENTSTATE_INACTIVE);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews * We are trying to enter the inactive state.
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews isc_socket_cancel(client->tcplistener, client->task,
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews /* Still waiting for accept cancel completion. */
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington /* Accept cancel is complete. */
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington if (client->state == NS_CLIENTSTATE_INACTIVE) {
bcdf37e0ff7d73310b7bf247d755194a5718ba38Mark Andrews INSIST(client->newstate == NS_CLIENTSTATE_FREED);
b6b9d8b8434e4eaab74b69cd14fcacf448055ca5Brian Wellington * We are trying to free the client.
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews * The client's task has received a shutdown event.
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsclient_shutdown(isc_task_t *task, isc_event_t *event) {
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews REQUIRE(event->ev_type == ISC_TASKEVENT_SHUTDOWN);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews (client->shutdown)(client->shutdown_arg, ISC_R_SHUTTINGDOWN);
0a77211c806fa84fd66638b5cccf550c7cd7760dAndreas Gustafsson INSIST(client->state == NS_CLIENTSTATE_WORKING);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews INSIST(dns_rdataset_isassociated(client->opt));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews dns_message_puttemprdataset(client->message, &client->opt);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson dns_message_reset(client->message, DNS_MESSAGE_INTENTPARSE);
1d16cf8bb8596c3e4dc1123a5bdf360bf24a272bAutomatic Updater isc_quota_detach(&client->recursionquota);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * This client object should normally go inactive
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * at this point, but if we have fewer active client
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * objects than desired due to earlier quota exhaustion,
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * keep it active to make up for the shortage.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * The UDP client quota is enforced by making
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * requests fail rather than by not listening
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * for new ones. Therefore, there is always a
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * full set of UDP clients listening.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * We don't need this client object. Recycle it.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews if (client->newstate >= NS_CLIENTSTATE_INACTIVE)
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrewsns_client_next(ns_client_t *client, isc_result_t result) {
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews REQUIRE(client->state == NS_CLIENTSTATE_WORKING);
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews "request failed: %s", isc_result_totext(result));
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * An error processing a TCP request may have left
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * the connection out of sync. To be safe, we always
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews * sever the connection when result != ISC_R_SUCCESS.
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews if (result == ISC_R_SUCCESS && TCP_CLIENT(client))
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrewsclient_senddone(isc_task_t *task, isc_event_t *event) {
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews isc_socketevent_t *sevent = (isc_socketevent_t *) event;
326bcfa0e2a6b924cb829a0bcc3bf9590ce21ad6Mark Andrews REQUIRE(sevent->ev_type == ISC_SOCKEVENT_SENDDONE);
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews "error sending response: %s",
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE);
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews unsigned char *data;
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews if ((client->attributes & NS_CLIENTATTR_RA) != 0)
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews * XXXRTH The following doesn't deal with TSIGs, TCP buffer resizing,
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews * or ENDS1 more data packets.
7389e8330d62a059b8923fb8ca6f933caeb559d9Mark Andrews * XXXRTH "tcpbuffer" is a hack to get things working.
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews client->tcpbuf = isc_mem_get(client->mctx, TCP_BUFFER_SIZE);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews isc_buffer_init(&tcpbuffer, data, TCP_BUFFER_SIZE);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews isc_buffer_init(&buffer, data + 2, TCP_BUFFER_SIZE - 2);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews result = dns_message_renderbegin(client->message, &buffer);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews result = dns_message_setopt(client->message, client->opt);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews * XXXRTH dns_message_setopt() should probably do this...
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews result = dns_message_rendersection(client->message,
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews result = dns_message_rendersection(client->message,
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result = dns_message_rendersection(client->message,
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington result = dns_message_rendersection(client->message,
30a4d5b0c23eb7a73d9635a98250560437a42d59David Lawrence if (result != ISC_R_SUCCESS && result != ISC_R_NOSPACE)
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington result = dns_message_renderend(client->message);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence isc_buffer_putuint16(&tcpbuffer, (isc_uint16_t) r.length);
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews socket = dns_dispatch_getsocket(client->dispatch);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson if ((client->attributes & NS_CLIENTATTR_PKTINFO) != 0)
fc8197c3ce31d81cd5e23703680572fac09a2e8aMark Andrews result = isc_socket_sendto(socket, &r, client->task, client_senddone,
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE);
73a691c373488e4f70387a62462cd8ce0d991705David Lawrencens_client_error(ns_client_t *client, isc_result_t result) {
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * message may be an in-progress reply that we had trouble
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * with, in which case QR will be set. We need to clear QR before
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence * calling dns_message_reply() to avoid triggering an assertion.
73a691c373488e4f70387a62462cd8ce0d991705David Lawrence * AA and AD shouldn't be set.
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence message->flags &= ~(DNS_MESSAGEFLAG_AA | DNS_MESSAGEFLAG_AD);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result = dns_message_reply(message, ISC_TRUE);
3db78e0855a8dfc162180880cd70d9c1a03d9301David Lawrence * It could be that we've got a query with a good header,
c4f9e613e12f03795bee18cf2ca8e6a9d39d6468Mark Andrews * but a bad question section, so we try again with
94b50bce2b5deeac93734457d5474736d7b76af1Michael Sawyer * want_question_section set to ISC_FALSE.
30a4d5b0c23eb7a73d9635a98250560437a42d59David Lawrence result = dns_message_reply(message, ISC_FALSE);
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews REQUIRE(client->opt == NULL); /* XXXRTH free old. */
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result = dns_message_gettemprdatalist(client->message, &rdatalist);
20bd7b4bbf2437ef2f9109edca168ab0ce8445b3David Lawrence result = dns_message_gettemprdata(client->message, &rdata);
72ddc4cef9c6a6de53aae530dea1ddbb90631131Mark Andrews result = dns_message_gettemprdataset(client->message, &rdataset);
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington * Set Maximum UDP buffer size.
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington * Set EXTENDED-RCODE, VERSION, and Z to 0.
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington * No ENDS options.
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson dns_rdatalist_tordataset(rdatalist, rdataset);
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson * Handle an incoming request event from the dispatch (UDP case)
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafsson * or tcpmsg (TCP case).
984ca288f1291c7b7bda9b3809a7af714e3ec82aAndreas Gustafssonclient_request(isc_task_t *task, isc_event_t *event) {
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson RWLOCK(&ns_g_server->conflock, isc_rwlocktype_read);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson dns_zonemgr_lockconf(ns_g_server->zonemgr, isc_rwlocktype_read);
71ca6e64b4d208a090d255eb64c24f945e615ea0Brian Wellington if (event->ev_type == DNS_EVENT_DISPATCH) {
71ca6e64b4d208a090d255eb64c24f945e615ea0Brian Wellington if ((devent->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0) {
71ca6e64b4d208a090d255eb64c24f945e615ea0Brian Wellington client->attributes |= NS_CLIENTATTR_PKTINFO;
71ca6e64b4d208a090d255eb64c24f945e615ea0Brian Wellington client->attributes &= ~NS_CLIENTATTR_PKTINFO;
d32b13e0be7f01020365c83a0bd36483ace4d7c3Mark Andrews if ((devent->attributes & ISC_SOCKEVENTATTR_MULTICAST) != 0)
8f66dad9393ae0724f758c4a51e06ff55c2d1219Brian Wellington client->attributes &= ~NS_CLIENTATTR_MULTICAST;
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington REQUIRE(event->ev_sender == &client->tcpmsg);
goto cleanup_serverlock;
goto cleanup_serverlock;
goto cleanup_serverlock;
goto cleanup_serverlock;
unsigned int version;
goto cleanup_serverlock;
if (version != 0) {
goto cleanup_serverlock;
int match;
match > 0))
goto cleanup_serverlock;
goto cleanup_viewlock;
case dns_opcode_query:
case dns_opcode_update:
case dns_opcode_notify:
case dns_opcode_iquery:
static isc_result_t
return (ISC_R_NOMEMORY);
goto cleanup_client;
goto cleanup_task;
goto cleanup_task;
goto cleanup_timer;
goto cleanup_message;
goto cleanup_sendbuf;
return (ISC_R_SUCCESS);
return (result);
goto fail;
fail:
goto freeevent;
return (result);
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
goto cleanup_manager;
return (ISC_R_SUCCESS);
return (result);
if (need_destroy)
REQUIRE(n > 0);
if (tcp) {
return (result);
int match;
if (default_allow)
goto allow;
goto deny;
if (match > 0)
goto allow;
return (ISC_R_SUCCESS);
deny:
return (DNS_R_REFUSED);