Fri Jul 24 07:44:35 2015 UTC ()
Pull up following revision(s) (requested by matt in ticket #1973):
	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.291.4.5 -r1.291.4.5.6.1 src/sys/netinet/tcp_input.c
diff -r1.167.10.1 -r1.167.10.1.2.1 src/sys/netinet/tcp_output.c

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

--- src/sys/netinet/tcp_input.c 2010/06/11 23:36:07 1.291.4.5
+++ src/sys/netinet/tcp_input.c 2015/07/24 07:44:35 1.291.4.5.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcp_input.c,v 1.291.4.5 2010/06/11 23:36:07 riz Exp $ */ 1/* $NetBSD: tcp_input.c,v 1.291.4.5.6.1 2015/07/24 07:44:35 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.
@@ -135,27 +135,27 @@ @@ -135,27 +135,27 @@
135 */ 135 */
136 136
137/* 137/*
138 * TODO list for SYN cache stuff: 138 * TODO list for SYN cache stuff:
139 * 139 *
140 * Find room for a "state" field, which is needed to keep a 140 * Find room for a "state" field, which is needed to keep a
141 * compressed state for TIME_WAIT TCBs. It's been noted already 141 * compressed state for TIME_WAIT TCBs. It's been noted already
142 * that this is fairly important for very high-volume web and 142 * that this is fairly important for very high-volume web and
143 * mail servers, which use a large number of short-lived 143 * mail servers, which use a large number of short-lived
144 * connections. 144 * connections.
145 */ 145 */
146 146
147#include <sys/cdefs.h> 147#include <sys/cdefs.h>
148__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.291.4.5 2010/06/11 23:36:07 riz Exp $"); 148__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.291.4.5.6.1 2015/07/24 07:44:35 martin Exp $");
149 149
150#include "opt_inet.h" 150#include "opt_inet.h"
151#include "opt_ipsec.h" 151#include "opt_ipsec.h"
152#include "opt_inet_csum.h" 152#include "opt_inet_csum.h"
153#include "opt_tcp_debug.h" 153#include "opt_tcp_debug.h"
154 154
155#include <sys/param.h> 155#include <sys/param.h>
156#include <sys/systm.h> 156#include <sys/systm.h>
157#include <sys/malloc.h> 157#include <sys/malloc.h>
158#include <sys/mbuf.h> 158#include <sys/mbuf.h>
159#include <sys/protosw.h> 159#include <sys/protosw.h>
160#include <sys/socket.h> 160#include <sys/socket.h>
161#include <sys/socketvar.h> 161#include <sys/socketvar.h>
@@ -2428,27 +2428,30 @@ after_listen: @@ -2428,27 +2428,30 @@ after_listen:
2428 */ 2428 */
2429 tp->t_congctl->newack(tp, th); 2429 tp->t_congctl->newack(tp, th);
2430 2430
2431 nd6_hint(tp); 2431 nd6_hint(tp);
2432 if (acked > so->so_snd.sb_cc) { 2432 if (acked > so->so_snd.sb_cc) {
2433 tp->snd_wnd -= so->so_snd.sb_cc; 2433 tp->snd_wnd -= so->so_snd.sb_cc;
2434 sbdrop(&so->so_snd, (int)so->so_snd.sb_cc); 2434 sbdrop(&so->so_snd, (int)so->so_snd.sb_cc);
2435 ourfinisacked = 1; 2435 ourfinisacked = 1;
2436 } else { 2436 } else {
2437 if (acked > (tp->t_lastoff - tp->t_inoff)) 2437 if (acked > (tp->t_lastoff - tp->t_inoff))
2438 tp->t_lastm = NULL; 2438 tp->t_lastm = NULL;
2439 sbdrop(&so->so_snd, acked); 2439 sbdrop(&so->so_snd, acked);
2440 tp->t_lastoff -= acked; 2440 tp->t_lastoff -= acked;
2441 tp->snd_wnd -= acked; 2441 if (tp->snd_wnd > acked)
 2442 tp->snd_wnd -= acked;
 2443 else
 2444 tp->snd_wnd = 0;
2442 ourfinisacked = 0; 2445 ourfinisacked = 0;
2443 } 2446 }
2444 sowwakeup(so); 2447 sowwakeup(so);
2445 2448
2446 icmp_check(tp, th, acked); 2449 icmp_check(tp, th, acked);
2447 2450
2448 tp->snd_una = th->th_ack; 2451 tp->snd_una = th->th_ack;
2449 if (SEQ_GT(tp->snd_una, tp->snd_fack)) 2452 if (SEQ_GT(tp->snd_una, tp->snd_fack))
2450 tp->snd_fack = tp->snd_una; 2453 tp->snd_fack = tp->snd_una;
2451 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) 2454 if (SEQ_LT(tp->snd_nxt, tp->snd_una))
2452 tp->snd_nxt = tp->snd_una; 2455 tp->snd_nxt = tp->snd_una;
2453 if (SEQ_LT(tp->snd_high, tp->snd_una)) 2456 if (SEQ_LT(tp->snd_high, tp->snd_una))
2454 tp->snd_high = tp->snd_una; 2457 tp->snd_high = tp->snd_una;

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

