Subject: inet6 userland and non-inet6 kernel
To: None <current-users@netbsd.org>
From: Jukka Salmi <j+nbsd@2006.salmi.ch>
List: current-users
Date: 05/27/2006 18:04:18
--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

running a kernel missing INET6 and executing netstat(1) built from
HEAD sources without any special options results in

$ netstat -an
Active Internet connections (including servers)
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
[...]
tcp        0      0  *.23                   *.*                    LISTEN
tcp        0      0  *.22                   *.*                    LISTEN
[...]
udp        0      0  *.123                  *.*                   
udp        0      0  *.68                   *.*                   
netstat: sysctlnametomib: No such file or directory

Is this userland / kernel combination considered "supported"? The
attached patch seems to fix the problem.


Cheers, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: usr.bin/netstat/inet6.c
===================================================================
RCS file: /cvsroot/src/usr.bin/netstat/inet6.c,v
retrieving revision 1.37
diff -u -p -r1.37 inet6.c
--- usr.bin/netstat/inet6.c	21 May 2006 21:01:56 -0000	1.37
+++ usr.bin/netstat/inet6.c	27 May 2006 16:03:24 -0000
@@ -123,6 +123,7 @@ extern char *tcpstates[];
 #include <netdb.h>
 
 #include <err.h>
+#include <errno.h>
 #include <kvm.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -248,6 +249,7 @@ ip6protopr(off, name)
 		int mib[8];
 		size_t namelen = 0, size = 0, i;
 		char *mibname = NULL;
+		extern int errno;
 
 		memset(mib, 0, sizeof(mib));
 
@@ -255,8 +257,10 @@ ip6protopr(off, name)
 			err(1, "asprintf");
 
 		/* get dynamic pcblist node */
-		if (sysctlnametomib(mibname, mib, &namelen) == -1)
+		if (sysctlnametomib(mibname, mib, &namelen) == -1) {
+			if (errno == ENOENT) return;
 			err(1, "sysctlnametomib");
+		}
 
 		if (sysctl(mib, sizeof(mib) / sizeof(*mib), NULL, &size,
 		    NULL, 0) == -1)

--zhXaljGHf11kAtnf--