On Tue, Feb 22, 2005 at 11:42:21AM +0200, Michael S. Tsirkin wrote:
> SDP_CONN_PUT was called before SDP_CONN_UNLOCK.
> If this is the last reference, the connection could be removed
> and an attempt to unlock would crash.

  
  The conn_hold can be moved to after sdp_cm_connect() returns a
success result, which removes the need to call conn_put in case of
error. I'd also rather move it closer to the send_cm_req() request
which is the request that is really the reason for the increment
in reference. 

  In making that move a couple other functions then need to reflect
this change. Here's a patch which makes this update, and simplifies
the active connection sequence.

-Libor

Index: infiniband/ulp/sdp/sdp_inet.c
===================================================================
--- infiniband/ulp/sdp/sdp_inet.c       (revision 1909)
+++ infiniband/ulp/sdp/sdp_inet.c       (working copy)
@@ -590,8 +590,6 @@
 
                conn->dst_addr = ntohl(addr->sin_addr.s_addr);
                conn->dst_port = ntohs(addr->sin_port);
-
-               sdp_conn_hold(conn);    /* CM reference */
                /*
                 * close, allow connection completion notification.
                 */
@@ -610,8 +608,6 @@
                        sock->state = SS_UNCONNECTED;
                        conn->istate = SDP_SOCK_ST_CLOSED;
 
-                       sdp_conn_put(conn);     /* CM reference */
-
                        goto done;
                }
 
Index: infiniband/ulp/sdp/sdp_proto.h
===================================================================
--- infiniband/ulp/sdp/sdp_proto.h      (revision 1908)
+++ infiniband/ulp/sdp/sdp_proto.h      (working copy)
@@ -120,8 +120,6 @@
 
 int sdp_wall_send_abort(struct sdp_opt *conn);
 
-int sdp_wall_recv_reject(struct sdp_opt *conn, int error);
-
 int sdp_wall_recv_confirm(struct sdp_opt *conn);
 
 int sdp_wall_recv_failed(struct sdp_opt *conn, int error);
@@ -334,6 +332,7 @@
                       struct ib_cm_event *event,
                       struct sdp_opt *conn);
 
+void sdp_cm_actv_error(struct sdp_opt *conn, int error);
 /*
  * passive connect functions
  */
@@ -351,10 +350,6 @@
 
 int sdp_cm_reject(struct sdp_opt *conn);
 
-int sdp_cm_failed(struct sdp_opt *conn);
-
-int sdp_cm_confirm(struct sdp_opt *conn);
-
 int sdp_recv_flush(struct sdp_opt *conn);
 
 int sdp_send_flush(struct sdp_opt *conn);
Index: infiniband/ulp/sdp/sdp_actv.c
===================================================================
--- infiniband/ulp/sdp/sdp_actv.c       (revision 1909)
+++ infiniband/ulp/sdp/sdp_actv.c       (working copy)
@@ -37,7 +37,72 @@
 /*
  * Connection establishment functions
  */
