Patchwork resolver does not try other nameservers on SERVFAIL

login
register
mail settings
Submitter Michel Stam
Date March 3, 2014, 10:46 a.m.
Message ID <53145D87.40308@reverze.net>
Download mbox | patch
Permalink /patch/325777/
State Accepted
Commit 064d18b8e5dc93d33f24d2d46123f71bdb753061
Headers show

Comments

Michel Stam - March 3, 2014, 10:46 a.m.
Commit e1420eca7374cd8f583e9d774c890645a205aaee fixed a bug where a
response code should mean the next server is tried. However, it tries
only the next search domain, and never skips to the next server.

In my specific situation, I was using tmdns as a DNS -> mDNS bridge to 
resolve mDNS names. tmdns returns SERVFAIL on any domain that does not 
end in .local.

uClibc then tries all the search domains in /etc/resolv.conf and gives 
up, not jumping to the next nameserver in the list (in my case the real 
nameserver). Thus, any non-.local domain never got resolved.

My resolv.conf;
domain bla.net
search bla.net
nameserver 127.0.0.1
nameserver 172.16.1.1

The patch I have attached basically allows SERVFAIL to go back to the 
case as it was before 0.9.32, except that search domains are still tried.

Best regards,

Michel Stam
From 3e44112543d61f73f5955793c6718e9f327f55ec Mon Sep 17 00:00:00 2001
From: Michel Stam <michel@reverze.net>
Date: Thu, 27 Feb 2014 21:42:38 +0100
Subject: [PATCH] resolv: try next server on SERVFAIL

Commit e1420eca7374cd8f583e9d774c890645a205aaee fixed a bug where a
response code should mean the next server is tried. However, it tries
only the next search domain, and never skips to the next server. This
fix makes sure we try the next server on SERVFAIL.

Signed-off-by: Michel Stam <michel@reverze.net>
---
 libc/inet/resolv.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
Michel Stam - March 13, 2014, 10:42 a.m.
Dear mailing list,

I have seen very little response on this topic; Would it be possible to 
apply this patch to trunk?

I would like to add that without this patch, the behaviour in uClibc 
differs from glibc.

Best regads,

Michel Stam
On 03/03/2014 11:46 AM, Michel Stam wrote:
> Commit e1420eca7374cd8f583e9d774c890645a205aaee fixed a bug where a
> response code should mean the next server is tried. However, it tries
> only the next search domain, and never skips to the next server.
>
> In my specific situation, I was using tmdns as a DNS -> mDNS bridge to 
> resolve mDNS names. tmdns returns SERVFAIL on any domain that does not 
> end in .local.
>
> uClibc then tries all the search domains in /etc/resolv.conf and gives 
> up, not jumping to the next nameserver in the list (in my case the 
> real nameserver). Thus, any non-.local domain never got resolved.
>
> My resolv.conf;
> domain bla.net
> search bla.net
> nameserver 127.0.0.1
> nameserver 172.16.1.1
>
> The patch I have attached basically allows SERVFAIL to go back to the 
> case as it was before 0.9.32, except that search domains are still tried.
>
> Best regards,
>
> Michel Stam
>
>
>
>
> _______________________________________________
> uClibc mailing list
> uClibc@uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
aldot - March 17, 2014, 7:19 p.m.
On 13 March 2014 11:43:05 Michel Stam <michel.uclibc@reverze.net> wrote:

> Dear mailing list,
>
> I have seen very little response on this topic; Would it be possible to 
> apply this patch to trunk?

I'm verifying the patch right now, will apply it afterwards. Will followup 
in the push.

Thanks!
>
> I would like to add that without this patch, the behaviour in uClibc 
> differs from glibc.
>
> Best regads,
>
> Michel Stam
> On 03/03/2014 11:46 AM, Michel Stam wrote:
> > Commit e1420eca7374cd8f583e9d774c890645a205aaee fixed a bug where a
> > response code should mean the next server is tried. However, it tries
> > only the next search domain, and never skips to the next server.
> >
> > In my specific situation, I was using tmdns as a DNS -> mDNS bridge to 
> resolve mDNS names. tmdns returns SERVFAIL on any domain that does not end 
> in .local.
> >
> > uClibc then tries all the search domains in /etc/resolv.conf and gives 
> up, not jumping to the next nameserver in the list (in my case the real 
> nameserver). Thus, any non-.local domain never got resolved.
> >
> > My resolv.conf;
> > domain bla.net
> > search bla.net
> > nameserver 127.0.0.1
> > nameserver 172.16.1.1
> >
> > The patch I have attached basically allows SERVFAIL to go back to the 
> case as it was before 0.9.32, except that search domains are still tried.
> >
> > Best regards,
> >
> > Michel Stam
> >
> >
> >
> >


Sent with AquaMail for Android
http://www.aqua-mail.com
aldot - April 23, 2014, 2:04 p.m.
On 3 March 2014 11:46, Michel Stam <michel.uclibc@reverze.net> wrote:
> Commit e1420eca7374cd8f583e9d774c890645a205aaee fixed a bug where a
> response code should mean the next server is tried. However, it tries
> only the next search domain, and never skips to the next server.
>
> In my specific situation, I was using tmdns as a DNS -> mDNS bridge to
> resolve mDNS names. tmdns returns SERVFAIL on any domain that does not end
> in .local.
>
> uClibc then tries all the search domains in /etc/resolv.conf and gives up,
> not jumping to the next nameserver in the list (in my case the real
> nameserver). Thus, any non-.local domain never got resolved.
>
> My resolv.conf;
> domain bla.net
> search bla.net
> nameserver 127.0.0.1
> nameserver 172.16.1.1
>
> The patch I have attached basically allows SERVFAIL to go back to the case
> as it was before 0.9.32, except that search domains are still tried.
>
Applied, thanks!

Patch

diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 154734d..cfc1eee 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1471,9 +1471,11 @@  int __dns_lookup(const char *name,
 				}
 				/* no more search domains to try */
 			}
-			/* dont loop, this is "no such host" situation */
-			h_errno = HOST_NOT_FOUND;
-			goto fail1;
+			if (h.rcode != SERVFAIL) {
+				/* dont loop, this is "no such host" situation */
+				h_errno = HOST_NOT_FOUND;
+				goto fail1;
+			}
 		}
 		/* Insert other non-fatal errors here, which do not warrant
 		 * switching to next nameserver */