]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sdp: added differentiation between bind failures of sdp.
authorEldad Zinger <eldadz@mellanox.co.il>
Thu, 8 Apr 2010 07:09:37 +0000 (10:09 +0300)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:04:52 +0000 (05:04 -0700)
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 <eldadz@mellanox.co.il>
drivers/infiniband/ulp/sdp/sdp.h
drivers/infiniband/ulp/sdp/sdp_main.c
include/rdma/sdp_socket.h

index bb9bcaff485894863683c32c9b301ae25f6725aa..b2d84da67ba6956796e9f6fd36c6419c23e44012 100644 (file)
@@ -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)
index 74d6f0ef31469895667250625318fde430b7eba8..597201d0d08e25c35fd72b2fcd933bebb2481fd2 100644 (file)
@@ -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;
        }
index 91dbf191eddaaffdca26b03d28096b3b1ca4ca73..902dc97443487f5b40419f7e9ae16cb9dc4f7bfe 100644 (file)
 #define SDP_ZCOPY_THRESH 80
 #endif
 
+#ifndef SDP_LAST_BIND_ERR
+#define SDP_LAST_BIND_ERR 81
+#endif
+
 /* TODO: AF_INET6_SDP ? */
 
 #endif