From owner-svn-src-all@FreeBSD.ORG Tue Aug 21 18:09:33 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D215E106566C; Tue, 21 Aug 2012 18:09:33 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B28918FC1C; Tue, 21 Aug 2012 18:09:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7LI9XAd080339; Tue, 21 Aug 2012 18:09:33 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7LI9XTl080333; Tue, 21 Aug 2012 18:09:33 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201208211809.q7LI9XTl080333@svn.freebsd.org> From: Navdeep Parhar Date: Tue, 21 Aug 2012 18:09:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239511 - in head/sys: dev/cxgb/ulp/tom dev/cxgbe/tom netinet X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2012 18:09:33 -0000 Author: np Date: Tue Aug 21 18:09:33 2012 New Revision: 239511 URL: http://svn.freebsd.org/changeset/base/239511 Log: Correctly handle the case where an inp has already been dropped by the time the TOE driver reports that an active open failed. toe_connect_failed is supposed to handle this but it should be provided the inpcb instead of the tcpcb which may no longer be around. Modified: head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c head/sys/dev/cxgbe/tom/t4_connect.c head/sys/netinet/toecore.c head/sys/netinet/toecore.h Modified: head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c ============================================================================== --- head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Tue Aug 21 17:58:39 2012 (r239510) +++ head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Tue Aug 21 18:09:33 2012 (r239511) @@ -880,10 +880,10 @@ act_open_rpl_status_to_errno(int status) case CPL_ERR_CONN_TIMEDOUT: return (ETIMEDOUT); case CPL_ERR_TCAM_FULL: - return (ENOMEM); + return (EAGAIN); case CPL_ERR_CONN_EXIST: log(LOG_ERR, "ACTIVE_OPEN_RPL: 4-tuple in use\n"); - return (EADDRINUSE); + return (EAGAIN); default: return (EIO); } @@ -912,8 +912,7 @@ do_act_open_rpl(struct sge_qset *qs, str unsigned int atid = G_TID(ntohl(rpl->atid)); struct toepcb *toep = lookup_atid(&td->tid_maps, atid); struct inpcb *inp = toep->tp_inp; - struct tcpcb *tp = intotcpcb(inp); - int s = rpl->status; + int s = rpl->status, rc; CTR3(KTR_CXGB, "%s: atid %u, status %u ", __func__, atid, s); @@ -923,17 +922,14 @@ do_act_open_rpl(struct sge_qset *qs, str if (act_open_has_tid(s)) queue_tid_release(tod, GET_TID(rpl)); - if (s == CPL_ERR_TCAM_FULL || s == CPL_ERR_CONN_EXIST) { - INP_WLOCK(inp); - toe_connect_failed(tod, tp, EAGAIN); - toepcb_release(toep); /* unlocks inp */ - } else { + rc = act_open_rpl_status_to_errno(s); + if (rc != EAGAIN) INP_INFO_WLOCK(&V_tcbinfo); - INP_WLOCK(inp); - toe_connect_failed(tod, tp, act_open_rpl_status_to_errno(s)); - toepcb_release(toep); /* unlocks inp */ + INP_WLOCK(inp); + toe_connect_failed(tod, inp, rc); + toepcb_release(toep); /* unlocks inp */ + if (rc != EAGAIN) INP_INFO_WUNLOCK(&V_tcbinfo); - } m_freem(m); return (0); Modified: head/sys/dev/cxgbe/tom/t4_connect.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_connect.c Tue Aug 21 17:58:39 2012 (r239510) +++ head/sys/dev/cxgbe/tom/t4_connect.c Tue Aug 21 18:09:33 2012 (r239511) @@ -167,10 +167,10 @@ act_open_rpl_status_to_errno(int status) case CPL_ERR_CONN_TIMEDOUT: return (ETIMEDOUT); case CPL_ERR_TCAM_FULL: - return (ENOMEM); + return (EAGAIN); case CPL_ERR_CONN_EXIST: log(LOG_ERR, "ACTIVE_OPEN_RPL: 4-tuple in use\n"); - return (EADDRINUSE); + return (EAGAIN); default: return (EIO); } @@ -186,8 +186,8 @@ do_act_open_rpl(struct sge_iq *iq, const unsigned int status = G_AOPEN_STATUS(be32toh(cpl->atid_status)); struct toepcb *toep = lookup_atid(sc, atid); struct inpcb *inp = toep->inp; - struct tcpcb *tp = intotcpcb(inp); struct toedev *tod = &toep->td->tod; + int rc; KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__)); KASSERT(toep->tid == atid, ("%s: toep tid/atid mismatch", __func__)); @@ -204,17 +204,14 @@ do_act_open_rpl(struct sge_iq *iq, const if (status && act_open_has_tid(status)) release_tid(sc, GET_TID(cpl), toep->ctrlq); - if (status == CPL_ERR_TCAM_FULL) { - INP_WLOCK(inp); - toe_connect_failed(tod, tp, EAGAIN); - final_cpl_received(toep); /* unlocks inp */ - } else { + rc = act_open_rpl_status_to_errno(status); + if (rc != EAGAIN) INP_INFO_WLOCK(&V_tcbinfo); - INP_WLOCK(inp); - toe_connect_failed(tod, tp, act_open_rpl_status_to_errno(status)); - final_cpl_received(toep); /* unlocks inp */ + INP_WLOCK(inp); + toe_connect_failed(tod, inp, rc); + final_cpl_received(toep); /* unlocks inp */ + if (rc != EAGAIN) INP_INFO_WUNLOCK(&V_tcbinfo); - } return (0); } Modified: head/sys/netinet/toecore.c ============================================================================== --- head/sys/netinet/toecore.c Tue Aug 21 17:58:39 2012 (r239510) +++ head/sys/netinet/toecore.c Tue Aug 21 18:09:33 2012 (r239511) @@ -478,15 +478,17 @@ toe_l2_resolve(struct toedev *tod, struc } void -toe_connect_failed(struct toedev *tod, struct tcpcb *tp, int err) +toe_connect_failed(struct toedev *tod, struct inpcb *inp, int err) { - struct inpcb *inp = tp->t_inpcb; INP_WLOCK_ASSERT(inp); - KASSERT(tp->t_flags & TF_TOE, - ("%s: tp %p not offloaded.", __func__, tp)); if (!(inp->inp_flags & INP_DROPPED)) { + struct tcpcb *tp = intotcpcb(inp); + + KASSERT(tp->t_flags & TF_TOE, + ("%s: tp %p not offloaded.", __func__, tp)); + if (err == EAGAIN) { /* Modified: head/sys/netinet/toecore.h ============================================================================== --- head/sys/netinet/toecore.h Tue Aug 21 17:58:39 2012 (r239510) +++ head/sys/netinet/toecore.h Tue Aug 21 18:09:33 2012 (r239511) @@ -119,7 +119,7 @@ int unregister_toedev(struct toedev *); int toe_l2_resolve(struct toedev *, struct ifnet *, struct sockaddr *, uint8_t *, uint16_t *); -void toe_connect_failed(struct toedev *, struct tcpcb *, int); +void toe_connect_failed(struct toedev *, struct inpcb *, int); void toe_syncache_add(struct in_conninfo *, struct tcpopt *, struct tcphdr *, struct inpcb *, void *, void *);