From ffe3a1337c1380a5b79651b34037c6c9f66b9ea1 Mon Sep 17 00:00:00 2001 From: Stephan Brunner Date: Tue, 1 Nov 2022 09:51:14 +0100 Subject: Use 64-bit interface statistics rather than doing custom 32-bit overflow handling. When a link has a relatively high throughput, the 32-bit packet and byte counters could overflow multiple times between accounting runs. To accommodate this limitation, directly use 64-bit interface statistics. This also gets rid of the internal giga-word counters. --- accel-pppd/radius/acct.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'accel-pppd/radius') diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index 9300bcb8..8b3f95d5 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -41,7 +41,7 @@ static int req_set_RA(struct rad_req_t *req, const char *secret) static int req_set_stat(struct rad_req_t *req, struct ap_session *ses) { - struct rtnl_link_stats stats; + struct rtnl_link_stats64 stats; struct radius_pd_t *rpd = req->rpd; struct timespec ts; int ret = 0; @@ -52,12 +52,12 @@ static int req_set_stat(struct rad_req_t *req, struct ap_session *ses) clock_gettime(CLOCK_MONOTONIC, &ts); if (ap_session_read_stats(ses, &stats) == 0) { - rad_packet_change_int(req->pack, NULL, "Acct-Input-Octets", stats.rx_bytes); - rad_packet_change_int(req->pack, NULL, "Acct-Output-Octets", stats.tx_bytes); - rad_packet_change_int(req->pack, NULL, "Acct-Input-Packets", stats.rx_packets); - rad_packet_change_int(req->pack, NULL, "Acct-Output-Packets", stats.tx_packets); - rad_packet_change_int(req->pack, NULL, "Acct-Input-Gigawords", rpd->ses->acct_input_gigawords); - rad_packet_change_int(req->pack, NULL, "Acct-Output-Gigawords", rpd->ses->acct_output_gigawords); + rad_packet_change_int(req->pack, NULL, "Acct-Input-Octets", (int) (stats.rx_bytes & UINT32_MAX)); + rad_packet_change_int(req->pack, NULL, "Acct-Output-Octets", (int) (stats.tx_bytes & UINT32_MAX)); + rad_packet_change_int(req->pack, NULL, "Acct-Input-Packets", (int) (stats.rx_packets & UINT32_MAX)); + rad_packet_change_int(req->pack, NULL, "Acct-Output-Packets", (int) (stats.tx_packets & UINT32_MAX)); + rad_packet_change_int(req->pack, NULL, "Acct-Input-Gigawords", (int) (stats.rx_bytes >> (sizeof(uint32_t) * 8))); + rad_packet_change_int(req->pack, NULL, "Acct-Output-Gigawords", (int) (stats.tx_bytes >> (sizeof(uint32_t) * 8))); } else ret = -1; -- cgit v1.2.3