NetBSD Problem Report #9413

Received: (qmail 13820 invoked from network); 13 Feb 2000 23:01:44 -0000
Message-Id: <20000213230129.AFCC5D48@WintelKiller.HEH.Uni-Oldenburg.DE>
Date: Mon, 14 Feb 2000 00:01:29 +0100 (MET)
From: Thilo.Manske@HEH.Uni-Oldenburg.DE
Reply-To: Thilo.Manske@HEH.Uni-Oldenburg.DE
To: gnats-bugs@gnats.netbsd.org
Subject: resolver weirdnesses
X-Send-Pr-Version: 3.95

>Number:         9413
>Category:       lib
>Synopsis:       strange problems with NetBSD's resolver
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    itojun
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 13 15:03:00 +0000 2000
>Closed-Date:    Sat Feb 26 03:29:25 +0000 2000
>Last-Modified:  Sat Feb 26 03:30:27 +0000 2000
>Originator:     Thilo Manske
>Release:        4th and 12th February
>Organization:
Dies ist Thilos Unix Signature! Viel Spass damit.
>Environment:

System: NetBSD WintelKiller 1.4S NetBSD 1.4S (WintelKiller) #194: Sat Feb 12 15:16:01 MET 2000 thilo@WintelKiller:/usr/src/sys/arch/i386/compile/WintelKiller i386

No IPv6 enabled at all.

>Description:
I've discovered strange actions by NetBSD's resolver:

When I issue rlogin seti-100 NetBSD does this:

WintelKiller-100.65372 > seti-100.domain:  10782+ AAAA? seti-100.HEH.Uni-Oldenburg.DE. (47)
seti-100.domain > WintelKiller-100.65372:  10782 NXDomain* 0/1/0 (115)
WintelKiller-100.65371 > seti-100.domain:  10783+ AAAA? seti-100. (26)
seti-100.domain > WintelKiller-100.65371:  10783 NXDomain 0/1/0 (99)

HEH.Uni-Oldenburg.de is my defaultdomain, set in /etc/resolv.conf (search
option))

