From 5d3e96a67dc6ea6ca81156bdccd83b9b7e241ccb Mon Sep 17 00:00:00 2001 From: Stephan Brunner Date: Tue, 1 Nov 2022 10:08:06 +0100 Subject: Add PACKETS_SENT and PACKETS_RCVD to the pppd-compat environment. --- accel-pppd/extra/pppd_compat.c | 24 +++++++++++++++++++++++- accel-pppd/include/ap_session.h | 2 ++ accel-pppd/session.c | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 9bc393b4..040e7d90 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -30,7 +30,7 @@ #include "memdebug.h" #define ENV_MEM 1024 -#define ENV_MAX 16 +#define ENV_MAX 32 static char *conf_ip_up; static char *conf_ip_pre_up; @@ -686,9 +686,13 @@ static void fill_env(char **env, char *mem, struct pppd_compat_pd *pd) if (pd->ses->stop_time) { uint64_t tx_bytes; uint64_t rx_bytes; + uint64_t tx_packets; + uint64_t rx_packets; tx_bytes = ses->acct_tx_bytes; rx_bytes = ses->acct_rx_bytes; + tx_packets = ses->acct_tx_packets; + rx_packets = ses->acct_rx_packets; env[n] = mem; write_sz = snprintf(mem, mem_sz, "CONNECT_TIME=%lu", @@ -714,6 +718,24 @@ static void fill_env(char **env, char *mem, struct pppd_compat_pd *pd) rx_bytes); if (write_sz < 0 || write_sz >= mem_sz) goto out; + mem_sz -= write_sz + 1; + mem += write_sz + 1; + ++n; + + env[n] = mem; + write_sz = snprintf(mem, mem_sz, "PACKETS_SENT=%" PRIu64, + tx_packets); + if (write_sz < 0 || write_sz >= mem_sz) + goto out; + mem_sz -= write_sz + 1; + mem += write_sz + 1; + ++n; + + env[n] = mem; + write_sz = snprintf(mem, mem_sz, "PACKETS_RCVD=%" PRIu64, + rx_packets); + if (write_sz < 0 || write_sz >= mem_sz) + goto out; ++n; } diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index 629b58ee..70515133 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -110,6 +110,8 @@ struct ap_session int session_timeout; struct triton_timer_t timer; + uint64_t acct_rx_packets; + uint64_t acct_tx_packets; uint64_t acct_rx_bytes; uint64_t acct_tx_bytes; uint64_t acct_rx_packets_i; diff --git a/accel-pppd/session.c b/accel-pppd/session.c index af70b1d0..c01417f3 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -401,6 +401,8 @@ 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(); + ses->acct_rx_packets = stats->rx_packets; + ses->acct_tx_packets = stats->tx_packets; ses->acct_rx_bytes = stats->rx_bytes; ses->acct_tx_bytes = stats->tx_bytes; -- cgit v1.2.3