diff options
-rw-r--r-- | include/conntrackd.h | 6 | ||||
-rw-r--r-- | src/traffic_stats.c | 15 |
2 files changed, 11 insertions, 10 deletions
diff --git a/include/conntrackd.h b/include/conntrackd.h index 9b3cdf2..9615c2e 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -128,8 +128,10 @@ struct ct_general_state { /* statistics */ struct { - uint64_t bytes[NFCT_DIR_MAX]; - uint64_t packets[NFCT_DIR_MAX]; + uint64_t bytes_orig; + uint64_t bytes_repl; + uint64_t packets_orig; + uint64_t packets_repl; time_t daemon_start_time; diff --git a/src/traffic_stats.c b/src/traffic_stats.c index 52ca09a..6535527 100644 --- a/src/traffic_stats.c +++ b/src/traffic_stats.c @@ -21,13 +21,13 @@ void update_traffic_stats(struct nf_conntrack *ct) { - STATE(stats).bytes[NFCT_DIR_ORIGINAL] += + STATE(stats).bytes_orig += nfct_get_attr_u32(ct, ATTR_ORIG_COUNTER_BYTES); - STATE(stats).bytes[NFCT_DIR_REPLY] += + STATE(stats).bytes_repl += nfct_get_attr_u32(ct, ATTR_REPL_COUNTER_BYTES); - STATE(stats).packets[NFCT_DIR_ORIGINAL] += + STATE(stats).packets_orig += nfct_get_attr_u32(ct, ATTR_ORIG_COUNTER_PACKETS); - STATE(stats).packets[NFCT_DIR_REPLY] += + STATE(stats).packets_repl += nfct_get_attr_u32(ct, ATTR_REPL_COUNTER_PACKETS); } @@ -35,10 +35,9 @@ void dump_traffic_stats(int fd) { char buf[512]; int size; - uint64_t bytes = STATE(stats).bytes[NFCT_DIR_ORIGINAL] + - STATE(stats).bytes[NFCT_DIR_REPLY]; - uint64_t packets = STATE(stats).packets[NFCT_DIR_ORIGINAL] + - STATE(stats).packets[NFCT_DIR_REPLY]; + uint64_t bytes = STATE(stats).bytes_orig + STATE(stats).bytes_repl; + uint64_t packets = STATE(stats).packets_orig + + STATE(stats).packets_repl; size = sprintf(buf, "traffic processed:\n"); size += sprintf(buf+size, "%20llu Bytes ", (unsigned long long)bytes); |