summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/netflow/netflow.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2004-12-28 12:11:32 +0000
committerglebius <glebius@FreeBSD.org>2004-12-28 12:11:32 +0000
commitdde029219c4d1ee06d1f06f9289ddc4790dc1052 (patch)
tree7225ae6f8c96619cef0a5703c4d527bd81461f81 /sys/netgraph/netflow/netflow.c
parent4215504a99e3adfa0d45ee46c233cc63fe18e57d (diff)
downloadFreeBSD-src-dde029219c4d1ee06d1f06f9289ddc4790dc1052.zip
FreeBSD-src-dde029219c4d1ee06d1f06f9289ddc4790dc1052.tar.gz
- Plug a memory leak in ng_netflow_cache_init().
- Initialize error to 0 in ng_netflow_flow_add() (a nop change). - Update cache statistics holding workqueue mutex. MFC after: 3 days
Diffstat (limited to 'sys/netgraph/netflow/netflow.c')
-rw-r--r--sys/netgraph/netflow/netflow.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/netgraph/netflow/netflow.c b/sys/netgraph/netflow/netflow.c
index 91a484b..c5bfe2b 100644
--- a/sys/netgraph/netflow/netflow.c
+++ b/sys/netgraph/netflow/netflow.c
@@ -398,8 +398,10 @@ ng_netflow_cache_init(priv_p priv)
NBUCKETS * sizeof(struct flow_hash_entry),
M_NETFLOW, M_WAITOK | M_ZERO);
- if (priv->hash == NULL)
+ if (priv->hash == NULL) {
+ FREE(priv->cache, M_NETFLOW);
return (ENOMEM);
+ }
TAILQ_INIT(&priv->work_queue);
SLIST_INIT(&priv->free_list);
@@ -458,12 +460,10 @@ ng_netflow_flow_add(priv_p priv, struct mbuf **m, iface_p iface)
register struct flow_entry *fle;
struct flow_rec r;
int plen;
- int error = 1;
+ int error = 0;
uint32_t slot;
uint8_t tcp_flags = 0;
- priv->info.nfinfo_packets ++;
-
/* Try to fill *rec */
bzero(&r, sizeof(r));
if ((error = make_flow_rec(m, &plen, &r, &tcp_flags, iface->info.ifinfo_index)))
@@ -472,6 +472,11 @@ ng_netflow_flow_add(priv_p priv, struct mbuf **m, iface_p iface)
slot = ip_hash(&r);
mtx_lock(&priv->work_mtx);
+
+ /* Update node statistics. */
+ priv->info.nfinfo_packets ++;
+ priv->info.nfinfo_bytes += plen;
+
fle = hash_lookup(h, slot, &r); /* New flow entry or existent? */
if (fle) { /* an existent entry */
@@ -496,7 +501,6 @@ ng_netflow_flow_add(priv_p priv, struct mbuf **m, iface_p iface)
TAILQ_INSERT_TAIL(&priv->work_queue, fle, fle_work);
mtx_unlock(&priv->work_mtx);
- priv->info.nfinfo_bytes += plen;
} else { /* a new flow entry */
@@ -508,6 +512,7 @@ ng_netflow_flow_add(priv_p priv, struct mbuf **m, iface_p iface)
mtx_assert(&priv->work_mtx, MA_NOTOWNED);
mtx_assert(&priv->expire_mtx, MA_NOTOWNED);
mtx_assert(&priv->free_mtx, MA_NOTOWNED);
+
return (0);
}
OpenPOWER on IntegriCloud