From owner-svn-src-all@FreeBSD.ORG Thu Oct 8 11:07:15 2009 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 E27E8106566B; Thu, 8 Oct 2009 11:07:15 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B60248FC08; Thu, 8 Oct 2009 11:07:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n98B7FTE021079; Thu, 8 Oct 2009 11:07:15 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n98B7FZ9021077; Thu, 8 Oct 2009 11:07:15 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200910081107.n98B7FZ9021077@svn.freebsd.org> From: Robert Watson Date: Thu, 8 Oct 2009 11:07:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197854 - in stable/8/sys: . amd64/include/xen cddl/contrib/opensolaris contrib/dev/acpica contrib/pf dev/xen/xenpci 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: Thu, 08 Oct 2009 11:07:16 -0000 Author: rwatson Date: Thu Oct 8 11:07:15 2009 New Revision: 197854 URL: http://svn.freebsd.org/changeset/base/197854 Log: Merge r197795 from head to stable/8: In tcp_input(), we acquire a global write lock at first only if a segment is likely to trigger a TCP state change (i.e., FIN/RST/SYN). If we later have to upgrade the lock, we acquire an inpcb reference and drop both global/inpcb locks before reacquiring in-order. In that gap, the connection may transition into TIMEWAIT, so we need to loop back and reevaluate the inpcb after relocking. Reported by: Kamigishi Rei Reviewed by: bz Approved by: re (kib) Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/netinet/tcp_input.c Modified: stable/8/sys/netinet/tcp_input.c ============================================================================== --- stable/8/sys/netinet/tcp_input.c Thu Oct 8 10:26:49 2009 (r197853) +++ stable/8/sys/netinet/tcp_input.c Thu Oct 8 11:07:15 2009 (r197854) @@ -648,6 +648,7 @@ findpcb: * tried to free the inpcb, in which case we need to loop back and * try to find a new inpcb to deliver to. */ +relocked: if (inp->inp_flags & INP_TIMEWAIT) { KASSERT(ti_locked == TI_RLOCKED || ti_locked == TI_WLOCKED, ("%s: INP_TIMEWAIT ti_locked %d", __func__, ti_locked)); @@ -698,7 +699,8 @@ findpcb: * We've identified a valid inpcb, but it could be that we need an * inpcbinfo write lock and have only a read lock. In this case, * attempt to upgrade/relock using the same strategy as the TIMEWAIT - * case above. + * case above. If we relock, we have to jump back to 'relocked' as + * the connection might now be in TIMEWAIT. */ if (tp->t_state != TCPS_ESTABLISHED || (thflags & (TH_SYN | TH_FIN | TH_RST)) != 0 || @@ -720,6 +722,7 @@ findpcb: goto findpcb; } tcp_wlock_relocked++; + goto relocked; } else { ti_locked = TI_WLOCKED; tcp_wlock_upgraded++;