Subject: bin/7593: "ifconfig interface" defaults only to inet
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itojun@itojun.org>
List: netbsd-bugs
Date: 05/17/1999 00:22:12
>Number:         7593
>Category:       bin
>Synopsis:       "ifconfig interface" defaults only to inet
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 17 00:05:01 1999
>Last-Modified:
>Originator:     Jun-ichiro itojun Hagino
>Organization:
itojun.org
>Release:        NetBSD 1.4
>Environment:
IBM ThinkPad 570
NetBSD 1.4
System: NetBSD lychee.itojun.org 1.4 NetBSD 1.4 (LYCHEE.v6) #15: Sun May 16 15:56:25 JST 1999 itojun@lychee.itojun.org:/export/home/itojun/hyd14/sys/arch/i386/compile/LYCHEE.v6 i386


>Description:
	src/sbin/ifconfig/ifconfig.c:main() initializes variable afp before
	calling status().  On the contrary, status() expects afp to be NULL
	when no address family is specified (see very last part of status).
	I believe the initialization (afp = afs) is too early.

	The current source code defaults to inet, if no address family is
	specified.
 >% ifconfig ne2
 >ne2: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 >	media: Ethernet manual
 >	inet 203.178.141.206 netmask 0xffffffe0 broadcast 203.178.141.223

	However, this should be all the address families available on the
	interface, like:
 >% ifconfig ne2
 >ne2: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 >	media: Ethernet manual
 >	inet 203.178.141.206 netmask 0xffffffe0 broadcast 203.178.141.223
 >	inet6 fe80:1::a00:5aff:fe38:6f86 prefixlen 64
 >% ifconfig ne2 inet
 >ne2: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 >	media: Ethernet manual
 >	inet 203.178.141.206 netmask 0xffffffe0 broadcast 203.178.141.223

	The problem becomes visible only if you have configured non-inet
	addresses onto interface.

>How-To-Repeat:
	take arbitrary ethernet interface (say ne2) with multiple addresses
	with multiple address families, and do
	% ifconfig ne2
	only inet will be displayed.
>Fix:
	

*** ifconfig.c.r14	Mon May 17 15:29:49 1999
--- ifconfig.c	Mon May 17 15:30:39 1999
***************
*** 367,375 ****
  		}
  	}
  
  	if (afp == NULL)
! 		afp = afs;
! 	af = ifr.ifr_addr.sa_family = afp->af_af;
  
  	/* Get information about the interface. */
  	(void) strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
--- 367,375 ----
  		}
  	}
  
+ 	/* initialize af, just for use in getinfo() */
  	if (afp == NULL)
! 		af = afs->af_af;
  
  	/* Get information about the interface. */
  	(void) strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
***************
*** 381,386 ****
--- 381,391 ----
  		status(NULL, 0);
  		exit(0);
  	}
+ 
+ 	/* following operations assume inet familiy as default */
+ 	if (afp == NULL)
+ 		afp = afs;
+ 	af = ifr.ifr_addr.sa_family = afp->af_af;
  
  	/* Process commands. */
  	while (argc > 0) {
>Audit-Trail:
>Unformatted: