Subject: kern/1285: SIOCGIFCONF makes bad names for if10+
To: None <gnats-bugs@gnats.netbsd.org>
From: Jarkko Torppa <torppa@cute.fi>
List: netbsd-bugs
Date: 07/27/1995 06:17:20
>Number:         1285
>Category:       kern
>Synopsis:       SIOCGIFCONF ioctl generates bad names for if10+
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 26 23:50:02 1995
>Last-Modified:
>Originator:     
>Organization:
-- 
 Jarkko.Torppa@cute.fi     +358-0-648090          Cute Communications Oy
>Release:        also present in 26.07.1995 sup
>Environment:
	
System: NetBSD tuhnu.cute.fi 1.0A NetBSD 1.0A (TUHNU) #5: Mon Jul 17 10:45:07 EET DST 1995 torppa@tuhnu.cute.fi:/console/NetBSD/NetBSD-current/src/sys/arch/i386/compile/TUHNU i386


>Description:

SIOCGIFCONF(net/if.c ifconf()) makes names for iterfaces from straight
collating ascii sequence starting from '0', that works untill it
hits 10 which is named 'if:'

Other parts of the module(net/if.c) seem to make nicer names.
>How-To-Repeat:

configure 11+ ppp devices, try ifconfig -a

>Fix:

Ugly patch included. it would be nicer to generate all interface names
in one place ?

--- if.c.orig	Tue Apr 25 13:21:57 1995
+++ if.c	Thu Jul 27 06:06:39 1995
@@ -583,6 +583,7 @@
 	register char *cp, *ep;
 	struct ifreq ifr, *ifrp;
 	int space = ifc->ifc_len, error = 0;
+	char workbuf[12],*unitname;
 
 	ifrp = ifc->ifc_req;
 	ep = ifr.ifr_name + sizeof (ifr.ifr_name) - 2;
@@ -590,7 +591,9 @@
 		strncpy(ifr.ifr_name, ifp->if_name, sizeof(ifr.ifr_name) - 2);
 		for (cp = ifr.ifr_name; cp < ep && *cp; cp++)
 			continue;
-		*cp++ = '0' + ifp->if_unit; *cp = '\0';
+		unitname=sprint_d((u_int)ifp->if_unit,workbuf,sizeof(workbuf));
+		strcpy(cp,unitname);
+
 		if ((ifa = ifp->if_addrlist) == 0) {
 			bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
 			error = copyout((caddr_t)&ifr, (caddr_t)ifrp,

>Audit-Trail:
>Unformatted: