This oversight allowed monitor IDs to be duplicated when the
monitor_cond_change request changed them.

Signed-off-by: Ben Pfaff <[email protected]>
---
 ovsdb/jsonrpc-server.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index da3b3835f0d7..36e50241b040 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -1420,6 +1420,14 @@ ovsdb_jsonrpc_monitor_cond_change(struct 
ovsdb_jsonrpc_session *s,
         goto error;
     }
 
+    struct ovsdb_jsonrpc_monitor *m2
+        = ovsdb_jsonrpc_monitor_find(s, params->u.array.elems[1]);
+    if (m2 && m2 != m) {
+        error = ovsdb_syntax_error(params->u.array.elems[1], NULL,
+                                   "duplicate monitor ID");
+        goto error;
+    }
+
     monitor_cond_change_reqs = params->u.array.elems[2];
     if (monitor_cond_change_reqs->type != JSON_OBJECT) {
         error =
@@ -1467,10 +1475,12 @@ ovsdb_jsonrpc_monitor_cond_change(struct 
ovsdb_jsonrpc_session *s,
     }
 
     /* Change monitor id */
-    hmap_remove(&s->monitors, &m->node);
-    json_destroy(m->monitor_id);
-    m->monitor_id = json_clone(params->u.array.elems[1]);
-    hmap_insert(&s->monitors, &m->node, json_hash(m->monitor_id, 0));
+    if (m != m2) {
+        hmap_remove(&s->monitors, &m->node);
+        json_destroy(m->monitor_id);
+        m->monitor_id = json_clone(params->u.array.elems[1]);
+        hmap_insert(&s->monitors, &m->node, json_hash(m->monitor_id, 0));
+    }
 
     /* Send the new update, if any,  represents the difference from the old
      * condition and the new one. */
-- 
2.10.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to