From leres@fun.ee.lbl.gov  Sun Sep 10 16:02:10 2000
Return-Path: <leres@fun.ee.lbl.gov>
Received: from fun.ee.lbl.gov (fun.ee.lbl.gov [131.243.1.81])
	by hub.freebsd.org (Postfix) with ESMTP id 04A1237B424
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Sep 2000 16:02:10 -0700 (PDT)
Received: (from leres@localhost)
	by fun.ee.lbl.gov (8.11.0/8.11.0) id e8AN29271497;
	Sun, 10 Sep 2000 16:02:09 -0700 (PDT)
Message-Id: <200009102302.e8AN29271497@fun.ee.lbl.gov>
Date: Sun, 10 Sep 2000 16:02:08 -0700
From: Craig Leres <leres@ee.lbl.gov>
Sender: leres@fun.ee.lbl.gov
To: FreeBSD-gnats-submit@freebsd.org
Cc: leres@ee.lbl.gov (Craig Leres)
Subject: [PATCH] ifinfo dumps core (plus other fixes)
X-Send-Pr-Version: 3.2

>Number:         21177
>Category:       bin
>Synopsis:       [PATCH] ifinfo dumps core (plus other fixes)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 10 16:10:01 PDT 2000
>Closed-Date:    Wed Sep 13 12:55:34 PDT 2000
>Last-Modified:  Wed Sep 13 12:56:27 PDT 2000
>Originator:     Craig Leres
>Release:        FreeBSD 4.1-RELEASE i386
>Organization:
Lawrence Berkeley National Laboratory
>Environment:
>Description:

Ifinfo fails to compile; if you ifdef out the obsolete if_data
struct references and your kerenl has gif(4) interfaces, it dumps
core. It's also missing a few interface descriptions.

>How-To-Repeat:

fun 1182 % ifinfo
[...]
Interface gif0:
	flags: ffff8010
	promiscuous listeners: 0
	send queue length: 0
	send queue max length: 50
	send queue drops: 0
Segmentation fault (core dumped)

>Fix:

Appended is a context diff to tools/tools/ifinfo/ifinfo.c

===================================================================
RCS file: RCS/ifinfo.c,v
retrieving revision 1.1
diff -c -r1.1 ifinfo.c
*** ifinfo.c	2000/09/10 22:44:21	1.1
--- ifinfo.c	2000/09/10 22:51:52
***************
*** 160,168 ****
--- 160,170 ----
  	printf("\tinput queue drops: %lu\n", ifmd->ifmd_data.ifi_iqdrops);
  	printf("\tpackets for unknown protocol: %lu\n", 
  	       ifmd->ifmd_data.ifi_noproto);
+ #ifdef notdef
  	printf("\treceive timing: %lu usec\n", ifmd->ifmd_data.ifi_recvtiming);
  	printf("\ttransmit timing: %lu usec\n", 
  	       ifmd->ifmd_data.ifi_xmittiming);
+ #endif
  }
  
  static const char *const if_types[] = {
***************
*** 220,226 ****
  	"SONETVT",
  	"SMDS InterCarrier Interface",
  	"Proprietary virtual interface",
! 	"Proprietary multiplexing"
  };
  #define	NIFTYPES ((sizeof if_types)/(sizeof if_types[0]))
  
--- 222,231 ----
  	"SONETVT",
  	"SMDS InterCarrier Interface",
  	"Proprietary virtual interface",
! 	"Proprietary multiplexing",
! 	"Generic tunnel interface",
! 	"IPv6-to-IPv4 TCP relay capturing interface",
! 	"6to4 tunnel interface"
  };
  #define	NIFTYPES ((sizeof if_types)/(sizeof if_types[0]))
  
***************
*** 229,235 ****
  {
  	static char buf[256];
  
! 	if (type <= 0 || type > NIFTYPES) {
  		sprintf(buf, "unknown type %d", type);
  		return buf;
  	}
--- 234,240 ----
  {
  	static char buf[256];
  
! 	if (type <= 0 || type >= NIFTYPES) {
  		sprintf(buf, "unknown type %d", type);
  		return buf;
  	}

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wollman 
State-Changed-When: Wed Sep 13 12:55:34 PDT 2000 
State-Changed-Why:  
Applied in revs. 1.6 and 1.5.2.1. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21177 
>Unformatted:
