]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: Verify size of route_len
authorSean Hefty <sean.hefty@intel.com>
Wed, 28 Sep 2011 06:22:21 +0000 (23:22 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 29 Sep 2011 21:17:15 +0000 (14:17 -0700)
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
src/acm.c

index e69d8ce6988c73e93114cc382a88bcd0c323878d..31c233de862e681f85a3f2f9410a655311fdabea 100755 (executable)
@@ -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
index 1fa6c6242cf8d9f71f0213c461281ecc9ae52e14..00e004360e117ae4d28834f15c2dfa25d20dee68 100755 (executable)
--- 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);