From owner-svn-src-stable-7@FreeBSD.ORG Sat Nov 6 13:46:59 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A126106564A; Sat, 6 Nov 2010 13:46:59 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 378318FC19; Sat, 6 Nov 2010 13:46:59 +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 oA6Dkx2i032875; Sat, 6 Nov 2010 13:46:59 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA6DkxWv032871; Sat, 6 Nov 2010 13:46:59 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <201011061346.oA6DkxWv032871@svn.freebsd.org> From: Lawrence Stewart Date: Sat, 6 Nov 2010 13:46:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214878 - stable/7/sys/netinet X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 13:46:59 -0000 Author: lstewart Date: Sat Nov 6 13:46:58 2010 New Revision: 214878 URL: http://svn.freebsd.org/changeset/base/214878 Log: MFC r213158: Internalise reassembly queue related functionality and variables which should not be used outside of the reassembly queue implementation. Provide a new function to flush all segments from a reassembly queue and call it from the appropriate places instead of manipulating the queue directly. The base code from r213158 was modified as part of this MFC in order to work correctly on FreeBSD 7. Sponsored by: FreeBSD Foundation Reviewed by: andre, gnn, rpaulo Modified: stable/7/sys/netinet/tcp_reass.c stable/7/sys/netinet/tcp_subr.c stable/7/sys/netinet/tcp_var.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/netinet/tcp_reass.c ============================================================================== --- stable/7/sys/netinet/tcp_reass.c Sat Nov 6 13:43:18 2010 (r214877) +++ stable/7/sys/netinet/tcp_reass.c Sat Nov 6 13:46:58 2010 (r214878) @@ -81,7 +81,7 @@ SYSCTL_INT(_net_inet_tcp_reass, OID_AUTO &tcp_reass_maxseg, 0, "Global maximum number of TCP Segments in Reassembly Queue"); -int tcp_reass_qsize = 0; +static int tcp_reass_qsize = 0; SYSCTL_INT(_net_inet_tcp_reass, OID_AUTO, cursegments, CTLFLAG_RD, &tcp_reass_qsize, 0, "Global number of TCP Segments currently in Reassembly Queue"); @@ -96,6 +96,8 @@ SYSCTL_INT(_net_inet_tcp_reass, OID_AUTO &tcp_reass_overflows, 0, "Global number of TCP Segment Reassembly Queue Overflows"); +static uma_zone_t tcp_reass_zone; + /* Initialize TCP reassembly queue */ static void tcp_reass_zone_change(void *tag) @@ -105,8 +107,6 @@ tcp_reass_zone_change(void *tag) uma_zone_set_max(tcp_reass_zone, tcp_reass_maxseg); } -uma_zone_t tcp_reass_zone; - void tcp_reass_init(void) { @@ -121,6 +121,26 @@ tcp_reass_init(void) tcp_reass_zone_change, NULL, EVENTHANDLER_PRI_ANY); } +void +tcp_reass_flush(struct tcpcb *tp) +{ + struct tseg_qent *qe; + + INP_WLOCK_ASSERT(tp->t_inpcb); + + while ((qe = LIST_FIRST(&tp->t_segq)) != NULL) { + LIST_REMOVE(qe, tqe_q); + m_freem(qe->tqe_m); + uma_zfree(tcp_reass_zone, qe); + tp->t_segqlen--; + tcp_reass_qsize--; + } + + KASSERT((tp->t_segqlen == 0), + ("TCP reass queue %p segment count is %d instead of 0 after flush.", + tp, tp->t_segqlen)); +} + int tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) { Modified: stable/7/sys/netinet/tcp_subr.c ============================================================================== --- stable/7/sys/netinet/tcp_subr.c Sat Nov 6 13:43:18 2010 (r214877) +++ stable/7/sys/netinet/tcp_subr.c Sat Nov 6 13:46:58 2010 (r214878) @@ -704,7 +704,6 @@ tcp_drop(struct tcpcb *tp, int errno) void tcp_discardcb(struct tcpcb *tp) { - struct tseg_qent *q; struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; #ifdef INET6 @@ -782,13 +781,7 @@ tcp_discardcb(struct tcpcb *tp) } /* free the reassembly queue, if any */ - while ((q = LIST_FIRST(&tp->t_segq)) != NULL) { - LIST_REMOVE(q, tqe_q); - m_freem(q->tqe_m); - uma_zfree(tcp_reass_zone, q); - tp->t_segqlen--; - tcp_reass_qsize--; - } + tcp_reass_flush(tp); /* Disconnect offload device, if any. */ tcp_offload_detach(tp); @@ -840,7 +833,6 @@ tcp_drain(void) if (do_tcpdrain) { struct inpcb *inpb; struct tcpcb *tcpb; - struct tseg_qent *te; /* * Walk the tcpbs, if existing, and flush the reassembly queue, @@ -856,14 +848,7 @@ tcp_drain(void) continue; INP_WLOCK(inpb); if ((tcpb = intotcpcb(inpb)) != NULL) { - while ((te = LIST_FIRST(&tcpb->t_segq)) - != NULL) { - LIST_REMOVE(te, tqe_q); - m_freem(te->tqe_m); - uma_zfree(tcp_reass_zone, te); - tcpb->t_segqlen--; - tcp_reass_qsize--; - } + tcp_reass_flush(tcpb); tcp_clean_sackreport(tcpb); } INP_WUNLOCK(inpb); Modified: stable/7/sys/netinet/tcp_var.h ============================================================================== --- stable/7/sys/netinet/tcp_var.h Sat Nov 6 13:43:18 2010 (r214877) +++ stable/7/sys/netinet/tcp_var.h Sat Nov 6 13:46:58 2010 (r214878) @@ -48,8 +48,6 @@ struct tseg_qent { struct mbuf *tqe_m; /* mbuf contains packet */ }; LIST_HEAD(tsegqe_head, tseg_qent); -extern int tcp_reass_qsize; -extern struct uma_zone *tcp_reass_zone; struct sackblk { tcp_seq start; /* start seq no. of sack block */ @@ -543,6 +541,7 @@ char *tcp_log_vain(struct in_conninfo *, const void *); int tcp_reass(struct tcpcb *, struct tcphdr *, int *, struct mbuf *); void tcp_reass_init(void); +void tcp_reass_flush(struct tcpcb *); void tcp_input(struct mbuf *, int); u_long tcp_maxmtu(struct in_conninfo *, int *); u_long tcp_maxmtu6(struct in_conninfo *, int *);