From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 6 18:51:16 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AB32016A4CE for ; Mon, 6 Dec 2004 18:51:16 +0000 (GMT) Received: from mailfe03.swip.net (mailfe03.swip.net [212.247.154.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id A62E143D62 for ; Mon, 6 Dec 2004 18:51:15 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: Y1QAsIk9O44SO+J/q9KNyQ== Received: from [193.216.45.91] (HELO curly.tele2.no) by mailfe03.swip.net (CommuniGate Pro SMTP 4.2.6) with ESMTP id 40830800 for freebsd-hackers@freebsd.org; Mon, 06 Dec 2004 19:51:12 +0100 Received: (from root@localhost) by curly.tele2.no (8.12.5/8.12.3) id iB6IvBIP000596 for freebsd-hackers@freebsd.org; Mon, 6 Dec 2004 19:57:11 +0100 (CET) (envelope-from hselasky@c2i.net) Date: Mon, 6 Dec 2004 19:57:09 +0100 From: Hans Petter Selasky To: freebsd-hackers@freebsd.org Message-ID: <20041206195709.A332@curly.tele2.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Subject: hostname lookup problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2004 18:51:16 -0000 Hi, I have come across a problem where res_send() goes into a minute-long wait loop, waiting for the hostname to be looked up, after a getaddrinfo() call. I have captured the packets sent/received, and according to the code the query response does not match. Is this a bug in libc or is it a DNS server problem? A temporary patch is to make the code go on with the next packet instead of waiting for a timeout. Then getaddrinfo only takes a few seconds more, instead of a minute. src/lib/libc/net/res_send.c:res_send(): if (!(_res.options & RES_INSECURE2) && !res_queriesmatch(buf, buf + buflen, ans, ans + anssiz)) { /* * response contains wrong query? ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; wrong query name:\n"), ans, (resplen>anssiz)?anssiz:resplen); res_close(); goto next_ns; //goto wait; } Trace output from "fetch www.google.com" on a PPP link: 8X (fails): -- TE->NT - unit:0 - frame:000175 - time:03.12 19:11:46.845441 - length:69 ----- B2:000 ff 03 00 3d c0 00 00 0b 21 45 00 00 3c 02 43 00 ...=....!E..<.C. B2:010 00 40 11 28 a3 c1 d9 cb 0f c1 d8 01 0a c3 9a 00 .@.(............ B2:020 35 00 28 6d 95 ef aa 01 00 00 01 00 00 00 00 00 5.(m............ B2:030 00 03 77 77 77 06 67 6f 6f 67 6c 65 03 63 6f 6d ..www.google.com B2:040 00 00 1c 00 01 ..... -- NT->TE - unit:0 - frame:000176 - time:03.12 19:11:46.971341 - length:71 ----- B2:000 ff 03 00 21 45 00 00 43 74 53 40 00 fc 11 ba 8a ...!E..CtS@..... B2:010 c1 d8 01 0a c1 d9 cb 0f 00 35 c3 9a 00 2f 06 6b .........5.../.k B2:020 ef aa 81 80 00 01 00 00 00 00 00 00 03 77 77 77 .............www B2:030 06 67 6f 6f 67 6c 65 06 61 6b 61 64 6e 73 03 6e .google.akadns.n B2:040 65 74 00 00 1c 00 01 et..... (above is IPv6 (AAAA), below is IPv4 (A) ??) 1X (succeeds): -- TE->NT - unit:0 - frame:000211 - time:03.12 19:13:08.633794 - length:69 ----- B2:000 ff 03 00 3d c0 00 00 17 21 45 00 00 3c 02 4b 00 ...=....!E..<.K. B2:010 00 40 11 28 9b c1 d9 cb 0f c1 d8 01 0a ef 03 00 .@.(............ B2:020 35 00 28 42 46 ef ab 01 00 00 01 00 00 00 00 00 5.(BF........... B2:030 00 03 77 77 77 06 67 6f 6f 67 6c 65 03 63 6f 6d ..www.google.com B2:040 00 00 01 00 01 ..... -- NT->TE - unit:0 - frame:000212 - time:03.12 19:13:08.825249 - length:531 ---- B2:000 ff 03 00 21 45 00 02 0f 74 57 40 00 fc 11 b8 ba ...!E...tW@..... B2:010 c1 d8 01 0a c1 d9 cb 0f 00 35 ef 03 01 fb cc 3d .........5.....= B2:020 ef ab 81 80 00 01 00 03 00 0d 00 0c 03 77 77 77 .............www B2:030 06 67 6f 6f 67 6c 65 03 63 6f 6d 00 00 01 00 01 .google.com..... B2:040 c0 0c 00 05 00 01 00 00 00 1e 00 17 03 77 77 77 .............www B2:050 06 67 6f 6f 67 6c 65 06 61 6b 61 64 6e 73 03 6e .google.akadns.n B2:060 65 74 00 c0 2c 00 01 00 01 00 00 00 8e 00 04 42 et..,..........B B2:070 66 0b 68 c0 2c 00 01 00 01 00 00 00 8e 00 04 42 f.h.,..........B B2:080 66 0b 63 00 00 02 00 01 00 02 3e 59 00 11 01 41 f.c.......>Y...A B2:090 0c 52 4f 4f 54 2d 53 45 52 56 45 52 53 c0 3e 00 .ROOT-SERVERS.>. B2:0a0 00 02 00 01 00 02 3e 59 00 04 01 48 c0 70 00 00 ......>Y...H.p.. B2:0b0 02 00 01 00 02 3e 59 00 04 01 43 c0 70 00 00 02 .....>Y...C.p... B2:0c0 00 01 00 02 3e 59 00 04 01 47 c0 70 00 00 02 00 ....>Y...G.p.... B2:0d0 01 00 02 3e 59 00 04 01 46 c0 70 00 00 02 00 01 ...>Y...F.p..... B2:0e0 00 02 3e 59 00 04 01 42 c0 70 00 00 02 00 01 00 ..>Y...B.p...... B2:0f0 02 3e 59 00 04 01 4a c0 70 00 00 02 00 01 00 02 .>Y...J.p....... B2:100 3e 59 00 04 01 4b c0 70 00 00 02 00 01 00 02 3e >Y...K.p.......> B2:110 59 00 04 01 4c c0 70 00 00 02 00 01 00 02 3e 59 Y...L.p.......>Y B2:120 00 04 01 4d c0 70 00 00 02 00 01 00 02 3e 59 00 ...M.p.......>Y. B2:130 04 01 49 c0 70 00 00 02 00 01 00 02 3e 59 00 04 ..I.p.......>Y.. B2:140 01 45 c0 70 00 00 02 00 01 00 02 3e 59 00 04 01 .E.p.......>Y... B2:150 44 c0 70 c0 6e 00 01 00 01 00 06 33 f4 00 04 c6 D.p.n......3.... B2:160 29 00 04 c0 8a 00 01 00 01 00 06 33 f4 00 04 80 )..........3.... B2:170 3f 02 35 c0 99 00 01 00 01 00 06 33 f4 00 04 c0 ?.5........3.... B2:180 21 04 0c c0 a8 00 01 00 01 00 06 33 f4 00 04 c0 !..........3.... B2:190 70 24 04 c0 b7 00 01 00 01 00 06 33 f4 00 04 c0 p$.........3.... B2:1a0 05 05 f1 c0 c6 00 01 00 01 00 06 33 f4 00 04 c0 ...........3.... B2:1b0 e4 4f c9 c0 d5 00 01 00 01 00 06 33 89 00 04 c0 .O.........3.... B2:1c0 3a 80 1e c0 e4 00 01 00 01 00 06 33 89 00 04 c1 :..........3.... B2:1d0 00 0e 81 c0 f3 00 01 00 01 00 06 33 89 00 04 c6 ...........3.... B2:1e0 20 40 0c c1 02 00 01 00 01 00 06 33 89 00 04 ca @.........3.... B2:1f0 0c 1b 21 c1 11 00 01 00 01 00 06 33 89 00 04 c0 ..!........3.... B2:200 24 94 11 c1 20 00 01 00 01 00 06 33 f4 00 04 c0 $... ......3.... B2:210 cb e6 0a ... Yours -HPS