nvmf: check for duplicate listen addresses
Don't allow a duplicate listener to be added to a subsystem. Change-Id: I1a5f2ae09146a31859921430fb716a36d7f2048e Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/398652 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
69c91d6706
commit
6ad3a5ce9b
@ -649,6 +649,21 @@ spdk_nvmf_host_get_nqn(struct spdk_nvmf_host *host)
|
||||
return host->nqn;
|
||||
}
|
||||
|
||||
static struct spdk_nvmf_listener *
|
||||
_spdk_nvmf_subsystem_find_listener(struct spdk_nvmf_subsystem *subsystem,
|
||||
const struct spdk_nvme_transport_id *trid)
|
||||
{
|
||||
struct spdk_nvmf_listener *listener;
|
||||
|
||||
TAILQ_FOREACH(listener, &subsystem->listeners, link) {
|
||||
if (spdk_nvme_transport_id_compare(&listener->trid, trid) == 0) {
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvmf_subsystem_add_listener(struct spdk_nvmf_subsystem *subsystem,
|
||||
struct spdk_nvme_transport_id *trid)
|
||||
@ -661,6 +676,11 @@ spdk_nvmf_subsystem_add_listener(struct spdk_nvmf_subsystem *subsystem,
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
if (_spdk_nvmf_subsystem_find_listener(subsystem, trid)) {
|
||||
/* Listener already exists in this subsystem */
|
||||
return 0;
|
||||
}
|
||||
|
||||
transport = spdk_nvmf_tgt_get_transport(subsystem->tgt, trid->trtype);
|
||||
if (transport == NULL) {
|
||||
SPDK_ERRLOG("Unknown transport type %d\n", trid->trtype);
|
||||
|
Loading…
Reference in New Issue
Block a user