From nobody Thu Jan 30 15:52:00 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YkNnF04Gyz5lb65; Thu, 30 Jan 2025 15:52:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YkNnD3vPXz3Xht; Thu, 30 Jan 2025 15:52:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738252320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YgoPUpLOa3iHF5SEm3rhsz+COdNWlPyxfqChtILO7d4=; b=MJi1ZAIZv3EOGiDqKl2ETLnaM8kyKByC+VnqpSwCEjBED1n0/oitTu+IMpXJUpgC4gngWU sI9pvd+2tPbZ8YzZhnWUT7GyHr3DUnV+OiazV/FiOQA1s/kafrF1V5oSUd67QaFKKxVNOv UJWNbbR7zVtBVJySDJL3Q86zV6M1JEPYhfqpVqNNU28Lqa1L0kPS31J+G6rzublqBReQVu 4A5O3zeIl3qmD8HswT9pRHibe8U18mQ7681Jg2u3BDzF9IF/S2kYjTiLrJKdEFNsSb0JNB lmQLYbacP9eQSlSYzaRGPIpwbkt4Z/MCuMS1pToiJIwDJlhMCEZGGMJXErkNfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738252320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YgoPUpLOa3iHF5SEm3rhsz+COdNWlPyxfqChtILO7d4=; b=KmP4XUpsNpMaDRhHq0YwvAVqX285VCNpEjCapFZM34AWhhg+3TizlSvuKGkNCoCxSNgsj/ 6gFMRyzjnUgV0OSmNJcpMh2gPV+uwgR40RroAuu1TfkMY5R5BOQgdpETzIqTJ8zSwT8jCs NhHR/fGX7aW8Fab5SYrAseBzKQ0o0Dlz5ZpXKT4bG9pPlMPV5lnvRz9Md9lUaIDV5FLf1W 814RGyXFogGeHx0PziKpqzd1GBfYfmwLL0sFAeIX005HiEFGH1I+Cbuae+se57AZhsvXCr tXtxW1+5kukWHOqbVqajVEz3vq2kF6POfigPqZUKCOIrBylwNpY5myljY4pysA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738252320; a=rsa-sha256; cv=none; b=HtiAeUZJfvWhM20tR0IzNHm/n6CPKwUNus7R+zpn4s5JE8fanEF9CamrGP3Rzp3QF1NZp/ ZJkxIAGb7dTWPORHkSXMUiuE3kgJMrjxDlA/IswWWjyWVUXAg6bO0xw/XI8YVK6N+8UUjd pv6ku5JdpMjdSiEua38jzQEjkmZY2lx84C183YwIS4iZnS5IZXcPk24UXWowjteZLy172x qmfWYSS09mUdk6ibIZVgvSs+oMu1j4hxAtOO03p3WobtLW9j94sS90gHgm68YzimZv8MVI 5Ox9DKT/sZo+M5KK26kfZ5311ZfWOfjPjO5zvfOtuFA/Z2nR0hD5pXC0ukLq5Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YkNnD3VZmztyk; Thu, 30 Jan 2025 15:52:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50UFq00X016975; Thu, 30 Jan 2025 15:52:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50UFq07o016972; Thu, 30 Jan 2025 15:52:00 GMT (envelope-from git) Date: Thu, 30 Jan 2025 15:52:00 GMT Message-Id: <202501301552.50UFq07o016972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: ec282601f720 - main - nvmecontrol: Only do name resolution once for Fabrics connections List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ec282601f720c1ebda50d9c7065d1b629f38f69f Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ec282601f720c1ebda50d9c7065d1b629f38f69f commit ec282601f720c1ebda50d9c7065d1b629f38f69f Author: John Baldwin AuthorDate: 2025-01-30 15:50:58 +0000 Commit: John Baldwin CommitDate: 2025-01-30 15:50:58 +0000 nvmecontrol: Only do name resolution once for Fabrics connections Reuse the addrinfo structure from the admin queue to establish connections to I/O queues for the TCP transport. Reviewed by: dab, imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48456 --- sbin/nvmecontrol/fabrics.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/sbin/nvmecontrol/fabrics.c b/sbin/nvmecontrol/fabrics.c index 89589c88f7e3..5fdbf68127d4 100644 --- a/sbin/nvmecontrol/fabrics.c +++ b/sbin/nvmecontrol/fabrics.c @@ -148,7 +148,8 @@ nvmf_parse_cntlid(const char *cntlid) static bool tcp_qpair_params(struct nvmf_qpair_params *params, int adrfam, - const char *address, const char *port) + const char *address, const char *port, struct addrinfo **aip, + struct addrinfo **listp) { struct addrinfo hints, *ai, *list; int error, s; @@ -173,7 +174,11 @@ tcp_qpair_params(struct nvmf_qpair_params *params, int adrfam, } params->tcp.fd = s; - freeaddrinfo(list); + if (listp != NULL) { + *aip = ai; + *listp = list; + } else + freeaddrinfo(list); return (true); } warn("Failed to connect to controller at %s:%s", address, port); @@ -181,6 +186,24 @@ tcp_qpair_params(struct nvmf_qpair_params *params, int adrfam, return (false); } +static bool +tcp_qpair_params_ai(struct nvmf_qpair_params *params, struct addrinfo *ai) +{ + int s; + + s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + if (s == -1) + return (false); + + if (connect(s, ai->ai_addr, ai->ai_addrlen) != 0) { + close(s); + return (false); + } + + params->tcp.fd = s; + return (true); +} + static void tcp_discovery_association_params(struct nvmf_association_params *params) { @@ -228,7 +251,7 @@ connect_discovery_adminq(enum nvmf_trtype trtype, const char *address, err(EX_IOERR, "Failed to create discovery association"); memset(&qparams, 0, sizeof(qparams)); qparams.admin = true; - if (!tcp_qpair_params(&qparams, AF_UNSPEC, address, port)) + if (!tcp_qpair_params(&qparams, AF_UNSPEC, address, port, NULL, NULL)) exit(EX_NOHOST); qp = nvmf_connect(na, &qparams, 0, NVME_MIN_ADMIN_ENTRIES, hostid, NVMF_CNTLID_DYNAMIC, NVMF_DISCOVERY_NQN, hostnqn, 0); @@ -417,6 +440,7 @@ connect_nvm_queues(const struct nvmf_association_params *aparams, { struct nvmf_qpair_params qparams; struct nvmf_association *na; + struct addrinfo *ai, *list; u_int queues; int error; uint16_t mqes; @@ -446,7 +470,7 @@ connect_nvm_queues(const struct nvmf_association_params *aparams, /* Admin queue. */ memset(&qparams, 0, sizeof(qparams)); qparams.admin = true; - if (!tcp_qpair_params(&qparams, adrfam, address, port)) { + if (!tcp_qpair_params(&qparams, adrfam, address, port, &ai, &list)) { nvmf_free_association(na); return (EX_NOHOST); } @@ -454,6 +478,7 @@ connect_nvm_queues(const struct nvmf_association_params *aparams, kato, &mqes); if (error != 0) { nvmf_free_association(na); + freeaddrinfo(list); return (error); } @@ -495,7 +520,9 @@ connect_nvm_queues(const struct nvmf_association_params *aparams, for (u_int i = 0; i < num_io_queues; i++) { memset(&qparams, 0, sizeof(qparams)); qparams.admin = false; - if (!tcp_qpair_params(&qparams, adrfam, address, port)) { + if (!tcp_qpair_params_ai(&qparams, ai)) { + warn("Failed to connect to controller at %s:%s", + address, port); error = EX_NOHOST; goto out; } @@ -509,11 +536,13 @@ connect_nvm_queues(const struct nvmf_association_params *aparams, } } nvmf_free_association(na); + freeaddrinfo(list); return (0); out: disconnect_nvm_queues(*admin, io, num_io_queues); nvmf_free_association(na); + freeaddrinfo(list); return (error); }