summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_input.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2002-03-02 00:44:53 +0000
committerNiels Provos <provos@cvs.openbsd.org>2002-03-02 00:44:53 +0000
commit3841130e9eea84837afe61d60ced60051d68eb24 (patch)
treeca9c41c6e0a4667da0fda98e0beb5223ef36045a /sys/netinet/tcp_input.c
parent8947d29f92fe14e732c743a3d75d85cb985c26a8 (diff)
disable immediate ack on TH_PUSH. make behaviour sysctl tuneable.
from netbsd; also fix a bug where setting TF_ACKNOW didn't actually result in an ack.
Diffstat (limited to 'sys/netinet/tcp_input.c')
-rw-r--r--sys/netinet/tcp_input.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 85074de4cd5..60394196464 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.105 2002/03/01 22:29:29 provos Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.106 2002/03/02 00:44:52 provos Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -142,6 +142,21 @@ do { \
#endif
/*
+ * Macro to compute ACK transmission behavior. Delay the ACK unless
+ * we have already delayed an ACK (must send an ACK every two segments).
+ * We also ACK immediately if we received a PUSH and the ACK-on-PUSH
+ * option is enabled.
+ */
+#define TCP_SETUP_ACK(tp, th) \
+do { \
+ if ((tp)->t_flags & TF_DELACK || \
+ (tcp_ack_on_push && (th)->th_flags & TH_PUSH)) \
+ tp->t_flags |= TF_ACKNOW; \
+ else \
+ TCP_SET_DELACK(tp); \
+} while (0)
+
+/*
* Insert segment ti into reassembly queue of tcp with
* control block tp. Return TH_FIN if reassembly now includes
* a segment with FIN. The macro form does the common case inline
@@ -992,13 +1007,12 @@ findpcb:
* Drop TCP, IP headers and TCP options then add data
* to socket buffer.
*/
- if (th->th_flags & TH_PUSH)
- tp->t_flags |= TF_ACKNOW;
- else
- TCP_SET_DELACK(tp);
m_adj(m, iphlen + off);
sbappend(&so->so_rcv, m);
sorwakeup(so);
+ TCP_SETUP_ACK(tp, th);
+ if (tp->t_flags & TF_ACKNOW)
+ (void) tcp_output(tp);
return;
}
}
@@ -1978,10 +1992,7 @@ dodata: /* XXX */
TCPS_HAVERCVDFIN(tp->t_state) == 0) {
if (th->th_seq == tp->rcv_nxt && tp->segq.lh_first == NULL &&
tp->t_state == TCPS_ESTABLISHED) {
- if (th->th_flags & TH_PUSH)
- tp->t_flags |= TF_ACKNOW;
- else
- TCP_SET_DELACK(tp);
+ TCP_SETUP_ACK(tp, th);
tp->rcv_nxt += tlen;
tiflags = th->th_flags & TH_FIN;
tcpstat.tcps_rcvpack++;