mirror of
https://github.com/openvswitch/ovs
synced 2025-10-29 15:28:56 +00:00
ovsdb: Fix use of non-array for JSON-RPC parameters.
JSON-RPC requires that "params" be an array, but we weren't observing this properly in the ovsdb specifications or code. Thanks to Jeremy Stribling for pointing out the problem.
This commit is contained in:
10
ovsdb/SPECS
10
ovsdb/SPECS
@@ -32,6 +32,10 @@ values. Additional notation is presented later.
|
||||
A JSON number with an integer value, within a certain range
|
||||
(currently -2**63...+2**63-1).
|
||||
|
||||
<value>
|
||||
|
||||
Any JSON value.
|
||||
|
||||
Schema Format
|
||||
-------------
|
||||
|
||||
@@ -255,7 +259,7 @@ cancel
|
||||
Request object members:
|
||||
|
||||
"method": "cancel" required
|
||||
"params": the "id" for an outstanding request required
|
||||
"params": [the "id" for an outstanding request] required
|
||||
"id": null required
|
||||
|
||||
Response object members:
|
||||
@@ -283,8 +287,8 @@ echo
|
||||
Request object members:
|
||||
|
||||
"method": "echo" required
|
||||
"params": any JSON value required
|
||||
"id": any JSON value required
|
||||
"params": JSON array with any contents required
|
||||
"id": <value> required
|
||||
|
||||
Response object members:
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ ovsdb_jsonrpc_session_run(struct ovsdb_jsonrpc_session *s)
|
||||
|
||||
case RECONNECT_PROBE:
|
||||
if (s->rpc) {
|
||||
struct json *params = json_integer_create(0);
|
||||
struct json *params = json_array_create_empty();
|
||||
jsonrpc_send(s->rpc, jsonrpc_create_request("echo", params));
|
||||
}
|
||||
break;
|
||||
@@ -453,12 +453,15 @@ ovsdb_jsonrpc_session_got_request(struct ovsdb_jsonrpc_session *s,
|
||||
static void
|
||||
execute_cancel(struct ovsdb_jsonrpc_session *s, struct jsonrpc_msg *request)
|
||||
{
|
||||
size_t hash = json_hash(request->id, 0);
|
||||
struct ovsdb_jsonrpc_trigger *t;
|
||||
if (json_array(request->params)->n == 1) {
|
||||
struct ovsdb_jsonrpc_trigger *t;
|
||||
struct json *id;
|
||||
|
||||
t = ovsdb_jsonrpc_trigger_find(s, request->params, hash);
|
||||
if (t) {
|
||||
ovsdb_jsonrpc_trigger_complete(t);
|
||||
id = request->params->u.array.elems[0];
|
||||
t = ovsdb_jsonrpc_trigger_find(s, id, json_hash(id, 0));
|
||||
if (t) {
|
||||
ovsdb_jsonrpc_trigger_complete(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user