From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 11 23:50:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C0AD16A41B for ; Fri, 11 Jan 2008 23:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 06E0213C458 for ; Fri, 11 Jan 2008 23:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0BNo0KV008845 for ; Fri, 11 Jan 2008 23:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0BNo0dH008844; Fri, 11 Jan 2008 23:50:00 GMT (envelope-from gnats) Resent-Date: Fri, 11 Jan 2008 23:50:00 GMT Resent-Message-Id: <200801112350.m0BNo0dH008844@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Alexander Chernikov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB97916A468 for ; Fri, 11 Jan 2008 23:48:43 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 8A2D613C459 for ; Fri, 11 Jan 2008 23:48:43 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m0BNlXxp085209 for ; Fri, 11 Jan 2008 23:47:33 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m0BNlXrK085208; Fri, 11 Jan 2008 23:47:33 GMT (envelope-from nobody) Message-Id: <200801112347.m0BNlXrK085208@www.freebsd.org> Date: Fri, 11 Jan 2008 23:47:33 GMT From: Alexander Chernikov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/119581: [patch] systat(1): systat -ifstat fails if iface table is `sparse` X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jan 2008 23:50:01 -0000 >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 #include #include +#include #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: