From aa67900a2e42b33386033ed906844d751a57599a Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 18 May 2018 09:05:36 -0700 Subject: [PATCH] jsonrpc: make "jsonrpc" request field optional The "jsonrpc" field, per spec, is meant to contain the exact string "2.0" to indicate the version of the JSON-RPC specification implemented by the client. We don't do anything useful with this information except to drop requests for (theoretical) other versions, so it should be safe to allow the parameter to be optional. If the version is specified, we will still validate that it is 2.0. This enables interoperability with a Go JSON-RPC client, as mentioned in issue #303: https://godoc.org/github.com/mafredri/cdp/rpcc Change-Id: Ifde32b3f47a5d7942f4ab74b4d6029dd0168efa8 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/411742 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/jsonrpc/jsonrpc_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jsonrpc/jsonrpc_server.c b/lib/jsonrpc/jsonrpc_server.c index 0d799d341..7de51c89e 100644 --- a/lib/jsonrpc/jsonrpc_server.c +++ b/lib/jsonrpc/jsonrpc_server.c @@ -71,8 +71,8 @@ parse_single_request(struct spdk_jsonrpc_request *request, struct spdk_json_val goto done; } - if (!req.version || req.version->type != SPDK_JSON_VAL_STRING || - !spdk_json_strequal(req.version, "2.0")) { + if (req.version && (req.version->type != SPDK_JSON_VAL_STRING || + !spdk_json_strequal(req.version, "2.0"))) { invalid = true; }