From patchwork Sat Apr 5 17:56:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Stam X-Patchwork-Id: 337220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 07D071400C6 for ; Sun, 6 Apr 2014 04:56:24 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C1A1A8CB2C; Sat, 5 Apr 2014 18:56:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RLxCGtdjzo7z; Sat, 5 Apr 2014 18:56:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id B2ABC8BB6B; Sat, 5 Apr 2014 18:56:19 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 07C321BF97E for ; Sat, 5 Apr 2014 18:56:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0299B8BB6B for ; Sat, 5 Apr 2014 18:56:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e1LO7cVYLsAm for ; Sat, 5 Apr 2014 18:56:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fsm.reverze.net (smtp.reverze.net [82.161.88.7]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3078F8B730 for ; Sat, 5 Apr 2014 18:56:15 +0000 (UTC) Received: from [192.168.0.17] (ltm.reverze.net [192.168.0.17] (may be forged)) (authenticated bits=0) by fsm.reverze.net (8.14.5/8.14.5) with ESMTP id s35IuBUA013029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 5 Apr 2014 20:56:11 +0200 Message-ID: <534043D6.9090500@reverze.net> Date: Sat, 05 Apr 2014 19:56:38 +0200 From: Michel Stam User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Bernhard Reutner-Fischer Subject: Re: [PATCH] resolver does not try other nameservers on SERVFAIL References: <53145D87.40308@reverze.net> <53218BB1.90702@reverze.net> <144d17be690.2760.0f39ed3bcad52ef2c88c90062b7714dc@gmail.com> In-Reply-To: X-Virus-Scanned: clamav-milter 0.97.6 at fsm X-Virus-Status: Clean Cc: "" X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: uclibc-bounces@uclibc.org Hello Bernard, Sorry for my late response. I was not able to test the patch sooner. I tested it now, but it does not work in my specific situation, as the SERVFAIL returned by tmdns (which is a temporary failure) makes the whole lookup fail. The next nameserver in the list is not tried in that case. If i change the following if statement around line 1464 in libc/inet/resolv.c, > if (h.rcode==REFUSED) { should become: > if ((h.rcode ==REFUSED)||(h.rcode==SERVFAIL)) { then things seem to work. See also my attached patch, which should be applied on top of yours. Again, sorry for my tardiness. Cheers, Michel On 03/27/2014 08:06 AM, Bernhard Reutner-Fischer wrote: > On 17 March 2014 20:23, Michel Stam wrote: >> Thanks Bernhard. >> >> Cheers >> >> Michel Stam >> >> >>> On 17 mrt. 2014, at 20:19, "Bernhard Reutner-Fischer" wrote: >>> >>>> On 13 March 2014 11:43:05 Michel Stam 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. >>>>> > Not entirely happy with that. > How about the attached instead, without looking at the size(1) implications yet? > > Revert e1420eca7374cd8f583e9d774c890645a205aaee > Rephrase __dns_lookup rcode handling to fix bug 660 and fix ???? as > reported by Michel Stam. > > Details: > # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) > # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN > nameserver 193.170.61.4 > nameserver 193.170.61.5 > #nameserver 131.130.250.130 > nameserver 192.168.100.42 > search loc lane wifi wien berlin ac.at at > > $ for i in nxdomain univie nic;do echo "# $i";./ghbn $i;echo > "#############################################";done > # nxdomain > argc=2 argv=0x7fffd5941508 envp=0x7fffd5941520 > ELF header=0x7f3dd946f000 > First Dynamic section entry=0x7f3dd9678ea0 > Scanning DYNAMIC section > Done scanning DYNAMIC section > About to do library loader relocations > Done relocating ldso; we can now use globals and make function calls! > _dl_get_ready_to_run:450: Cool, ldso survived making function calls > _dl_malloc:240: mmapping more memory > _dl_ldsopath_init:156: Lib Loader: (0xd946f000) > /scratch/src/uClibc.push7/lib/ld64-uClibc.so.0: using path: > /scratch/src/uClibc.push7/lib > _dl_load_elf_shared_library:772: Found TLS header for > /scratch/src/uClibc.push7/lib/libc.so.0 > _dl_load_elf_shared_library:799: Relocated TLS initial image from > 0x2ca968 to 0x7f3dd9466968 (size = 0x8) > _dl_get_ready_to_run:1053: Loading: (0x7f3dd919c000) > /scratch/src/uClibc.push7/lib/libc.so.0 > _dl_get_ready_to_run:1053: Loading: (0x7f3dd946f000) > /scratch/src/uClibc.push7/lib/ld64-uClibc.so.0 > _dl_get_ready_to_run:1194: Calling init_tls()! > _dl_malloc:240: mmapping more memory > _dl_malloc:240: mmapping more memory > _dl_get_ready_to_run:1296: Beginning relocation fixups > _dl_get_ready_to_run:1326: Calling _dl_allocate_tls_init()! > transfering control to application @ 0x400550 > Nothing found in /etc/hosts > Looking up type 1 answer for 'nxdomain' > adding search loc > adding search lane > adding search wifi > adding search wien > adding search berlin > adding search ac.at > adding search at > nameservers = 3 > encoding header > lookup name: nxdomain > On try 8, sending query to 193.170.61.4, port 53 > Xmit packet len:26 id:2 qr:0 > len:26 id:2 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=0,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=0,rcode=5 > encoding header > lookup name: nxdomain > On try 7, sending query to 193.170.61.5, port 53 > Xmit packet len:26 id:3 qr:0 > len:26 id:3 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=0,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=0,rcode=5 > encoding header > lookup name: nxdomain > On try 6, sending query to 192.168.100.42, port 53 > Xmit packet len:26 id:4 qr:0 > len:101 id:4 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:-1 sdomains:7 > encoding header > lookup name: nxdomain.loc > On try 5, sending query to 192.168.100.42, port 53 > Xmit packet len:30 id:5 qr:0 > len:81 id:5 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:0 sdomains:7 > encoding header > lookup name: nxdomain.lane > On try 4, sending query to 192.168.100.42, port 53 > Xmit packet len:31 id:6 qr:0 > len:85 id:6 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:1 sdomains:7 > encoding header > lookup name: nxdomain.wifi > On try 3, sending query to 192.168.100.42, port 53 > Xmit packet len:31 id:7 qr:0 > len:85 id:7 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:2 sdomains:7 > encoding header > lookup name: nxdomain.wien > On try 2, sending query to 192.168.100.42, port 53 > Xmit packet len:31 id:8 qr:0 > len:98 id:8 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:3 sdomains:7 > encoding header > lookup name: nxdomain.berlin > On try 1, sending query to 192.168.100.42, port 53 > Xmit packet len:33 id:9 qr:0 > len:100 id:9 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:4 sdomains:7 > encoding header > lookup name: nxdomain.ac.at > On try 0, sending query to 192.168.100.42, port 53 > Xmit packet len:32 id:10 qr:0 > len:96 id:10 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:5 sdomains:7 > __dns_lookup returned < 0 > ERROR: : Resolver error > ############################################# > # univie > argc=2 argv=0x7ffff9da32a8 envp=0x7ffff9da32c0 > ELF header=0x7f517874d000 > First Dynamic section entry=0x7f5178956ea0 > Scanning DYNAMIC section > Done scanning DYNAMIC section > About to do library loader relocations > Done relocating ldso; we can now use globals and make function calls! > _dl_get_ready_to_run:450: Cool, ldso survived making function calls > _dl_malloc:240: mmapping more memory > _dl_ldsopath_init:156: Lib Loader: (0x7874d000) > /scratch/src/uClibc.push7/lib/ld64-uClibc.so.0: using path: > /scratch/src/uClibc.push7/lib > _dl_load_elf_shared_library:772: Found TLS header for > /scratch/src/uClibc.push7/lib/libc.so.0 > _dl_load_elf_shared_library:799: Relocated TLS initial image from > 0x2ca968 to 0x7f5178744968 (size = 0x8) > _dl_get_ready_to_run:1053: Loading: (0x7f517847a000) > /scratch/src/uClibc.push7/lib/libc.so.0 > _dl_get_ready_to_run:1053: Loading: (0x7f517874d000) > /scratch/src/uClibc.push7/lib/ld64-uClibc.so.0 > _dl_get_ready_to_run:1194: Calling init_tls()! > _dl_malloc:240: mmapping more memory > _dl_malloc:240: mmapping more memory > _dl_get_ready_to_run:1296: Beginning relocation fixups > _dl_get_ready_to_run:1326: Calling _dl_allocate_tls_init()! > transfering control to application @ 0x400550 > Nothing found in /etc/hosts > Looking up type 1 answer for 'univie' > adding search loc > adding search lane > adding search wifi > adding search wien > adding search berlin > adding search ac.at > adding search at > nameservers = 3 > encoding header > lookup name: univie > On try 8, sending query to 193.170.61.4, port 53 > Xmit packet len:24 id:2 qr:0 > len:24 id:2 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=0,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=0,rcode=5 > encoding header > lookup name: univie > On try 7, sending query to 193.170.61.5, port 53 > Xmit packet len:24 id:3 qr:0 > len:24 id:3 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=0,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=0,rcode=5 > encoding header > lookup name: univie > On try 6, sending query to 192.168.100.42, port 53 > Xmit packet len:24 id:4 qr:0 > len:99 id:4 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:-1 sdomains:7 > encoding header > lookup name: univie.loc > On try 5, sending query to 192.168.100.42, port 53 > Xmit packet len:28 id:5 qr:0 > len:79 id:5 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:0 sdomains:7 > encoding header > lookup name: univie.lane > On try 4, sending query to 192.168.100.42, port 53 > Xmit packet len:29 id:6 qr:0 > len:83 id:6 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:1 sdomains:7 > encoding header > lookup name: univie.wifi > On try 3, sending query to 192.168.100.42, port 53 > Xmit packet len:29 id:7 qr:0 > len:83 id:7 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:2 sdomains:7 > encoding header > lookup name: univie.wien > On try 2, sending query to 192.168.100.42, port 53 > Xmit packet len:29 id:8 qr:0 > len:96 id:8 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:3 sdomains:7 > encoding header > lookup name: univie.berlin > On try 1, sending query to 192.168.100.42, port 53 > Xmit packet len:31 id:9 qr:0 > len:98 id:9 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:4 sdomains:7 > encoding header > lookup name: univie.ac.at > On try 0, sending query to 192.168.100.42, port 53 > Xmit packet len:30 id:10 qr:0 > len:257 id:10 qr:1 > Got response (i think)! > qrcount=1,ancount=1,nscount=13,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=0 > Skipping question 0 at 12 > Length of question 0 is 18 > Decoding answer at pos 30 > decode_answer(start): off 30, len 257 > Total decode len = 2 > i=2,rdlength=4 > Answer name = |univie.ac.at| > Answer type = |1| > a.add_count:0 a.rdlength:4 a.rdata:0x63f03a > name : univie.ac.at > fam : 2 > addrlen: 4 > addr : 131.130.70.17 > total 1 addresses > aliases: univie > ############################################# > # nic > argc=2 argv=0x7fff5356d078 envp=0x7fff5356d090 > ELF header=0x7f2c1397f000 > First Dynamic section entry=0x7f2c13b88ea0 > Scanning DYNAMIC section > Done scanning DYNAMIC section > About to do library loader relocations > Done relocating ldso; we can now use globals and make function calls! > _dl_get_ready_to_run:450: Cool, ldso survived making function calls > _dl_malloc:240: mmapping more memory > _dl_ldsopath_init:156: Lib Loader: (0x1397f000) > /scratch/src/uClibc.push7/lib/ld64-uClibc.so.0: using path: > /scratch/src/uClibc.push7/lib > _dl_load_elf_shared_library:772: Found TLS header for > /scratch/src/uClibc.push7/lib/libc.so.0 > _dl_load_elf_shared_library:799: Relocated TLS initial image from > 0x2ca968 to 0x7f2c13976968 (size = 0x8) > _dl_get_ready_to_run:1053: Loading: (0x7f2c136ac000) > /scratch/src/uClibc.push7/lib/libc.so.0 > _dl_get_ready_to_run:1053: Loading: (0x7f2c1397f000) > /scratch/src/uClibc.push7/lib/ld64-uClibc.so.0 > _dl_get_ready_to_run:1194: Calling init_tls()! > _dl_malloc:240: mmapping more memory > _dl_malloc:240: mmapping more memory > _dl_get_ready_to_run:1296: Beginning relocation fixups > _dl_get_ready_to_run:1326: Calling _dl_allocate_tls_init()! > transfering control to application @ 0x400550 > Nothing found in /etc/hosts > Looking up type 1 answer for 'nic' > adding search loc > adding search lane > adding search wifi > adding search wien > adding search berlin > adding search ac.at > adding search at > nameservers = 3 > encoding header > lookup name: nic > On try 8, sending query to 193.170.61.4, port 53 > Xmit packet len:21 id:2 qr:0 > len:21 id:2 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=0,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=0,rcode=5 > encoding header > lookup name: nic > On try 7, sending query to 193.170.61.5, port 53 > Xmit packet len:21 id:3 qr:0 > len:21 id:3 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=0,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=0,rcode=5 > encoding header > lookup name: nic > On try 6, sending query to 192.168.100.42, port 53 > Xmit packet len:21 id:4 qr:0 > len:96 id:4 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=3 > variant:-1 sdomains:7 > encoding header > lookup name: nic.loc > On try 5, sending query to 192.168.100.42, port 53 > Xmit packet len:25 id:5 qr:0 > len:76 id:5 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:0 sdomains:7 > encoding header > lookup name: nic.lane > On try 4, sending query to 192.168.100.42, port 53 > Xmit packet len:26 id:6 qr:0 > len:80 id:6 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:1 sdomains:7 > encoding header > lookup name: nic.wifi > On try 3, sending query to 192.168.100.42, port 53 > Xmit packet len:26 id:7 qr:0 > len:80 id:7 qr:1 > Got response (i think)! > qrcount=1,ancount=0,nscount=1,arcount=0 > opcode=0,aa=1,tc=0,rd=1,ra=1,rcode=3 > variant:2 sdomains:7 > encoding header > lookup name: nic.wien > On try 2, sending query to 192.168.100.42, port 53 > Xmit packet len:26 id:8 qr:0 > len:198 id:8 qr:1 > Got response (i think)! > qrcount=1,ancount=1,nscount=3,arcount=5 > opcode=0,aa=0,tc=0,rd=1,ra=1,rcode=0 > Skipping question 0 at 12 > Length of question 0 is 14 > Decoding answer at pos 26 > decode_answer(start): off 26, len 198 > Total decode len = 2 > i=2,rdlength=4 > Answer name = |nic.wien| > Answer type = |1| > a.add_count:0 a.rdlength:4 a.rdata:0x1d76036 > name : nic.wien > fam : 2 > addrlen: 4 > addr : 188.40.87.61 > total 1 addresses > aliases: nic > ############################################# > > vs. > > $ for i in nxdomain univie nic;do echo "# $i";./ghbn_glibc $i;echo > "#############################################";done > # nxdomain > ERROR: : Resolver Error 0 (no error) > ############################################# > # univie > name : univie.ac.at > fam : 2 > addrlen: 4 > addr : 131.130.70.17 > total 1 addresses > aliases: > ############################################# > # nic > name : nic.wien > fam : 2 > addrlen: 4 > addr : 188.40.87.61 > total 1 addresses > aliases: > ############################################# > > which leaves us with a diff for 'nxdomain' which you might want to > rectify in an incremental update? > > TIA && cheers, --- libc/inet/resolv.c 2014-04-05 16:17:06.850156346 +0200 +++ libc/inet/resolv.c 2014-04-05 16:15:00.560454001 +0200 @@ -1461,7 +1461,7 @@ * and retry, which is, eh, an error. :) */ /* Try to keep latency and traffic low here, please! */ - if (h.rcode == REFUSED) { + if ((h.rcode == REFUSED)||(h.rcode==SERVFAIL)) { /* type not supported, try the next server, with fresh variants */ goto try_next_server;