From owner-freebsd-questions Fri Jun 4 8:20:13 1999 Delivered-To: freebsd-questions@freebsd.org Received: from hal6000.thp.Uni-Duisburg.DE (hal6000.uni-duisburg.de [134.91.140.2]) by hub.freebsd.org (Postfix) with ESMTP id 4DFF415409 for ; Fri, 4 Jun 1999 08:20:04 -0700 (PDT) (envelope-from ralf@thp.Uni-Duisburg.DE) Received: from localhost (ralf@localhost) by hal6000.thp.Uni-Duisburg.DE (8.9.0/8.9.0) with ESMTP id RAA61738 for ; Fri, 4 Jun 1999 17:19:56 +0200 Date: Fri, 4 Jun 1999 17:19:56 +0200 (MESZ) From: Ralf Meyer To: freebsd-questions@FreeBSD.org Subject: netstat, getnetent(), and /etc/networks Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, I have encountered a problem with the use of netstat -r and the /etc/networks file. In /etc/networks I have the following line derived from the default /etc/networks file: asgard 192.168.8 Nevertheless netstat -r reports something like: 192.168.8 link#1 UC 0 0 ed0 (File lookup is enabled in /etc/host.conf). If I change the entry in /etc/networks to asgard 192.168.8.0 netstat correctly reports asgard link#1 UC 0 0 ed0 Looking into the sources I found that the reason for this is the way the network address in /etc/networks is interpreted by the getnetent() function. In the first case this function returns for the n_net field 0xc0a808 while in the second case 0xc0a80800 is returned. I assume that this behavior of getnetent() is for historical reasons. That this is not only a bug can be seen from the fact that the netname lookup feature of programs like route take care to shift network addresses before calling getnetbyaddr(). This has the side effect that an entry of 192.168.8.0 in /etc/networks is not found by route (since the show command has been removed from route in FreeBSD the only command affected by this is "route flush"). My question is whether the behavior of netstat should simply be treated as a bug and a patch be supplied to shift network addresses before calling getnetbyaddr() in a similar way like route does this (I would be willing to provide such a patch). On the other hand the way getnetent() interprets network addresses in /etc/network is not very reliable and can cause a lot of problems more. Therefore I think it might be worth to think about changing this behavior. This, however has to be done very carefully, since important programs like route would be affected by such a change. Nevertheless, in OpenBSD the result of getnetent() is different (e.g. 192.168.8 => 0xc0a80800). It seems that they have gone through this change. Any comments? Ralf To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message