bin/112126: [patch] netstat(1) segfaults on unusual ICMP statistics

Maxim Konovalov maxim at macomnet.ru
Fri Apr 27 05:20:10 UTC 2007


The following reply was made to PR bin/112126; it has been noted by GNATS.

From: Maxim Konovalov <maxim at macomnet.ru>
To: Christoph Weber-Fahr <wefa2 at gmx.de>
Cc: bug-followup at FreeBSD.org
Subject: Re: bin/112126: [patch] netstat(1) segfaults on unusual ICMP statistics
Date: Fri, 27 Apr 2007 09:12:24 +0400 (MSD)

 On Fri, 27 Apr 2007, 03:50+0200, Christoph Weber-Fahr wrote:
 
 > Hello,
 >
 > Maxim Konovalov wrote:
 > > On Thu, 26 Apr 2007, 00:00+0200, Chris wrote:
 > > > > +static  const char *icmpnames[ICMP_MAXTYPE + 1] = {
 > > > with this he actually avoids the crash in case of an
 > > > out of sync kernel interface (assumed the array gets
 > > > automatically zeroed at allocation time - does it ? )
 > > >
 > > > But this still produces a very funny netstat output
 > > > with just numbers and no labels. I continue to prefer
 > > > my suggestion.
 > >
 > > I see:
 > >
 > >         Output histogram:
 > >                 echo reply: 41
 > >                 destination unreachable: 495
 > > [...]
 > >         Input histogram:
 > >                 echo reply: 12
 > >                 destination unreachable: 1
 > >                 echo: 41
 > >                 #20: 7
 > >                 icmp traceroute: 16
 > >                 mobile registration req: 25
 > >                 #37: 31
 >
 > Actually, you don't see that. You'd see:
 
 I just run hacked version of ping(8):
 
 for i in `jot 255`; do; /usr/obj/usr/src/sbin/ping/ping -c 1 -x $i;
 
 Here what I see after it:
 
         Input histogram:
                 echo reply: 4969
                 #1: 1
                 #2: 1
                 destination unreachable: 4
                 source quench: 1
                 routing redirect: 1
                 #6: 1
                 #7: 1
                 echo: 27
                 router advertisement: 1
                 router solicitation: 1
                 time exceeded: 1
                 parameter problem: 1
                 time stamp: 1
                 time stamp reply: 2
                 information request: 1
                 information request reply: 1
                 address mask request: 1
                 address mask reply: 2
                 #19: 1
                 #20: 1
                 #21: 1
                 #22: 1
                 #23: 1
                 #24: 1
                 #25: 1
                 #26: 1
                 #27: 1
                 #28: 1
                 #29: 1
                 icmp traceroute: 1
                 datagram conversion error: 1
                 mobile host redirect: 1
                 IPv6 where-are-you: 1
                 IPv6 i-am-here: 1
                 mobile registration req: 1
                 mobile registration reply: 1
                 domain name request: 1
                 domain name reply: 1
                 icmp SKIP: 1
                 icmp photuris: 1
 
 >          Input histogram:
 >                  echo reply: 12
 >                  destination unreachable: 1
 >                  echo: 41
 >                  #20: 7
 >                  icmp traceroute: 16
 >                  mobile registration req: 25
 >                  #37: 31
 > 		 8
 >                  15
 >
 > Note the last two untagged values. They
 > are created when the kernel, which in
 > the meantime has a ICM_MAXTYPE at, say, 49,
 > has logged 8 packets of type 44, and 15 of type 47.
 >
 > > What is yours?
 >
 > My variant would produce:
 >
 >          Input histogram:
 >                  echo reply: 12
 >                  destination unreachable: 1
 >                  echo: 41
 >                  #20: 7
 >                  icmp traceroute: 16
 >                  mobile registration req: 25
 >                  #37: 31
 > 		 unknown ICMP #44: 8
 >                  unknown ICMP #47: 15
 >
 > This is preferable because it both gives more
 > information (you still get the type number) and
 > doesn't break the tag: value format that many
 > monitoring setups use for simple parsing.
 
 icmpstat.icps_outhist and icps_inhist are definde this way:
 
 	u_long icps_outhist[ICMP_MAXTYPE + 1];
 	u_long icps_inhist[ICMP_MAXTYPE + 1];
 
 How do you fit types > ICMP_MAXTYPE + 1 there?
 
 -- 
 Maxim Konovalov


More information about the freebsd-bugs mailing list