--- src/sys/netinet/tcp_output.c 2011/03/29 20:12:14 1.167.10.1
+++ src/sys/netinet/tcp_output.c 2015/07/24 07:44:35 1.167.10.1.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcp_output.c,v 1.167.10.1 2011/03/29 20:12:14 riz Exp $ */ 1/* $NetBSD: tcp_output.c,v 1.167.10.1.2.1 2015/07/24 07:44:35 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.167.10.1 2011/03/29 20:12:14 riz Exp $"); 138__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.167.10.1.2.1 2015/07/24 07:44:35 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>
@@ -1514,34 +1514,44 @@ send: @@ -1514,34 +1514,44 @@ send:
1514 TCP_STATINC(TCP_STAT_SEGSTIMED); 1514 TCP_STATINC(TCP_STAT_SEGSTIMED);
1515 } 1515 }
1516 } 1516 }
1517 1517
1518 /* 1518 /*
1519 * Set retransmit timer if not currently set, 1519 * Set retransmit timer if not currently set,
1520 * and not doing an ack or a keep-alive probe. 1520 * and not doing an ack or a keep-alive probe.
1521 * Initial value for retransmit timer is smoothed 1521 * Initial value for retransmit timer is smoothed
1522 * round-trip time + 2 * round-trip time variance. 1522 * round-trip time + 2 * round-trip time variance.
1523 * Initialize shift counter which is used for backoff 1523 * Initialize shift counter which is used for backoff
1524 * of retransmit time. 1524 * of retransmit time.
1525 */ 1525 */
1526timer: 1526timer:
1527 if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0 && 1527 if (TCP_TIMER_ISARMED(tp, TCPT_REXMT) == 0) {
1528 ((sack_rxmit && tp->snd_nxt != tp->snd_max) || 1528 if ((sack_rxmit && tp->snd_nxt != tp->snd_max)
1529 tp->snd_nxt != tp->snd_una)) { 1529 || tp->snd_nxt != tp->snd_una) {
1530 if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) { 1530 if (TCP_TIMER_ISARMED(tp, TCPT_PERSIST)) {
1531 TCP_TIMER_DISARM(tp, TCPT_PERSIST); 1531 TCP_TIMER_DISARM(tp, TCPT_PERSIST);
 1532 tp->t_rxtshift = 0;
 1533 }
 1534 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur);
 1535 } else if (len == 0 && so->so_snd.sb_cc > 0
 1536 && TCP_TIMER_ISARMED(tp, TCPT_PERSIST) == 0) {
 1537 /*
 1538 * If we are sending a window probe and there's
 1539 * unacked data in the socket, make sure at
 1540 * least the persist timer is running.
 1541 */
1532 tp->t_rxtshift = 0; 1542 tp->t_rxtshift = 0;
 1543 tcp_setpersist(tp);
1533 } 1544 }
1534 TCP_TIMER_ARM(tp, TCPT_REXMT, tp->t_rxtcur); 
1535 } 1545 }
1536 } else 1546 } else
1537 if (SEQ_GT(tp->snd_nxt + len, tp->snd_max)) 1547 if (SEQ_GT(tp->snd_nxt + len, tp->snd_max))
1538 tp->snd_max = tp->snd_nxt + len; 1548 tp->snd_max = tp->snd_nxt + len;
1539 1549
1540#ifdef TCP_DEBUG 1550#ifdef TCP_DEBUG
1541 /* 1551 /*
1542 * Trace. 1552 * Trace.
1543 */ 1553 */
1544 if (so->so_options & SO_DEBUG) 1554 if (so->so_options & SO_DEBUG)
1545 tcp_trace(TA_OUTPUT, tp->t_state, tp, m, 0); 1555 tcp_trace(TA_OUTPUT, tp->t_state, tp, m, 0);
1546#endif 1556#endif
1547 1557