Fri Jul 24 07:37:49 2015 UTC ()
Pull up following revision(s) (requested by matt in ticket #1315):
	sys/netinet/tcp_output.c: revision 1.184
	sys/netinet/tcp_input.c: revision 1.343

If we are sending a window probe and there's unacked data in the
socket, make sure at least the persist timer is running.
Make sure that snd_win doesn't go negative.


(martin)
diff -r1.321 -r1.321.6.1 src/sys/netinet/tcp_input.c
diff -r1.173.6.1 -r1.173.6.2 src/sys/netinet/tcp_output.c

cvs diff -r1.321 -r1.321.6.1 src/sys/netinet/tcp_input.c (expand / switch to unified diff)

--- src/sys/netinet/tcp_input.c 2012/01/11 14:39:08 1.321
+++ src/sys/netinet/tcp_input.c 2015/07/24 07:37:49 1.321.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcp_input.c,v 1.321 2012/01/11 14:39:08 drochner Exp $ */ 1/* $NetBSD: tcp_input.c,v 1.321.6.1 2015/07/24 07:37:49 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -138,27 +138,27 @@ @@ -138,27 +138,27 @@
138 */ 138 */
139 139
140/* 140/*
141 * TODO list for SYN cache stuff: 141 * TODO list for SYN cache stuff:
142 * 142 *
143 * Find room for a "state" field, which is needed to keep a 143 * Find room for a "state" field, which is needed to keep a
144 * compressed state for TIME_WAIT TCBs. It's been noted already 144 * compressed state for TIME_WAIT TCBs. It's been noted already
145 * that this is fairly important for very high-volume web and 145 * that this is fairly important for very high-volume web and
146 * mail servers, which use a large number of short-lived 146 * mail servers, which use a large number of short-lived
147 * connections. 147 * connections.
148 */ 148 */
149 149
150#include <sys/cdefs.h> 150#include <sys/cdefs.h>
151__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.321 2012/01/11 14:39:08 drochner Exp $"); 151__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.321.6.1 2015/07/24 07:37:49 martin Exp $");
152 152
153#include "opt_inet.h" 153#include "opt_inet.h"
154#include "opt_ipsec.h" 154#include "opt_ipsec.h"
155#include "opt_inet_csum.h" 155#include "opt_inet_csum.h"
156#include "opt_tcp_debug.h" 156#include "opt_tcp_debug.h"
157 157
158#include <sys/param.h> 158#include <sys/param.h>
159#include <sys/systm.h> 159#include <sys/systm.h>
160#include <sys/malloc.h> 160#include <sys/malloc.h>
161#include <sys/mbuf.h> 161#include <sys/mbuf.h>
162#include <sys/protosw.h> 162#include <sys/protosw.h>
163#include <sys/socket.h> 163#include <sys/socket.h>
164#include <sys/socketvar.h> 164#include <sys/socketvar.h>
@@ -2709,27 +2709,30 @@ after_listen: @@ -2709,27 +2709,30 @@ after_listen:
2709 */ 2709 */
2710 tp->t_congctl->newack(tp, th); 2710 tp->t_congctl->newack(tp, th);
2711 2711
2712 nd6_hint(tp); 2712 nd6_hint(tp);
2713 if (acked > so->so_snd.sb_cc) { 2713 if (acked > so->so_snd.sb_cc) {
2714 tp->snd_wnd -= so->so_snd.sb_cc; 2714 tp->snd_wnd -= so->so_snd.sb_cc;
2715 sbdrop(&so->so_snd, (int)so->so_snd.sb_cc); 2715 sbdrop(&so->so_snd, (int)so->so_snd.sb_cc);
2716 ourfinisacked = 1; 2716 ourfinisacked = 1;
2717 } else { 2717 } else {
2718 if (acked > (tp->t_lastoff - tp->t_inoff)) 2718 if (acked > (tp->t_lastoff - tp->t_inoff))
2719 tp->t_lastm = NULL; 2719 tp->t_lastm = NULL;
2720 sbdrop(&so->so_snd, acked); 2720 sbdrop(&so->so_snd, acked);
2721 tp->t_lastoff -= acked; 2721 tp->t_lastoff -= acked;
2722 tp->snd_wnd -= acked; 2722 if (tp->snd_wnd > acked)
 2723 tp->snd_wnd -= acked;
 2724 else
 2725 tp->snd_wnd = 0;
2723 ourfinisacked = 0; 2726 ourfinisacked = 0;
2724 } 2727 }
2725 sowwakeup(so); 2728 sowwakeup(so);
2726 2729
2727 icmp_check(tp, th, acked); 2730 icmp_check(tp, th, acked);
2728 2731
2729 tp->snd_una = th->th_ack; 2732 tp->snd_una = th->th_ack;
2730 if (SEQ_GT(tp->snd_una, tp->snd_fack)) 2733 if (SEQ_GT(tp->snd_una, tp->snd_fack))
2731 tp->snd_fack = tp->snd_una; 2734 tp->snd_fack = tp->snd_una;
2732 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) 2735 if (SEQ_LT(tp->snd_nxt, tp->snd_una))
2733 tp->snd_nxt = tp->snd_una; 2736 tp->snd_nxt = tp->snd_una;
2734 if (SEQ_LT(tp->snd_high, tp->snd_una)) 2737 if (SEQ_LT(tp->snd_high, tp->snd_una))
2735 tp->snd_high = tp->snd_una; 2738 tp->snd_high = tp->snd_una;