+void sdp_cm_actv_error(struct sdp_opt *conn, int error)
+{
+       int result;
+       /*
+        * error value is positive error.
+        *
+        * Handle errors within active connections stream. 
+        * First generate appropriate response, REJ, DREQ or nothing.
+        * Second the socket must be notified of the error.
+        */
+       switch (conn->state) {
+       default:
+               sdp_dbg_warn(conn, "REP error in unknown connection state");
+       case SDP_CONN_ST_REQ_PATH:
+               /*
+                * CM message was never sent.
+                */
+               conn->state = SDP_CONN_ST_CLOSED;
+       case SDP_CONN_ST_CLOSED:
+               break;
+       case SDP_CONN_ST_ERROR_STRM: /* socket has been destroyed. */
+               error = ECONNRESET;
+        case SDP_CONN_ST_REQ_SENT: 
+       case SDP_CONN_ST_REP_RECV:
+       case SDP_CONN_ST_RTU_SENT:
+               /*
+                * All four states we have gotten a REP and are now in
+                * one of these states.
+                */
+               result = ib_send_cm_rej(conn->cm_id, 
+                                       IB_CM_REJ_CONSUMER_DEFINED,
+                                       NULL, 0, NULL, 0);
 
+               if (0 > result)
+                       sdp_dbg_warn(conn, "Error <%d> sending CM REJ.",
+                                    result);
+
+               conn->state = SDP_CONN_ST_CLOSED;
+               break;
+       case SDP_CONN_ST_ESTABLISHED:
+               /*
+                * Made it all the way to esablished, need to initiate a
+                * full disconnect.
+                */
+               result = ib_send_cm_dreq(conn->cm_id, NULL, 0);
+               if (0 > result)
+                       sdp_dbg_warn(NULL, "Error <%d> sending CM DREQ", 
+                                    result);
+               
+               conn->state = SDP_CONN_ST_TIME_WAIT_1;
+               break;
+       }
+
+       SDP_CONN_SET_ERR(conn, error);
+       conn->istate = SDP_SOCK_ST_ERROR;
+       conn->shutdown = SHUTDOWN_MASK;
+       conn->send_buf = 0;
+
+       if (conn->sk->sk_socket)
+               conn->sk->sk_socket->state = SS_UNCONNECTED;
+
+       sdp_iocb_q_cancel_all(conn, (0 - error));
+       sdp_inet_wake_error(conn->sk);
+       return;
+}
+
 /*
  * _sdp_actv_conn_establish - process an accepted connection request.
  */
@@ -53,134 +118,97 @@
                     conn->dst_addr, conn->dst_port);
 
        sk = conn->sk;
+
+       qp_attr = kmalloc(sizeof(*qp_attr), GFP_KERNEL);
+       if (!qp_attr)
+               return -ENOMEM;
        /*
-        * only reason not to confirm is if the connection state has changed
-        * from under us, and the change wasn't followed up with a Abort(),
-        * which it should have been.
+        * modify QP to RTR
         */
-       if (SDP_SOCK_ST_CONNECT == conn->istate) {
-               qp_attr = kmalloc(sizeof(*qp_attr), GFP_KERNEL);
-               if (!qp_attr) {
-                       result = -ENOMEM;
-                       goto error;
-               }
-               /*
-                * modify QP to RTR
-                */
-               qp_attr->qp_state = IB_QPS_RTR;
+       qp_attr->qp_state = IB_QPS_RTR;
 
-               result = ib_cm_init_qp_attr(conn->cm_id, qp_attr, &attr_mask);
-               if (result) {
-                       sdp_dbg_warn(conn, "Error <%d> QP attributes for RTR",
-                                    result);
-                       goto error;
-               }
+       result = ib_cm_init_qp_attr(conn->cm_id, qp_attr, &attr_mask);
+       if (result) {
+               sdp_dbg_warn(conn, "Error <%d> QP attributes for RTR", result);
+               goto done;
+       }
 
-               qp_attr->min_rnr_timer = 0; /* IB_RNR_TIMER_122_88; */
-               qp_attr->rq_psn        = conn->rq_psn;
-               
-               attr_mask |= (IB_QP_MIN_RNR_TIMER | IB_QP_RQ_PSN);
+       qp_attr->min_rnr_timer = 0; /* IB_RNR_TIMER_122_88; */
+       qp_attr->rq_psn        = conn->rq_psn;
+       
+       attr_mask |= (IB_QP_MIN_RNR_TIMER | IB_QP_RQ_PSN);
 
-               result = ib_modify_qp(conn->qp, qp_attr, attr_mask);
-               if (result) {
-                       sdp_dbg_warn(conn, "Error <%d> QP modify to RTR",
-                                    result);
-                       goto error;
-               }
-               /*
-                * finalize connection acceptance.
-                */
-               SDP_CONN_ST_SET(conn, SDP_CONN_ST_RTU_SENT);
-               /*
-                * post receive buffers.
-                */
-               result = sdp_recv_flush(conn);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> posting recv buffers.",
-                                    result);
-                       goto error;
-               }
-               /*
-                * modify QP to RTS
-                */
-               qp_attr->qp_state = IB_QPS_RTS;
+       result = ib_modify_qp(conn->qp, qp_attr, attr_mask);
+       if (result) {
+               sdp_dbg_warn(conn, "Error <%d> QP modify to RTR", result);
+               goto done;
+       }
+       /*
+        * finalize connection acceptance.
+        */
+       SDP_CONN_ST_SET(conn, SDP_CONN_ST_RTU_SENT);
+       /*
+        * post receive buffers.
+        */
+       result = sdp_recv_flush(conn);
+       if (0 > result) {
+               sdp_dbg_warn(conn, "Error <%d> posting recv buffers.", result);
+               goto done;
+       }
+       /*
+        * modify QP to RTS
+        */
+       qp_attr->qp_state = IB_QPS_RTS;
 
