Commit 48352fbb authored by kyuho.son's avatar kyuho.son Committed by Jim Harris
Browse files

nvmf: Add API for stopping mDNS Pull Registration Request



Change-Id: I4264505720f937017b1fbde549fbd0a349f63b04
Signed-off-by: default avatarkyuho.son <kyuho.son@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23037


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent e2d54380
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -13247,3 +13247,37 @@ Example response:
  "result": true
}
~~~

### nvmf_stop_mdns_prr {#rpc_nvmf_stop_mdns_prr}

This interface is used to stop publishing the NVMf target's service location
using mDNS (Multicast DNS) protocol. It removes the published service location,
preventing clients from discovering the NVMf target.

#### Parameters

Name                       | Optional | Type        | Description
-------------------------- | -------- | ----------- | -----------
tgt_name                   | Optional | string      | Parent NVMe-oF target name.

#### Example

Example request:

~~~json
{
  "jsonrpc": "2.0",
  "method": "nvmf_stop_mdns_prr",
  "id": 1
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~
+11 −0
Original line number Diff line number Diff line
@@ -93,6 +93,17 @@ nvmf_ctx_stop_mdns_prr(struct mdns_publish_ctx *ctx)
	ctx->stop = true;
}

void
nvmf_tgt_stop_mdns_prr(struct spdk_nvmf_tgt *tgt)
{
	if (g_mdns_publish_ctx && g_mdns_publish_ctx->tgt == tgt) {
		nvmf_ctx_stop_mdns_prr(g_mdns_publish_ctx);
		return;
	}

	SPDK_ERRLOG("Failed to stop mDNS PRR. It is not running on target %s.\n", tgt->name);
}

static int
publish_pull_registration_request(AvahiClient *client, struct mdns_publish_ctx *publish_ctx)
{
+7 −0
Original line number Diff line number Diff line
@@ -585,4 +585,11 @@ void nvmf_bdev_ctrlr_zcopy_end(struct spdk_nvmf_request *req, bool commit);
 */
int nvmf_publish_mdns_prr(struct spdk_nvmf_tgt *tgt);

/**
 * Stops the mDNS PRR (Pull Registration Request) for the NVMe-oF target.
 *
 * \param tgt The NVMe-oF target
 */
void nvmf_tgt_stop_mdns_prr(struct spdk_nvmf_tgt *tgt);

#endif /* __NVMF_INTERNAL_H__ */
+39 −0
Original line number Diff line number Diff line
@@ -3038,3 +3038,42 @@ rpc_nvmf_publish_mdns_prr(struct spdk_jsonrpc_request *request,
	free(req.tgt_name);
}
SPDK_RPC_REGISTER("nvmf_publish_mdns_prr", rpc_nvmf_publish_mdns_prr, SPDK_RPC_RUNTIME);

static void
rpc_nvmf_stop_mdns_prr(struct spdk_jsonrpc_request *request,
		       const struct spdk_json_val *params)
{
#ifndef SPDK_CONFIG_AVAHI
	SPDK_ERRLOG("nvmf_stop_mdns_prr is supported when SPDK is built with the --with-avahi option.\n");
	spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
					 "nvmf_stop_mdns_prr is supported when SPDK is built with the --with-avahi option.");
	return;
#endif

	struct rpc_mdns_prr req = { 0 };
	struct spdk_nvmf_tgt *tgt;

	if (params) {
		if (spdk_json_decode_object(params, rpc_mdns_prr_decoders,
					    SPDK_COUNTOF(rpc_mdns_prr_decoders),
					    &req)) {
			SPDK_ERRLOG("spdk_json_decode_object failed\n");
			spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
			return;
		}
	}

	tgt = spdk_nvmf_get_tgt(req.tgt_name);
	if (!tgt) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
						 "Unable to find a target.");
		free(req.tgt_name);
		return;
	}

	nvmf_tgt_stop_mdns_prr(tgt);

	spdk_jsonrpc_send_bool_response(request, true);
	free(req.tgt_name);
}
SPDK_RPC_REGISTER("nvmf_stop_mdns_prr", rpc_nvmf_stop_mdns_prr, SPDK_RPC_RUNTIME);
+16 −0
Original line number Diff line number Diff line
@@ -718,3 +718,19 @@ def nvmf_publish_mdns_prr(client, tgt_name=None):
        params['tgt_name'] = tgt_name

    return client.call('nvmf_publish_mdns_prr', params)


def nvmf_stop_mdns_prr(client, tgt_name=None):
    """Stop publishing mdns pull registration request

    Args:
        tgt_name: name of the NVMe-oF target (optional).

    Returns:
        Success or Fail
    """
    params = {}
    if tgt_name:
        params['tgt_name'] = tgt_name

    return client.call('nvmf_stop_mdns_prr', params)
Loading