diff options
-rw-r--r-- | accel-pppd/cli/show_sessions.c | 15 | ||||
-rw-r--r-- | accel-pppd/extra/pppd_compat.c | 5 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 16 | ||||
-rw-r--r-- | accel-pppd/libnetlink/iputils.c | 6 | ||||
-rw-r--r-- | accel-pppd/libnetlink/iputils.h | 2 | ||||
-rw-r--r-- | accel-pppd/lua/session.c | 6 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_lcp.c | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_lcp.h | 2 | ||||
-rw-r--r-- | accel-pppd/radius/acct.c | 14 | ||||
-rw-r--r-- | accel-pppd/session.c | 13 |
10 files changed, 35 insertions, 46 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) diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 663e545..9bc393b 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -684,12 +684,11 @@ static void fill_env(char **env, char *mem, struct pppd_compat_pd *pd) } if (pd->ses->stop_time) { - uint64_t gword_sz = (uint64_t)UINT32_MAX + 1; uint64_t tx_bytes; uint64_t rx_bytes; - tx_bytes = ses->acct_tx_bytes + gword_sz * ses->acct_output_gigawords; - rx_bytes = ses->acct_rx_bytes + gword_sz * ses->acct_input_gigawords; + tx_bytes = ses->acct_tx_bytes; + rx_bytes = ses->acct_rx_bytes; env[n] = mem; write_sz = snprintf(mem, mem_sz, "CONNECT_TIME=%lu", diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index 1227718..629b58e 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -110,14 +110,12 @@ struct ap_session int session_timeout; struct triton_timer_t timer; - uint32_t acct_rx_bytes; - uint32_t acct_tx_bytes; - uint32_t acct_input_gigawords; - uint32_t acct_output_gigawords; - uint32_t acct_rx_packets_i; - uint32_t acct_tx_packets_i; - uint32_t acct_rx_bytes_i; - uint32_t acct_tx_bytes_i; + uint64_t acct_rx_bytes; + uint64_t acct_tx_bytes; + uint64_t acct_rx_packets_i; + uint64_t acct_tx_packets_i; + uint64_t acct_rx_bytes_i; + uint64_t acct_tx_bytes_i; int acct_start; }; @@ -156,7 +154,7 @@ int ap_session_rename(struct ap_session *ses, const char *ifname, int len); int ap_session_vrf(struct ap_session *ses, const char *vrf_name, int len); #endif -int ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats *stats); +int ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats64 *stats); int ap_shutdown_soft(void (*cb)(void), int term); diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c index a1ededb..550717f 100644 --- a/accel-pppd/libnetlink/iputils.c +++ b/accel-pppd/libnetlink/iputils.c @@ -103,7 +103,7 @@ out_err: return -1; } -int __export iplink_get_stats(int ifindex, struct rtnl_link_stats *stats) +int __export iplink_get_stats(int ifindex, struct rtnl_link_stats64 *stats) { struct iplink_req { struct nlmsghdr n; @@ -142,8 +142,8 @@ int __export iplink_get_stats(int ifindex, struct rtnl_link_stats *stats) goto out; parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); - if (tb[IFLA_STATS]) { - memcpy(stats, RTA_DATA(tb[IFLA_STATS]), sizeof(*stats)); + if (tb[IFLA_STATS64]) { + memcpy(stats, RTA_DATA(tb[IFLA_STATS64]), sizeof(*stats)); r = 0; } diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h index 7822474..9292cea 100644 --- a/accel-pppd/libnetlink/iputils.h +++ b/accel-pppd/libnetlink/iputils.h @@ -8,7 +8,7 @@ typedef int (*iplink_list_func)(int index, int flags, const char *name, int iflink, int vid, void *arg); int iplink_list(iplink_list_func func, void *arg); -int iplink_get_stats(int ifindex, struct rtnl_link_stats *stats); +int iplink_get_stats(int ifindex, struct rtnl_link_stats64 *stats); int iplink_set_mtu(int ifindex, int mtu); int iplink_vlan_add(const char *ifname, int ifindex, int vid); diff --git a/accel-pppd/lua/session.c b/accel-pppd/lua/session.c index a6ce2b0..6d3b676 100644 --- a/accel-pppd/lua/session.c +++ b/accel-pppd/lua/session.c @@ -218,13 +218,12 @@ static int session_ipv6(lua_State *L) static int session_rx_bytes(lua_State *L) { struct ap_session *ses = luaL_checkudata(L, 1, LUA_AP_SESSION); - uint64_t gword_sz = (uint64_t)UINT32_MAX + 1; uint64_t bytes; if (!ses) return 0; - bytes = gword_sz*ses->acct_input_gigawords + ses->acct_rx_bytes; + bytes = ses->acct_rx_bytes; lua_pushnumber(L, bytes); return 1; @@ -233,13 +232,12 @@ static int session_rx_bytes(lua_State *L) static int session_tx_bytes(lua_State *L) { struct ap_session *ses = luaL_checkudata(L, 1, LUA_AP_SESSION); - uint64_t gword_sz = (uint64_t)UINT32_MAX + 1; uint64_t bytes; if (!ses) return 0; - bytes = gword_sz*ses->acct_output_gigawords + ses->acct_tx_bytes; + bytes = ses->acct_tx_bytes; lua_pushnumber(L, bytes); return 1; diff --git a/accel-pppd/ppp/ppp_lcp.c b/accel-pppd/ppp/ppp_lcp.c index fdbb318..10babec 100644 --- a/accel-pppd/ppp/ppp_lcp.c +++ b/accel-pppd/ppp/ppp_lcp.c @@ -621,7 +621,7 @@ static void send_echo_reply(struct ppp_lcp_t *lcp) static void send_echo_request(struct triton_timer_t *t) { struct ppp_lcp_t *lcp = container_of(t, typeof(*lcp), echo_timer); - struct rtnl_link_stats stats; + struct rtnl_link_stats64 stats; struct lcp_echo_req { struct lcp_hdr_t hdr; uint32_t magic; diff --git a/accel-pppd/ppp/ppp_lcp.h b/accel-pppd/ppp/ppp_lcp.h index 39693d4..9b90e08 100644 --- a/accel-pppd/ppp/ppp_lcp.h +++ b/accel-pppd/ppp/ppp_lcp.h @@ -122,7 +122,7 @@ struct ppp_lcp_t struct triton_timer_t echo_timer; int echo_sent; int magic; - unsigned long last_ipackets; + uint64_t last_ipackets; time_t last_echo_ts; struct list_head ropt_list; // last received ConfReq 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; diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 81ac271..af70b1d 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -72,7 +72,7 @@ void __export ap_session_init(struct ap_session *ses) void __export ap_session_set_ifindex(struct ap_session *ses) { - struct rtnl_link_stats stats; + struct rtnl_link_stats64 stats; if (iplink_get_stats(ses->ifindex, &stats)) log_ppp_warn("failed to get interface statistics\n"); @@ -83,8 +83,6 @@ void __export ap_session_set_ifindex(struct ap_session *ses) ses->acct_tx_bytes_i = stats.tx_bytes; ses->acct_rx_bytes = 0; ses->acct_tx_bytes = 0; - ses->acct_input_gigawords = 0; - ses->acct_output_gigawords = 0; } } @@ -380,9 +378,9 @@ static void generate_sessionid(struct ap_session *ses) } } -int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats *stats) +int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats64 *stats) { - struct rtnl_link_stats lstats; + struct rtnl_link_stats64 lstats; if (ses->ifindex == -1) return -1; @@ -403,12 +401,7 @@ int __export ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stat if (stats->rx_bytes != ses->acct_rx_bytes) ses->idle_time = _time(); - if (stats->rx_bytes < ses->acct_rx_bytes) - ses->acct_input_gigawords++; ses->acct_rx_bytes = stats->rx_bytes; - - if (stats->tx_bytes < ses->acct_tx_bytes) - ses->acct_output_gigawords++; ses->acct_tx_bytes = stats->tx_bytes; return 0; |