-               result = ib_cm_init_qp_attr(conn->cm_id, qp_attr, &attr_mask);
-               if (result) {
-                       sdp_dbg_warn(conn, "Error <%d> QP attributes for RTS",
-                                    result);
-                       goto error;
-               }
+       result = ib_cm_init_qp_attr(conn->cm_id, qp_attr, &attr_mask);
+       if (result) {
+               sdp_dbg_warn(conn, "Error <%d> QP attributes for RTS", result);
+               goto done;
+       }
 
-               result = ib_modify_qp(conn->qp, qp_attr, attr_mask);
-               if (result) {
-                       sdp_dbg_warn(conn, "Error <%d> QP modify to RTS",
-                                    result);
-                       goto error;
-               }
-               /*
-                * respond to the remote connection manager with a RTU
-                */
-               result = sdp_cm_confirm(conn);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> CM connect confirm",
-                                    result);
-                       goto error;
-               }
-               /*
-                * wake the accepting connection
-                */
-               SDP_CONN_ST_SET(conn, SDP_CONN_ST_ESTABLISHED);
+       result = ib_modify_qp(conn->qp, qp_attr, attr_mask);
+       if (result) {
+               sdp_dbg_warn(conn, "Error <%d> QP modify to RTS", result);
+               goto done;
+       }
+       /*
+        * respond to the remote connection manager with a RTU
+        */
+       result = ib_send_cm_rtu(conn->cm_id, NULL, 0);
+       if (0 > result) {
+               sdp_dbg_warn(conn, "Error <%d> sending CM RTU.", result);
+               goto done;
+       }
+       /*
+        * wake the accepting connection
+        */
+       SDP_CONN_ST_SET(conn, SDP_CONN_ST_ESTABLISHED);
 
-               sk->sk_socket->state = SS_CONNECTED;
-               conn->istate = SDP_SOCK_ST_ESTABLISHED;
-               conn->send_buf = SDP_INET_SEND_SIZE;
-               /*
-                * release disconnects.
-                */
-               conn->flags &= ~SDP_CONN_F_DIS_HOLD;
+       sk->sk_socket->state = SS_CONNECTED;
+       conn->istate = SDP_SOCK_ST_ESTABLISHED;
+       conn->send_buf = SDP_INET_SEND_SIZE;
+       /*
+        * release disconnects.
+        */
+       conn->flags &= ~SDP_CONN_F_DIS_HOLD;
                
-               inet_sk(sk)->saddr     = htonl(conn->src_addr);
-               inet_sk(sk)->rcv_saddr = htonl(conn->src_addr);
+       inet_sk(sk)->saddr     = htonl(conn->src_addr);
+       inet_sk(sk)->rcv_saddr = htonl(conn->src_addr);
 
