From owner-freebsd-net@FreeBSD.ORG Thu Sep 11 21:59:59 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4038B271 for ; Thu, 11 Sep 2014 21:59:59 +0000 (UTC) Received: from mail-la0-x232.google.com (mail-la0-x232.google.com [IPv6:2a00:1450:4010:c03::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C3C79B52 for ; Thu, 11 Sep 2014 21:59:58 +0000 (UTC) Received: by mail-la0-f50.google.com with SMTP id ty20so9326198lab.9 for ; Thu, 11 Sep 2014 14:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=UkOR+mPCH3nbGzBVNqauodF3UYPTUeMHjjdct1kKn1g=; b=TOHYIuc4kJWMD68zMy49ImIXwXFG8gfHm9NblfzPA3hRBpSy9zmZJ3hUxyjPnJyNIT HiIBUSQXJx6ANeZYLNvuWbHsJkdcjWn1tR3mytSg9savNJ+ZHCKV9vzaEtM6xRx/4xTa +fSOXyCuBMv0TilhvAj9gHMJh3N50YYQVMApsZWzD98jd6QphVgVyVAeB8JQ/JmreuVC LpCwLSbHVWmTJBi5s81B88r7zTGhiShZKvMm9Sj6FoL2gmvkJ1kIp8l6QOGVuVskDo82 r2MvP0fwZmRncng34tDoGm5uxwxg5cCayIJYx8Q8UvVh7Jq6RUGww1JnfHZGM2a24KU2 cfdA== MIME-Version: 1.0 X-Received: by 10.112.34.143 with SMTP id z15mr4150630lbi.86.1410472795672; Thu, 11 Sep 2014 14:59:55 -0700 (PDT) Received: by 10.25.21.166 with HTTP; Thu, 11 Sep 2014 14:59:55 -0700 (PDT) Date: Thu, 11 Sep 2014 17:59:55 -0400 Message-ID: Subject: [PATCH] Fix integer truncation in systat -ifstat From: Ryan Stone To: freebsd-net Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Sep 2014 21:59:59 -0000 systat -ifstat currently truncates byte counters down to 32-bit integers. The following fixes the issue, but I'm not very happy with it. u_long is what the rest of our code uses for network counters, but that ends up meaning that our counters are 32-bits wide on 32-bit platforms. I could make it uint64_t but that's not very future proof. RIght now I'm leaning towards punting on the issue and using u_long as there is an awful lot of code that would have to be modified for extended byte counters to actually work on all platforms. [rstone@rstone-laptop systat]svn diff Index: ifstat.c =================================================================== --- ifstat.c (revision 271439) +++ ifstat.c (working copy) @@ -269,8 +269,8 @@ struct if_stat *ifp = NULL; struct timeval tv, new_tv, old_tv; double elapsed = 0.0; - u_int new_inb, new_outb, old_inb, old_outb = 0; - u_int new_inp, new_outp, old_inp, old_outp = 0; + u_long new_inb, new_outb, old_inb, old_outb = 0; + u_long new_inp, new_outp, old_inp, old_outp = 0; SLIST_FOREACH(ifp, &curlist, link) { /*