Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Mar 1996 11:33:09 -0600
From:      Alex Nash <alex@zen.nash.org>
To:        bugs@freebsd.org
Subject:   netstat output bug
Message-ID:  <199603311733.LAA12210@zen.nash.org>

next in thread | raw e-mail | index | archive | help
[I tried to use send-pr, but I got:

  send-pr: could not read /usr/local/lib/gnats/FreeBSD for categories list.

I looked in the FAQ, Handbook, www.freebsd.org, ftp.cdrom.com and didn't 
find a way to make this work.  What did I miss?]



OS Version:   2.1.0-RELEASE
Bug severity: Minor
Program:      /usr/bin/netstat
Submitted by: Alex Nash (nash@mcs.com)

Problem:
netstat's interface display option prints many unsigned long values
as signed ints (this is especially noticeable when using the -b
option).

Suggested Fix:
Apply the following patch to /usr/src/usr.bin/netstat/if.c:

diff -c netstat/if.c netstat-2.1.0-RELEASE/if.c
*** netstat/if.c	Sun Mar 31 02:19:42 1996
--- netstat-2.1.0-RELEASE/if.c	Tue Mar 26 18:28:15 1996
***************
*** 116,122 ****
  				return;
  			tname[15] = '\0';
  			ifnetaddr = (u_long)ifnet.if_next;
! 			snprintf(name, 32, "%s%hd", tname, ifnet.if_unit);
  			if (interface != 0 && (strcmp(name, interface) != 0))
  				continue;
  			cp = index(name, '\0');
--- 116,122 ----
  				return;
  			tname[15] = '\0';
  			ifnetaddr = (u_long)ifnet.if_next;
! 			snprintf(name, 32, "%s%d", tname, ifnet.if_unit);
  			if (interface != 0 && (strcmp(name, interface) != 0))
  				continue;
  			cp = index(name, '\0');
***************
*** 125,131 ****
  			*cp = '\0';
  			ifaddraddr = (u_long)ifnet.if_addrlist;
  		}
! 		printf("%-5.5s %-5lu ", name, ifnet.if_mtu);
  		if (ifaddraddr == 0) {
  			printf("%-11.11s ", "none");
  			printf("%-15.15s ", "none");
--- 125,131 ----
  			*cp = '\0';
  			ifaddraddr = (u_long)ifnet.if_addrlist;
  		}
! 		printf("%-5.5s %-5d ", name, ifnet.if_mtu);
  		if (ifaddraddr == 0) {
  			printf("%-11.11s ", "none");
  			printf("%-15.15s ", "none");
***************
*** 201,217 ****
  			}
  			ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
  		}
! 		printf("%8lu %5lu ",
  		    ifnet.if_ipackets, ifnet.if_ierrors);
  		if (bflag)
! 			printf("%10lu ", ifnet.if_ibytes);
! 		printf("%8lu %5lu ",
  		    ifnet.if_opackets, ifnet.if_oerrors);
  		if (bflag)
! 			printf("%10lu ", ifnet.if_obytes);
! 		printf("%5lu", ifnet.if_collisions);
  		if (tflag)
! 			printf(" %3hd", ifnet.if_timer);
  		if (dflag)
  			printf(" %3d", ifnet.if_snd.ifq_drops);
  		putchar('\n');
--- 201,217 ----
  			}
  			ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
  		}
! 		printf("%8d %5d ",
  		    ifnet.if_ipackets, ifnet.if_ierrors);
  		if (bflag)
! 			printf("%10d ", ifnet.if_ibytes);
! 		printf("%8d %5d ",
  		    ifnet.if_opackets, ifnet.if_oerrors);
  		if (bflag)
! 			printf("%10d ", ifnet.if_obytes);
! 		printf("%5d", ifnet.if_collisions);
  		if (tflag)
! 			printf(" %3d", ifnet.if_timer);
  		if (dflag)
  			printf(" %3d", ifnet.if_snd.ifq_drops);
  		putchar('\n');
***************
*** 266,272 ****
  		if (kread((u_long)ifnet.if_name, tname, 16))
  			break;
  		tname[15] = '\0';
! 		snprintf(name, 16, "%s%hd", tname, ifnet.if_unit);
  		if (interface && strcmp(name, interface) == 0)
  			interesting = ip;
  		snprintf(ip->ift_name, 16, "(%s)", name);;
--- 266,272 ----
  		if (kread((u_long)ifnet.if_name, tname, 16))
  			break;
  		tname[15] = '\0';
! 		snprintf(name, 16, "%s%d", tname, ifnet.if_unit);
  		if (interface && strcmp(name, interface) == 0)
  			interesting = ip;
  		snprintf(ip->ift_name, 16, "(%s)", name);;
***************
*** 338,354 ****
  			continue;
  		}
  		if (ip == interesting) {
! 			printf("%8lu %5lu ",
  				ifnet.if_ipackets - ip->ift_ip,
  				ifnet.if_ierrors - ip->ift_ie);
  			if (bflag)
! 				printf("%10lu ", ifnet.if_ibytes - ip->ift_ib);
! 			printf("%8lu %5lu ",
  				ifnet.if_opackets - ip->ift_op,
  				ifnet.if_oerrors - ip->ift_oe);
  			if (bflag)
! 				printf("%10lu ", ifnet.if_obytes - ip->ift_ob);
! 			printf("%5lu", ifnet.if_collisions - ip->ift_co);
  			if (dflag)
  				printf(" %5u",
  				    ifnet.if_snd.ifq_drops - ip->ift_dr);
--- 338,354 ----
  			continue;
  		}
  		if (ip == interesting) {
! 			printf("%8u %5u ",
  				ifnet.if_ipackets - ip->ift_ip,
  				ifnet.if_ierrors - ip->ift_ie);
  			if (bflag)
! 				printf("%10u ", ifnet.if_ibytes - ip->ift_ib);
! 			printf("%8u %5u ",
  				ifnet.if_opackets - ip->ift_op,
  				ifnet.if_oerrors - ip->ift_oe);
  			if (bflag)
! 				printf("%10u ", ifnet.if_obytes - ip->ift_ob);
! 			printf("%5u", ifnet.if_collisions - ip->ift_co);
  			if (dflag)
  				printf(" %5u",
  				    ifnet.if_snd.ifq_drops - ip->ift_dr);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603311733.LAA12210>