From owner-svn-ports-head@FreeBSD.ORG Thu Oct 2 19:11:09 2014 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0EF5A52C; Thu, 2 Oct 2014 19:11:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EE8411DC; Thu, 2 Oct 2014 19:11:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s92JB8qP048402; Thu, 2 Oct 2014 19:11:08 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s92JB82f048400; Thu, 2 Oct 2014 19:11:08 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201410021911.s92JB82f048400@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 2 Oct 2014 19:11:08 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r369851 - in head/devel/plan9port: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Oct 2014 19:11:09 -0000 Author: glebius (src committer) Date: Thu Oct 2 19:11:07 2014 New Revision: 369851 URL: https://svnweb.freebsd.org/changeset/ports/369851 QAT: https://qat.redports.org/buildarchive/r369851/ Log: Use getifaddrs(3) instead of kvm(3) to access ifnet statistics. Fixes current breakage on head and future ones. Approved by: bapt (blanket) Added: head/devel/plan9port/files/patch-src-cmd-auxstats-FreeBSD.c (contents, props changed) Modified: head/devel/plan9port/Makefile Modified: head/devel/plan9port/Makefile ============================================================================== --- head/devel/plan9port/Makefile Thu Oct 2 19:07:34 2014 (r369850) +++ head/devel/plan9port/Makefile Thu Oct 2 19:11:07 2014 (r369851) @@ -3,7 +3,7 @@ PORTNAME= plan9port PORTVERSION= 20140306 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel plan9 MASTER_SITES= http://swtch.com/${PORTNAME}/ Added: head/devel/plan9port/files/patch-src-cmd-auxstats-FreeBSD.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/plan9port/files/patch-src-cmd-auxstats-FreeBSD.c Thu Oct 2 19:11:07 2014 (r369851) @@ -0,0 +1,89 @@ +--- src/cmd/auxstats/FreeBSD.c.orig 2010-03-18 01:25:34.000000000 +0300 ++++ src/cmd/auxstats/FreeBSD.c 2014-10-02 22:55:32.000000000 +0400 +@@ -8,20 +8,15 @@ + #include + #include + #include +-#include + #include + #include +-#if __FreeBSD_version < 600000 +-#include +-#endif + #include + #include + #include + #include ++#include + #include "dat.h" + +-/* XXX: #if __FreeBSD_version */ +- + void xapm(int); + void xloadavg(int); + void xcpu(int); +@@ -45,7 +40,6 @@ + static kvm_t *kvm; + + static struct nlist nl[] = { +- { "_ifnet" }, + { "_cp_time" }, + { "" } + }; +@@ -86,44 +80,26 @@ + void + xnet(int first) + { ++ struct ifaddrs *ifap, *ifa; + ulong out, in, outb, inb, err; +- static ulong ifnetaddr; +- ulong addr; +- struct ifnet ifnet; +- struct ifnethead ifnethead; +- char name[16]; + + if(first) + return; + +- if(ifnetaddr == 0){ +- ifnetaddr = nl[0].n_value; +- if(ifnetaddr == 0) +- return; +- } +- +- if(kread(ifnetaddr, (char*)&ifnethead, sizeof ifnethead) < 0) ++ if (getifaddrs(&ifap) != 0) + return; + + out = in = outb = inb = err = 0; +- addr = (ulong)TAILQ_FIRST(&ifnethead); +- while(addr){ +-#if __FreeBSD_version < 500000 +- if(kread(addr, (char*)&ifnet, sizeof ifnet) < 0 +- || kread((ulong)ifnet.if_name, name, 16) < 0) +- return; +-#else +- if(kread(addr, (char*)&ifnet, sizeof ifnet) < 0 +- || kread((ulong)ifnet.if_dname, name, 16) < 0) +- return; +-#endif +- name[15] = 0; +- addr = (ulong)TAILQ_NEXT(&ifnet, if_link); +- out += ifnet.if_opackets; +- in += ifnet.if_ipackets; +- outb += ifnet.if_obytes; +- inb += ifnet.if_ibytes; +- err += ifnet.if_oerrors+ifnet.if_ierrors; ++ ++#define IFA_STAT(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s) ++ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { ++ if (ifa->ifa_addr->sa_family != AF_LINK) ++ continue; ++ out += IFA_STAT(opackets); ++ in += IFA_STAT(ipackets); ++ outb += IFA_STAT(obytes); ++ inb += IFA_STAT(ibytes); ++ err += IFA_STAT(oerrors) + IFA_STAT(ierrors); + } + Bprint(&bout, "etherin %lud 1000\n", in); + Bprint(&bout, "etherout %lud 1000\n", out);