nvmf/rdma: parse listen address directive for rdma and tcp transport
Package ip address parsing code into a separate function. This change is the first patch in the series to enable FC listen address support. Signed-off-by: Anil Veerabhadrappa <anil.veerabhadrappa@broadcom.com> Change-Id: Ia86c61d001a091dfb9f825b68f76cdaf94537303 Signed-off-by: Anil Veerabhadrappa <anil.veerabhadrappa@broadcom.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471024 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
8ed9e0a187
commit
32e3e269a3
@ -232,7 +232,7 @@
|
||||
# - NQN is required and must be unique.
|
||||
# - Between 1 and 255 Listen directives are allowed. This defines
|
||||
# the addresses on which new connections may be accepted. The format
|
||||
# is Listen <type> <address> where type currently can only be RDMA.
|
||||
# is Listen <type> <address> where type can be RDMA or TCP.
|
||||
# - Between 0 and 255 Host directives are allowed. This defines the
|
||||
# NQNs of allowed hosts. If no Host directive is specified, all hosts
|
||||
# are allowed to connect.
|
||||
|
@ -240,12 +240,37 @@ spdk_nvmf_tgt_listen_done(void *cb_arg, int status)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nvmf_tgt_parse_listen_ip_addr(char *address,
|
||||
struct spdk_nvme_transport_id *trid)
|
||||
{
|
||||
char *host;
|
||||
char *port;
|
||||
|
||||
if (spdk_parse_ip_addr(address, &host, &port) < 0) {
|
||||
SPDK_ERRLOG("Unable to parse listen address '%s'\n", address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strchr(host, ':')) {
|
||||
trid->adrfam = SPDK_NVMF_ADRFAM_IPV6;
|
||||
} else {
|
||||
trid->adrfam = SPDK_NVMF_ADRFAM_IPV4;
|
||||
}
|
||||
|
||||
snprintf(trid->traddr, sizeof(trid->traddr), "%s", host);
|
||||
if (port) {
|
||||
snprintf(trid->trsvcid, sizeof(trid->trsvcid), "%s", port);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
|
||||
{
|
||||
const char *nqn, *mode;
|
||||
size_t i;
|
||||
int ret;
|
||||
int lcore;
|
||||
bool allow_any_host;
|
||||
const char *sn;
|
||||
@ -391,8 +416,6 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
|
||||
const char *transport;
|
||||
const char *address;
|
||||
char *address_dup;
|
||||
char *host;
|
||||
char *port;
|
||||
|
||||
transport = spdk_conf_section_get_nmval(sp, "Listen", i, 0);
|
||||
if (!transport) {
|
||||
@ -414,23 +437,14 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = spdk_parse_ip_addr(address_dup, &host, &port);
|
||||
if (ret < 0) {
|
||||
SPDK_ERRLOG("Unable to parse listen address '%s'\n", address);
|
||||
free(address_dup);
|
||||
continue;
|
||||
if (trid.trtype == SPDK_NVME_TRANSPORT_RDMA ||
|
||||
trid.trtype == SPDK_NVME_TRANSPORT_TCP) {
|
||||
if (spdk_nvmf_tgt_parse_listen_ip_addr(address_dup, &trid)) {
|
||||
free(address_dup);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(host, ':')) {
|
||||
trid.adrfam = SPDK_NVMF_ADRFAM_IPV6;
|
||||
} else {
|
||||
trid.adrfam = SPDK_NVMF_ADRFAM_IPV4;
|
||||
}
|
||||
|
||||
snprintf(trid.traddr, sizeof(trid.traddr), "%s", host);
|
||||
if (port) {
|
||||
snprintf(trid.trsvcid, sizeof(trid.trsvcid), "%s", port);
|
||||
}
|
||||
free(address_dup);
|
||||
|
||||
spdk_nvmf_tgt_listen(g_spdk_nvmf_tgt, &trid, spdk_nvmf_tgt_listen_done, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user