What's strange is, that
A) seti-100 is in /etc/hosts (and nsswitch.conf set properly)
B) I don't have IPv6 enabled, so I'm not intereseted in "AAAA" records
C) Some tools do this (rlogin, telnet, ftp, rsh, tcpdump...) some not
(i.e. work correctly; ping and ntpdate e.g. - and host of course (doesn't
use NetBSD'S resolver, right?))

A dummy program using gethostbyname(3) works correctly as well.

When our site and thus my cacheing nameserver (seti-100) has lost its
connection to the rest of the 'net this saturday name resolving needed
ages.  (And that was the reason I've started investigating this :-)

Here's a lookup of an nonexistent host (not present in /etc/host):

WintelKiller-100.65376 > seti-100.domain:  19293+ AAAA? doesnotexist.HEH.Uni-Oldenburg.DE. (51)
seti-100.domain > WintelKiller-100.65376:  19293 NXDomain* 0/1/0 (119)
WintelKiller-100.65375 > seti-100.domain:  19294+ AAAA? doesnotexist. (30)
seti-100.domain > WintelKiller-100.65375:  19294 NXDomain 0/1/0 (103)
WintelKiller-100.65374 > seti-100.domain:  19295+ A? doesnotexist.HEH.Uni-Oldenburg.DE. (51)
seti-100.domain > WintelKiller-100.65374:  19295 NXDomain* 0/1/0 (119)
WintelKiller-100.65373 > seti-100.domain:  19296+ A? doesnotexist. (30)
seti-100.domain > WintelKiller-100.65373:  19296 NXDomain 0/1/0 (103)

Looks like the resolver does this in some cases:
1. IPv6 adress requests (AAAA),
2. following the rules in /etc/nsswitch.conf

I've browsed the resolver sources in src/lib/libc/net quickly to find
a maybe undocumented option of nsswitch.conf but didn't succeed.

I've discovered the problem with world build around 4th February but it
still exists with yesterday's sources.

Here are parts of a ktrace "rsh seti-100 echo":
(I hope the interesting ones):

  1190 rsh      NAMI  "/etc/nsswitch.conf"
  1190 rsh      RET   __stat13 0
  1190 rsh      CALL  open(0x480cf882,0,0x1b6)
  1190 rsh      NAMI  "/etc/hosts"
  1190 rsh      RET   open 3
  1190 rsh      CALL  __fstat13(0x3,0xefbfd53c)
  1190 rsh      RET   __fstat13 0
  1190 rsh      CALL  read(0x3,0x8050000,0x2000)
  1190 rsh      GIO   fd 3 read 64 bytes
       "127.0.0.1       localhost
        10.2.0.1        seti-100
        10.2.0.2        WintelKiller-100
       "
  1190 rsh      RET   read 64/0x40
  1190 rsh      CALL  read(0x3,0x8050000,0x2000)
  1190 rsh      GIO   fd 3 read 0 bytes
       ""
  1190 rsh      RET   read 0
  1190 rsh      CALL  close(0x3)
  1190 rsh      RET   close 0
  1190 rsh      CALL  madvise(0x8050000,0x2000,0x6)
  1190 rsh      RET   madvise 0
  1190 rsh      CALL  gettimeofday(0xefbfcd98,0)
  1190 rsh      RET   gettimeofday 0
  1190 rsh      CALL  getpid
  1190 rsh      RET   getpid 1190/0x4a6
  1190 rsh      CALL  open(0x480d1237,0,0x1b6)
  1190 rsh      NAMI  "/etc/resolv.conf"
  1190 rsh      RET   open 3
  1190 rsh      CALL  __fstat13(0x3,0xefbfccd8)
  1190 rsh      RET   __fstat13 0
  1190 rsh      CALL  read(0x3,0x8050000,0x2000)
  1190 rsh      GIO   fd 3 read 48 bytes
       "search HEH.Uni-Oldenburg.DE
        nameserver 10.2.0.1
       "
  1190 rsh      RET   read 48/0x30
  1190 rsh      CALL  read(0x3,0x8050000,0x2000)
  1190 rsh      GIO   fd 3 read 0 bytes
       ""
  1190 rsh      RET   read 0
  1190 rsh      CALL  close(0x3)
  1190 rsh      RET   close 0
  1190 rsh      CALL  madvise(0x8050000,0x2000,0x6)
  1190 rsh      RET   madvise 0
  1190 rsh      CALL  socket(0x2,0x2,0)
  1190 rsh      RET   socket 3
  1190 rsh      CALL  connect(0x3,0x480e18a0,0x10)
  1190 rsh      RET   connect 0
  1190 rsh      CALL  sendto(0x3,0xefbfc9c0,0x2f,0,0,0)
  1190 rsh      GIO   fd 3 wrote 47 bytes
       "gL\^A\0\0\^A\0\0\0\0\0\0\bseti-100\^CHEH\rUni-Oldenburg\^BDE\0\0\^\\0\
        \^A"
  1190 rsh      RET   sendto 47/0x2f
  1190 rsh      CALL  poll(0xefbfc778,0x1,0x1388)
  1190 rsh      RET   poll 1
  1190 rsh      CALL  recvfrom(0x3,0xefbfd25c,0x400,0,0xefbfc78c,0xefbfc774)
  1190 rsh      GIO   fd 3 read 115 bytes
       "gL\M^E\M^C\0\^A\0\0\0\^A\0\0\bseti-100\^CHEH\rUni-Oldenburg\^BDE\0\0\
        \^\\0\^A\^CHEH\rUni-Oldenburg\^BDE\0\0\^F\0\^A\0\^AQ\M^@\0$\^FServer\
        \M-@/\^Droot\M-@Ow5\M-b\M-U\0\08@\0\0\^N\^P\0   :\M^@\0\^AQ\M^@"
  1190 rsh      RET   recvfrom 115/0x73
  1190 rsh      CALL  close(0x3)
  1190 rsh      RET   close 0
  1190 rsh      CALL  socket(0x2,0x2,0)
  1190 rsh      RET   socket 3
  1190 rsh      CALL  connect(0x3,0x480e18a0,0x10)
  1190 rsh      RET   connect 0
  1190 rsh      CALL  sendto(0x3,0xefbfc9c0,0x1a,0,0,0)
  1190 rsh      GIO   fd 3 wrote 26 bytes
       "gM\^A\0\0\^A\0\0\0\0\0\0\bseti-100\0\0\^\\0\^A"
  1190 rsh      RET   sendto 26/0x1a
  1190 rsh      CALL  poll(0xefbfc778,0x1,0x1388)
  1190 rsh      RET   poll 1
  1190 rsh      CALL  recvfrom(0x3,0xefbfd25c,0x400,0,0xefbfc78c,0xefbfc774)
  1190 rsh      GIO   fd 3 read 99 bytes
       "gM\M^A\M^C\0\^A\0\0\0\^A\0\0\bseti-100\0\0\^\\0\^A\0\0\^F\0\^A\0\0"N\0\
        >\^AA\fROOT-SERVERS\^CNET\0
        hostmaster\binternic\M-@4w5\M-g4\0\0\a\b\0\0\^C\M^D\0   :\M^@\0\^AQ\
        \M^@"
  1190 rsh      RET   recvfrom 99/0x63
  1190 rsh      CALL  close(0x3)
  1190 rsh      RET   close 0

I hope this is enough information :-)

>How-To-Repeat:
"tcpdump -vv -i <interface> port domain" in one shell
and "rlogin <somehost>" etc in another one.

rlogin host
>Fix:
>Release-Note:
>Audit-Trail:

From: itojun@iijlab.net
To: Thilo.Manske@HEH.Uni-Oldenburg.DE
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/9413: resolver weirdnesses
Date: Mon, 14 Feb 2000 11:39:48 +0900

 >>Synopsis:       strange problems with NetBSD's resolver
 >I've discovered strange actions by NetBSD's resolver:
 >When I issue rlogin seti-100 NetBSD does this:
 >HEH.Uni-Oldenburg.de is my defaultdomain, set in /etc/resolv.conf (search
 >option))
 >What's strange is, that
 >A) seti-100 is in /etc/hosts (and nsswitch.conf set properly)
 >B) I don't have IPv6 enabled, so I'm not intereseted in "AAAA" records

 	Sorry, this is (one of) known problem.
 	There are multiple reasons on it.

 	Dual stack ready userland programs (like rsh/rlogin as you've
 	experiencded) uses get{addr,name}info, not gethostby*, to query names.
 	get{addr,name}info calls gethostbyname2 twice, once for AAAA and
 	once for A (since there's no other good primitive there).
 	This result in:
 		AAAA query on /etc/hosts
 		AAAA query on DNS
 		A query on /etc/hosts
 		A query on DNS
 	Also, (due to binary distribution and other reasons) current userland
 	programs cannot/do not change benavior based on IPv4/v6 kernel support.

 	One way to address this problem is modify resolver internal, and
 	provide primitive function that does
 		AAAA query on /etc/hosts
 		A query on /etc/hosts
 		AAAA query on DNS
 		A query on DNS
 	when you specify "hosts: files dns" in nsswitch.conf.
 	Current internal primitives do not do this for me.
 	Another way (which can coexist with the former) is to implement
 	part of post-RFC2553 getaddrinfo specification (AI_ADDRCONFIG flag),
 	and use it from userland programs.  This allows get{addr,name}info
 	to behave differently based on kernel supported address families.

 	I'll try to explore both sooner.

 >C) Some tools do this (rlogin, telnet, ftp, rsh, tcpdump...) some not
 >(i.e. work correctly; ping and ntpdate e.g. - and host of course (doesn't
 >use NetBSD'S resolver, right?))

 	programs which work "correctly" are not dual stack ready (IPv4-only),
 	and uses gethostby*.

 itojun
Responsible-Changed-From-To: lib-bug-people->itojun 
Responsible-Changed-By: itojun 
Responsible-Changed-When: Sun Feb 13 23:27:30 PST 2000 
Responsible-Changed-Why:  
mine 

From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
To: Thilo.Manske@heh.uni-oldenburg.de
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/9413: resolver weirdnesses
Date: Mon, 14 Feb 2000 10:01:54 +0100 (MET)

 The cause is: rcmd -> orcmd_af() -> getaddrinfo().
 Our libc is always INET6 enabled.

 I use ::ffff:10.x.x.x records to bypass these lookups.

 > >Number:         9413
 > >Category:       lib
 > >Synopsis:       strange problems with NetBSD's resolver
 >  ...


 -- 
 Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)

From: Thilo Manske <Thilo.Manske@HEH.Uni-Oldenburg.DE>
To: itojun@iijlab.net
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/9413: resolver weirdnesses
Date: Mon, 14 Feb 2000 13:05:04 +0100

 On Mon, Feb 14, 2000 at 11:39:48AM +0900, itojun@iijlab.net wrote:
 > 	Dual stack ready userland programs (like rsh/rlogin as you've
 > 	experiencded) uses get{addr,name}info, not gethostby*, to query names.
 > 	get{addr,name}info calls gethostbyname2 twice, once for AAAA and
 > 	once for A (since there's no other good primitive there).
 > 	This result in:
 > 		AAAA query on /etc/hosts
 > 		AAAA query on DNS
 > 		A query on /etc/hosts
 > 		A query on DNS
 Oh, yes. Now I remember a post (IIRC from you) about this. Maybe this
 should be documented in the BUGS section of nsswitch.conf?

 And thanks to Juergen for the workaround!
 -- 
 Dies ist Thilos Unix Signature! Viel Spass damit.

From: itojun@iijlab.net
To: Thilo Manske <Thilo.Manske@HEH.Uni-Oldenburg.DE>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/9413: resolver weirdnesses
Date: Mon, 14 Feb 2000 21:07:48 +0900

 >> 	Dual stack ready userland programs (like rsh/rlogin as you've
 >> 	experiencded) uses get{addr,name}info, not gethostby*, to query names.
 >> 	get{addr,name}info calls gethostbyname2 twice, once for AAAA and
 >> 	once for A (since there's no other good primitive there).
 >> 	This result in:
 >> 		AAAA query on /etc/hosts
 >> 		AAAA query on DNS
 >> 		A query on /etc/hosts
 >> 		A query on DNS
 >Oh, yes. Now I remember a post (IIRC from you) about this. Maybe this
 >should be documented in the BUGS section of nsswitch.conf?
 >And thanks to Juergen for the workaround!

 	This is not just about nsswitch.conf.  This is about all part of
 	resolver code...  a big one.

 	anyway I should put some notes somewhere, thanks for suggestion.

 itojun

From: Thilo Manske <Thilo.Manske@HEH.Uni-Oldenburg.DE>
To: itojun@iijlab.net
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: lib/9413: resolver weirdnesses
Date: Mon, 14 Feb 2000 13:58:07 +0100

 On Mon, Feb 14, 2000 at 09:07:48PM +0900, itojun@iijlab.net wrote:
 > >Oh, yes. Now I remember a post (IIRC from you) about this. Maybe this
 > >should be documented in the BUGS section of nsswitch.conf?
 > >And thanks to Juergen for the workaround!
 > 
 > 	This is not just about nsswitch.conf.  This is about all part of
 > 	resolver code...  a big one.
 Yes, of course. But the manpage of nsswitch.conf is the first you read
 if you want know how to control hostname lookups.
 And if you read there:

 EXAMPLES
      To lookup hosts in /etc/hosts and then from the DNS, and lookup user in-
      formation from NIS then files, use:

      hosts:     files dns
 [...]

 You expect it to work that way.

 So I think the manpage of nsswitch.conf would be the best place.
 -- 
 Dies ist Thilos Unix Signature! Viel Spass damit.
State-Changed-From-To: open->feedback 
State-Changed-By: itojun 
State-Changed-When: Thu Feb 24 21:24:40 PST 2000 
State-Changed-Why:  
it should be okay by now, by getaddrinfo change i made couple of days before. 
State-Changed-From-To: feedback->closed 
State-Changed-By: itojun 
State-Changed-When: Fri Feb 25 19:29:25 PST 2000 
State-Changed-Why:  
confirmed by submitter 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.