summaryrefslogtreecommitdiff
path: root/ofproto/collectors.c
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2010-02-25 09:02:26 -0500
committerJustin Pettit <jpettit@nicira.com>2010-02-20 14:36:59 -0800
commit8ff9b354bccd7b6d79c721217f21f11963daad59 (patch)
treedec52a3847e81e570481c057fb5bcf6257661816 /ofproto/collectors.c
parentefa6c663df0bcad748e3a89d7b3f4dec187f6f53 (diff)
downloadopenvswitch-8ff9b354bccd7b6d79c721217f21f11963daad59.tar.gz
collectors: Check for NULL set of collectors.
If the set of collectors for NetFlow or sFlow is empty due to an error it will cause a crash when trying to send data. Reported-by: Tetsuo NAKAGAWA <nakagawa@mxc.nes.nec.co.jp>
Diffstat (limited to 'ofproto/collectors.c')
-rw-r--r--ofproto/collectors.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/ofproto/collectors.c b/ofproto/collectors.c
index 4589f3298..f0639836e 100644
--- a/ofproto/collectors.c
+++ b/ofproto/collectors.c
@@ -111,13 +111,15 @@ collectors_destroy(struct collectors *c)
void
collectors_send(const struct collectors *c, const void *payload, size_t n)
{
- size_t i;
+ if (c) {
+ size_t i;
- for (i = 0; i < c->n_fds; i++) {
- static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
- if (send(c->fds[i], payload, n, 0) == -1) {
- VLOG_WARN_RL(&rl, "sending to collector failed: %s",
- strerror(errno));
+ for (i = 0; i < c->n_fds; i++) {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+ if (send(c->fds[i], payload, n, 0) == -1) {
+ VLOG_WARN_RL(&rl, "sending to collector failed: %s",
+ strerror(errno));
+ }
}
}
}
@@ -125,5 +127,5 @@ collectors_send(const struct collectors *c, const void *payload, size_t n)
int
collectors_count(const struct collectors *c)
{
- return c->n_fds;
+ return c ? c->n_fds : 0;
}