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/cli | |
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/cli')
-rw-r--r-- | accel-pppd/cli/show_sessions.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index fb3ff52..73adc54 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -2,6 +2,7 @@ #include <time.h> #include <string.h> #include <unistd.h> +#include <inttypes.h> #include <signal.h> #include <arpa/inet.h> #include <linux/if_link.h> @@ -52,7 +53,7 @@ struct cell_t static LIST_HEAD(col_list); static char *conf_def_columns = NULL; -static __thread struct rtnl_link_stats stats; +static __thread struct rtnl_link_stats64 stats; static __thread int stats_set; void __export cli_show_ses_register(const char *name, const char *desc, void (*print)(struct ap_session *ses, char *buf)) @@ -580,7 +581,7 @@ static void print_rx_bytes(struct ap_session *ses, char *buf) get_stats(ses); stats_set = 1; } - format_bytes(buf, 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes); + format_bytes(buf, stats.rx_bytes); } static void print_tx_bytes(struct ap_session *ses, char *buf) @@ -589,7 +590,7 @@ static void print_tx_bytes(struct ap_session *ses, char *buf) get_stats(ses); stats_set = 1; } - format_bytes(buf, 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes); + format_bytes(buf, stats.tx_bytes); } static void print_rx_bytes_raw(struct ap_session *ses, char *buf) @@ -598,7 +599,7 @@ static void print_rx_bytes_raw(struct ap_session *ses, char *buf) get_stats(ses); stats_set = 1; } - sprintf(buf, "%llu", 4294967296ll*ses->acct_input_gigawords + stats.rx_bytes); + sprintf(buf, PRIu64, stats.rx_bytes); } static void print_tx_bytes_raw(struct ap_session *ses, char *buf) @@ -607,7 +608,7 @@ static void print_tx_bytes_raw(struct ap_session *ses, char *buf) get_stats(ses); stats_set = 1; } - sprintf(buf, "%llu", 4294967296ll*ses->acct_output_gigawords + stats.tx_bytes); + sprintf(buf, PRIu64, stats.tx_bytes); } static void print_rx_pkts(struct ap_session *ses, char *buf) @@ -616,7 +617,7 @@ static void print_rx_pkts(struct ap_session *ses, char *buf) get_stats(ses); stats_set = 1; } - sprintf(buf, "%u", stats.rx_packets); + sprintf(buf, PRIu64, stats.rx_packets); } static void print_tx_pkts(struct ap_session *ses, char *buf) @@ -625,7 +626,7 @@ static void print_tx_pkts(struct ap_session *ses, char *buf) get_stats(ses); stats_set = 1; } - sprintf(buf, "%u", stats.tx_packets); + sprintf(buf, PRIu64, stats.tx_packets); } static void load_config(void *data) |