diff options
author | Stephan Brunner <s.brunner@stephan-brunner.net> | 2022-11-01 09:51:14 +0100 |
---|---|---|
committer | Stephan Brunner <s.brunner@stephan-brunner.net> | 2022-11-01 09:51:34 +0100 |
commit | ffe3a1337c1380a5b79651b34037c6c9f66b9ea1 (patch) | |
tree | 077d1e424913b5a55e621a842215baea1739535c /accel-pppd/radius | |
parent | f4a22056a221d69bf8d1aaa8eca39f276b52431d (diff) | |
download | accel-ppp-xebd-ffe3a1337c1380a5b79651b34037c6c9f66b9ea1.tar.gz accel-ppp-xebd-ffe3a1337c1380a5b79651b34037c6c9f66b9ea1.zip |
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.
Diffstat (limited to 'accel-pppd/radius')
-rw-r--r-- | accel-pppd/radius/acct.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index 9300bcb..8b3f95d 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; |