If the user provides a source address as a hint, copy the address to rdma_addrinfo ai_src_addr.
Signed-off-by: Sean Hefty <[email protected]> --- Changes from v1: Only copy the source address if one is provided by the user though the hints. Do not assign a source address otherwise. The kernel will resolve the source address for us via rdma_resolve_addr(). src/addrinfo.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/src/addrinfo.c b/src/addrinfo.c index 15ae071..f5f86a0 100644 --- a/src/addrinfo.c +++ b/src/addrinfo.c @@ -39,6 +39,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> +#include <unistd.h> #include "cma.h" #include <rdma/rdma_cma.h> @@ -159,6 +160,17 @@ int rdma_getaddrinfo(char *node, char *service, if (ret) goto err2; + if (!rai->ai_src_len && hints && hints->ai_src_len) { + rai->ai_src_addr = calloc(1, hints->ai_src_len); + if (!rai->ai_src_addr) { + ret = ERR(ENOMEM); + goto err2; + } + memcpy(rai->ai_src_addr, hints->ai_src_addr, + hints->ai_src_len); + rai->ai_src_len = hints->ai_src_len; + } + freeaddrinfo(ai); *res = rai; return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
