svn commit: r214878 - stable/7/sys/netinet
Lawrence Stewart
lstewart at FreeBSD.org
Sat Nov 6 13:46:59 UTC 2010
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 *);
More information about the svn-src-stable
mailing list