From e0ca35c4f660c07abf0854e56e3ae72c1f8ef38c Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 10 Feb 2022 17:48:35 +0000 Subject: [PATCH] spdk_top: allow connecting with TCP port JSON-RPC server (spdk_rpc_listen) only listens on a UNIX domain socket. If users wish to issue JSON-RPC calls over a TCP socket for debugging purposes, they can forward calls using socat, i.e. socat TCP4-LISTEN:8989,reuseaddr,fork,bind=127.0.0.1 \ UNIX-CLIENT:/var/tmp/spdk.sock This could allow running spdk_top to debug or monitor an SPDK application remotely. But currently spdk_top -r option assumes AF_UNIX. Look at the first character in the -r option (if provided) - if it's '/' use AF_UNIX, otherwise AF_INET. Signed-off-by: Jim Harris Change-Id: Ie9c33bb0fb66dff895359f6f6608862df42b542c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11567 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Konrad Sztyber Reviewed-by: Changpeng Liu --- app/spdk_top/spdk_top.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 7fac0f40b..edab0ecdd 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -3134,7 +3134,7 @@ int main(int argc, char **argv) } } - g_rpc_client = spdk_jsonrpc_client_connect(socket, AF_UNIX); + g_rpc_client = spdk_jsonrpc_client_connect(socket, socket[0] == '/' ? AF_UNIX : AF_INET); if (!g_rpc_client) { fprintf(stderr, "spdk_jsonrpc_client_connect() failed: %d\n", errno); return 1;