Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jan 2008 23:47:33 GMT
From:      Alexander Chernikov <admin@su29.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/119581: [patch] systat(1): systat -ifstat fails if iface table is `sparse`
Message-ID:  <200801112347.m0BNlXrK085208@www.freebsd.org>
Resent-Message-ID: <200801112350.m0BNo0dH008844@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         119581
>Category:       bin
>Synopsis:       [patch] systat(1): systat -ifstat fails if iface table is `sparse`
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 11 23:50:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Chernikov
>Release:        6.2-RELEASE
>Organization:
>Environment:
FreeBSD pochta.alo.ru 6.2-RELEASE-p1 FreeBSD 6.2-RELEASE-p1 #1: Sun Mar 25 13:26:51 MSD 2007     root@pochta.alo.ru:/usr/obj/usr/src/sys/POCHTA  amd64
>Description:
systat -ifstat returns 
'systat: sysctl error getting interface data: No such file or directory'
if interface from the 'middle' of interface table is deleted.

The problem resides in an incorrect ifmib(4) sysctl usage.
systat(1) does not handle `sparse` table case correctly and exits instead of skipping row.
>How-To-Repeat:
tcsh# kldload ng_iface
tcsh# ngctl mkpeer iface dummy inet
tcsh# ngctl mkpeer iface dummy inet
tcsh# ngctl mkpeer iface dummy inet
[We now got 3 ngX interfaces, ng0-2]

tcsh# ngctl shutdown ng1:
tcsh# systat -ifstat
systat: sysctl error getting interface data: No such file or directory

>Fix:
Apply the following patch:


Patch attached with submission follows:

--- /usr/src/usr.bin/systat/ifstat.c	2008-01-12 01:14:47.000000000 +0300
+++ /usr/src/usr.bin/systat/ifstat.c	2008-01-12 01:25:22.000000000 +0300
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <err.h>
+#include <errno.h>
 
 #include "systat.h"
 #include "extern.h"
@@ -384,8 +385,8 @@
 	datalen = sizeof(*data);
 	name[4] = row;
 
-	if (sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
-	    (size_t)0) != 0)
+	if ((sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
+	    (size_t)0) != 0) && (errno != ENOENT))
 		IFSTAT_ERR(2, "sysctl error getting interface data");
 }
 


>Release-Note:
>Audit-Trail:
>Unformatted:



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