cvs diff -r1.173.6.1 -r1.173.6.2 src/sys/netinet/tcp_output.c (expand / switch to unified diff)

--- src/sys/netinet/tcp_output.c 2014/11/03 23:06:13 1.173.6.1
+++ src/sys/netinet/tcp_output.c 2015/07/24 07:37:49 1.173.6.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcp_output.c,v 1.173.6.1 2014/11/03 23:06:13 msaitoh Exp $ */ 1/* $NetBSD: tcp_output.c,v 1.173.6.2 2015/07/24 07:37:49 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -125,27 +125,27 @@ @@ -125,27 +125,27 @@
125 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 125 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
126 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 126 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
127 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 127 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
128 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 128 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
129 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 129 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
130 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 130 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
132 * SUCH DAMAGE. 132 * SUCH DAMAGE.
133 * 133 *
134 * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95 134 * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95
135 */ 135 */
136 136
137#include <sys/cdefs.h> 137#include <sys/cdefs.h>
138__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.173.6.1 2014/11/03 23:06:13 msaitoh Exp $"); 138__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.173.6.2 2015/07/24 07:37:49 martin Exp $");
139 139
140#include "opt_inet.h" 140#include "opt_inet.h"
141#include "opt_ipsec.h" 141#include "opt_ipsec.h"
142#include "opt_tcp_debug.h" 142#include "opt_tcp_debug.h"
143 143
144#include <sys/param.h> 144#include <sys/param.h>
145#include <sys/systm.h> 145#include <sys/systm.h>
146#include <sys/malloc.h> 146#include <sys/malloc.h>
147#include <sys/mbuf.h> 147#include <sys/mbuf.h>
148#include <sys/protosw.h> 148#include <sys/protosw.h>
149#include <sys/socket.h> 149#include <sys/socket.h>
150#include <sys/socketvar.h> 150#include <sys/socketvar.h>
151#include <sys/errno.h> 151#include <sys/errno.h>
@@ -1517,34 +1517,44 @@ send: @@ -1517,34 +1517,44 @@ send:
1517 TCP_STATINC(TCP_STAT_SEGSTIMED); 1517 TCP_STATINC(TCP_STAT_SEGSTIMED);
1518 } 1518 }
1519 } 1519 }
1520 1520
1521 /* 1521 /*
1522 * Set retransmit timer if not currently set, 1522 * Set retransmit timer if not currently set,
1523 * and not doing an ack or a keep-alive probe. 1523 * and not doing an ack or a keep-alive probe.
1524 * Initial value for retransmit timer is smoothed 1524 * Initial value for retransmit timer is smoothed
1525 * round-trip time + 2 * round-trip time variance. 1525 * round-trip time + 2 * round-trip time variance.
1526 * Initialize shift counter which is used for backoff 1526 * Initialize shift counter which is used for backoff
1527 * of retransmit time. 1527 * of retransmit time.
1528 */ 1528 */
1529timer: 1529timer:
1530 if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0 && 1530 if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0) {
1531 ((sack_rxmit && tp->snd_nxt != tp->snd_max) || 1531 if ((sack_rxmit && tp->snd_nxt != tp->snd_max)
1532 tp->snd_nxt != tp->snd_una)) { 1532 || tp->snd_nxt != tp->snd_una) {
1533 if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) { 1533 if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) {
1534 TCP_TIMER_DISARM(tp, TCPT_PERSIST); 1534 TCP_TIMER_DISARM(tp, TCPT_PERSIST);
 1535 tp->t_rxtshift = 0;
 1536 }
 1537 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur);
 1538 } else if (len == 0 && so->so_snd.sb_cc > 0
 1539 && TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) {
 1540 /*
 1541 * If we are sending a window probe and there's
 1542 * unacked data in the socket, make sure at
 1543 * least the persist timer is running.
 1544 */
1535 tp->t_rxtshift = 0; 1545 tp->t_rxtshift = 0;
 1546 tcp_setpersist(tp);
1536 } 1547 }
1537 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur); 
1538 } 1548 }
1539 } else 1549 } else
1540 if (SEQ_GT(tp->snd_nxt + len, tp->snd_max)) 1550 if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
1541 tp->snd_max = tp->snd_nxt + len; 1551 tp->snd_max = tp->snd_nxt + len;
1542 1552
1543#ifdef TCP_DEBUG 1553#ifdef TCP_DEBUG
1544 /* 1554 /*
1545 * Trace. 1555 * Trace.
1546 */ 1556 */
1547 if (so->so_options & SO_DEBUG) 1557 if (so->so_options & SO_DEBUG)
1548 tcp_trace(TA_OUTPUT, tp->t_state, tp, m, 0); 1558 tcp_trace(TA_OUTPUT, tp->t_state, tp, m, 0);
1549#endif 1559#endif
1550 1560