Date: Fri, 4 Jun 1999 17:19:56 +0200 (MESZ) From: Ralf Meyer <ralf@thp.Uni-Duisburg.DE> To: freebsd-questions@FreeBSD.org Subject: netstat, getnetent(), and /etc/networks Message-ID: <Pine.A41.4.05.9906041327420.101740-100000@hal6000.thp.Uni-Duisburg.DE>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.A41.4.05.9906041327420.101740-100000>