From 59a5fee7f48e4041bed214767f6394e6a2575d98 Mon Sep 17 00:00:00 2001 From: Eldad Zinger Date: Thu, 8 Apr 2010 10:09:37 +0300 Subject: [PATCH] sdp: added differentiation between bind failures of sdp. When bind()ing in mode 'BOTH', bind(sdp_sock) might fail if: 1. the IP&port is already bounded. 2. the IP is not part of IB network. previous implementation returned errno=EADDRINUSE either way. Only the first case should fail the bind(), the second is legitimate because the TCP socket will hanle the connection. This fix corresponds to a fix in libsdp. Signed-off-by: Eldad Zinger --- drivers/infiniband/ulp/sdp/sdp.h | 2 ++ drivers/infiniband/ulp/sdp/sdp_main.c | 7 ++++++- include/rdma/sdp_socket.h | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h index bb9bcaff4858..b2d84da67ba6 100644 --- a/drivers/infiniband/ulp/sdp/sdp.h +++ b/drivers/infiniband/ulp/sdp/sdp.h @@ -418,6 +418,8 @@ struct sdp_sock { /* BZCOPY data */ int bzcopy_thresh; + + int last_bind_err; }; static inline void tx_sa_reset(struct tx_srcavail_state *tx_sa) diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c index 74d6f0ef3146..597201d0d08e 100644 --- a/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/drivers/infiniband/ulp/sdp/sdp_main.c @@ -167,7 +167,7 @@ static int sdp_get_port(struct sock *sk, unsigned short snum) if (!memcmp(&addr, &ssk->id->route.addr.src_addr, sizeof addr)) return 0; - rc = rdma_bind_addr(ssk->id, (struct sockaddr *)&addr); + rc = ssk->last_bind_err = rdma_bind_addr(ssk->id, (struct sockaddr *)&addr); if (rc) { sdp_dbg(sk, "Destroying qp\n"); rdma_destroy_id(ssk->id); @@ -1086,6 +1086,8 @@ int sdp_init_sock(struct sock *sk) init_timer(&ssk->nagle_timer); init_timer(&sk->sk_timer); + ssk->last_bind_err = 0; + return 0; } @@ -1275,6 +1277,9 @@ static int sdp_getsockopt(struct sock *sk, int level, int optname, case SDP_ZCOPY_THRESH: val = ssk->bzcopy_thresh ? ssk->bzcopy_thresh : sdp_bzcopy_thresh; break; + case SDP_LAST_BIND_ERR: + val = ssk->last_bind_err; + break; default: return -ENOPROTOOPT; } diff --git a/include/rdma/sdp_socket.h b/include/rdma/sdp_socket.h index 91dbf191edda..902dc9744348 100644 --- a/include/rdma/sdp_socket.h +++ b/include/rdma/sdp_socket.h @@ -12,6 +12,10 @@ #define SDP_ZCOPY_THRESH 80 #endif +#ifndef SDP_LAST_BIND_ERR +#define SDP_LAST_BIND_ERR 81 +#endif + /* TODO: AF_INET6_SDP ? */ #endif -- 2.50.1