lib/iscsi: Add iscsi_target_node_request_logout RPC
For the login redirection feature, the current implementation works only if a portal is redirected from an initial portal to a redirect portal. However, the login redirection feature should work even if a portal is redirected from one redirect portal to another redirect portal. A public portal group knows only a redirect portal and does not know the portal group of the redirect portal. Moreover, it is very likely that an initial portal and a redirect portal exist in different SPDK iSCSI target applications. To cover all these concerns, add an new iscsi_target_node_request_logout RPC to request connections whose portal group tag match for the target node. To cover potential use cases, make the second parameter portal group tag optional. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I612672490722fb22fd4eba055998b7408ab84ca5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3780 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
8cf5581fa9
commit
e97fd6c936
@ -4153,6 +4153,43 @@ Example response:
|
||||
}
|
||||
~~~
|
||||
|
||||
## iscsi_target_node_request_logout method {#rpc_iscsi_target_node_request_logout}
|
||||
|
||||
For the target node, request connections whose portal group tag match to logout,
|
||||
or request all connections to logout if portal group tag is omitted.
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Optional | Type | Description
|
||||
--------------------------- | -------- | --------| -----------
|
||||
name | Required | string | Target node name (ASCII)
|
||||
pg_tag | Optional | number | Existing portal group tag
|
||||
|
||||
### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~
|
||||
{
|
||||
"params": {
|
||||
"name": "iqn.2016-06.io.spdk:target1",
|
||||
"pg_tag": 1
|
||||
},
|
||||
"jsonrpc": "2.0",
|
||||
"method": "iscsi_target_node_request_logout",
|
||||
"id": 1
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": true
|
||||
}
|
||||
~~~
|
||||
|
||||
# NVMe-oF Target {#jsonrpc_components_nvmf_tgt}
|
||||
|
||||
|
@ -1218,6 +1218,65 @@ rpc_iscsi_target_node_set_redirect(struct spdk_jsonrpc_request *request,
|
||||
SPDK_RPC_REGISTER("iscsi_target_node_set_redirect", rpc_iscsi_target_node_set_redirect,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_target_logout {
|
||||
char *name;
|
||||
int32_t pg_tag;
|
||||
};
|
||||
|
||||
static void
|
||||
free_rpc_target_logout(struct rpc_target_logout *req)
|
||||
{
|
||||
free(req->name);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_target_logout_decoders[] = {
|
||||
{"name", offsetof(struct rpc_target_logout, name), spdk_json_decode_string},
|
||||
{"pg_tag", offsetof(struct rpc_target_logout, pg_tag), spdk_json_decode_int32, true},
|
||||
};
|
||||
|
||||
static void
|
||||
rpc_iscsi_target_node_request_logout(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_target_logout req = {};
|
||||
struct spdk_iscsi_tgt_node *target;
|
||||
struct spdk_json_write_ctx *w;
|
||||
|
||||
/* If pg_tag is omitted, request all connections to the specified target
|
||||
* to logout.
|
||||
*/
|
||||
req.pg_tag = -1;
|
||||
|
||||
if (spdk_json_decode_object(params, rpc_target_logout_decoders,
|
||||
SPDK_COUNTOF(rpc_target_logout_decoders),
|
||||
&req)) {
|
||||
SPDK_ERRLOG("spdk_json_decode_object failed\n");
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"Invalid parameters");
|
||||
free_rpc_target_logout(&req);
|
||||
return;
|
||||
}
|
||||
|
||||
target = iscsi_find_tgt_node(req.name);
|
||||
if (target == NULL) {
|
||||
SPDK_ERRLOG("target %s is not found\n", req.name);
|
||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"Target %s is not found", req.name);
|
||||
free_rpc_target_logout(&req);
|
||||
return;
|
||||
}
|
||||
|
||||
iscsi_conns_request_logout(target, req.pg_tag);
|
||||
|
||||
free_rpc_target_logout(&req);
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_json_write_bool(w, true);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("iscsi_target_node_request_logout", rpc_iscsi_target_node_request_logout,
|
||||
SPDK_RPC_RUNTIME)
|
||||
|
||||
static void
|
||||
rpc_iscsi_get_options(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
|
@ -1127,6 +1127,19 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
p.add_argument('-p', '--redirect_port', help='Numeric TCP port for redirect portal', required=False)
|
||||
p.set_defaults(func=iscsi_target_node_set_redirect)
|
||||
|
||||
def iscsi_target_node_request_logout(args):
|
||||
rpc.iscsi.iscsi_target_node_request_logout(
|
||||
args.client,
|
||||
name=args.name,
|
||||
pg_tag=args.pg_tag)
|
||||
|
||||
p = subparsers.add_parser('iscsi_target_node_request_logout',
|
||||
help="""For the target node, request connections whose portal group tag
|
||||
match to logout, or request all connections if portal group tag is omitted.""")
|
||||
p.add_argument('name', help='Target node name (ASCII)')
|
||||
p.add_argument('-t', '--pg-tag', help='Portal group tag (unique, integer > 0)', type=int, required=False)
|
||||
p.set_defaults(func=iscsi_target_node_request_logout)
|
||||
|
||||
def iscsi_create_portal_group(args):
|
||||
portals = []
|
||||
for p in args.portal_list.strip().split(' '):
|
||||
|
@ -398,6 +398,23 @@ def iscsi_target_node_set_redirect(client, name, pg_tag, redirect_host, redirect
|
||||
return client.call('iscsi_target_node_set_redirect', params)
|
||||
|
||||
|
||||
def iscsi_target_node_request_logout(client, name, pg_tag):
|
||||
"""Request connections to the target node to logout.
|
||||
|
||||
Args:
|
||||
name: Target node name (ASCII)
|
||||
pg_tag: Portal group tag (unique, integer > 0) (optional)
|
||||
|
||||
Returns:
|
||||
True or False
|
||||
"""
|
||||
params = {'name': name}
|
||||
|
||||
if pg_tag:
|
||||
params['pg_tag'] = pg_tag
|
||||
return client.call('iscsi_target_node_request_logout', params)
|
||||
|
||||
|
||||
@deprecated_alias('add_portal_group')
|
||||
def iscsi_create_portal_group(client, portals, tag, private):
|
||||
"""Add a portal group.
|
||||
|
Loading…
Reference in New Issue
Block a user