-               result = sdp_send_flush(conn);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> flushing receives.",
-                                    result);
-                       goto error;
-               }
-               /*
-                * write/read ready. (for those waiting on just one...)
-                */
-               sdp_inet_wake_send(sk);
-               sdp_inet_wake_recv(sk, 0);
-
-               kfree(qp_attr);
-       } else {
-               /*
-                * fail this connection
-                */
-               result = sdp_cm_failed(conn);
-               if (0 > result)
-                       sdp_dbg_warn(conn, "Error <%d> CM connect failed", 
-                                    result);
-
-               SDP_CONN_SET_ERR(conn, EPROTO);
-               conn->istate = SDP_SOCK_ST_ERROR;
-
-               goto drop;
+       result = sdp_send_flush(conn);
+       if (0 > result) {
+               sdp_dbg_warn(conn, "Error <%d> flushing receives.", result);
+               goto done;
        }
-
-       return 0;
-error:
-       SDP_CONN_SET_ERR(conn, result);
-       conn->istate = SDP_SOCK_ST_ERROR;
-
+       /*
+        * write/read ready. (for those waiting on just one...)
+        */
+       sdp_inet_wake_send(sk);
+       sdp_inet_wake_recv(sk, 0);
+       
+       result = 0;
+done:
        kfree(qp_attr);
-drop:
-       sdp_inet_wake_error(sk);
-
-       sdp_conn_put(conn);     /* CM sk reference */
        return result;
 }
 
@@ -246,100 +274,76 @@
                       struct sdp_opt *conn)
 {
        struct sdp_msg_hello_ack *hello_ack;
-       int result;
-       int error;
+       int result = -EPROTO;
 
        if (NULL == conn)
                return -EINVAL;
        
-       if (cm_id != conn->cm_id)
+       if (cm_id != conn->cm_id) {
                sdp_dbg_warn(conn, "REP comm ID mismatch. <%08x:%08x>",
                             conn->cm_id->local_id, cm_id->local_id);
+               return -EINVAL;
+       }
 
        hello_ack = (struct sdp_msg_hello_ack *)event->private_data;
 
        sdp_dbg_ctrl(conn, "CM REP. comm <%08x>", cm_id->local_id);
+
+       if (conn->state != SDP_CONN_ST_REQ_SENT)
+               goto error;
+
        /*
-        * lock the connection
+        * check Hello Header Ack, to determine if we want
+        * the connection.
         */
-       switch (conn->state) {
-       case SDP_CONN_ST_ERROR_STRM:
-               result = sdp_cm_reject(conn);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> CM reject request",
-                                    result);
-                       error = result;
-                       goto done;
-               }
+       result = _sdp_cm_hello_ack_check(hello_ack);
+       if (0 > result) {
+               sdp_dbg_warn(conn, "Error <%d> hello ack check.", result);
+               goto error;
+       }
 
-               sdp_conn_put(conn);
+       SDP_CONN_ST_SET(conn, SDP_CONN_ST_REP_RECV);
+       /*
+        * read remote information
+        */
+       conn->send_size = hello_ack->hah.l_rcv_size;
+       conn->r_max_adv = hello_ack->hah.max_adv;
+       conn->r_recv_bf = hello_ack->bsdh.recv_bufs;
+       conn->recv_seq  = hello_ack->bsdh.seq_num;
+       conn->advt_seq  = hello_ack->bsdh.seq_num;
 
-               break;
-       case SDP_CONN_ST_REQ_SENT:
-               /*
-                * check Hello Header Ack, to determine if we want
-                * the connection.
-                */
-               result = _sdp_cm_hello_ack_check(hello_ack);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> hello ack check.",
-                                    result);
-                       error = result;
-                       goto reject;
-               }
+       conn->d_qpn  = event->param.rep_rcvd.remote_qpn;
+       /*
+        * The maximum amount of data that can be sent to the remote
+        * peer is the smaller of the local and remote buffer sizes, 
+        * minus the size of the message header.
+        */
+       conn->send_size = min((u16)sdp_buff_pool_buff_size(),
+                             (u16)conn->send_size) - SDP_MSG_HDR_SIZE;
+       /*
+        * Pop the hello message that was sent
+        */
+       (void)sdp_buff_pool_put(sdp_buff_q_get_head(&conn->send_post));
 
-               SDP_CONN_ST_SET(conn, SDP_CONN_ST_REP_RECV);
-               /*
-                * read remote information
-                */
-               conn->send_size = hello_ack->hah.l_rcv_size;
-               conn->r_max_adv = hello_ack->hah.max_adv;
-               conn->r_recv_bf = hello_ack->bsdh.recv_bufs;
-               conn->recv_seq  = hello_ack->bsdh.seq_num;
-               conn->advt_seq  = hello_ack->bsdh.seq_num;
+       result = _sdp_actv_conn_establish(conn);
+       if (0 > result) {
+               sdp_dbg_warn(conn, "Error <%d> accept receive failed", result);
+               goto error;
+       }
 
