[ovs-dev] [PATCH] monitor: Fix improper use of stubs.
Ethan Jackson
ethan at nicira.com
Fri Oct 11 00:57:51 UTC 2013
Stubs must be uninitialized when used in case they allocate memory.
Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
ofproto/ofproto-dpif-monitor.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ofproto/ofproto-dpif-monitor.c b/ofproto/ofproto-dpif-monitor.c
index a0c3843..75fd093 100644
--- a/ofproto/ofproto-dpif-monitor.c
+++ b/ofproto/ofproto-dpif-monitor.c
@@ -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];
+ static 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. */
--
1.7.9.5
More information about the dev
mailing list