monitor: Fix improper use of stubs.
authorEthan Jackson <ethan@nicira.com>
Fri, 11 Oct 2013 00:52:31 +0000 (17:52 -0700)
committerEthan Jackson <ethan@nicira.com>
Fri, 11 Oct 2013 01:19:09 +0000 (18:19 -0700)
Stubs must be uninitialized when used in case they allocate memory.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif-monitor.c

index a0c3843..75cf206 100644 (file)
@@ -142,24 +142,26 @@ ofproto_dpif_monitor_port_update(const struct ofport_dpif *ofport,
 void
 ofproto_dpif_monitor_run_fast(void)
 {
-    struct mport *mport;
-    static uint32_t buf_stub[128 / 4];
+    uint32_t stub[512 / 4];
     struct ofpbuf packet;
+    struct mport *mport;
 
+    ofpbuf_use_stub(&packet, stub, sizeof stub);
     ovs_rwlock_rdlock(&monitor_rwlock);
     HMAP_FOR_EACH (mport, hmap_node, &monitor_hmap) {
         if (mport->cfm && cfm_should_send_ccm(mport->cfm)) {
-            ofpbuf_use_stub(&packet, buf_stub, sizeof buf_stub);
+            ofpbuf_clear(&packet);
             cfm_compose_ccm(mport->cfm, &packet, mport->hw_addr);
             ofproto_dpif_send_packet(mport->ofport, &packet);
         }
         if (mport->bfd && bfd_should_send_packet(mport->bfd)) {
-            ofpbuf_use_stub(&packet, buf_stub, sizeof buf_stub);
+            ofpbuf_clear(&packet);
             bfd_put_packet(mport->bfd, &packet, mport->hw_addr);
             ofproto_dpif_send_packet(mport->ofport, &packet);
         }
     }
     ovs_rwlock_unlock(&monitor_rwlock);
+    ofpbuf_uninit(&packet);
 }
 
 /* Executes bfd_run(), cfm_run() on all mports. */