netdev: do not allow devices to be opened with conflicting types
[cascardo/ovs.git] / ovsdb / replication.c
index 9bf3721..52b7085 100644 (file)
@@ -20,7 +20,7 @@
 #include "replication.h"
 
 #include "condition.h"
-#include "json.h"
+#include "openvswitch/json.h"
 #include "jsonrpc.h"
 #include "ovsdb.h"
 #include "ovsdb-error.h"
@@ -38,7 +38,6 @@ static struct sset monitored_tables = SSET_INITIALIZER(&monitored_tables);
 static struct sset tables_blacklist = SSET_INITIALIZER(&tables_blacklist);
 static bool reset_dbs = true;
 
-void replication_init(void);
 static struct jsonrpc *open_jsonrpc(const char *server);
 static struct ovsdb_error *check_jsonrpc_error(int error,
                                                struct jsonrpc_msg **reply_);
@@ -118,25 +117,27 @@ set_remote_ovsdb_server(const char *remote_server)
     remote_ovsdb_server = nullable_xstrdup(remote_server);
 }
 
+const char *
+get_remote_ovsdb_server(void)
+{
+    return remote_ovsdb_server;
+}
+
 void
 set_tables_blacklist(const char *blacklist)
 {
-    char *save_ptr = NULL;
-    char *blacklist_item;
-
     replication_init();
-
     if (blacklist) {
-        char *t_blacklist = xstrdup(blacklist);
-        for (blacklist_item = strtok_r(t_blacklist, ",", &save_ptr);
-             blacklist_item != NULL;
-             blacklist_item = strtok_r(NULL, ",", &save_ptr)) {
-            sset_add(&tables_blacklist, blacklist_item);
-        }
-        free(t_blacklist);
+        sset_from_delimited_string(&tables_blacklist, blacklist, ",");
     }
 }
 
+struct sset
+get_tables_blacklist(void)
+{
+    return tables_blacklist;
+}
+
 void
 disconnect_remote_server(void)
 {
@@ -208,8 +209,7 @@ open_jsonrpc(const char *server)
     struct stream *stream;
     int error;
 
-    error = stream_open_block(jsonrpc_stream_open(server, &stream,
-                                                  DSCP_DEFAULT), &stream);
+    error = jsonrpc_stream_open(server, &stream, DSCP_DEFAULT);
 
     return error ? NULL : jsonrpc_open(stream);
 }
@@ -469,8 +469,8 @@ process_table_update(struct json *table_update, const char *table_name,
     struct ovsdb_error *error;
 
     if (table_update->type != JSON_OBJECT) {
-        error = ovsdb_error("Not a JSON object",
-                            "<table-update> for table is not object");
+        return ovsdb_error("Not a JSON object",
+                           "<table-update> for table is not object");
     }
 
     table = ovsdb_get_table(database, table_name);
@@ -546,7 +546,7 @@ execute_delete(struct ovsdb_txn *txn, const char *uuid,
 {
     const struct json *where;
     struct ovsdb_error *error;
-    struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
+    struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER(&condition);
     char where_string[UUID_LEN+29];
 
     if (!table) {
@@ -597,7 +597,7 @@ execute_update(struct ovsdb_txn *txn, const char *uuid,
                struct ovsdb_table *table, struct json *json_row)
 {
     struct ovsdb_column_set columns = OVSDB_COLUMN_SET_INITIALIZER;
-    struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER;
+    struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER(&condition);
     struct update_row_cbdata ur;
     struct ovsdb_row *row;
     struct ovsdb_error *error;