From patchwork Mon May 15 14:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 1781494 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=HmCCdvE+; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=t-8ch.de header.i=@t-8ch.de header.a=rsa-sha256 header.s=mail header.b=bj/n2q7k; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKj9t4Gzgz20KF for ; Tue, 16 May 2023 00:56:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=SDROY+zqlPX1Pgj5LkyW6zP9eVfC2jrOxne6hD4aUMo=; b=HmCCdvE+gp0zi/ ujEGR+OLyZt3/rZE0gP9o2RobHD2gz3WIhHCXc2mhvhImTM14smRlGgmgVn1CrheDhhVXr2hzEaQH 2rCzwc/2fbqpjaLd6bx1hTkrXw1mwYdIV9ar4v1klkxLHpYG0NvPWVljMq3pdoZ+SlOF9oG4y4Xo8 bbiMGkaEJPIfCc290zv7VEUU0II2w3a0E4at5UYLaeDpx/xblVBmxf6R4oVcOIYJBLQ4V8U1dOb4Q r2Rv0pReizzz8U3wupjGRWINN2seAjt4m1q0EJlTmUHoRVJ1zWt63yz5gtGe4qSaBSYuZ50ZseX5P XDEatu61Ld76WZh67zGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pyZay-002TQA-1C; Mon, 15 May 2023 14:54:40 +0000 Received: from todd.t-8ch.de ([2a01:4f8:c010:41de::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pyZav-002TOZ-2y for openwrt-devel@lists.openwrt.org; Mon, 15 May 2023 14:54:39 +0000 From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1684162475; bh=ftqEo/MxVV2H7eW9mETghKzj7nrsmy5msxqLkkwWNRo=; h=From:To:Cc:Subject:Date:From; b=bj/n2q7krVCSKj/gY47sz4ogS+eEiPZZLXb/vrLyUenPmxpanGPUR0Y3y+S0sT10U lpeQxhxyfkWcuMucXQUzlLLlEjDlAp9WmevuJndno7iRTEfQGYdq3bGTbSrcQUXH1j YOOx77S3/G+PzVoC76vS0FTjL88vJup/GlXypvEE= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH iwinfo] lib: report byte counters as 64 bit values Date: Mon, 15 May 2023 16:54:27 +0200 Message-Id: <20230515145427.1628898-1-thomas@t-8ch.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230515_075438_109979_87A6674A X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The 32bit counter can only count to 4GiB before wrapping. Switching to the 64bit variant avoids this issue. In practice some users are interpreting the counter values as signed integer bringing down the usable range for 32bit values down to only 2GiB. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The 32bit counter can only count to 4GiB before wrapping. Switching to the 64bit variant avoids this issue. In practice some users are interpreting the counter values as signed integer bringing down the usable range for 32bit values down to only 2GiB. Signed-off-by: Thomas Weißschuh --- include/iwinfo.h | 4 ++-- iwinfo_nl80211.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) base-commit: b3888b29535a92584524e14aadf25fcb85e7fed2 diff --git a/include/iwinfo.h b/include/iwinfo.h index eae99302704a..b50de69f49ca 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -240,8 +240,8 @@ struct iwinfo_assoclist_entry { uint64_t rx_drop_misc; struct iwinfo_rate_entry rx_rate; struct iwinfo_rate_entry tx_rate; - uint32_t rx_bytes; - uint32_t tx_bytes; + uint64_t rx_bytes; + uint64_t tx_bytes; uint32_t tx_retries; uint32_t tx_failed; uint64_t t_offset; diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 50bb8f03c2fd..1e0a0c77dc39 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -1554,6 +1554,8 @@ static int nl80211_fill_signal_cb(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 }, [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 }, + [NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 }, + [NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 }, [NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 }, [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 }, @@ -2214,6 +2216,8 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_SIGNAL_AVG] = { .type = NLA_U8 }, [NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 }, + [NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 }, + [NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 }, [NL80211_STA_INFO_TX_RETRIES] = { .type = NLA_U32 }, [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 }, [NL80211_STA_INFO_CONNECTED_TIME]= { .type = NLA_U32 }, @@ -2277,10 +2281,14 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg) sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) nl80211_parse_rateinfo(rinfo, &e->tx_rate); - if (sinfo[NL80211_STA_INFO_RX_BYTES]) + if (sinfo[NL80211_STA_INFO_RX_BYTES64]) + e->rx_bytes = nla_get_u64(sinfo[NL80211_STA_INFO_RX_BYTES64]); + else if (sinfo[NL80211_STA_INFO_RX_BYTES]) e->rx_bytes = nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]); - if (sinfo[NL80211_STA_INFO_TX_BYTES]) + if (sinfo[NL80211_STA_INFO_TX_BYTES64]) + e->tx_bytes = nla_get_u64(sinfo[NL80211_STA_INFO_TX_BYTES64]); + else if (sinfo[NL80211_STA_INFO_TX_BYTES]) e->tx_bytes = nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]); if (sinfo[NL80211_STA_INFO_TX_RETRIES])