Fri Jul 24 04:31:21 2015 UTC ()
Make sure that snd_win doesn't go negative.


(matt)
diff -r1.342 -r1.343 src/sys/netinet/tcp_input.c

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

--- src/sys/netinet/tcp_input.c 2015/07/15 09:20:18 1.342
+++ src/sys/netinet/tcp_input.c 2015/07/24 04:31:20 1.343
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tcp_input.c,v 1.342 2015/07/15 09:20:18 ozaki-r Exp $ */ 1/* $NetBSD: tcp_input.c,v 1.343 2015/07/24 04:31:20 matt 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.342 2015/07/15 09:20:18 ozaki-r Exp $"); 151__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.343 2015/07/24 04:31:20 matt 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>
@@ -2703,27 +2703,30 @@ after_listen: @@ -2703,27 +2703,30 @@ after_listen:
2703 */ 2703 */
2704 tp->t_congctl->newack(tp, th); 2704 tp->t_congctl->newack(tp, th);
2705 2705
2706 nd6_hint(tp); 2706 nd6_hint(tp);
2707 if (acked > so->so_snd.sb_cc) { 2707 if (acked > so->so_snd.sb_cc) {
2708 tp->snd_wnd -= so->so_snd.sb_cc; 2708 tp->snd_wnd -= so->so_snd.sb_cc;
2709 sbdrop(&so->so_snd, (int)so->so_snd.sb_cc); 2709 sbdrop(&so->so_snd, (int)so->so_snd.sb_cc);
2710 ourfinisacked = 1; 2710 ourfinisacked = 1;
2711 } else { 2711 } else {
2712 if (acked > (tp->t_lastoff - tp->t_inoff)) 2712 if (acked > (tp->t_lastoff - tp->t_inoff))
2713 tp->t_lastm = NULL; 2713 tp->t_lastm = NULL;
2714 sbdrop(&so->so_snd, acked); 2714 sbdrop(&so->so_snd, acked);
2715 tp->t_lastoff -= acked; 2715 tp->t_lastoff -= acked;
2716 tp->snd_wnd -= acked; 2716 if (tp->snd_wnd > acked)
 2717 tp->snd_wnd -= acked;
 2718 else
 2719 tp->snd_wnd = 0;
2717 ourfinisacked = 0; 2720 ourfinisacked = 0;
2718 } 2721 }
2719 sowwakeup(so); 2722 sowwakeup(so);
2720 2723
2721 icmp_check(tp, th, acked); 2724 icmp_check(tp, th, acked);
2722 2725
2723 tp->snd_una = th->th_ack; 2726 tp->snd_una = th->th_ack;
2724 if (SEQ_GT(tp->snd_una, tp->snd_fack)) 2727 if (SEQ_GT(tp->snd_una, tp->snd_fack))
2725 tp->snd_fack = tp->snd_una; 2728 tp->snd_fack = tp->snd_una;
2726 if (SEQ_LT(tp->snd_nxt, tp->snd_una)) 2729 if (SEQ_LT(tp->snd_nxt, tp->snd_una))
2727 tp->snd_nxt = tp->snd_una; 2730 tp->snd_nxt = tp->snd_una;
2728 if (SEQ_LT(tp->snd_high, tp->snd_una)) 2731 if (SEQ_LT(tp->snd_high, tp->snd_una))
2729 tp->snd_high = tp->snd_una; 2732 tp->snd_high = tp->snd_una;