mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
ovsdb: enable jasonrpc-server to service monitor2 request
ovsdb-server now accepts the new "monitor2" request. The next patch will switch IDL to use monitor2 by default. Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
parent
52553aeaa9
commit
92f8d65b1f
3
NEWS
3
NEWS
@ -1,6 +1,7 @@
|
|||||||
Post-v2.5.0
|
Post-v2.5.0
|
||||||
---------------------
|
---------------------
|
||||||
|
- ovsdb-server:
|
||||||
|
* New "monitor2" and "update2" extensions to RFC 7047.
|
||||||
|
|
||||||
v2.5.0 - xx xxx xxxx
|
v2.5.0 - xx xxx xxxx
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "timeval.h"
|
#include "timeval.h"
|
||||||
#include "transaction.h"
|
#include "transaction.h"
|
||||||
#include "trigger.h"
|
#include "trigger.h"
|
||||||
#include "monitor.h"
|
|
||||||
#include "openvswitch/vlog.h"
|
#include "openvswitch/vlog.h"
|
||||||
|
|
||||||
VLOG_DEFINE_THIS_MODULE(ovsdb_jsonrpc_server);
|
VLOG_DEFINE_THIS_MODULE(ovsdb_jsonrpc_server);
|
||||||
@ -82,7 +81,7 @@ static void ovsdb_jsonrpc_trigger_complete_done(
|
|||||||
/* Monitors. */
|
/* Monitors. */
|
||||||
static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_create(
|
static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_create(
|
||||||
struct ovsdb_jsonrpc_session *, struct ovsdb *, struct json *params,
|
struct ovsdb_jsonrpc_session *, struct ovsdb *, struct json *params,
|
||||||
const struct json *request_id);
|
enum ovsdb_monitor_version, const struct json *request_id);
|
||||||
static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cancel(
|
static struct jsonrpc_msg *ovsdb_jsonrpc_monitor_cancel(
|
||||||
struct ovsdb_jsonrpc_session *,
|
struct ovsdb_jsonrpc_session *,
|
||||||
struct json_array *params,
|
struct json_array *params,
|
||||||
@ -845,11 +844,15 @@ ovsdb_jsonrpc_session_got_request(struct ovsdb_jsonrpc_session *s,
|
|||||||
if (!reply) {
|
if (!reply) {
|
||||||
reply = execute_transaction(s, db, request);
|
reply = execute_transaction(s, db, request);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(request->method, "monitor")) {
|
} else if (!strcmp(request->method, "monitor") ||
|
||||||
|
!strcmp(request->method, "monitor2")) {
|
||||||
struct ovsdb *db = ovsdb_jsonrpc_lookup_db(s, request, &reply);
|
struct ovsdb *db = ovsdb_jsonrpc_lookup_db(s, request, &reply);
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
|
int l = strlen(request->method) - strlen("monitor");
|
||||||
|
enum ovsdb_monitor_version version = l ? OVSDB_MONITOR_V2
|
||||||
|
: OVSDB_MONITOR_V1;
|
||||||
reply = ovsdb_jsonrpc_monitor_create(s, db, request->params,
|
reply = ovsdb_jsonrpc_monitor_create(s, db, request->params,
|
||||||
request->id);
|
version, request->id);
|
||||||
}
|
}
|
||||||
} else if (!strcmp(request->method, "monitor_cancel")) {
|
} else if (!strcmp(request->method, "monitor_cancel")) {
|
||||||
reply = ovsdb_jsonrpc_monitor_cancel(s, json_array(request->params),
|
reply = ovsdb_jsonrpc_monitor_cancel(s, json_array(request->params),
|
||||||
@ -1040,6 +1043,7 @@ struct ovsdb_jsonrpc_monitor {
|
|||||||
struct ovsdb_monitor *dbmon;
|
struct ovsdb_monitor *dbmon;
|
||||||
uint64_t unflushed; /* The first transaction that has not been
|
uint64_t unflushed; /* The first transaction that has not been
|
||||||
flushed to the jsonrpc remote client. */
|
flushed to the jsonrpc remote client. */
|
||||||
|
enum ovsdb_monitor_version version;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ovsdb_jsonrpc_monitor *
|
static struct ovsdb_jsonrpc_monitor *
|
||||||
@ -1155,6 +1159,7 @@ ovsdb_jsonrpc_parse_monitor_request(struct ovsdb_monitor *dbmon,
|
|||||||
static struct jsonrpc_msg *
|
static struct jsonrpc_msg *
|
||||||
ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db,
|
ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db,
|
||||||
struct json *params,
|
struct json *params,
|
||||||
|
enum ovsdb_monitor_version version,
|
||||||
const struct json *request_id)
|
const struct json *request_id)
|
||||||
{
|
{
|
||||||
struct ovsdb_jsonrpc_monitor *m = NULL;
|
struct ovsdb_jsonrpc_monitor *m = NULL;
|
||||||
@ -1186,6 +1191,7 @@ ovsdb_jsonrpc_monitor_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db,
|
|||||||
m->db = db;
|
m->db = db;
|
||||||
m->dbmon = ovsdb_monitor_create(db, m);
|
m->dbmon = ovsdb_monitor_create(db, m);
|
||||||
m->unflushed = 0;
|
m->unflushed = 0;
|
||||||
|
m->version = version;
|
||||||
hmap_insert(&s->monitors, &m->node, json_hash(monitor_id, 0));
|
hmap_insert(&s->monitors, &m->node, json_hash(monitor_id, 0));
|
||||||
m->monitor_id = json_clone(monitor_id);
|
m->monitor_id = json_clone(monitor_id);
|
||||||
|
|
||||||
@ -1296,7 +1302,7 @@ ovsdb_jsonrpc_monitor_compose_update(struct ovsdb_jsonrpc_monitor *m,
|
|||||||
bool initial)
|
bool initial)
|
||||||
{
|
{
|
||||||
return ovsdb_monitor_get_update(m->dbmon, initial, &m->unflushed,
|
return ovsdb_monitor_get_update(m->dbmon, initial, &m->unflushed,
|
||||||
OVSDB_MONITOR_V1);
|
m->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -1322,6 +1328,27 @@ ovsdb_jsonrpc_monitor_destroy(struct ovsdb_jsonrpc_monitor *m)
|
|||||||
free(m);
|
free(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct jsonrpc_msg *
|
||||||
|
ovsdb_jsonrpc_create_notify(const struct ovsdb_jsonrpc_monitor *m,
|
||||||
|
struct json *params)
|
||||||
|
{
|
||||||
|
const char *method;
|
||||||
|
|
||||||
|
switch(m->version) {
|
||||||
|
case OVSDB_MONITOR_V1:
|
||||||
|
method = "update";
|
||||||
|
break;
|
||||||
|
case OVSDB_MONITOR_V2:
|
||||||
|
method = "update2";
|
||||||
|
break;
|
||||||
|
case OVSDB_MONITOR_VERSION_MAX:
|
||||||
|
default:
|
||||||
|
OVS_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonrpc_create_notify(method, params);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ovsdb_jsonrpc_monitor_flush_all(struct ovsdb_jsonrpc_session *s)
|
ovsdb_jsonrpc_monitor_flush_all(struct ovsdb_jsonrpc_session *s)
|
||||||
{
|
{
|
||||||
@ -1336,7 +1363,7 @@ ovsdb_jsonrpc_monitor_flush_all(struct ovsdb_jsonrpc_session *s)
|
|||||||
struct json *params;
|
struct json *params;
|
||||||
|
|
||||||
params = json_array_create_2(json_clone(m->monitor_id), json);
|
params = json_array_create_2(json_clone(m->monitor_id), json);
|
||||||
msg = jsonrpc_create_notify("update", params);
|
msg = ovsdb_jsonrpc_create_notify(m, params);
|
||||||
jsonrpc_session_send(s->js, msg);
|
jsonrpc_session_send(s->js, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user