summaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorAndy Zhou <azhou@nicira.com>2015-10-20 12:50:23 -0700
committerAndy Zhou <azhou@ovn.org>2015-12-11 14:22:33 -0800
commite47cb14c2a1adfff347a311389767fc5f0529353 (patch)
treeaa91ec250d8d951076e32fe86725593153066fa7 /ovsdb
parentdb2b5757328c36ff452c5c6af360cbc7fb05f0c8 (diff)
downloadopenvswitch-e47cb14c2a1adfff347a311389767fc5f0529353.tar.gz
ovsdb: test ovs-vswitchd for backward compatibility
Add test to make sure ovs-vswitchd fall back to use the "monitor" method when connecting to an older ovsdb-server that does not support "monitor2". For testing backward compatibility, add an ovs-appctl command: "ovsdb-server/disable-monitor2". This command will restart all currently open jsonrpc connections, but without support for 'monitor2' JSON-RPC method for the new connections. There is no corresponding enable command, since this feature is only useful for testing. 'monitor2' will be available when ovsdb-server restarts. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb')
-rw-r--r--ovsdb/jsonrpc-server.c13
-rw-r--r--ovsdb/jsonrpc-server.h1
-rw-r--r--ovsdb/ovsdb-server.c20
3 files changed, 33 insertions, 1 deletions
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 53c97cda5..1dcd39429 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -45,6 +45,10 @@ VLOG_DEFINE_THIS_MODULE(ovsdb_jsonrpc_server);
struct ovsdb_jsonrpc_remote;
struct ovsdb_jsonrpc_session;
+/* Set false to defeature monitor2, causing jsonrpc to respond to monitor2
+ * method with an error. */
+static bool monitor2_enable__ = true;
+
/* Message rate-limiting. */
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
@@ -845,7 +849,7 @@ ovsdb_jsonrpc_session_got_request(struct ovsdb_jsonrpc_session *s,
reply = execute_transaction(s, db, request);
}
} else if (!strcmp(request->method, "monitor") ||
- !strcmp(request->method, "monitor2")) {
+ (monitor2_enable__ && !strcmp(request->method, "monitor2"))) {
struct ovsdb *db = ovsdb_jsonrpc_lookup_db(s, request, &reply);
if (!reply) {
int l = strlen(request->method) - strlen("monitor");
@@ -1368,3 +1372,10 @@ ovsdb_jsonrpc_monitor_flush_all(struct ovsdb_jsonrpc_session *s)
}
}
}
+
+void
+ovsdb_jsonrpc_disable_monitor2()
+{
+ /* Once disabled, it is not possible to re-enable it. */
+ monitor2_enable__ = false;
+}
diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h
index fce8b7bd0..7a0bd31b1 100644
--- a/ovsdb/jsonrpc-server.h
+++ b/ovsdb/jsonrpc-server.h
@@ -71,5 +71,6 @@ void ovsdb_jsonrpc_server_get_memory_usage(const struct ovsdb_jsonrpc_server *,
struct ovsdb_jsonrpc_monitor;
void ovsdb_jsonrpc_monitor_destroy(struct ovsdb_jsonrpc_monitor *);
+void ovsdb_jsonrpc_disable_monitor2(void);
#endif /* ovsdb/jsonrpc-server.h */
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 97b65b658..25fa9c6bf 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -79,6 +79,7 @@ static unixctl_cb_func ovsdb_server_compact;
static unixctl_cb_func ovsdb_server_reconnect;
static unixctl_cb_func ovsdb_server_perf_counters_clear;
static unixctl_cb_func ovsdb_server_perf_counters_show;
+static unixctl_cb_func ovsdb_server_disable_monitor2;
struct server_config {
struct sset *remotes;
@@ -329,6 +330,11 @@ main(int argc, char *argv[])
unixctl_command_register("ovsdb-server/perf-counters-clear", "", 0, 0,
ovsdb_server_perf_counters_clear, NULL);
+ /* Simulate the behavior of OVS release prior to version 2.5 that
+ * does not support the monitor2 method. */
+ unixctl_command_register("ovsdb-server/disable-monitor2", "", 0, 0,
+ ovsdb_server_disable_monitor2, jsonrpc);
+
main_loop(jsonrpc, &all_dbs, unixctl, &remotes, run_process, &exiting);
ovsdb_jsonrpc_server_destroy(jsonrpc);
@@ -1052,6 +1058,20 @@ ovsdb_server_perf_counters_clear(struct unixctl_conn *conn, int argc OVS_UNUSED,
unixctl_command_reply(conn, NULL);
}
+/* "ovsdb-server/disable-monitor2": makes ovsdb-server drop all of its
+ * JSON-RPC connections and reconnect. New sessions will not recognize
+ * the 'monitor2' method. */
+static void
+ovsdb_server_disable_monitor2(struct unixctl_conn *conn, int argc OVS_UNUSED,
+ const char *argv[] OVS_UNUSED, void *jsonrpc_)
+{
+ struct ovsdb_jsonrpc_server *jsonrpc = jsonrpc_;
+
+ ovsdb_jsonrpc_disable_monitor2();
+ ovsdb_jsonrpc_server_reconnect(jsonrpc);
+ unixctl_command_reply(conn, NULL);
+}
+
static void
ovsdb_server_compact(struct unixctl_conn *conn, int argc,
const char *argv[], void *dbs_)