summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-11-13 11:37:27 +0100
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:40 +0200
commit7d0f81759c572d7f5506888d176061c561bc9885 (patch)
tree112e13cc16b4336ca92679c65bdbd825bf0e3734
parent4dc39b75c748184c39dec5224fca792882e44ed8 (diff)
IPFIX: more improvements
o reset sequence number on a restart o free allocated messsages o log lost flows Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--output/ipfix/ipfix.c4
-rw-r--r--output/ipfix/ulogd_output_IPFIX.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/output/ipfix/ipfix.c b/output/ipfix/ipfix.c
index c9d8e4f..0b1ebd4 100644
--- a/output/ipfix/ipfix.c
+++ b/output/ipfix/ipfix.c
@@ -39,6 +39,10 @@ ipfix_msg_free(struct ipfix_msg *msg)
if (!msg)
return;
+ if (msg->nrecs > 0)
+ ulogd_log(ULOGD_DEBUG, "%s: %d flows have been lost\n", __func__,
+ msg->nrecs);
+
free(msg);
}
diff --git a/output/ipfix/ulogd_output_IPFIX.c b/output/ipfix/ulogd_output_IPFIX.c
index 78fe4e1..7dff315 100644
--- a/output/ipfix/ulogd_output_IPFIX.c
+++ b/output/ipfix/ulogd_output_IPFIX.c
@@ -144,13 +144,13 @@ done:
}
/* do some polishing and enqueue it */
-static int
+static void
enqueue_msg(struct ipfix_priv *priv, struct ipfix_msg *msg)
{
struct ipfix_hdr *hdr = ipfix_msg_data(msg);
if (!msg)
- return 0;
+ return;
hdr->time = htonl(time(NULL));
hdr->seqno = htonl(priv->seqno += msg->nrecs);
@@ -162,10 +162,11 @@ enqueue_msg(struct ipfix_priv *priv, struct ipfix_msg *msg)
hdr->len = htons(ipfix_msg_len(msg));
llist_add(&msg->link, &priv->list);
-
- return 0;
}
+/**
+ * @return %ULOGD_IRET_OK or error value
+ */
static int
send_msgs(struct ulogd_pluginstance *pi)
{
@@ -197,6 +198,8 @@ send_msgs(struct ulogd_pluginstance *pi)
ret, ipfix_msg_len(msg));
llist_del(curr);
+ msg->nrecs = 0;
+ ipfix_msg_free(msg);
}
done:
@@ -325,6 +328,8 @@ ipfix_start(struct ulogd_pluginstance *pi)
break;
}
+ priv->seqno = 0;
+
upi_log(pi, ULOGD_INFO, "connected to %s:%d\n",
inet_ntop(AF_INET, &priv->sa.sin_addr, addr, sizeof(addr)),
port_ce(pi));