summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2002-01-24 22:42:50 +0000
committerNiels Provos <provos@cvs.openbsd.org>2002-01-24 22:42:50 +0000
commitaffebfba7ff72a56240a3f25cf83b7333d676eec (patch)
treeb73060374cd7d4638ca05913a33bbc505583fb5d
parent229f438bede61cf09c0e83a91465b8185242836c (diff)
allocate tcp reassembly queue via pool; based on netbsd; okay art@ angelos@
-rw-r--r--sys/netinet/ip_var.h3
-rw-r--r--sys/netinet/tcp_input.c10
-rw-r--r--sys/netinet/tcp_subr.c44
3 files changed, 28 insertions, 29 deletions
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 220b93416e3..9e73a1085ec 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_var.h,v 1.20 2001/06/23 05:54:50 angelos Exp $ */
+/* $OpenBSD: ip_var.h,v 1.21 2002/01/24 22:42:48 provos Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@@ -165,6 +165,7 @@ int ip_defttl; /* default IP ttl */
int ip_mtudisc; /* mtu discovery */
u_int ip_mtudisc_timeout; /* seconds to timeout mtu discovery */
struct rttimer_queue *ip_mtudisc_timeout_q;
+extern struct pool ipqent_pool;
int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
int ip_dooptions __P((struct mbuf *));
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 5c3bb764f76..5f53d9bd494 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.103 2002/01/15 19:18:01 provos Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.104 2002/01/24 22:42:48 provos Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -176,7 +176,7 @@ tcp_reass(tp, th, m, tlen)
* Allocate a new queue entry, before we throw away any data.
* If we can't, just drop the packet. XXX
*/
- MALLOC(tiqe, struct ipqent *, sizeof(struct ipqent), M_IPQ, M_NOWAIT);
+ tiqe = pool_get(&ipqent_pool, PR_NOWAIT);
if (tiqe == NULL) {
tcpstat.tcps_rcvmemdrop++;
m_freem(m);
@@ -207,7 +207,7 @@ tcp_reass(tp, th, m, tlen)
tcpstat.tcps_rcvduppack++;
tcpstat.tcps_rcvdupbyte += *tlen;
m_freem(m);
- FREE(tiqe, M_IPQ);
+ pool_put(&ipqent_pool, tiqe);
return (0);
}
m_adj(m, i);
@@ -237,7 +237,7 @@ tcp_reass(tp, th, m, tlen)
nq = q->ipqe_q.le_next;
m_freem(q->ipqe_m);
LIST_REMOVE(q, ipqe_q);
- FREE(q, M_IPQ);
+ pool_put(&ipqent_pool, q);
}
/* Insert the new fragment queue entry into place. */
@@ -273,7 +273,7 @@ present:
m_freem(q->ipqe_m);
else
sbappend(&so->so_rcv, q->ipqe_m);
- FREE(q, M_IPQ);
+ pool_put(&ipqent_pool, q);
q = nq;
} while (q != NULL && q->ipqe_tcp->th_seq == tp->rcv_nxt);
sorwakeup(so);
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 05bc7068064..2416d8bc73f 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.56 2002/01/23 00:39:48 art Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.57 2002/01/24 22:42:49 provos Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -148,6 +148,8 @@ struct pool tcpcb_pool;
struct pool sackhl_pool;
#endif
+int tcp_freeq __P((struct tcpcb *));
+
struct tcpstat tcpstat; /* tcp statistics */
/*
@@ -542,10 +544,8 @@ tcp_drop(tp, errno)
* wake up any sleepers
*/
struct tcpcb *
-tcp_close(tp)
- register struct tcpcb *tp;
+tcp_close(struct tcpcb *tp)
{
- register struct ipqent *qe;
struct inpcb *inp = tp->t_inpcb;
struct socket *so = inp->inp_socket;
#ifdef TCP_SACK
@@ -663,25 +663,8 @@ tcp_close(tp)
#endif /* RTV_RTT */
/* free the reassembly queue, if any */
-#ifdef INET6
- /* Reassembling TCP segments in v6 might be sufficiently different
- * to merit two codepaths to free the reasssembly queue.
- * If an undecided TCP socket, then the IPv4 codepath will be used
- * because it won't matter much anyway.
- */
- if (tp->pf == AF_INET6) {
- while ((qe = tp->segq.lh_first) != NULL) {
- LIST_REMOVE(qe, ipqe_q);
- m_freem(qe->ipqe_m);
- FREE(qe, M_IPQ);
- }
- } else
-#endif /* INET6 */
- while ((qe = tp->segq.lh_first) != NULL) {
- LIST_REMOVE(qe, ipqe_q);
- m_freem(qe->ipqe_m);
- FREE(qe, M_IPQ);
- }
+ tcp_freeq(tp);
+
#ifdef TCP_SACK
/* Free SACK holes. */
q = p = tp->snd_holes;
@@ -701,6 +684,21 @@ tcp_close(tp)
return ((struct tcpcb *)0);
}
+int
+tcp_freeq(struct tcpcb *tp)
+{
+ struct ipqent *qe;
+ int rv = 0;
+
+ while ((qe = LIST_FIRST(&tp->segq)) != NULL) {
+ LIST_REMOVE(qe, ipqe_q);
+ m_freem(qe->ipqe_m);
+ pool_put(&ipqent_pool, qe);
+ rv = 1;
+ }
+ return (rv);
+}
+
void
tcp_drain()
{