Subject: bin/4022: netstat -r does not print netmask/cidr prefix
To: None <gnats-bugs@gnats.netbsd.org>
From: None <hwr@pilhuhn.de>
List: netbsd-bugs
Date: 08/21/1997 13:20:44
>Number: 4022
>Category: bin
>Synopsis: netstat -r does not print netmask/cidr prefix
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu Aug 21 04:35:01 1997
>Last-Modified:
>Originator: Heiko W.Rupp
>Organization:
private
>Release: 1.1
>Environment:
System: NetBSD snert.pilhuhn.de 1.1 NetBSD 1.1 (SNERT+PPP) #11: Thu Jan 30 11:00:49 MET 1997 hwr@snert.pilhuhn.de:/usr/src/sys/arch/i386/compile/SNERT+PPP i386
>Description:
netstat does not print the netmask that comes with a route. for
claasfull routes this does not matter as netstat does the right
thing and only displays the part of the destination address that
is needed.
For CIDR adresses this fails.
>How-To-Repeat:
# route add 10.1.2.3 -netmask 255.255.0.0 snert
# route add 10.1.2.3 -netmask 255.255.128.0 pilhuhn
# netstat -r | grep 10
10.1 pilhuhn.de UGS 0 0 - ed0 =>
10.1 snert UGS 0 0 - ed0
With my hack below this gets:
snert# ./netstat -r | grep 10
10.1 /17 pilhuhn.de UGS 0 0 - ed0 =>
10.1 /16 snert UGS 0 0 - ed0
This seems to apply to all versions - not only to 1.1/i386
>Fix:
Something like:
Formatting is very bad, but I think you'll get the point ...
*** route.c,1 Thu Aug 21 11:39:26 1997
--- route.c Thu Aug 21 13:05:53 1997
***************
*** 452,457 ****
--- 452,465 ----
static char name[16];
p_sockaddr(kgetsa(rt_key(rt)), rt->rt_flags, WID_DST);
+ if(rt->rt_flags &RTF_HOST)
+ printf("/32 ");
+ else {
+ if(rt->rt_nodes[0].rn_b == -1)
+ printf("/0 ");
+ else
+ printf("/%-2d ",(-(rt->rt_nodes[0].rn_b)-33));
+ }
p_sockaddr(kgetsa(rt->rt_gateway), RTF_HOST, WID_GW);
p_flags(rt->rt_flags, "%-6.6s ");
printf("%6d %8d ", rt->rt_refcnt, rt->rt_use);
>Audit-Trail:
>Unformatted: