diff --git a/CHANGES b/CHANGES index a30a3ef9d7..6311612116 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1380. [func] 'rndc recursing' dump recursing queries to + 'recursing-file = "named.recursing";'. + 1379. [func] 'rndc stats' now reports tcp and recursion quota states. diff --git a/bin/named/client.c b/bin/named/client.c index 15b9445c22..dec027b08f 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.c,v 1.210 2002/05/24 06:22:30 marka Exp $ */ +/* $Id: client.c,v 1.211 2002/09/10 04:45:52 marka Exp $ */ #include @@ -2256,3 +2256,34 @@ ns_client_dumpmessage(ns_client_t *client, const char *reason) { if (buf != NULL) isc_mem_put(client->mctx, buf, len); } + +void +ns_client_dumprecursing(FILE *f, ns_clientmgr_t *manager) { + ns_client_t *client; + char namebuf[DNS_NAME_FORMATSIZE]; + char peerbuf[ISC_SOCKADDR_FORMATSIZE]; + const char *name; + const char *sep; + + REQUIRE(VALID_MANAGER(manager)); + + LOCK(&manager->lock); + client = ISC_LIST_HEAD(manager->recursing); + while (client != NULL) { + ns_client_name(client, peerbuf, sizeof(peerbuf)); + if (client->view != NULL && + strcmp(client->view->name, "_bind") != 0 && + strcmp(client->view->name, "_default") != 0) { + name = client->view->name; + sep = ": view "; + } else { + name = ""; + sep = ""; + } + dns_name_format(client->query.qname, namebuf, sizeof(namebuf)); + fprintf(f, "; client %s%s%s: '%s' requesttime %d\n", + peerbuf, sep, name, namebuf, client->requesttime); + client = ISC_LIST_NEXT(client, link); + } + UNLOCK(&manager->lock); +} diff --git a/bin/named/config.c b/bin/named/config.c index f04a3737c3..53daa9465f 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.c,v 1.31 2002/08/01 03:23:36 mayer Exp $ */ +/* $Id: config.c,v 1.32 2002/09/10 04:45:52 marka Exp $ */ #include @@ -64,6 +64,7 @@ options {\n\ # named-xfer ;\n\ # pid-file \"" NS_LOCALSTATEDIR "/named.pid\"; /* or /lwresd.pid */\n\ port 53;\n\ + recursing-file \"named.recursing\";\n\ " #ifdef PATH_RANDOMDEV "\ diff --git a/bin/named/control.c b/bin/named/control.c index f864305daf..e92ac41c3b 100644 --- a/bin/named/control.c +++ b/bin/named/control.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: control.c,v 1.15 2002/09/10 02:23:43 marka Exp $ */ +/* $Id: control.c,v 1.16 2002/09/10 04:45:52 marka Exp $ */ #include @@ -121,6 +121,8 @@ ns_control_docommand(isccc_sexpr_t *message, isc_buffer_t *text) { result = ns_server_freeze(ns_g_server, ISC_TRUE, command); } else if (command_compare(command, NS_COMMAND_UNFREEZE)) { result = ns_server_freeze(ns_g_server, ISC_FALSE, command); + } else if (command_compare(command, NS_COMMAND_RECURSING)) { + result = ns_server_dumprecursing(ns_g_server); } else if (command_compare(command, NS_COMMAND_TIMERPOKE)) { result = ISC_R_SUCCESS; isc_timermgr_poke(ns_g_timermgr); diff --git a/bin/named/include/named/client.h b/bin/named/include/named/client.h index d096e4116a..13f963ac28 100644 --- a/bin/named/include/named/client.h +++ b/bin/named/include/named/client.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.h,v 1.66 2002/02/20 03:33:29 marka Exp $ */ +/* $Id: client.h,v 1.67 2002/09/10 04:45:54 marka Exp $ */ #ifndef NAMED_CLIENT_H #define NAMED_CLIENT_H 1 @@ -320,4 +320,10 @@ ns_client_recursing(ns_client_t *client, isc_boolean_t killoldest); * kill the oldest recursive client (list head). */ +void +ns_client_dumprecursing(FILE *f, ns_clientmgr_t *manager); +/* + * Dump the outstanding recursive queries to 'f'. + */ + #endif /* NAMED_CLIENT_H */ diff --git a/bin/named/include/named/control.h b/bin/named/include/named/control.h index 2cb6eb10b1..43b26125aa 100644 --- a/bin/named/include/named/control.h +++ b/bin/named/include/named/control.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: control.h,v 1.11 2002/09/08 18:34:04 explorer Exp $ */ +/* $Id: control.h,v 1.12 2002/09/10 04:45:54 marka Exp $ */ #ifndef NAMED_CONTROL_H #define NAMED_CONTROL_H 1 @@ -48,6 +48,7 @@ #define NS_COMMAND_FREEZE "freeze" #define NS_COMMAND_UNFREEZE "unfreeze" #define NS_COMMAND_TIMERPOKE "timerpoke" +#define NS_COMMAND_RECURSING "recursing" isc_result_t ns_controls_create(ns_server_t *server, ns_controls_t **ctrlsp); diff --git a/bin/named/include/named/interfacemgr.h b/bin/named/include/named/interfacemgr.h index 5ddb8f1303..995260908a 100644 --- a/bin/named/include/named/interfacemgr.h +++ b/bin/named/include/named/interfacemgr.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfacemgr.h,v 1.24 2002/08/30 02:05:30 marka Exp $ */ +/* $Id: interfacemgr.h,v 1.25 2002/09/10 04:45:54 marka Exp $ */ #ifndef NAMED_INTERFACEMGR_H #define NAMED_INTERFACEMGR_H 1 @@ -164,4 +164,7 @@ ns_interface_shutdown(ns_interface_t *ifp); * May safely be called multiple times. */ +void +ns_interfacemgr_dumprecursing(FILE *f, ns_interfacemgr_t *mgr); + #endif /* NAMED_INTERFACEMGR_H */ diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h index aa8d2a1326..b5906cc417 100644 --- a/bin/named/include/named/server.h +++ b/bin/named/include/named/server.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.h,v 1.69 2002/09/10 02:23:44 marka Exp $ */ +/* $Id: server.h,v 1.70 2002/09/10 04:45:54 marka Exp $ */ #ifndef NAMED_SERVER_H #define NAMED_SERVER_H 1 @@ -51,6 +51,7 @@ struct ns_server { dns_acl_t *blackholeacl; char * statsfile; /* Statistics file name */ char * dumpfile; /* Dump file name */ + char * recfile; /* Recursive file name */ isc_boolean_t version_set; /* User has set version */ char * version; /* User-specified version */ isc_boolean_t hostname_set; /* User has set hostname */ @@ -191,4 +192,10 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text); isc_result_t ns_server_freeze(ns_server_t *server, isc_boolean_t freeze, char *args); +/* + * Dump the current recursive queries. + */ +isc_result_t +ns_server_dumprecursing(ns_server_t *server); + #endif /* NAMED_SERVER_H */ diff --git a/bin/named/interfacemgr.c b/bin/named/interfacemgr.c index 1183fad5f0..d32d64984e 100644 --- a/bin/named/interfacemgr.c +++ b/bin/named/interfacemgr.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfacemgr.c,v 1.70 2002/08/30 02:05:29 marka Exp $ */ +/* $Id: interfacemgr.c,v 1.71 2002/09/10 04:45:52 marka Exp $ */ #include @@ -856,3 +856,17 @@ ns_interfacemgr_setlistenon6(ns_interfacemgr_t *mgr, ns_listenlist_t *value) { ns_listenlist_attach(value, &mgr->listenon6); UNLOCK(&mgr->lock); } + +void +ns_interfacemgr_dumprecursing(FILE *f, ns_interfacemgr_t *mgr) { + ns_interface_t *interface; + + LOCK(&mgr->lock); + interface = ISC_LIST_HEAD(mgr->interfaces); + while (interface != NULL) { + if (interface->clientmgr != NULL) + ns_client_dumprecursing(f, interface->clientmgr); + interface = ISC_LIST_NEXT(interface, link); + } + UNLOCK(&mgr->lock); +} diff --git a/bin/named/server.c b/bin/named/server.c index 62908eac9d..186b3c4cdd 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.387 2002/09/10 02:23:44 marka Exp $ */ +/* $Id: server.c,v 1.388 2002/09/10 04:45:53 marka Exp $ */ #include @@ -2132,6 +2132,12 @@ load_configuration(const char *filename, ns_server_t *server, CHECKM(setstring(server, &server->dumpfile, cfg_obj_asstring(obj)), "strdup"); + obj = NULL; + result = ns_config_get(maps, "recursing-file", &obj); + INSIST(result == ISC_R_SUCCESS); + CHECKM(setstring(server, &server->recfile, cfg_obj_asstring(obj)), + "strdup"); + obj = NULL; result = ns_config_get(maps, "version", &obj); if (result == ISC_R_SUCCESS) { @@ -2453,6 +2459,10 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) { CHECKFATAL(server->dumpfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS, "isc_mem_strdup"); + server->recfile = isc_mem_strdup(server->mctx, "named.recursing"); + CHECKFATAL(server->recfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS, + "isc_mem_strdup"); + server->hostname_set = ISC_FALSE; server->hostname = NULL; server->version_set = ISC_FALSE; @@ -2483,6 +2493,7 @@ ns_server_destroy(ns_server_t **serverp) { isc_mem_free(server->mctx, server->statsfile); isc_mem_free(server->mctx, server->dumpfile); + isc_mem_free(server->mctx, server->recfile); if (server->version != NULL) isc_mem_free(server->mctx, server->version); @@ -3022,6 +3033,23 @@ ns_server_dumpdb(ns_server_t *server, char *args) { return (result); } +isc_result_t +ns_server_dumprecursing(ns_server_t *server) { + FILE *fp = NULL; + isc_result_t result; + + CHECKMF(isc_stdio_open(server->recfile, "w", &fp), + "could not open dump file", server->recfile); + fprintf(fp,";\n; Recursing Queries\n;\n"); + ns_interfacemgr_dumprecursing(fp, server->interfacemgr); + fprintf(fp, "; Dump complete\n"); + + cleanup: + if (fp != NULL) + result = isc_stdio_close(fp); + return (result); +} + isc_result_t ns_server_setdebuglevel(ns_server_t *server, char *args) { char *ptr; diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index df6db51c88..99c5f26b77 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: namedconf.c,v 1.8 2002/07/29 06:58:46 marka Exp $ */ +/* $Id: namedconf.c,v 1.9 2002/09/10 04:45:54 marka Exp $ */ #include @@ -493,6 +493,7 @@ options_clauses[] = { { "named-xfer", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE }, { "pid-file", &cfg_type_qstringornone, 0 }, { "port", &cfg_type_uint32, 0 }, + { "recursing-file", &cfg_type_qstring, 0 }, { "random-device", &cfg_type_qstring, 0 }, { "recursive-clients", &cfg_type_uint32, 0 }, { "serial-queries", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },