From 9e50f5cbc67b6ecbd354af8254b4f123113085b3 Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Thu, 1 Jan 2009 23:17:34 +1100 Subject: [PATCH] Skip per-host accounting if --hosts-max is zero. --- acct.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/acct.c b/acct.c index 7c70011..ae9c39d 100644 --- a/acct.c +++ b/acct.c @@ -101,19 +101,6 @@ acct_for(const pktsummary *sm) total_packets++; total_bytes += sm->len; - /* Hosts. */ - hs = host_get(sm->src_ip); - hs->out += sm->len; - hs->total += sm->len; - memcpy(hs->u.host.mac_addr, sm->src_mac, sizeof(sm->src_mac)); - hs->u.host.last_seen = now; - - hd = host_get(sm->dest_ip); /* this can invalidate hs! */ - hd->in += sm->len; - hd->total += sm->len; - memcpy(hd->u.host.mac_addr, sm->dst_mac, sizeof(sm->dst_mac)); - hd->u.host.last_seen = now; - /* Graphs. */ dir_in = dir_out = 0; @@ -141,6 +128,21 @@ acct_for(const pktsummary *sm) graph_acct((uint64_t)sm->len, GRAPH_IN); } + if (hosts_max == 0) return; /* skip per-host accounting */ + + /* Hosts. */ + hs = host_get(sm->src_ip); + hs->out += sm->len; + hs->total += sm->len; + memcpy(hs->u.host.mac_addr, sm->src_mac, sizeof(sm->src_mac)); + hs->u.host.last_seen = now; + + hd = host_get(sm->dest_ip); /* this can invalidate hs! */ + hd->in += sm->len; + hd->total += sm->len; + memcpy(hd->u.host.mac_addr, sm->dst_mac, sizeof(sm->dst_mac)); + hd->u.host.last_seen = now; + /* Protocols. */ hs = host_find(sm->src_ip); if (hs != NULL) { -- 2.17.1