Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > 0ffedb546e146cfbef3c4cdabc46b7c3 > files > 3

librdmacm-1.0.15-5.mga3.src.rpm

From b17cbf0636dc8bbe786c2055405e23104b513887 Mon Sep 17 00:00:00 2001
From: Sean Hefty <sean.hefty@intel.com>
Date: Tue, 27 Sep 2011 23:22:21 -0700
Subject: [PATCH 3/9] librdmacm: Verify size of route_len

If the user specifies route information on input to rdma_getaddrinfo,
verify that the size of the routing data is something that we're
prepared to handle.

The routing data is only useful if IB ACM is enabled and may be
either struct ibv_path_record or struct ibv_path_data on input.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
---
 man/rdma_getaddrinfo.3 |   13 +++++++++++--
 src/acm.c              |   19 +++++++++++++++----
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/man/rdma_getaddrinfo.3 b/man/rdma_getaddrinfo.3
index e69d8ce..31c233d 100755
--- a/man/rdma_getaddrinfo.3
+++ b/man/rdma_getaddrinfo.3
@@ -28,10 +28,15 @@ RDMA functional equivalent to getaddrinfo.
 Returns 0 on success, or -1 on error.  If an error occurs, errno will be
 set to indicate the failure reason.
 .SH "NOTES"
-Either node or service must be provided.  If hints are provided, the
+Either node, service, or hints must be provided.  If hints are provided, the
 operation will be controlled by hints.ai_flags.  If RAI_PASSIVE is
 specified, the call will resolve address information for use on the
 passive side of a connection.
+If node is provided, rdma_getaddrinfo will attempt to resolve the RDMA address,
+route, and connection data to the given node.  The hints parameter, if provided,
+may be used to control the resulting output as indicated below.
+If node is not given, rdma_getaddrinfo will attempt to resolve the RDMA addressing
+information based on the hints.ai_src_addr, hints.ai_dst_addr, or hints.ai_route.
 .SH "rdma_addrinfo"
 .IP "ai_flags" 12
 Hint flags that control the operation.  Supported flags are:
@@ -74,7 +79,11 @@ could be resolved.
 Routing information for RDMA transports that require routing data as part
 of connection establishment.  The format of the routing data depends on
 the underlying transport.  If Infiniband transports are
-used, ai_route will reference an array of struct ibv_path_data.
+used, ai_route will reference an array of struct ibv_path_data on output,
+if routing data is available.  Routing paths may be restricted by setting
+desired routing data fields on input to rdma_getaddrinfo.  For Infiniband,
+hints.ai_route may reference an array of struct ibv_path_record or
+struct ibv_path_data on input.
 .IP "ai_connect_len" 12
 Size of connection information referenced by ai_connect.  This will be
 0 if the underlying transport does not require additional connection
diff --git a/src/acm.c b/src/acm.c
index 1fa6c62..00e0043 100755
--- a/src/acm.c
+++ b/src/acm.c
@@ -300,10 +300,21 @@ void ucma_ib_resolve(struct rdma_addrinfo *rai, struct rdma_addrinfo *hints)
 	}
 
 	if (hints && hints->ai_route_len) {
-		data->type = ACM_EP_INFO_PATH;
-		memcpy(&data->info.path, hints->ai_route, hints->ai_route_len);
-		data++;
-		msg.hdr.length += ACM_MSG_EP_LENGTH;
+		struct ibv_path_record *path;
+
+		if (hints->ai_route_len == sizeof(struct ibv_path_record))
+			path = (struct ibv_path_record *) hints->ai_route;
+		else if (hints->ai_route_len == sizeof(struct ibv_path_data))
+			path = &((struct ibv_path_data *) hints->ai_route)->path;
+		else
+			path = NULL;
+
+		if (path) {
+			data->type = ACM_EP_INFO_PATH;
+			memcpy(&data->info.path, path, sizeof(*path));
+			data++;
+			msg.hdr.length += ACM_MSG_EP_LENGTH;
+		}
 	}
 
 	pthread_mutex_lock(&acm_lock);
-- 
1.7.6.4