From owner-svn-src-all@FreeBSD.ORG Tue Aug 21 22:23:18 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 06469106566C; Tue, 21 Aug 2012 22:23:18 +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 E5C748FC08; Tue, 21 Aug 2012 22:23:17 +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 q7LMNHpf016926; Tue, 21 Aug 2012 22:23:17 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7LMNH0K016923; Tue, 21 Aug 2012 22:23:17 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201208212223.q7LMNH0K016923@svn.freebsd.org> From: Navdeep Parhar Date: Tue, 21 Aug 2012 22:23:17 +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: r239544 - in head/sys/dev: cxgb/ulp/tom cxgbe/tom 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 22:23:18 -0000 Author: np Date: Tue Aug 21 22:23:17 2012 New Revision: 239544 URL: http://svn.freebsd.org/changeset/base/239544 Log: Deal with the case where a syncache entry added by the TOE driver is evicted from the syncache but a later syncache_expand succeeds because of syncookies. The TOE driver has to resort to more direct means to install its hooks in the socket in this case. Modified: head/sys/dev/cxgb/ulp/tom/cxgb_listen.c head/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h head/sys/dev/cxgbe/tom/t4_listen.c head/sys/dev/cxgbe/tom/t4_tom.h Modified: head/sys/dev/cxgb/ulp/tom/cxgb_listen.c ============================================================================== --- head/sys/dev/cxgb/ulp/tom/cxgb_listen.c Tue Aug 21 21:46:44 2012 (r239543) +++ head/sys/dev/cxgb/ulp/tom/cxgb_listen.c Tue Aug 21 22:23:17 2012 (r239544) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #define TCPSTATES #include @@ -759,6 +760,15 @@ reset: goto reset; } + if (__predict_false(!(synqe->flags & TP_SYNQE_EXPANDED))) { + struct inpcb *new_inp = sotoinpcb(so); + + INP_WLOCK(new_inp); + tcp_timer_activate(intotcpcb(new_inp), TT_KEEP, 0); + t3_offload_socket(tod, synqe, so); + INP_WUNLOCK(new_inp); + } + /* Remove the synq entry and release its reference on the lctx */ TAILQ_REMOVE(&lctx->synq, synqe, link); inp = release_lctx(td, lctx); @@ -1136,5 +1146,6 @@ t3_offload_socket(struct toedev *tod, vo offload_socket(so, toep); make_established(so, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt); update_tid(td, toep, synqe->tid); + synqe->flags |= TP_SYNQE_EXPANDED; } #endif Modified: head/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h ============================================================================== --- head/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h Tue Aug 21 21:46:44 2012 (r239543) +++ head/sys/dev/cxgb/ulp/tom/cxgb_toepcb.h Tue Aug 21 22:23:17 2012 (r239544) @@ -44,6 +44,7 @@ #define TP_IS_A_SYNQ_ENTRY (1 << 9) #define TP_ABORT_RPL_SENT (1 << 10) #define TP_SEND_FIN (1 << 11) +#define TP_SYNQE_EXPANDED (1 << 12) struct toepcb { TAILQ_ENTRY(toepcb) link; /* toep_list */ Modified: head/sys/dev/cxgbe/tom/t4_listen.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_listen.c Tue Aug 21 21:46:44 2012 (r239543) +++ head/sys/dev/cxgbe/tom/t4_listen.c Tue Aug 21 22:23:17 2012 (r239544) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #define TCPSTATES #include @@ -805,6 +806,7 @@ t4_offload_socket(struct toedev *tod, vo make_established(toep, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt); toep->flags |= TPF_CPL_PENDING; update_tid(sc, synqe->tid, toep); + synqe->flags |= TPF_SYNQE_EXPANDED; } static inline void @@ -1349,6 +1351,24 @@ reset: goto reset; } + /* + * This is for the unlikely case where the syncache entry that we added + * has been evicted from the syncache, but the syncache_expand above + * works because of syncookies. + * + * XXX: we've held the tcbinfo lock throughout so there's no risk of + * anyone accept'ing a connection before we've installed our hooks, but + * this somewhat defeats the purpose of having a tod_offload_socket :-( + */ + if (__predict_false(!(synqe->flags & TPF_SYNQE_EXPANDED))) { + struct inpcb *new_inp = sotoinpcb(so); + + INP_WLOCK(new_inp); + tcp_timer_activate(intotcpcb(new_inp), TT_KEEP, 0); + t4_offload_socket(TOEDEV(ifp), synqe, so); + INP_WUNLOCK(new_inp); + } + /* Done with the synqe */ TAILQ_REMOVE(&lctx->synq, synqe, link); inp = release_lctx(sc, lctx); Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Tue Aug 21 21:46:44 2012 (r239543) +++ head/sys/dev/cxgbe/tom/t4_tom.h Tue Aug 21 22:23:17 2012 (r239544) @@ -66,6 +66,7 @@ enum { TPF_SYNQE = (1 << 8), /* synq_entry, not really a toepcb */ TPF_SYNQE_NEEDFREE = (1 << 9), /* synq_entry was malloc'd separately */ TPF_SYNQE_TCPDDP = (1 << 10), /* ulp_mode TCPDDP in toepcb */ + TPF_SYNQE_EXPANDED = (1 << 11), /* toepcb ready, tid context updated */ }; enum {