Add +fail option to try next server after a SERVFAIL

Fix some minor problems in some of the new option processing code.
Slight change in mem debugging
TODO changes
This commit is contained in:
Michael Sawyer
2000-09-25 23:10:00 +00:00
parent 4da10bce4b
commit 0dabedcca5
4 changed files with 51 additions and 9 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dig.c,v 1.101 2000/09/25 16:14:20 mws Exp $ */
/* $Id: dig.c,v 1.102 2000/09/25 23:09:56 mws Exp $ */
#include <config.h>
#include <stdlib.h>
@@ -160,6 +160,7 @@ show_usage(void) {
" +[no]recursive (Recursive mode)\n"
" +[no]ignore (Don't revert to TCP for TC responses.)"
"\n"
" +[no]fail (Try next server on SERVFAIL reply)\n"
" +[no]aaonly (Set AA flag in query)\n"
" +[no]adflag (Set AD flag in query)\n"
" +[no]cdflag (Set CD flag in query)\n"
@@ -596,7 +597,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
lookup->section_additional = state;
break;
case 'f': /* adflag */
lookup->adflag = ISC_FALSE;
lookup->adflag = state;
break;
default:
goto invalid_option;
@@ -670,6 +671,9 @@ plus_option(char *option, isc_boolean_t is_batchfile,
goto invalid_option;
}
break;
case 'f': /* fail */
lookup->next_on_fail = state;
break;
case 'i':
switch (tolower(cmd[1])) {
case 'd': /* identify */
@@ -799,9 +803,6 @@ plus_option(char *option, isc_boolean_t is_batchfile,
show_details = ISC_TRUE;
}
break;
case 'e': /* recurse */
lookup->recurse = ISC_TRUE;
break;
case 'i': /* tries */
if (value == NULL)
goto need_value;
@@ -814,9 +815,11 @@ plus_option(char *option, isc_boolean_t is_batchfile,
default:
goto invalid_option;
}
break;
default:
goto invalid_option;
}
break;
case 'v': /* vc */
if (!is_batchfile)
lookup->tcp_mode = state;
@@ -867,7 +870,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup)
exit(0);
break;
case 'm':
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
isc_mem_debugging = ISC_MEM_DEBUGTRACE | ISC_MEM_DEBUGRECORD;
return (ISC_FALSE);
break;
case 'n':
@@ -1270,6 +1273,8 @@ main(int argc, char **argv) {
(dig_server_t *)s2, link);
isc_mem_free(mctx, s2);
}
if (isc_mem_debugging != 0)
isc_mem_stats(mctx, stderr);
isc_mem_free(mctx, default_lookup);
if (batchname != NULL) {
if (batchfp != stdin)

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dighost.c,v 1.133 2000/09/22 23:21:32 mws Exp $ */
/* $Id: dighost.c,v 1.134 2000/09/25 23:09:57 mws Exp $ */
/*
* Notice to programmers: Do not use this code as an example of how to
@@ -296,6 +296,7 @@ make_empty_lookup(void) {
looknew->trace_root = ISC_FALSE;
looknew->identify = ISC_FALSE;
looknew->ignore = ISC_FALSE;
looknew->next_on_fail = ISC_FALSE;
looknew->udpsize = 0;
looknew->recurse = ISC_TRUE;
looknew->aaonly = ISC_FALSE;
@@ -347,6 +348,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
looknew->trace_root = lookold->trace_root;
looknew->identify = lookold->identify;
looknew->ignore = lookold->ignore;
looknew->next_on_fail = lookold->next_on_fail;
looknew->udpsize = lookold->udpsize;
looknew->recurse = lookold->recurse;
looknew->aaonly = lookold->aaonly;
@@ -2175,6 +2177,36 @@ recv_done(isc_task_t *task, isc_event_t *event) {
UNLOCK_LOOKUP;
return;
}
if ((msg->rcode == dns_rcode_servfail) &&
l->next_on_fail) {
dig_query_t *next = ISC_LIST_NEXT(query, link);
if (l->current_query == query)
l->current_query = NULL;
if (next != NULL) {
debug("sending query %lx\n", next);
if (l->tcp_mode)
send_tcp_connect(next);
else
send_udp(next);
}
/*
* If our query is at the head of the list and there
* is no next, we're the only one left, so fall
* through to print the message.
*/
if ((ISC_LIST_HEAD(l->q) != query) ||
(ISC_LIST_NEXT(query, link) != NULL)) {
printf(";; Got SERVFAIL reply from %s, "
"trying next server\n",
query->servname);
clear_query(query);
check_next_lookup(l);
dns_message_destroy(&msg);
isc_event_free(&event);
UNLOCK_LOOKUP;
return;
}
}
if (key != NULL) {
result = dns_tsig_verify(&query->recvbuf, msg,

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dig.h,v 1.48 2000/09/21 23:47:41 marka Exp $ */
/* $Id: dig.h,v 1.49 2000/09/25 23:09:59 mws Exp $ */
#ifndef DIG_H
#define DIG_H
@@ -94,6 +94,7 @@ struct dig_lookup {
section_answer,
section_authority,
section_additional,
next_on_fail,
new_search;
char textname[MXNAME]; /* Name we're going to be looking up */
dns_rdatatype_t rdtype;

View File

@@ -8,6 +8,10 @@ Examine dig8's behavior when one of the servers it talks to servfail's
back, and, if necessary, reproduce behavior in dig9. (RT351)
Remove or fix port number display in places where it is not correctly
reported (nslookup, in particular). (RT352)
reported (nslookup, in particular). (RT352) [COMPLETED]
Check text strings for host and nslookup output ov various types.
Check functionality of +search option