Confusing `netstat -rn` output on 7.0-RC1
Yuri Pankov
yuri.pankov at gmail.com
Thu Feb 7 02:55:18 PST 2008
(sorry for cross-posting)
On Fri, Feb 01, 2008 at 04:30:21PM +0300, Yuri Pankov wrote:
> Hi,
>
> `netstat -rn` on 7.0-RC1/sparc64 shows 0.0.0.0 instead of actual network
> numbers, while those networks are accessible.
>
> > ifconfig
> dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
> options=8<VLAN_MTU>
> ether 00:03:ba:14:e8:65
> inet 192.168.0.252 netmask 0xffffff00 broadcast 192.168.0.255
> media: Ethernet autoselect (100baseTX <full-duplex>)
> status: active
> dc1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
> options=8<VLAN_MTU>
> ether 00:03:ba:14:e8:65
> inet 10.106.0.3 netmask 0xffffff00 broadcast 10.106.0.255
> media: Ethernet autoselect (100baseTX <full-duplex>)
> status: active
> lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
> inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
> inet6 ::1 prefixlen 128
> inet 127.0.0.1 netmask 0xff000000
> vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
> ether 00:03:ba:14:e8:65
> inet 10.7.12.254 netmask 0xffffff00 broadcast 10.7.12.255
> media: Ethernet autoselect (100baseTX <full-duplex>)
> status: active
> vlan: 301 parent interface: dc1
>
> > netstat -rn
> Routing tables
>
> Internet:
> Destination Gateway Flags Refs Use Netif Expire
> 0.0.0.0/24 link#4 UC 0 0 vlan0
> 0.0.0.0/24 link#2 UC 0 0 dc1
> 127.0.0.1 127.0.0.1 UH 0 0 lo0
> 0.0.0.0/24 link#1 UC 0 0 dc0
> 192.168.0.7 00:16:e0:25:c5:e1 UHLW 1 0 dc0 878
>
>
> Is it a known problem (or, may be, PEBKAC case)?
>
>
> TIA,
> Yuri
Attached patch fixes the problem for me.
Yuri
-------------- next part --------------
diff -ruN /usr/src/usr.bin/netstat/netstat.h /home/yuri/tmp/netstat/netstat.h
--- /usr/src/usr.bin/netstat/netstat.h 2007-07-16 21:15:55.000000000 +0400
+++ /home/yuri/tmp/netstat/netstat.h 2008-02-07 13:37:04.000000000 +0300
@@ -124,7 +124,7 @@
void upHex(char *);
char *routename(u_long);
-char *netname(u_long, u_long);
+char *netname(in_addr_t, u_long);
char *atalk_print(struct sockaddr *, int);
char *atalk_print2(struct sockaddr *, struct sockaddr *, int);
char *ipx_print(struct sockaddr *);
diff -ruN /usr/src/usr.bin/netstat/route.c /home/yuri/tmp/netstat/route.c
--- /usr/src/usr.bin/netstat/route.c 2007-11-13 01:43:29.000000000 +0300
+++ /home/yuri/tmp/netstat/route.c 2008-02-07 13:43:42.000000000 +0300
@@ -840,7 +840,7 @@
* The address is assumed to be that of a net or subnet, not a host.
*/
char *
-netname(u_long in, u_long mask)
+netname(in_addr_t in, u_long mask)
{
char *cp = 0;
static char line[MAXHOSTNAMELEN];
@@ -859,7 +859,7 @@
strncpy(line, cp, sizeof(line) - 1);
line[sizeof(line) - 1] = '\0';
} else {
- inet_ntop(AF_INET, (char *)&in, line, sizeof(line) - 1);
+ inet_ntop(AF_INET, &in, line, sizeof(line) - 1);
}
domask(line + strlen(line), i, mask);
return (line);
More information about the freebsd-net
mailing list