-               conn->d_qpn  = event->param.rep_rcvd.remote_qpn;
-               /*
-                * The maximum amount of data that can be sent to the remote
-                * peer is the smaller of the local and remote buffer sizes, 
-                * minus the size of the message header.
-                */
-               conn->send_size = (min((u16)sdp_buff_pool_buff_size(),
-                                      (u16)conn->send_size) - 
-                                  SDP_MSG_HDR_SIZE);
-               /*
-                * Pop the hello message that was sent
-                */
-               (void)sdp_buff_pool_put(sdp_buff_q_get_head(&conn->send_post));
+       return 0;
+error:
+       sdp_cm_actv_error(conn, (0 - result));
 
-               result = _sdp_actv_conn_establish(conn);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> accept receive failed",
-                                    result);
-                       error = result;
-                       goto done;
-               }
+       if (conn->state == SDP_CONN_ST_CLOSED) {
 
-               break;
-       default:
-               sdp_dbg_warn(conn, "REP received in unknown connection state");
-               /*
-                * drop CM reference
-                */
-               result = sdp_wall_recv_drop(conn);
-               SDP_EXPECT(!(0 > result));
+               conn->cm_id = NULL;
+               sdp_conn_put(conn); /* CM reference */
 
-               error = -EPROTO;
-               goto done;
+               return -EPROTO;
        }
 
        return 0;
-reject:
-       result = sdp_wall_recv_reject(conn, EPROTO);
-       SDP_EXPECT(!(0 > result));
-done:
-       conn->cm_id = NULL;
-       return error;
 }
 
 /*
@@ -375,8 +379,8 @@
        }
 
        if (SDP_CONN_ST_REQ_PATH != conn->state) {
-               sdp_dbg_warn(conn, "Path record completion in bad state");
-               goto done;
+               status = -EPROTO;
+               goto failed;
        }
 
        conn->plid = 0;
@@ -393,7 +397,9 @@
                             status);
                goto failed;
        }
-       
+
+       status = -ENOMEM; /* incase error path is taken */
+
        sdp_dbg_ctrl(conn, "Path record lookup complete <%016llx:%016llx:%d>",
                     (unsigned long long)
                     cpu_to_be64(path->dgid.global.subnet_prefix),
@@ -462,6 +468,7 @@
                expect = sdp_buff_pool_put(buff);
                SDP_EXPECT(!(0 > expect));
 
+               status = -EPROTO;
                goto failed;
        }
 #if 1
@@ -505,36 +512,28 @@
        if (NULL == conn->cm_id) {
                sdp_dbg_warn(conn, "Failed to create CM handle, %d",
                             (u8)(buff->tail - buff->data));
-
-               result = -ENOMEM;
                goto failed;
        }
 
-       SDP_CONN_ST_SET(conn, SDP_CONN_ST_REQ_SENT);
        /*
         * initiate connection
         */
        result = ib_send_cm_req(conn->cm_id, &param);
        if (0 != result) {
                sdp_dbg_warn(conn, "Error <%d> CM connect request", result);
+               status = result;
                goto failed;
        }
 
-       result = 0;
+       SDP_CONN_ST_SET(conn, SDP_CONN_ST_REQ_SENT);
+       sdp_conn_hold(conn); /* CM reference */
+
        goto done;
 failed:
-
-       result = sdp_wall_recv_reject(conn, (0 - status));
-       if (0 > result) {
-               sdp_dbg_warn(conn, "Error <%d> rejecting connection", result);
-               
-               expect = sdp_wall_recv_drop(conn);
-               SDP_EXPECT(!(0 > expect));
-       }
-       /* if */
+       sdp_cm_actv_error(conn, (0 - status));
 done:
        sdp_conn_unlock(conn);
-       sdp_conn_put(conn);
+       sdp_conn_put(conn); /* address resolution reference */
 }
 
 /*
@@ -542,23 +541,21 @@
  */
 int sdp_cm_connect(struct sdp_opt *conn)
 {
-       int result = 0;
-
+       int result;
        /*
         * get the buffer size we'll use for this connection. (and all others)
         */
        if (sizeof(struct sdp_msg_hello) > conn->recv_size) {
                sdp_dbg_warn(conn, "buffer size <%d> too small. <%Zu>",
                             conn->recv_size, sizeof(struct sdp_msg_hello));
-               result = -ENOBUFS;
-               goto error;
+               return -ENOBUFS;
        }
 
        SDP_CONN_ST_SET(conn, SDP_CONN_ST_REQ_PATH);
        /*
         * lookup the remote address
         */
-       sdp_conn_hold(conn);
+       sdp_conn_hold(conn); /* address resolution reference */
        sdp_conn_unlock(conn);
                                          
        result = sdp_link_path_lookup(htonl(conn->dst_addr),
@@ -577,13 +574,10 @@
                /*
                 * callback dosn't have this socket.
                 */
-               sdp_conn_put(conn);
+               sdp_conn_put(conn); /* address resolution reference */
 
-               result = -EDESTADDRREQ;
-               goto error;
+               return -EDESTADDRREQ;
        }
 
        return 0;
-error:
-       return result;
 }
