PERFORCE change 130532 for review

Kip Macy kmacy at FreeBSD.org
Sat Dec 8 22:28:43 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=130532

Change 130532 by kmacy at kmacy:storage:toestack on 2007/12/09 06:28:32

	fix abort handling to work reliably

Affected files ...

.. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#30 edit

Differences ...

==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#30 (text+ko) ====

@@ -141,6 +141,8 @@
 extern int tcp_autosndbuf_max;
 
 static void t3_send_reset(struct socket *so);
+static void send_abort_rpl(struct mbuf *m, struct toedev *tdev, int rst_status);
+
 
 static inline int
 is_t3a(const struct toedev *dev)
@@ -547,9 +549,18 @@
 cxgb_toe_abort(struct tcpcb *tp)
 {
 	struct socket *so;
-
+	struct toepcb *toep;
+	
 	so = tp->t_inpcb->inp_socket;
 	t3_send_reset(so);
+
+	/*
+	 * unhook from socket
+	 */
+	tp->t_flags &= ~TF_TOE;
+	toep = tp->t_toe;
+	toep->tp_tp = NULL;
+	tp->t_toe = NULL;
 	return (0);
 }
 
@@ -575,11 +586,27 @@
 	return (0);
 }
 
+static void
+cxgb_toe_detach(struct tcpcb *tp)
+{
+	struct toepcb *toep;
+
+	/*
+	 * unhook from socket
+	 */
+	tp->t_flags &= ~TF_TOE;
+	toep = tp->t_toe;
+	toep->tp_tp = NULL;
+	tp->t_toe = NULL;
+}
+	
+
 static struct toe_usrreqs cxgb_toe_usrreqs = {
 	.tu_disconnect = cxgb_toe_disconnect,
 	.tu_abort = cxgb_toe_abort,
 	.tu_send = cxgb_toe_send,
 	.tu_rcvd = cxgb_toe_rcvd,
+	.tu_detach = cxgb_toe_detach,
 };
 
 
@@ -870,6 +897,7 @@
 		l2t_release(L2DATA(cdev), toep->tp_l2t);
 		toep->tp_l2t = NULL;
 	}
+	printf("setting toep->tp_tp to NULL\n");
 	
 	toep->tp_tp = NULL;
 	tp->t_toe = NULL;
@@ -1145,15 +1173,14 @@
 do_act_open_rpl(struct t3cdev *cdev, struct mbuf *m, void *ctx)
 {
 	struct toepcb *toep = (struct toepcb *)ctx;
-	struct socket *so;
-	
-	so = toeptoso(toep);
+	struct socket *so = NULL;
+	struct cpl_act_open_rpl *rpl = cplhdr(m);
 	
-	struct cpl_act_open_rpl *rpl = cplhdr(m);
-
 	if (cdev->type != T3A && act_open_has_tid(rpl->status))
 		cxgb_queue_tid_release(cdev, GET_TID(rpl));
-
+	if (toep->tp_tp != NULL)
+		so = toeptoso(toep);
+	
 	active_open_failed(so, m);
 	return (0);
 }
@@ -1232,17 +1259,21 @@
 	soisconnecting(so);
 	toep = tp->t_toe;
 	m_set_toep(m, tp->t_toe);
-
-	DPRINTF("toep=%p toep->tp_tp=%p\n", toep, toep->tp_tp);
+	
+	printf("sending off request\n");
 	
 	l2t_send(d->cdev, (struct mbuf *)m, e);
+
 	if (toep->tp_ulp_mode)
 		t3_enable_ddp(so, 0);
 	return 	(0);
 	
 free_tid:
+	printf("failing connect - free atid\n");
+	
 	free_atid(d->cdev, atid);
 out_err:
+	printf("return ENOMEM\n");
        return (ENOMEM);
 }
 
@@ -1938,6 +1969,9 @@
 	INP_LOCK(tp->t_inpcb);
 	
 	if (toep->tp_flags & TP_ABORT_RPL_PENDING) {
+		/*
+		 * XXX panic on tcpdrop
+		 */
 		if (!(toep->tp_flags & TP_ABORT_RPL_RCVD) && !is_t3a(TOE_DEV(so)))
 			toep->tp_flags |= TP_ABORT_RPL_RCVD;
 		else {
@@ -1994,7 +2028,20 @@
 	if (!toep)
 		goto discard;
 
-	so = toeptoso(toep);
+	if (toep->tp_tp == NULL) {
+		printf("removing tid for abort\n");
+		cxgb_remove_tid(cdev, toep, toep->tp_tid);
+		if (toep->tp_l2t) 
+			l2t_release(L2DATA(cdev), toep->tp_l2t);
+
+		toepcb_release(toep);
+		goto discard;
+	}
+	
+	printf("toep=%p\n", toep);
+	printf("tp=%p\n", toep->tp_tp);
+
+	so = toeptoso(toep); /* <- XXX panic */
 	toepcb_hold(toep);
 	process_abort_rpl(so, m);
 	toepcb_release(toep);
@@ -2243,8 +2290,9 @@
 
 	printf("aborting tid=%d\n", toep->tp_tid);
 	
-	if (toep->tp_flags & TP_SYN_RCVD) {
+	if ((toep->tp_flags & (TP_SYN_RCVD|TP_ABORT_REQ_RCVD)) == TP_SYN_RCVD) {
 		cxgb_remove_tid(cdev, toep, toep->tp_tid);
+		toep->tp_flags |= TP_ABORT_REQ_RCVD;
 		printf("sending abort rpl\n");
 		
 		send_abort_rpl(m, toep->tp_toedev, CPL_ABORT_NO_RST);
@@ -2253,11 +2301,16 @@
 			l2t_release(L2DATA(cdev), toep->tp_l2t);
 
 		/*
+		 *  Unhook
+		 */
+		toep->tp_tp->t_toe = NULL;
+		toep->tp_tp->t_flags &= ~TF_TOE;
+		toep->tp_tp = NULL;
+		/*
 		 * XXX need to call syncache_chkrst - but we don't
 		 * have a way of doing that yet
 		 */
 		toepcb_release(toep);
-		
 		printf("abort for unestablished connection :-(\n");
 		return (0);
 	}
@@ -2654,7 +2707,7 @@
 	newtoep->tp_flags = TP_SYN_RCVD;
 	newtoep->tp_tid = tid;
 	newtoep->tp_toedev = tdev;
-		
+	
 	printf("inserting tid=%d\n", tid);
 	cxgb_insert_tid(cdev, d->client, newtoep, tid);
 
@@ -2945,6 +2998,7 @@
 	so->so_snd.sb_flags |= SB_TOE;
 	so->so_rcv.sb_flags |= SB_TOE;
 	toep->tp_tp = tp;
+	toep->tp_flags = 0;
 	tp->t_toe = toep;
 	reset_wr_list(tp);
 	tp->rcv_wnd = select_rcv_wnd(so);


More information about the p4-projects mailing list