collectors: Check for NULL set of collectors.
authorJesse Gross <jesse@nicira.com>
Thu, 25 Feb 2010 14:02:26 +0000 (09:02 -0500)
committerJustin Pettit <jpettit@nicira.com>
Sun, 21 Feb 2010 02:50:53 +0000 (18:50 -0800)
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>
ofproto/collectors.c

index f7cb1db..374fa8c 100644 (file)
@@ -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));
+            }
         }
     }
 }