Index: infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- infiniband/ulp/sdp/sdp_conn.c       (revision 1909)
+++ infiniband/ulp/sdp/sdp_conn.c       (working copy)
@@ -748,7 +748,7 @@
         * in case CM/IB are still tracking this connection.
         */
        if (conn->cm_id) {
-               sdp_dbg_warn(conn, "CM local id <%d>", conn->cm_id->local_id);
+               sdp_dbg_ctrl(conn, "CM local id <%d>", conn->cm_id->local_id);
 
                result = ib_destroy_cm_id(conn->cm_id);
                if (result)
Index: infiniband/ulp/sdp/sdp_wall.c
===================================================================
--- infiniband/ulp/sdp/sdp_wall.c       (revision 1908)
+++ infiniband/ulp/sdp/sdp_wall.c       (working copy)
@@ -227,11 +227,6 @@
                 * instead of canceling allow the path completion to 
                 * determine that the socket has moved to an error state.
                 */
-               result = sdp_wall_recv_drop(conn);
-               SDP_EXPECT(!(0 > result));
-               /*
-                * fall through
-                */
        case SDP_CONN_ST_REQ_SENT:
        case SDP_CONN_ST_REP_SENT:
                /*
@@ -277,32 +272,6 @@
  */
 
 /*
- * sdp_wall_recv_reject - callback to reject an active open
- */
-int sdp_wall_recv_reject(struct sdp_opt *conn, int error)
-{
-       sdp_dbg_ctrl(conn, "Reject recv. src <%08x:%04x> dst <%08x:%04x> <%d>",
-                    conn->src_addr, conn->src_port, 
-                    conn->dst_addr, conn->dst_port, error);
-       /*
-        * the connection has been rejected, move to error, and notify anyone
-        * waiting of the state change.
-        */
-       SDP_CONN_SET_ERR(conn, error);
-       conn->sk->sk_socket->state = SS_UNCONNECTED;
-       conn->istate = SDP_SOCK_ST_ERROR;
-       conn->shutdown = SHUTDOWN_MASK;
-
-       sdp_iocb_q_cancel_all(conn, (0 - error));
-
-       sdp_inet_wake_error(conn->sk);
-
-       sdp_conn_put(conn);     /* CM reference */
-
-       return 0;
-}
-
-/*
  * sdp_wall_recv_confirm - callback to confirm accepeted passive open
  */
 int sdp_wall_recv_confirm(struct sdp_opt *conn)
Index: infiniband/ulp/sdp/sdp_event.c
===================================================================
--- infiniband/ulp/sdp/sdp_event.c      (revision 1908)
+++ infiniband/ulp/sdp/sdp_event.c      (working copy)
@@ -222,25 +222,12 @@
         * check state
         */
        switch (conn->state) {
-       case SDP_CONN_ST_REQ_PATH:
-               /*
-                * cancel address resolution
-                */
-#if _OLD_CODE
-               result = ip2pr_path_record_cancel(conn->plid);
-               SDP_EXPECT(!(0 > result));
-#endif
-               /*
-                * fall through
-                */
-       case SDP_CONN_ST_REQ_SENT:      /* active open, Hello msg sent */
-               result = sdp_wall_recv_reject(conn, ECONNREFUSED);
-               if (0 > result) {
-                       sdp_dbg_warn(conn, "Error <%d> receiving CM reject.",
-                                    result);
-                       goto error;
-               }
+       case SDP_CONN_ST_REQ_SENT: /* active open, Hello msg sent */
+               conn->state = SDP_CONN_ST_CLOSED;
 
+               sdp_cm_actv_error(conn, ECONNREFUSED);
+               sdp_conn_put(conn); /* CM reference */
+
                break;
        case SDP_CONN_ST_REP_SENT:      /* passive open, Hello ack msg sent */
                result = sdp_wall_recv_failed(conn, ECONNREFUSED);
@@ -252,7 +239,6 @@
                }
 
                break;
-       case SDP_CONN_ST_REP_RECV:      /* active open, Hello ack msg recv'd */
        case SDP_CONN_ST_REQ_RECV:      /* passive open, Hello msg recv'd */
                /*
                 * connection state is outstanding to the gateway, so the
Index: infiniband/ulp/sdp/sdp_post.c
===================================================================
--- infiniband/ulp/sdp/sdp_post.c       (revision 1909)
+++ infiniband/ulp/sdp/sdp_post.c       (working copy)
@@ -131,55 +131,7 @@
 
        sdp_conn_put(conn);
 }
-
 /*
- * _sdp_cm_confirm - initiate a confirm request using the CM
- */
-static void _sdp_cm_confirm(void *arg)
-{
-       struct sdp_opt *conn = (struct sdp_opt *)arg;
-       int result;
-
-       if (NULL == conn)
-               sdp_dbg_warn(NULL, "Error, posting confirm for NULL conn");
-
-       sdp_dbg_ctrl(conn, "Defered confirm <%08x>", conn->cm_id->local_id);
-       /*
-        * send a confirm request using the connection manager
-        */
-       result = ib_send_cm_rtu(conn->cm_id, NULL, 0);
-       if (0 > result)
-               sdp_dbg_warn(NULL, "Error <%d> CM confirm request", result);
-
-       sdp_conn_put(conn);
-}
-
-/*
- * _sdp_cm_failed - initiate a Failed request using the CM
- */
-static void _sdp_cm_failed(void *arg)
-{
-       struct sdp_opt *conn = (struct sdp_opt *)arg;
-       int result;
-
-       if (NULL == conn)
-               sdp_dbg_warn(NULL, "Error, posting failed for NULL conn");
-
-       sdp_dbg_ctrl(conn, "Defered failed request <%08x>",
-                    conn->cm_id->local_id);
-       /*
-        * send a failed request using the connection manager
-        */
-       result = ib_send_cm_rej(conn->cm_id, 
-                               IB_CM_REJ_CONSUMER_DEFINED,
-                               NULL, 0, NULL, 0);
-       if (0 > result)
-               sdp_dbg_warn(NULL, "Error <%d> CM failed request", result);
-
-       sdp_conn_put(conn);
-}
-
-/*
  * _sdp_cm_deferred_generic - initiate a defered request using the CM
  */
 static int _sdp_cm_deferred_generic(struct sdp_opt *conn,
@@ -214,19 +166,3 @@
 {
        return _sdp_cm_deferred_generic(conn, _sdp_cm_reject);
 }
-
-/*
- * sdp_cm_confirm - initiate a confirm request using the CM
- */
-int sdp_cm_confirm(struct sdp_opt *conn)
-{
-       return _sdp_cm_deferred_generic(conn, _sdp_cm_confirm);
-}
-
-/*
- * sdp_cm_failed - initiate a failed request using the CM
- */
-int sdp_cm_failed(struct sdp_opt *conn)
-{
-       return _sdp_cm_deferred_generic(conn, _sdp_cm_failed);
-}

_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to