Subject: bin/7057: netstat -m fails if no memory allocated
To: None <gnats-bugs@gnats.netbsd.org>
From: Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>
List: netbsd-bugs
Date: 02/27/1999 16:53:16
>Number: 7057
>Category: bin
>Synopsis: netstat -m fails if no memory allocated
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 27 08:05:00 1999
>Last-Modified:
>Originator: Wolfgang Helbig
>Organization:
>Release: NetBSD-current Fri Feb 26
>Environment:
System: NetBSD rvc1 1.3I NetBSD 1.3I (RVC1) #0: Sat Feb 27 16:22:02 CET 1999 helbig@rvc1:/usr/src/sys/arch/i386/compile/RVC1 i386
>Description:
>How-To-Repeat:
Enter "netstat -m" when no mbufs are yet allocated. (like after
reboot)
>Fix:
--- usr.bin/netstat/mbuf.c.orig Sun Oct 19 16:23:11 1997
+++ usr.bin/netstat/mbuf.c Sat Feb 27 16:38:04 1999
@@ -131,7 +131,8 @@
totmem = totmbufs * msize + mbstat.m_clusters * mclbytes;
totfree = mbstat.m_clfree * mclbytes;
printf("%u Kbytes allocated to network (%d%% in use)\n",
- totmem / 1024, (totmem - totfree) * 100 / totmem);
+ totmem / 1024,
+ totmem ? (totmem - totfree) * 100 / totmem : 100);
printf("%lu requests for memory denied\n", mbstat.m_drops);
printf("%lu requests for memory delayed\n", mbstat.m_wait);
printf("%lu calls to protocol drain routines\n", mbstat.m_drain);
>Audit-Trail:
>Unformatted: