summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ovsdb/jsonrpc-server.c13
-rw-r--r--ovsdb/jsonrpc-server.h1
-rw-r--r--ovsdb/ovsdb-server.c20
-rw-r--r--tests/ovs-vswitchd.at24
4 files changed, 57 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_)
diff --git a/tests/ovs-vswitchd.at b/tests/ovs-vswitchd.at
index 8c2b2e0ed..492b9444f 100644
--- a/tests/ovs-vswitchd.at
+++ b/tests/ovs-vswitchd.at
@@ -163,3 +163,27 @@ OVS_WAIT_UNTIL([test -n "`grep ERR ovs-vswitchd.log | grep overwrite.file`"])
OVS_VSWITCHD_STOP(["/Not adding Unix domain socket controller/d"])
AT_CLEANUP
+
+dnl ----------------------------------------------------------------------
+dnl OVSDB server before release version 2.5 does not support the monitor2
+dnl method. This test defeatures the OVSDB server to simulate an older
+dnl OVSDB server and make sure ovs-vswitchd can still work with it
+AT_SETUP([ovs-vswitchd -- Compatible with OVSDB server - w/o monitor2)])
+OVS_VSWITCHD_START
+
+dnl defeature OVSDB server -- no monitor2
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor2])
+
+sleep 1
+
+AT_CHECK([ovs-vsctl add-port br0 p0 -- set interface p0 type=internal])
+AT_CHECK([ovs-vsctl add-port br0 p1 -- set interface p1 type=internal])
+
+dnl ovs-vswitchd should still 'see' ovsdb change with the 'monitor' method
+AT_CHECK([ovs-appctl dpif/show | tail -n +3], [0], [dnl
+ br0 65534/100: (dummy)
+ p0 1/1: (dummy)
+ p1 2/2: (dummy)
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP