diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index 0132033b6..d3fd8cfe0 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -317,6 +317,18 @@ const char *spdk_nvmf_host_get_nqn(struct spdk_nvmf_host *host); int spdk_nvmf_subsystem_add_listener(struct spdk_nvmf_subsystem *subsystem, struct spdk_nvme_transport_id *trid); +/** + * Stop accepting new connections on the address provided + * + * May only be performed on subsystems in the PAUSED or INACTIVE states. + * + * \param subsystem Subsystem to remove listener from + * \param trid The address to no longer accept connections from + * \return 0 on success. Negated errno value on failure. + */ +int spdk_nvmf_subsystem_remove_listener(struct spdk_nvmf_subsystem *subsystem, + const struct spdk_nvme_transport_id *trid); + /** * Check if connections originated from the given address are allowed to connect to the subsystem. * diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index de07186cf..dd9cf3fb5 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -700,6 +700,28 @@ spdk_nvmf_subsystem_add_listener(struct spdk_nvmf_subsystem *subsystem, return 0; } +int +spdk_nvmf_subsystem_remove_listener(struct spdk_nvmf_subsystem *subsystem, + const struct spdk_nvme_transport_id *trid) +{ + struct spdk_nvmf_listener *listener; + + if (!(subsystem->state == SPDK_NVMF_SUBSYSTEM_INACTIVE || + subsystem->state == SPDK_NVMF_SUBSYSTEM_PAUSED)) { + return -EAGAIN; + } + + listener = _spdk_nvmf_subsystem_find_listener(subsystem, trid); + if (listener == NULL) { + return -ENOENT; + } + + TAILQ_REMOVE(&subsystem->listeners, listener, link); + free(listener); + + return 0; +} + /* * TODO: this is the whitelist and will be called during connection setup */