|
|
9ae3a8 |
From b60d6390ff9415bc5960ba20ff5cc56e50078f85 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <b60d6390ff9415bc5960ba20ff5cc56e50078f85.1387382496.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
From: Nigel Croxon <ncroxon@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 14 Nov 2013 22:53:06 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 30/46] rdma: proper getaddrinfo() handling
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Nigel Croxon <ncroxon@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1384469598-13137-31-git-send-email-ncroxon@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55714
|
|
|
9ae3a8 |
O-Subject: [RHEL7.0 PATCH 30/42] rdma: proper getaddrinfo() handling
|
|
|
9ae3a8 |
Bugzilla: 1011720
|
|
|
9ae3a8 |
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: 1011720
|
|
|
9ae3a8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
>From commit ID:
|
|
|
9ae3a8 |
commit 6470215b794d6d9f9ffbd82f669645715eb014f8
|
|
|
9ae3a8 |
Author: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
9ae3a8 |
Date: Fri Aug 9 16:05:43 2013 -0400
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
rdma: proper getaddrinfo() handling
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
getaddrinfo() already knows what it's doing,
|
|
|
9ae3a8 |
but it can potentially return multiple addresses.
|
|
|
9ae3a8 |
We need to handle that...
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
|
|
|
9ae3a8 |
Message-id: 1376078746-24948-5-git-send-email-mrhines@linux.vnet.ibm.com
|
|
|
9ae3a8 |
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
migration-rdma.c | 56 +++++++++++++++++++++++++++--------------------------
|
|
|
9ae3a8 |
1 files changed, 29 insertions(+), 27 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
migration-rdma.c | 56 +++++++++++++++++++++++++++++---------------------------
|
|
|
9ae3a8 |
1 file changed, 29 insertions(+), 27 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/migration-rdma.c b/migration-rdma.c
|
|
|
9ae3a8 |
index 9c02ad3..e6fd77a 100644
|
|
|
9ae3a8 |
--- a/migration-rdma.c
|
|
|
9ae3a8 |
+++ b/migration-rdma.c
|
|
|
9ae3a8 |
@@ -392,7 +392,6 @@ typedef struct RDMAContext {
|
|
|
9ae3a8 |
uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
GHashTable *blockmap;
|
|
|
9ae3a8 |
- bool ipv6;
|
|
|
9ae3a8 |
} RDMAContext;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
@@ -745,7 +744,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
|
|
|
9ae3a8 |
char port_str[16];
|
|
|
9ae3a8 |
struct rdma_cm_event *cm_event;
|
|
|
9ae3a8 |
char ip[40] = "unknown";
|
|
|
9ae3a8 |
- int af = rdma->ipv6 ? PF_INET6 : PF_INET;
|
|
|
9ae3a8 |
+ struct addrinfo *e;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (rdma->host == NULL || !strcmp(rdma->host, "")) {
|
|
|
9ae3a8 |
ERROR(errp, "RDMA hostname has not been set");
|
|
|
9ae3a8 |
@@ -775,18 +774,23 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
|
|
|
9ae3a8 |
goto err_resolve_get_addr;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
|
|
|
9ae3a8 |
- ip, sizeof ip);
|
|
|
9ae3a8 |
- DPRINTF("%s => %s\n", rdma->host, ip);
|
|
|
9ae3a8 |
+ for (e = res; e != NULL; e = e->ai_next) {
|
|
|
9ae3a8 |
+ inet_ntop(e->ai_family,
|
|
|
9ae3a8 |
+ &((struct sockaddr_in *) e->ai_addr)->sin_addr, ip, sizeof ip);
|
|
|
9ae3a8 |
+ DPRINTF("Trying %s => %s\n", rdma->host, ip);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- /* resolve the first address */
|
|
|
9ae3a8 |
- ret = rdma_resolve_addr(rdma->cm_id, NULL, res->ai_addr,
|
|
|
9ae3a8 |
- RDMA_RESOLVE_TIMEOUT_MS);
|
|
|
9ae3a8 |
- if (ret) {
|
|
|
9ae3a8 |
- ERROR(errp, "could not resolve address %s", rdma->host);
|
|
|
9ae3a8 |
- goto err_resolve_get_addr;
|
|
|
9ae3a8 |
+ /* resolve the first address */
|
|
|
9ae3a8 |
+ ret = rdma_resolve_addr(rdma->cm_id, NULL, e->ai_addr,
|
|
|
9ae3a8 |
+ RDMA_RESOLVE_TIMEOUT_MS);
|
|
|
9ae3a8 |
+ if (!ret) {
|
|
|
9ae3a8 |
+ goto route;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ ERROR(errp, "could not resolve address %s", rdma->host);
|
|
|
9ae3a8 |
+ goto err_resolve_get_addr;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+route:
|
|
|
9ae3a8 |
qemu_rdma_dump_gid("source_resolve_addr", rdma->cm_id);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = rdma_get_cm_event(rdma->channel, &cm_event);
|
|
|
9ae3a8 |
@@ -2260,8 +2264,6 @@ err_rdma_source_connect:
|
|
|
9ae3a8 |
static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret = -EINVAL, idx;
|
|
|
9ae3a8 |
- int af = rdma->ipv6 ? PF_INET6 : PF_INET;
|
|
|
9ae3a8 |
- struct sockaddr_in sin;
|
|
|
9ae3a8 |
struct rdma_cm_id *listen_id;
|
|
|
9ae3a8 |
char ip[40] = "unknown";
|
|
|
9ae3a8 |
struct addrinfo *res;
|
|
|
9ae3a8 |
@@ -2292,35 +2294,36 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
|
|
|
9ae3a8 |
goto err_dest_init_create_listen_id;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- memset(&sin, 0, sizeof(sin));
|
|
|
9ae3a8 |
- sin.sin_family = af;
|
|
|
9ae3a8 |
- sin.sin_port = htons(rdma->port);
|
|
|
9ae3a8 |
snprintf(port_str, 16, "%d", rdma->port);
|
|
|
9ae3a8 |
port_str[15] = '\0';
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (rdma->host && strcmp("", rdma->host)) {
|
|
|
9ae3a8 |
+ struct addrinfo *e;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
ret = getaddrinfo(rdma->host, port_str, NULL, &res;;
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
ERROR(errp, "could not getaddrinfo address %s", rdma->host);
|
|
|
9ae3a8 |
goto err_dest_init_bind_addr;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ for (e = res; e != NULL; e = e->ai_next) {
|
|
|
9ae3a8 |
+ inet_ntop(e->ai_family,
|
|
|
9ae3a8 |
+ &((struct sockaddr_in *) e->ai_addr)->sin_addr, ip, sizeof ip);
|
|
|
9ae3a8 |
+ DPRINTF("Trying %s => %s\n", rdma->host, ip);
|
|
|
9ae3a8 |
+ ret = rdma_bind_addr(listen_id, e->ai_addr);
|
|
|
9ae3a8 |
+ if (!ret) {
|
|
|
9ae3a8 |
+ goto listen;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
|
|
|
9ae3a8 |
- ip, sizeof ip);
|
|
|
9ae3a8 |
+ ERROR(errp, "Error: could not rdma_bind_addr!");
|
|
|
9ae3a8 |
+ goto err_dest_init_bind_addr;
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
ERROR(errp, "migration host and port not specified!");
|
|
|
9ae3a8 |
ret = -EINVAL;
|
|
|
9ae3a8 |
goto err_dest_init_bind_addr;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- DPRINTF("%s => %s\n", rdma->host, ip);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- ret = rdma_bind_addr(listen_id, res->ai_addr);
|
|
|
9ae3a8 |
- if (ret) {
|
|
|
9ae3a8 |
- ERROR(errp, "Error: could not rdma_bind_addr!");
|
|
|
9ae3a8 |
- goto err_dest_init_bind_addr;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+listen:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
rdma->listen_id = listen_id;
|
|
|
9ae3a8 |
qemu_rdma_dump_gid("dest_init", listen_id);
|
|
|
9ae3a8 |
@@ -2351,7 +2354,6 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
|
|
|
9ae3a8 |
if (addr != NULL) {
|
|
|
9ae3a8 |
rdma->port = atoi(addr->port);
|
|
|
9ae3a8 |
rdma->host = g_strdup(addr->host);
|
|
|
9ae3a8 |
- rdma->ipv6 = addr->ipv6;
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
ERROR(errp, "bad RDMA migration address '%s'", host_port);
|
|
|
9ae3a8 |
g_free(rdma);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.11.7
|
|
|
9ae3a8 |
|