@@ -355,6 +355,13 @@ xprt_setup_rdma(struct xprt_create *args)
xprt_rdma_format_addresses(xprt, sap);
new_xprt = rpcx_to_rdmax(xprt);
+
+ /* Copy source address if specified */
+ if (args->srcaddr) {
+ new_xprt->rx_has_srcaddr = true;
+ memcpy(&new_xprt->rx_saddr, args->srcaddr, args->addrlen);
+ }
+
rc = rpcrdma_buffer_create(new_xprt);
if (rc) {
xprt_rdma_free_addresses(xprt);
@@ -314,6 +314,7 @@ static struct rdma_cm_id *rpcrdma_create_id(struct rpcrdma_xprt *r_xprt,
unsigned long wtimeout = msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT) + 1;
struct rpc_xprt *xprt = &r_xprt->rx_xprt;
struct rdma_cm_id *id;
+ struct sockaddr *saddr = NULL;
int rc;
init_completion(&ep->re_done);
@@ -324,7 +325,19 @@ static struct rdma_cm_id *rpcrdma_create_id(struct rpcrdma_xprt *r_xprt,
return id;
ep->re_async_rc = -ETIMEDOUT;
- rc = rdma_resolve_addr(id, NULL, (struct sockaddr *)&xprt->addr,
+ if (r_xprt->rx_has_srcaddr) {
+ char buf[0x50] = {0, };
+ saddr = (struct sockaddr *)&r_xprt->rx_saddr;
+
+ rpc_ntop(saddr, buf, sizeof(buf));
+
+ dprintk("xprt=%p, source address port %s\n", xprt, buf);
+ }
+
+ dprintk("xprt=%p, %s:%s resolving addr\n", xprt,
+ rpcrdma_addrstr(r_xprt), rpcrdma_portstr(r_xprt));
+
+ rc = rdma_resolve_addr(id, saddr, (struct sockaddr *)&xprt->addr,
RDMA_RESOLVE_TIMEOUT);
if (rc)
goto out;
@@ -421,6 +421,8 @@ struct rpcrdma_stats {
*/
struct rpcrdma_xprt {
struct rpc_xprt rx_xprt;
+ struct sockaddr_storage rx_saddr;
+ bool rx_has_srcaddr;
struct rpcrdma_ep *rx_ep;
struct rpcrdma_buffer rx_buf;
struct delayed_work rx_connect_worker;
Until now, rpcrdma did not make use of the local address when binding a QP. For subnets where the local machine has multiple IP addresses that are all connected to the same subnet, it may be desired to tell from which interface a QP is going out. Signed-off-by: Dan Aloni <dan@kernelim.com> --- net/sunrpc/xprtrdma/transport.c | 7 +++++++ net/sunrpc/xprtrdma/verbs.c | 15 ++++++++++++++- net/sunrpc/xprtrdma/xprt_rdma.h | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-)