Date: Wed, 25 Jan 2012 11:16:31 +0000 (UTC) From: Andre Oppermann <andre@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r230535 - stable/7/sys/netinet Message-ID: <201201251116.q0PBGVXG022527@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andre Date: Wed Jan 25 11:16:31 2012 New Revision: 230535 URL: http://svn.freebsd.org/changeset/base/230535 Log: MFC r226113 and r228016: Prevent TCP sessions from stalling indefinitely in reassembly when reaching the zone limit of reassembly queue entries. Reviewed by: lstewart Modified: stable/7/sys/netinet/tcp_reass.c 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 Wed Jan 25 11:15:52 2012 (r230534) +++ stable/7/sys/netinet/tcp_reass.c Wed Jan 25 11:16:31 2012 (r230535) @@ -160,7 +160,9 @@ tcp_reass(struct tcpcb *tp, struct tcphd struct tseg_qent *nq; struct tseg_qent *te = NULL; struct socket *so = tp->t_inpcb->inp_socket; + char *s = NULL; int flags; + struct tseg_qent tqs; INP_WLOCK_ASSERT(tp->t_inpcb); @@ -199,19 +201,45 @@ tcp_reass(struct tcpcb *tp, struct tcphd tcpstat.tcps_rcvmemdrop++; m_freem(m); *tlenp = 0; + if ((s = tcp_log_addrs(&tp->t_inpcb->inp_inc, th, NULL, NULL))) { + log(LOG_DEBUG, "%s; %s: queue limit reached, " + "segment dropped\n", s, __func__); + free(s, M_TCPLOG); + } return (0); } /* * Allocate a new queue entry. If we can't, or hit the zone limit * just drop the pkt. + * + * Use a temporary structure on the stack for the missing segment + * when the zone is exhausted. Otherwise we may get stuck. */ te = uma_zalloc(tcp_reass_zone, M_NOWAIT); if (te == NULL) { - tcpstat.tcps_rcvmemdrop++; - m_freem(m); - *tlenp = 0; - return (0); + if (th->th_seq != tp->rcv_nxt) { + tcpstat.tcps_rcvmemdrop++; + m_freem(m); + *tlenp = 0; + if ((s = tcp_log_addrs(&tp->t_inpcb->inp_inc, th, NULL, + NULL))) { + log(LOG_DEBUG, "%s; %s: global zone limit " + "reached, segment dropped\n", s, __func__); + free(s, M_TCPLOG); + } + return (0); + } else { + bzero(&tqs, sizeof(struct tseg_qent)); + te = &tqs; + if ((s = tcp_log_addrs(&tp->t_inpcb->inp_inc, th, NULL, + NULL))) { + log(LOG_DEBUG, + "%s; %s: global zone limit reached, using " + "stack for missing segment\n", s, __func__); + free(s, M_TCPLOG); + } + } } tp->t_segqlen++; @@ -287,6 +315,8 @@ tcp_reass(struct tcpcb *tp, struct tcphd if (p == NULL) { LIST_INSERT_HEAD(&tp->t_segq, te, tqe_q); } else { + KASSERT(te != &tqs, ("%s: temporary stack based entry not " + "first element in queue", __func__)); LIST_INSERT_AFTER(p, te, tqe_q); } @@ -310,7 +340,8 @@ present: m_freem(q->tqe_m); else sbappendstream_locked(&so->so_rcv, q->tqe_m); - uma_zfree(tcp_reass_zone, q); + if (q != &tqs) + uma_zfree(tcp_reass_zone, q); tp->t_segqlen--; q = nq; } while (q && q->tqe_th->th_seq == tp->rcv_nxt);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201251116.q0PBGVXG022527>