Commit 3c8c4ce3 authored by Pawel Kaminski's avatar Pawel Kaminski Committed by Darek Stojaczyk
Browse files

net/rpc: Add logs with more information about rpc error.



Now if rpc fails ambiguous logs are printed.
Use more descriptive errors.

Change-Id: Ia70cacd4699fb2e421334db177b9510626997378
Signed-off-by: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462773


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 2b483475
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -336,13 +336,13 @@ static int netlink_addr_msg(uint32_t ifc_idx, uint32_t ip_address, uint32_t crea
	struct rtattr *rta;

	if (spdk_interface_available(ifc_idx)) {
		return -1;
		return -ENODEV;
	}

	fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
	if (fd < 0) {
		SPDK_ERRLOG("socket failed!\n");
		return -1;
		return errno;
	}

	/* setup local address & bind using this address. */
+24 −4
Original line number Diff line number Diff line
@@ -63,15 +63,26 @@ spdk_rpc_add_ip_address(struct spdk_jsonrpc_request *request,
{
	struct rpc_ip_address req = {};
	struct spdk_json_write_ctx *w;
	int ret_val = 0;

	if (spdk_json_decode_object(params, rpc_ip_address_decoders,
				    SPDK_COUNTOF(rpc_ip_address_decoders),
				    &req)) {
		SPDK_DEBUGLOG(SPDK_LOG_NET, "spdk_json_decode_object failed\n");
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
						 "spdk_json_decode_object failed");
		goto invalid;
	}

	if (spdk_interface_add_ip_address(req.ifc_index, req.ip_address)) {
	ret_val = spdk_interface_add_ip_address(req.ifc_index, req.ip_address);
	if (ret_val) {
		if (ret_val == -ENODEV) {
			spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_STATE,
							     "Interface %d not available", req.ifc_index);
		} else {
			spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
							 strerror(ret_val));
		}
		goto invalid;
	}

@@ -83,7 +94,6 @@ spdk_rpc_add_ip_address(struct spdk_jsonrpc_request *request,
	return;

invalid:
	spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
	free_rpc_ip_address(&req);
}
SPDK_RPC_REGISTER("add_ip_address", spdk_rpc_add_ip_address, SPDK_RPC_RUNTIME)
@@ -94,15 +104,26 @@ spdk_rpc_delete_ip_address(struct spdk_jsonrpc_request *request,
{
	struct rpc_ip_address req = {};
	struct spdk_json_write_ctx *w;
	int ret_val = 0;

	if (spdk_json_decode_object(params, rpc_ip_address_decoders,
				    SPDK_COUNTOF(rpc_ip_address_decoders),
				    &req)) {
		SPDK_DEBUGLOG(SPDK_LOG_NET, "spdk_json_decode_object failed\n");
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
						 "spdk_json_decode_object failed");
		goto invalid;
	}

	if (spdk_interface_delete_ip_address(req.ifc_index, req.ip_address)) {
	ret_val = spdk_interface_delete_ip_address(req.ifc_index, req.ip_address);
	if (ret_val) {
		if (ret_val == -ENODEV) {
			spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_STATE,
							     "Interface %d not available", req.ifc_index);
		} else {
			spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
							 strerror(ret_val));
		}
		goto invalid;
	}

@@ -114,7 +135,6 @@ spdk_rpc_delete_ip_address(struct spdk_jsonrpc_request *request,
	return;

invalid:
	spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
	free_rpc_ip_address(&req);
}
SPDK_RPC_REGISTER("delete_ip_address", spdk_rpc_delete_ip_address, SPDK_RPC_RUNTIME)