Introduce ovsdb_cs_clear_condition routine in order to remove
ovsdb_cs_db_table entries when they are not part of db schema in
ovsdb_idl_compose_monitor_request().

Signed-off-by: Lorenzo Bianconi <[email protected]>
---
 lib/ovsdb-cs.c  | 35 +++++++++++++++++++++++++++++------
 lib/ovsdb-cs.h  |  1 +
 lib/ovsdb-idl.c |  4 ++++
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/lib/ovsdb-cs.c b/lib/ovsdb-cs.c
index df33a835d..09796f37a 100644
--- a/lib/ovsdb-cs.c
+++ b/lib/ovsdb-cs.c
@@ -912,17 +912,40 @@ ovsdb_cs_db_get_table(struct ovsdb_cs_db *db, const char 
*table)
     return t;
 }
 
+static void
+ovsdb_cs_db_destroy_table(struct ovsdb_cs_db_table *table,
+                          struct ovsdb_cs_db *db)
+{
+    json_destroy(table->ack_cond);
+    json_destroy(table->req_cond);
+    json_destroy(table->new_cond);
+    hmap_remove(&db->tables, &table->hmap_node);
+    free(table->name);
+    free(table);
+}
+
+/* Destroy a given ovsdb_cs_db_table according to the table name. */
+void
+ovsdb_cs_clear_condition(struct ovsdb_cs *cs, const char *table)
+{
+    uint32_t hash = hash_string(table, 0);
+    struct ovsdb_cs_db *db = &cs->data;
+
+    struct ovsdb_cs_db_table *t;
+    HMAP_FOR_EACH_WITH_HASH (t, hmap_node, hash, &db->tables) {
+        if (!strcmp(t->name, table)) {
+            ovsdb_cs_db_destroy_table(t, db);
+            return;
+        }
+    }
+}
+
 static void
 ovsdb_cs_db_destroy_tables(struct ovsdb_cs_db *db)
 {
     struct ovsdb_cs_db_table *table;
     HMAP_FOR_EACH_SAFE (table, hmap_node, &db->tables) {
-        json_destroy(table->ack_cond);
-        json_destroy(table->req_cond);
-        json_destroy(table->new_cond);
-        hmap_remove(&db->tables, &table->hmap_node);
-        free(table->name);
-        free(table);
+        ovsdb_cs_db_destroy_table(table, db);
     }
     hmap_destroy(&db->tables);
 }
diff --git a/lib/ovsdb-cs.h b/lib/ovsdb-cs.h
index bcc3dcd71..0ac691352 100644
--- a/lib/ovsdb-cs.h
+++ b/lib/ovsdb-cs.h
@@ -144,6 +144,7 @@ void ovsdb_cs_set_probe_interval(const struct ovsdb_cs *, 
int probe_interval);
 unsigned int ovsdb_cs_set_condition(struct ovsdb_cs *, const char *table,
                                     const struct json *condition);
 unsigned int ovsdb_cs_get_condition_seqno(const struct ovsdb_cs *);
+void ovsdb_cs_clear_condition(struct ovsdb_cs *, const char *table);
 
 /* Database change awareness. */
 void ovsdb_cs_set_db_change_aware(struct ovsdb_cs *, bool set_db_change_aware);
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index fe90deda7..a53e94819 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -852,6 +852,10 @@ ovsdb_idl_compose_monitor_request(const struct json 
*schema_json, void *idl_)
             json_object_put(monitor_requests, tc->name,
                             json_array_create_1(monitor_request));
         }
+
+        if (!table->in_server_schema) {
+            ovsdb_cs_clear_condition(idl->cs, table->class_->name);
+        }
     }
     ovsdb_cs_free_schema(schema);
 
-- 
2.53.0

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

Reply via email to