diff options
author | Corubba Smith <corubba@gmx.de> | 2025-02-16 15:05:01 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2025-03-11 16:36:16 +0100 |
commit | e318d352b1085ec55b998c501d67d758dfa74a1f (patch) | |
tree | 55ee436b9621a3a3fc17d8fd6f1378365f445a56 | |
parent | bebb752ce4d4d9d6bfedeb595fef8fdee42dd98a (diff) |
ipfix: re-arm send timer
I am not sure what this timer was meant to do. My best guess is to send
an ipfix message every second if there is data, as to make sure reports
go out in a timely manner. Otherwise a message is only sent when adding
another flow would go past the max mtu, which may take a while if there
isn't much (filtered) traffic.
Timers in ulogd only fire once; if they should fire repeatedly (which I
guess was the intention here), they need to be re-armed in the callback.
Because that wasn't done, the timer only fired once 1 second after
starting the plugin (when there is unlikely any data yet), and then
never again.
The timer is now re-armed in the callback to make it fire repeatedly
every second(ish). A macro is used to make sure the initial and re-arm
time interval is the same.
Fixes: 4f639231c83b ("IPFIX: Add IPFIX output plugin")
Signed-off-by: Corubba Smith <corubba@gmx.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r-- | output/ipfix/ulogd_output_IPFIX.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/output/ipfix/ulogd_output_IPFIX.c b/output/ipfix/ulogd_output_IPFIX.c index 1c0f730..88e0035 100644 --- a/output/ipfix/ulogd_output_IPFIX.c +++ b/output/ipfix/ulogd_output_IPFIX.c @@ -83,6 +83,8 @@ static const struct config_keyset ipfix_kset = { } }; +#define SEND_TIMER_INTERVAL_SEC 1 + struct ipfix_priv { struct ulogd_fd ufd; uint32_t seqno; @@ -259,6 +261,8 @@ static void ipfix_timer_cb(struct ulogd_timer *t, void *data) priv->msg = NULL; send_msgs(pi); } + + ulogd_add_timer(&priv->timer, SEND_TIMER_INTERVAL_SEC); } static int ipfix_configure(struct ulogd_pluginstance *pi, struct ulogd_pluginstance_stack *stack) @@ -394,8 +398,8 @@ static int ipfix_start(struct ulogd_pluginstance *pi) if (ulogd_register_fd(&priv->ufd) < 0) return ULOGD_IRET_ERR; - /* Add a 1 second timer */ - ulogd_add_timer(&priv->timer, 1); + /* Start the repeating send timer */ + ulogd_add_timer(&priv->timer, SEND_TIMER_INTERVAL_SEC); return ULOGD_IRET_OK; } |