mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
[master] dig: retain domain when retrying with tcp
4712. [bug] "dig +domain" and "dig +search" didn't retain the search domain when retrying with TCP. [RT #45547]
This commit is contained in:
parent
3e66721b35
commit
8e014c45ae
3
CHANGES
3
CHANGES
@ -1,3 +1,6 @@
|
|||||||
|
4712. [bug] "dig +domain" and "dig +search" didn't retain the
|
||||||
|
search domain when retrying with TCP. [RT #45547]
|
||||||
|
|
||||||
4711. [test] Some RR types were missing from genzones.sh.
|
4711. [test] Some RR types were missing from genzones.sh.
|
||||||
[RT #45782]
|
[RT #45782]
|
||||||
|
|
||||||
|
@ -731,6 +731,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
|
|||||||
looknew->section_answer = lookold->section_answer;
|
looknew->section_answer = lookold->section_answer;
|
||||||
looknew->section_authority = lookold->section_authority;
|
looknew->section_authority = lookold->section_authority;
|
||||||
looknew->section_additional = lookold->section_additional;
|
looknew->section_additional = lookold->section_additional;
|
||||||
|
looknew->origin = lookold->origin;
|
||||||
looknew->retries = lookold->retries;
|
looknew->retries = lookold->retries;
|
||||||
looknew->tsigctx = NULL;
|
looknew->tsigctx = NULL;
|
||||||
looknew->need_search = lookold->need_search;
|
looknew->need_search = lookold->need_search;
|
||||||
@ -3631,7 +3632,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
newedns);
|
newedns);
|
||||||
l->edns = newedns;
|
l->edns = newedns;
|
||||||
n = requeue_lookup(l, ISC_TRUE);
|
n = requeue_lookup(l, ISC_TRUE);
|
||||||
n->origin = query->lookup->origin;
|
|
||||||
if (l->trace && l->trace_root)
|
if (l->trace && l->trace_root)
|
||||||
n->rdtype = l->qrdtype;
|
n->rdtype = l->qrdtype;
|
||||||
dns_message_destroy(&msg);
|
dns_message_destroy(&msg);
|
||||||
@ -3650,7 +3650,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
printf(";; Truncated, retrying in TCP mode.\n");
|
printf(";; Truncated, retrying in TCP mode.\n");
|
||||||
n = requeue_lookup(l, ISC_TRUE);
|
n = requeue_lookup(l, ISC_TRUE);
|
||||||
n->tcp_mode = ISC_TRUE;
|
n->tcp_mode = ISC_TRUE;
|
||||||
n->origin = query->lookup->origin;
|
|
||||||
if (l->trace && l->trace_root)
|
if (l->trace && l->trace_root)
|
||||||
n->rdtype = l->qrdtype;
|
n->rdtype = l->qrdtype;
|
||||||
dns_message_destroy(&msg);
|
dns_message_destroy(&msg);
|
||||||
@ -3672,7 +3671,6 @@ recv_done(isc_task_t *task, isc_event_t *event) {
|
|||||||
if (l->seenbadcookie)
|
if (l->seenbadcookie)
|
||||||
n->tcp_mode = ISC_TRUE;
|
n->tcp_mode = ISC_TRUE;
|
||||||
n->seenbadcookie = ISC_TRUE;
|
n->seenbadcookie = ISC_TRUE;
|
||||||
n->origin = query->lookup->origin;
|
|
||||||
if (l->trace && l->trace_root)
|
if (l->trace && l->trace_root)
|
||||||
n->rdtype = l->qrdtype;
|
n->rdtype = l->qrdtype;
|
||||||
dns_message_destroy(&msg);
|
dns_message_destroy(&msg);
|
||||||
|
@ -27,7 +27,12 @@
|
|||||||
#
|
#
|
||||||
# There can be any number of patterns, each associated
|
# There can be any number of patterns, each associated
|
||||||
# with any number of response RRs. Each pattern is a
|
# with any number of response RRs. Each pattern is a
|
||||||
# Perl regular expression.
|
# Perl regular expression. If an empty pattern ("//") is
|
||||||
|
# received, the server will ignore all incoming queries (TCP
|
||||||
|
# connections will still be accepted, but both UDP queries
|
||||||
|
# and TCP queries will not be responded to). If a non-empty
|
||||||
|
# pattern is then received over the same control connection,
|
||||||
|
# default behavior is restored.
|
||||||
#
|
#
|
||||||
# Each incoming query is converted into a string of the form
|
# Each incoming query is converted into a string of the form
|
||||||
# "qname qtype" (the printable query domain name, space,
|
# "qname qtype" (the printable query domain name, space,
|
||||||
@ -98,6 +103,9 @@ $SIG{TERM} = \&rmpid;
|
|||||||
|
|
||||||
#my @answers = ();
|
#my @answers = ();
|
||||||
my @rules;
|
my @rules;
|
||||||
|
my $udphandler;
|
||||||
|
my $tcphandler;
|
||||||
|
|
||||||
sub handleUDP {
|
sub handleUDP {
|
||||||
my ($buf) = @_;
|
my ($buf) = @_;
|
||||||
my $request;
|
my $request;
|
||||||
@ -448,8 +456,15 @@ for (;;) {
|
|||||||
while (my $line = $conn->getline) {
|
while (my $line = $conn->getline) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ($line =~ m!^/(.*)/$!) {
|
if ($line =~ m!^/(.*)/$!) {
|
||||||
$rule = { pattern => $1, answer => [] };
|
if (length($1) == 0) {
|
||||||
push(@rules, $rule);
|
$udphandler = sub { return; };
|
||||||
|
$tcphandler = sub { return; };
|
||||||
|
} else {
|
||||||
|
$udphandler = \&handleUDP;
|
||||||
|
$tcphandler = \&handleTCP;
|
||||||
|
$rule = { pattern => $1, answer => [] };
|
||||||
|
push(@rules, $rule);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
push(@{$rule->{answer}},
|
push(@{$rule->{answer}},
|
||||||
new Net::DNS::RR($line));
|
new Net::DNS::RR($line));
|
||||||
@ -464,9 +479,11 @@ for (;;) {
|
|||||||
printf "UDP request\n";
|
printf "UDP request\n";
|
||||||
my $buf;
|
my $buf;
|
||||||
$udpsock->recv($buf, 512);
|
$udpsock->recv($buf, 512);
|
||||||
my $result = handleUDP($buf);
|
my $result = &$udphandler($buf);
|
||||||
my $num_chars = $udpsock->send($result);
|
if (defined($result)) {
|
||||||
print " Sent $num_chars bytes via UDP\n";
|
my $num_chars = $udpsock->send($result);
|
||||||
|
print " Sent $num_chars bytes via UDP\n";
|
||||||
|
}
|
||||||
} elsif (vec($rout, fileno($tcpsock), 1)) {
|
} elsif (vec($rout, fileno($tcpsock), 1)) {
|
||||||
my $conn = $tcpsock->accept;
|
my $conn = $tcpsock->accept;
|
||||||
my $buf;
|
my $buf;
|
||||||
@ -478,12 +495,14 @@ for (;;) {
|
|||||||
$n = $conn->sysread($buf, $len);
|
$n = $conn->sysread($buf, $len);
|
||||||
last unless $n == $len;
|
last unless $n == $len;
|
||||||
print "TCP request\n";
|
print "TCP request\n";
|
||||||
my $result = handleTCP($buf);
|
my $result = &$tcphandler($buf);
|
||||||
foreach my $response (@$result) {
|
if (defined($result)) {
|
||||||
$len = length($response);
|
foreach my $response (@$result) {
|
||||||
$n = $conn->syswrite(pack("n", $len), 2);
|
$len = length($response);
|
||||||
$n = $conn->syswrite($response, $len);
|
$n = $conn->syswrite(pack("n", $len), 2);
|
||||||
print " Sent: $n chars via TCP\n";
|
$n = $conn->syswrite($response, $len);
|
||||||
|
print " Sent: $n chars via TCP\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$conn->close;
|
$conn->close;
|
||||||
|
0
bin/tests/system/digdelv/ans4/startme
Normal file
0
bin/tests/system/digdelv/ans4/startme
Normal file
@ -11,6 +11,7 @@ status=0
|
|||||||
n=0
|
n=0
|
||||||
# using dig insecure mode as not testing dnssec here
|
# using dig insecure mode as not testing dnssec here
|
||||||
DIGOPTS="-i -p 5300"
|
DIGOPTS="-i -p 5300"
|
||||||
|
SENDCMD="$PERL $SYSTEMTESTTOP/send.pl 10.53.0.4 5301"
|
||||||
|
|
||||||
if [ -x ${DIG} ] ; then
|
if [ -x ${DIG} ] ; then
|
||||||
n=`expr $n + 1`
|
n=`expr $n + 1`
|
||||||
@ -198,6 +199,18 @@ if [ -x ${DIG} ] ; then
|
|||||||
if [ $ret != 0 ]; then echo "I:failed"; fi
|
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||||
status=`expr $status + $ret`
|
status=`expr $status + $ret`
|
||||||
|
|
||||||
|
n=`expr $n + 1`
|
||||||
|
echo "I:checking dig preserves origin on TCP retries ($n)"
|
||||||
|
ret=0
|
||||||
|
# Ask ans4 to still accept TCP connections, but not respond to queries
|
||||||
|
echo "//" | $SENDCMD
|
||||||
|
$DIG $DIGOPTS -d +tcp @10.53.0.4 +retry=1 +time=1 +domain=bar foo > dig.out.test$n 2>&1 && ret=1
|
||||||
|
l=`grep "trying origin bar" dig.out.test$n | wc -l`
|
||||||
|
[ ${l:-0} -eq 2 ] || ret=1
|
||||||
|
grep "using root origin" < dig.out.test$n > /dev/null && ret=1
|
||||||
|
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||||
|
status=`expr $status + $ret`
|
||||||
|
|
||||||
n=`expr $n + 1`
|
n=`expr $n + 1`
|
||||||
echo "I:checking dig -6 -4 ($n)"
|
echo "I:checking dig -6 -4 ($n)"
|
||||||
ret=0
|
ret=0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user