diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-09-05 23:24:51 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-09-05 23:24:51 +0400 |
commit | 490f6384f6a54e388587329c0309a6602d5544e8 (patch) | |
tree | 5e70a9e4e7a8f6714a4694826ec68f293d1e55a8 /accel-pppd/extra | |
parent | a10ec0f4636cd559209659304709924daad96340 (diff) | |
download | accel-ppp-490f6384f6a54e388587329c0309a6602d5544e8.tar.gz accel-ppp-490f6384f6a54e388587329c0309a6602d5544e8.zip |
generalize interface statistics gathering
Diffstat (limited to 'accel-pppd/extra')
-rw-r--r-- | accel-pppd/extra/CMakeLists.txt | 3 | ||||
-rw-r--r-- | accel-pppd/extra/pppd_compat.c | 33 | ||||
-rw-r--r-- | accel-pppd/extra/sigchld.c | 3 |
3 files changed, 13 insertions, 26 deletions
diff --git a/accel-pppd/extra/CMakeLists.txt b/accel-pppd/extra/CMakeLists.txt index da1ac54c..ea640b18 100644 --- a/accel-pppd/extra/CMakeLists.txt +++ b/accel-pppd/extra/CMakeLists.txt @@ -1,7 +1,8 @@ +ADD_LIBRARY(sigchld SHARED sigchld.c) ADD_LIBRARY(pppd_compat SHARED pppd_compat.c) +TARGET_LINK_LIBRARIES(pppd_compat sigchld) ADD_LIBRARY(ippool SHARED ippool.c) ADD_LIBRARY(ipv6pool SHARED ipv6pool.c) -ADD_LIBRARY(sigchld SHARED sigchld.c) ADD_LIBRARY(chap-secrets SHARED chap-secrets.c) ADD_LIBRARY(logwtmp SHARED logwtmp.c) TARGET_LINK_LIBRARIES(logwtmp util) diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index 71934ab8..59d052c9 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -6,6 +6,7 @@ #include <unistd.h> #include <sched.h> #include <limits.h> +#include <inttypes.h> #include <sys/ioctl.h> #include <netinet/in.h> #include "linux_ppp.h" @@ -18,7 +19,7 @@ #include "log.h" #include "utils.h" #include "sigchld.h" -#include "iplink.h" +#include "iputils.h" #ifdef RADIUS #include "radius.h" @@ -48,8 +49,6 @@ struct pppd_compat_pd_t #endif int started:1; int res; - int bytes_sent; - int bytes_rcvd; in_addr_t ipv4_addr; in_addr_t ipv4_peer_addr; }; @@ -226,23 +225,6 @@ static void ev_ses_started(struct ap_session *ses) pd->started = 1; } -static void ev_ses_finishing(struct ap_session *ses) -{ - struct rtnl_link_stats stats; - struct pppd_compat_pd_t *pd = find_pd(ses); - - if (!pd) - return; - - if (iplink_get_stats(ses->ifindex, &stats)) { - log_ppp_error("pppd_compat: failed to get interface statistics\n"); - return; - } - - pd->bytes_sent = stats.tx_bytes; - pd->bytes_rcvd = stats.rx_bytes; -} - static void ev_ses_finished(struct ap_session *ses) { pid_t pid; @@ -498,12 +480,18 @@ static void fill_argv(char **argv, struct pppd_compat_pd_t *pd, char *path) static void fill_env(char **env, struct pppd_compat_pd_t *pd) { + struct ap_session *ses = pd->ses; + uint64_t tx_bytes, rx_bytes; + + tx_bytes = (uint64_t)ses->acct_tx_bytes + ses->acct_output_gigawords*4294967296llu; + rx_bytes = (uint64_t)ses->acct_rx_bytes + ses->acct_input_gigawords*4294967296llu; + snprintf(env[0], 64, "PEERNAME=%s", pd->ses->username); if (pd->ses->stop_time && env[1]) { snprintf(env[1], 24, "CONNECT_TIME=%lu", pd->ses->stop_time - pd->ses->start_time); - snprintf(env[2], 24, "BYTES_SENT=%u", pd->bytes_sent); - snprintf(env[3], 24, "BYTES_RCVD=%u", pd->bytes_rcvd); + snprintf(env[2], 24, "BYTES_SENT=%" PRIu64, tx_bytes); + snprintf(env[3], 24, "BYTES_RCVD=%" PRIu64, rx_bytes); } } @@ -538,7 +526,6 @@ static void init(void) triton_event_register_handler(EV_SES_STARTING, (triton_event_func)ev_ses_starting); triton_event_register_handler(EV_SES_PRE_UP, (triton_event_func)ev_ses_pre_up); triton_event_register_handler(EV_SES_STARTED, (triton_event_func)ev_ses_started); - triton_event_register_handler(EV_SES_FINISHING, (triton_event_func)ev_ses_finishing); triton_event_register_handler(EV_SES_PRE_FINISHED, (triton_event_func)ev_ses_finished); #ifdef RADIUS if (triton_module_loaded("radius")) { diff --git a/accel-pppd/extra/sigchld.c b/accel-pppd/extra/sigchld.c index 8f1a979e..d6b0df5f 100644 --- a/accel-pppd/extra/sigchld.c +++ b/accel-pppd/extra/sigchld.c @@ -109,10 +109,9 @@ void __export sigchld_unlock() pthread_mutex_unlock(&handlers_lock); } -static void init(void) +static void __init init(void) { if (pthread_create(&sigchld_thr, NULL, sigchld_thread, NULL)) log_emerg("sigchld: pthread_create: %s\n", strerror(errno)); } -DEFINE_INIT(100, init);
\ No newline at end of file |