From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4BNH-0007pl-Cy for qemu-devel@nongnu.org; Tue, 30 Jul 2013 10:58:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4BN8-0004bI-Fy for qemu-devel@nongnu.org; Tue, 30 Jul 2013 10:58:07 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:52723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4BN8-0004at-Cc for qemu-devel@nongnu.org; Tue, 30 Jul 2013 10:57:58 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 30 Jul 2013 10:57:56 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 0355538C804A for ; Tue, 30 Jul 2013 10:57:52 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6UEvrQa108770 for ; Tue, 30 Jul 2013 10:57:53 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6UEvqbr027052 for ; Tue, 30 Jul 2013 11:57:52 -0300 Message-ID: <51F7D470.6050708@linux.vnet.ibm.com> Date: Tue, 30 Jul 2013 10:57:52 -0400 From: "Michael R. Hines" MIME-Version: 1.0 References: <1374891788-17567-1-git-send-email-mrhines@linux.vnet.ibm.com> <51F775EE.9020109@redhat.com> In-Reply-To: <51F775EE.9020109@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] rdma: bugfix: make IPv6 support work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Orit Wasserman Cc: pbonzini@redhat.com, aliguori@us.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org, mrhines@us.ibm.com On 07/30/2013 04:14 AM, Orit Wasserman wrote: > On 07/27/2013 05:23 AM, mrhines@linux.vnet.ibm.com wrote: >> From: "Michael R. Hines" >> >> When testing with libvirt, a simple IPv6 migration test failed >> because we were not using getaddrinfo() properly. >> This makes IPv6 migration over RDMA work. >> >> Also, we forgot to turn the DPRINTF flag off =). >> >> Signed-off-by: Michael R. Hines >> --- >> migration-rdma.c | 35 ++++++++++++++++++++++------------- >> 1 file changed, 22 insertions(+), 13 deletions(-) >> >> diff --git a/migration-rdma.c b/migration-rdma.c >> index d044830..3256c9b 100644 >> --- a/migration-rdma.c >> +++ b/migration-rdma.c >> @@ -27,7 +27,7 @@ >> #include >> #include >> >> -#define DEBUG_RDMA >> +//#define DEBUG_RDMA > Can you put this in a separate patch? Acknowledged. >> //#define DEBUG_RDMA_VERBOSE >> //#define DEBUG_RDMA_REALLY_VERBOSE >> >> @@ -392,6 +392,7 @@ typedef struct RDMAContext { >> uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX]; >> >> GHashTable *blockmap; >> + bool ipv6; >> } RDMAContext; >> >> /* >> @@ -744,6 +745,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) >> char port_str[16]; >> struct rdma_cm_event *cm_event; >> char ip[40] = "unknown"; >> + int af = rdma->ipv6 ? PF_INET6 : PF_INET; > We have code that handles ipv6 in utils/qemu-sockets.c, it also handle host > and port parsing please take a look at inet_parse_connect_opts. > I think it can be reused here and for the destination. RDMA cannot use that function - it creates a socket and RDMA does not use sockets. RDMA is *already*, however, using inet_parse() which does exactly what you said. > Regards, > Orit >> >> if (rdma->host == NULL || !strcmp(rdma->host, "")) { >> ERROR(errp, "RDMA hostname has not been set\n"); >> @@ -773,7 +775,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) >> goto err_resolve_get_addr; >> } >> >> - inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr, >> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr, >> ip, sizeof ip); >> DPRINTF("%s => %s\n", rdma->host, ip); >> >> @@ -2236,9 +2238,12 @@ err_rdma_source_connect: >> static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) >> { >> int ret = -EINVAL, idx; >> + int af = rdma->ipv6 ? PF_INET6 : PF_INET; >> struct sockaddr_in sin; >> struct rdma_cm_id *listen_id; >> char ip[40] = "unknown"; >> + struct addrinfo *res; >> + char port_str[16]; >> >> for (idx = 0; idx <= RDMA_WRID_MAX; idx++) { >> rdma->wr_data[idx].control_len = 0; >> @@ -2266,27 +2271,30 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) >> } >> >> memset(&sin, 0, sizeof(sin)); >> - sin.sin_family = AF_INET; >> + sin.sin_family = af; >> sin.sin_port = htons(rdma->port); >> + snprintf(port_str, 16, "%d", rdma->port); >> + port_str[15] = '\0'; >> >> if (rdma->host && strcmp("", rdma->host)) { >> - struct hostent *dest_addr; >> - dest_addr = gethostbyname(rdma->host); >> - if (!dest_addr) { >> - ERROR(errp, "migration could not gethostbyname!\n"); >> - ret = -EINVAL; >> + ret = getaddrinfo(rdma->host, port_str, NULL, &res); >> + if (ret < 0) { >> + ERROR(errp, "could not getaddrinfo address %s\n", rdma->host); >> goto err_dest_init_bind_addr; >> } >> - memcpy(&sin.sin_addr.s_addr, dest_addr->h_addr, >> - dest_addr->h_length); >> - inet_ntop(AF_INET, dest_addr->h_addr, ip, sizeof ip); >> + >> + >> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr, >> + ip, sizeof ip); >> } else { >> - sin.sin_addr.s_addr = INADDR_ANY; >> + ERROR(errp, "migration host and port not specified!\n"); >> + ret = -EINVAL; >> + goto err_dest_init_bind_addr; >> } >> >> DPRINTF("%s => %s\n", rdma->host, ip); >> >> - ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin); >> + ret = rdma_bind_addr(listen_id, res->ai_addr); >> if (ret) { >> ERROR(errp, "Error: could not rdma_bind_addr!\n"); >> goto err_dest_init_bind_addr; >> @@ -2321,6 +2329,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp) >> if (addr != NULL) { >> rdma->port = atoi(addr->port); >> rdma->host = g_strdup(addr->host); >> + rdma->ipv6 = addr->ipv6; >> } else { >> ERROR(errp, "bad RDMA migration address '%s'", host_port); >> g_free(rdma); >>