Home | History | Annotate | Line # | Download | only in netinet
tcp_congctl.c revision 1.12.6.2
      1  1.12.6.2  yamt /*	$NetBSD: tcp_congctl.c,v 1.12.6.2 2006/12/30 20:50:33 yamt Exp $	*/
      2  1.12.6.2  yamt 
      3  1.12.6.2  yamt /*-
      4  1.12.6.2  yamt  * Copyright (c) 1997, 1998, 1999, 2001, 2005, 2006 The NetBSD Foundation, Inc.
      5  1.12.6.2  yamt  * All rights reserved.
      6  1.12.6.2  yamt  *
      7  1.12.6.2  yamt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.12.6.2  yamt  * by Jason R. Thorpe and Kevin M. Lahey of the Numerical Aerospace Simulation
      9  1.12.6.2  yamt  * Facility, NASA Ames Research Center.
     10  1.12.6.2  yamt  * This code is derived from software contributed to The NetBSD Foundation
     11  1.12.6.2  yamt  * by Charles M. Hannum.
     12  1.12.6.2  yamt  * This code is derived from software contributed to The NetBSD Foundation
     13  1.12.6.2  yamt  * by Rui Paulo.
     14  1.12.6.2  yamt  *
     15  1.12.6.2  yamt  * Redistribution and use in source and binary forms, with or without
     16  1.12.6.2  yamt  * modification, are permitted provided that the following conditions
     17  1.12.6.2  yamt  * are met:
     18  1.12.6.2  yamt  * 1. Redistributions of source code must retain the above copyright
     19  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer.
     20  1.12.6.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     21  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     22  1.12.6.2  yamt  *    documentation and/or other materials provided with the distribution.
     23  1.12.6.2  yamt  * 3. All advertising materials mentioning features or use of this software
     24  1.12.6.2  yamt  *    must display the following acknowledgement:
     25  1.12.6.2  yamt  *	This product includes software developed by the NetBSD
     26  1.12.6.2  yamt  *	Foundation, Inc. and its contributors.
     27  1.12.6.2  yamt  * 4. Neither the name of The NetBSD Foundation nor the names of its
     28  1.12.6.2  yamt  *    contributors may be used to endorse or promote products derived
     29  1.12.6.2  yamt  *    from this software without specific prior written permission.
     30  1.12.6.2  yamt  *
     31  1.12.6.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     32  1.12.6.2  yamt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     33  1.12.6.2  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     34  1.12.6.2  yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     35  1.12.6.2  yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     36  1.12.6.2  yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     37  1.12.6.2  yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     38  1.12.6.2  yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     39  1.12.6.2  yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     40  1.12.6.2  yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.12.6.2  yamt  * POSSIBILITY OF SUCH DAMAGE.
     42  1.12.6.2  yamt  */
     43  1.12.6.2  yamt 
     44  1.12.6.2  yamt /*
     45  1.12.6.2  yamt  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
     46  1.12.6.2  yamt  * All rights reserved.
     47  1.12.6.2  yamt  *
     48  1.12.6.2  yamt  * Redistribution and use in source and binary forms, with or without
     49  1.12.6.2  yamt  * modification, are permitted provided that the following conditions
     50  1.12.6.2  yamt  * are met:
     51  1.12.6.2  yamt  * 1. Redistributions of source code must retain the above copyright
     52  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer.
     53  1.12.6.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     54  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     55  1.12.6.2  yamt  *    documentation and/or other materials provided with the distribution.
     56  1.12.6.2  yamt  * 3. Neither the name of the project nor the names of its contributors
     57  1.12.6.2  yamt  *    may be used to endorse or promote products derived from this software
     58  1.12.6.2  yamt  *    without specific prior written permission.
     59  1.12.6.2  yamt  *
     60  1.12.6.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     61  1.12.6.2  yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     62  1.12.6.2  yamt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     63  1.12.6.2  yamt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     64  1.12.6.2  yamt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     65  1.12.6.2  yamt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     66  1.12.6.2  yamt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     67  1.12.6.2  yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     68  1.12.6.2  yamt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     69  1.12.6.2  yamt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     70  1.12.6.2  yamt  * SUCH DAMAGE.
     71  1.12.6.2  yamt  */
     72  1.12.6.2  yamt 
     73  1.12.6.2  yamt /*
     74  1.12.6.2  yamt  *      @(#)COPYRIGHT   1.1 (NRL) 17 January 1995
     75  1.12.6.2  yamt  *
     76  1.12.6.2  yamt  * NRL grants permission for redistribution and use in source and binary
     77  1.12.6.2  yamt  * forms, with or without modification, of the software and documentation
     78  1.12.6.2  yamt  * created at NRL provided that the following conditions are met:
     79  1.12.6.2  yamt  *
     80  1.12.6.2  yamt  * 1. Redistributions of source code must retain the above copyright
     81  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer.
     82  1.12.6.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     83  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     84  1.12.6.2  yamt  *    documentation and/or other materials provided with the distribution.
     85  1.12.6.2  yamt  * 3. All advertising materials mentioning features or use of this software
     86  1.12.6.2  yamt  *    must display the following acknowledgements:
     87  1.12.6.2  yamt  *      This product includes software developed by the University of
     88  1.12.6.2  yamt  *      California, Berkeley and its contributors.
     89  1.12.6.2  yamt  *      This product includes software developed at the Information
     90  1.12.6.2  yamt  *      Technology Division, US Naval Research Laboratory.
     91  1.12.6.2  yamt  * 4. Neither the name of the NRL nor the names of its contributors
     92  1.12.6.2  yamt  *    may be used to endorse or promote products derived from this software
     93  1.12.6.2  yamt  *    without specific prior written permission.
     94  1.12.6.2  yamt  *
     95  1.12.6.2  yamt  * THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
     96  1.12.6.2  yamt  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     97  1.12.6.2  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     98  1.12.6.2  yamt  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL NRL OR
     99  1.12.6.2  yamt  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    100  1.12.6.2  yamt  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    101  1.12.6.2  yamt  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    102  1.12.6.2  yamt  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    103  1.12.6.2  yamt  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    104  1.12.6.2  yamt  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    105  1.12.6.2  yamt  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    106  1.12.6.2  yamt  *
    107  1.12.6.2  yamt  * The views and conclusions contained in the software and documentation
    108  1.12.6.2  yamt  * are those of the authors and should not be interpreted as representing
    109  1.12.6.2  yamt  * official policies, either expressed or implied, of the US Naval
    110  1.12.6.2  yamt  * Research Laboratory (NRL).
    111  1.12.6.2  yamt  */
    112  1.12.6.2  yamt 
    113  1.12.6.2  yamt /*
    114  1.12.6.2  yamt  * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
    115  1.12.6.2  yamt  *	The Regents of the University of California.  All rights reserved.
    116  1.12.6.2  yamt  *
    117  1.12.6.2  yamt  * Redistribution and use in source and binary forms, with or without
    118  1.12.6.2  yamt  * modification, are permitted provided that the following conditions
    119  1.12.6.2  yamt  * are met:
    120  1.12.6.2  yamt  * 1. Redistributions of source code must retain the above copyright
    121  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer.
    122  1.12.6.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
    123  1.12.6.2  yamt  *    notice, this list of conditions and the following disclaimer in the
    124  1.12.6.2  yamt  *    documentation and/or other materials provided with the distribution.
    125  1.12.6.2  yamt  * 3. Neither the name of the University nor the names of its contributors
    126  1.12.6.2  yamt  *    may be used to endorse or promote products derived from this software
    127  1.12.6.2  yamt  *    without specific prior written permission.
    128  1.12.6.2  yamt  *
    129  1.12.6.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    130  1.12.6.2  yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    131  1.12.6.2  yamt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    132  1.12.6.2  yamt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    133  1.12.6.2  yamt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    134  1.12.6.2  yamt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    135  1.12.6.2  yamt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    136  1.12.6.2  yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    137  1.12.6.2  yamt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    138  1.12.6.2  yamt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    139  1.12.6.2  yamt  * SUCH DAMAGE.
    140  1.12.6.2  yamt  *
    141  1.12.6.2  yamt  *	@(#)tcp_input.c	8.12 (Berkeley) 5/24/95
    142  1.12.6.2  yamt  */
    143  1.12.6.2  yamt 
    144  1.12.6.2  yamt #include <sys/cdefs.h>
    145  1.12.6.2  yamt __KERNEL_RCSID(0, "$NetBSD: tcp_congctl.c,v 1.12.6.2 2006/12/30 20:50:33 yamt Exp $");
    146  1.12.6.2  yamt 
    147  1.12.6.2  yamt #include "opt_inet.h"
    148  1.12.6.2  yamt #include "opt_tcp_debug.h"
    149  1.12.6.2  yamt #include "opt_tcp_congctl.h"
    150  1.12.6.2  yamt 
    151  1.12.6.2  yamt #include <sys/param.h>
    152  1.12.6.2  yamt #include <sys/systm.h>
    153  1.12.6.2  yamt #include <sys/malloc.h>
    154  1.12.6.2  yamt #include <sys/mbuf.h>
    155  1.12.6.2  yamt #include <sys/protosw.h>
    156  1.12.6.2  yamt #include <sys/socket.h>
    157  1.12.6.2  yamt #include <sys/socketvar.h>
    158  1.12.6.2  yamt #include <sys/errno.h>
    159  1.12.6.2  yamt #include <sys/syslog.h>
    160  1.12.6.2  yamt #include <sys/pool.h>
    161  1.12.6.2  yamt #include <sys/domain.h>
    162  1.12.6.2  yamt #include <sys/kernel.h>
    163  1.12.6.2  yamt #include <sys/lock.h>
    164  1.12.6.2  yamt 
    165  1.12.6.2  yamt #include <net/if.h>
    166  1.12.6.2  yamt #include <net/route.h>
    167  1.12.6.2  yamt 
    168  1.12.6.2  yamt #include <netinet/in.h>
    169  1.12.6.2  yamt #include <netinet/in_systm.h>
    170  1.12.6.2  yamt #include <netinet/ip.h>
    171  1.12.6.2  yamt #include <netinet/in_pcb.h>
    172  1.12.6.2  yamt #include <netinet/in_var.h>
    173  1.12.6.2  yamt #include <netinet/ip_var.h>
    174  1.12.6.2  yamt 
    175  1.12.6.2  yamt #ifdef INET6
    176  1.12.6.2  yamt #ifndef INET
    177  1.12.6.2  yamt #include <netinet/in.h>
    178  1.12.6.2  yamt #endif
    179  1.12.6.2  yamt #include <netinet/ip6.h>
    180  1.12.6.2  yamt #include <netinet6/ip6_var.h>
    181  1.12.6.2  yamt #include <netinet6/in6_pcb.h>
    182  1.12.6.2  yamt #include <netinet6/ip6_var.h>
    183  1.12.6.2  yamt #include <netinet6/in6_var.h>
    184  1.12.6.2  yamt #include <netinet/icmp6.h>
    185  1.12.6.2  yamt #include <netinet6/nd6.h>
    186  1.12.6.2  yamt #endif
    187  1.12.6.2  yamt 
    188  1.12.6.2  yamt #include <netinet/tcp.h>
    189  1.12.6.2  yamt #include <netinet/tcp_fsm.h>
    190  1.12.6.2  yamt #include <netinet/tcp_seq.h>
    191  1.12.6.2  yamt #include <netinet/tcp_timer.h>
    192  1.12.6.2  yamt #include <netinet/tcp_var.h>
    193  1.12.6.2  yamt #include <netinet/tcpip.h>
    194  1.12.6.2  yamt #include <netinet/tcp_congctl.h>
    195  1.12.6.2  yamt #ifdef TCP_DEBUG
    196  1.12.6.2  yamt #include <netinet/tcp_debug.h>
    197  1.12.6.2  yamt #endif
    198  1.12.6.2  yamt 
    199  1.12.6.2  yamt /*
    200  1.12.6.2  yamt  * TODO:
    201  1.12.6.2  yamt  *   consider separating the actual implementations in another file.
    202  1.12.6.2  yamt  */
    203  1.12.6.2  yamt 
    204  1.12.6.2  yamt static int  tcp_reno_fast_retransmit(struct tcpcb *, const struct tcphdr *);
    205  1.12.6.2  yamt static void tcp_reno_slow_retransmit(struct tcpcb *);
    206  1.12.6.2  yamt static void tcp_reno_fast_retransmit_newack(struct tcpcb *,
    207  1.12.6.2  yamt     const struct tcphdr *);
    208  1.12.6.2  yamt static void tcp_reno_newack(struct tcpcb *, const struct tcphdr *);
    209  1.12.6.2  yamt static void tcp_reno_congestion_exp(struct tcpcb *tp);
    210  1.12.6.2  yamt 
    211  1.12.6.2  yamt static int  tcp_newreno_fast_retransmit(struct tcpcb *, const struct tcphdr *);
    212  1.12.6.2  yamt static void tcp_newreno_fast_retransmit_newack(struct tcpcb *,
    213  1.12.6.2  yamt 	const struct tcphdr *);
    214  1.12.6.2  yamt static void tcp_newreno_newack(struct tcpcb *, const struct tcphdr *);
    215  1.12.6.2  yamt 
    216  1.12.6.2  yamt 
    217  1.12.6.2  yamt static void tcp_congctl_fillnames(void);
    218  1.12.6.2  yamt 
    219  1.12.6.2  yamt extern int tcprexmtthresh;
    220  1.12.6.2  yamt 
    221  1.12.6.2  yamt MALLOC_DEFINE(M_TCPCONGCTL, "tcpcongctl", "TCP congestion control structures");
    222  1.12.6.2  yamt 
    223  1.12.6.2  yamt /*
    224  1.12.6.2  yamt  * Used to list the available congestion control algorithms.
    225  1.12.6.2  yamt  */
    226  1.12.6.2  yamt struct tcp_congctlent {
    227  1.12.6.2  yamt 	TAILQ_ENTRY(tcp_congctlent) congctl_ent;
    228  1.12.6.2  yamt 	char               congctl_name[TCPCC_MAXLEN];
    229  1.12.6.2  yamt 	struct tcp_congctl *congctl_ctl;
    230  1.12.6.2  yamt };
    231  1.12.6.2  yamt TAILQ_HEAD(, tcp_congctlent) tcp_congctlhd;
    232  1.12.6.2  yamt 
    233  1.12.6.2  yamt struct simplelock tcp_congctl_slock;
    234  1.12.6.2  yamt 
    235  1.12.6.2  yamt void
    236  1.12.6.2  yamt tcp_congctl_init(void)
    237  1.12.6.2  yamt {
    238  1.12.6.2  yamt 	int r;
    239  1.12.6.2  yamt 
    240  1.12.6.2  yamt 	TAILQ_INIT(&tcp_congctlhd);
    241  1.12.6.2  yamt 	simple_lock_init(&tcp_congctl_slock);
    242  1.12.6.2  yamt 
    243  1.12.6.2  yamt 	/* Base algorithms. */
    244  1.12.6.2  yamt 	r = tcp_congctl_register("reno", &tcp_reno_ctl);
    245  1.12.6.2  yamt 	KASSERT(r == 0);
    246  1.12.6.2  yamt 	r = tcp_congctl_register("newreno", &tcp_newreno_ctl);
    247  1.12.6.2  yamt 	KASSERT(r == 0);
    248  1.12.6.2  yamt 
    249  1.12.6.2  yamt 	/* NewReno is the default. */
    250  1.12.6.2  yamt #ifndef TCP_CONGCTL_DEFAULT
    251  1.12.6.2  yamt #define TCP_CONGCTL_DEFAULT "newreno"
    252  1.12.6.2  yamt #endif
    253  1.12.6.2  yamt 
    254  1.12.6.2  yamt 	r = tcp_congctl_select(NULL, TCP_CONGCTL_DEFAULT);
    255  1.12.6.2  yamt 	KASSERT(r == 0);
    256  1.12.6.2  yamt }
    257  1.12.6.2  yamt 
    258  1.12.6.2  yamt /*
    259  1.12.6.2  yamt  * Register a congestion algorithm and select it if we have none.
    260  1.12.6.2  yamt  */
    261  1.12.6.2  yamt int
    262  1.12.6.2  yamt tcp_congctl_register(const char *name, struct tcp_congctl *tcc)
    263  1.12.6.2  yamt {
    264  1.12.6.2  yamt 	struct tcp_congctlent *ntcc, *tccp;
    265  1.12.6.2  yamt 
    266  1.12.6.2  yamt 	TAILQ_FOREACH(tccp, &tcp_congctlhd, congctl_ent)
    267  1.12.6.2  yamt 		if (!strcmp(name, tccp->congctl_name)) {
    268  1.12.6.2  yamt 			/* name already registered */
    269  1.12.6.2  yamt 			return EEXIST;
    270  1.12.6.2  yamt 		}
    271  1.12.6.2  yamt 
    272  1.12.6.2  yamt 	ntcc = malloc(sizeof(*ntcc), M_TCPCONGCTL, M_WAITOK);
    273  1.12.6.2  yamt 
    274  1.12.6.2  yamt 	strlcpy(ntcc->congctl_name, name, sizeof(ntcc->congctl_name) - 1);
    275  1.12.6.2  yamt 	ntcc->congctl_ctl = tcc;
    276  1.12.6.2  yamt 
    277  1.12.6.2  yamt 	TAILQ_INSERT_TAIL(&tcp_congctlhd, ntcc, congctl_ent);
    278  1.12.6.2  yamt 	tcp_congctl_fillnames();
    279  1.12.6.2  yamt 
    280  1.12.6.2  yamt 	if (TAILQ_FIRST(&tcp_congctlhd) == ntcc)
    281  1.12.6.2  yamt 		tcp_congctl_select(NULL, name);
    282  1.12.6.2  yamt 
    283  1.12.6.2  yamt 	return 0;
    284  1.12.6.2  yamt }
    285  1.12.6.2  yamt 
    286  1.12.6.2  yamt int
    287  1.12.6.2  yamt tcp_congctl_unregister(const char *name)
    288  1.12.6.2  yamt {
    289  1.12.6.2  yamt 	struct tcp_congctlent *tccp, *rtccp;
    290  1.12.6.2  yamt 	unsigned int size;
    291  1.12.6.2  yamt 
    292  1.12.6.2  yamt 	rtccp = NULL;
    293  1.12.6.2  yamt 	size = 0;
    294  1.12.6.2  yamt 	TAILQ_FOREACH(tccp, &tcp_congctlhd, congctl_ent) {
    295  1.12.6.2  yamt 		if (!strcmp(name, tccp->congctl_name))
    296  1.12.6.2  yamt 			rtccp = tccp;
    297  1.12.6.2  yamt 		size++;
    298  1.12.6.2  yamt 	}
    299  1.12.6.2  yamt 
    300  1.12.6.2  yamt 	if (!rtccp)
    301  1.12.6.2  yamt 		return ENOENT;
    302  1.12.6.2  yamt 
    303  1.12.6.2  yamt 	if (size <= 1 || tcp_congctl_global == rtccp->congctl_ctl ||
    304  1.12.6.2  yamt 	    rtccp->congctl_ctl->refcnt)
    305  1.12.6.2  yamt 		return EBUSY;
    306  1.12.6.2  yamt 
    307  1.12.6.2  yamt 	TAILQ_REMOVE(&tcp_congctlhd, rtccp, congctl_ent);
    308  1.12.6.2  yamt 	free(rtccp, M_TCPCONGCTL);
    309  1.12.6.2  yamt 	tcp_congctl_fillnames();
    310  1.12.6.2  yamt 
    311  1.12.6.2  yamt 	return 0;
    312  1.12.6.2  yamt }
    313  1.12.6.2  yamt 
    314  1.12.6.2  yamt /*
    315  1.12.6.2  yamt  * Select a congestion algorithm by name.
    316  1.12.6.2  yamt  */
    317  1.12.6.2  yamt int
    318  1.12.6.2  yamt tcp_congctl_select(struct tcpcb *tp, const char *name)
    319  1.12.6.2  yamt {
    320  1.12.6.2  yamt 	struct tcp_congctlent *tccp;
    321  1.12.6.2  yamt 
    322  1.12.6.2  yamt 	KASSERT(name);
    323  1.12.6.2  yamt 
    324  1.12.6.2  yamt 	TAILQ_FOREACH(tccp, &tcp_congctlhd, congctl_ent)
    325  1.12.6.2  yamt 		if (!strcmp(name, tccp->congctl_name)) {
    326  1.12.6.2  yamt 			if (tp) {
    327  1.12.6.2  yamt 				simple_lock(&tcp_congctl_slock);
    328  1.12.6.2  yamt 				tp->t_congctl->refcnt--;
    329  1.12.6.2  yamt 				tp->t_congctl = tccp->congctl_ctl;
    330  1.12.6.2  yamt 				tp->t_congctl->refcnt++;
    331  1.12.6.2  yamt 				simple_unlock(&tcp_congctl_slock);
    332  1.12.6.2  yamt 			} else {
    333  1.12.6.2  yamt 				tcp_congctl_global = tccp->congctl_ctl;
    334  1.12.6.2  yamt 				strlcpy(tcp_congctl_global_name,
    335  1.12.6.2  yamt 				    tccp->congctl_name,
    336  1.12.6.2  yamt 				    sizeof(tcp_congctl_global_name) - 1);
    337  1.12.6.2  yamt 			}
    338  1.12.6.2  yamt 			return 0;
    339  1.12.6.2  yamt 		}
    340  1.12.6.2  yamt 
    341  1.12.6.2  yamt 	return EINVAL;
    342  1.12.6.2  yamt }
    343  1.12.6.2  yamt 
    344  1.12.6.2  yamt /*
    345  1.12.6.2  yamt  * Returns the name of a congestion algorithm.
    346  1.12.6.2  yamt  */
    347  1.12.6.2  yamt const char *
    348  1.12.6.2  yamt tcp_congctl_bystruct(const struct tcp_congctl *tcc)
    349  1.12.6.2  yamt {
    350  1.12.6.2  yamt 	struct tcp_congctlent *tccp;
    351  1.12.6.2  yamt 
    352  1.12.6.2  yamt 	KASSERT(tcc);
    353  1.12.6.2  yamt 
    354  1.12.6.2  yamt 	TAILQ_FOREACH(tccp, &tcp_congctlhd, congctl_ent)
    355  1.12.6.2  yamt 		if (tccp->congctl_ctl == tcc)
    356  1.12.6.2  yamt 			return tccp->congctl_name;
    357  1.12.6.2  yamt 
    358  1.12.6.2  yamt 	return NULL;
    359  1.12.6.2  yamt }
    360  1.12.6.2  yamt 
    361  1.12.6.2  yamt static void
    362  1.12.6.2  yamt tcp_congctl_fillnames(void)
    363  1.12.6.2  yamt {
    364  1.12.6.2  yamt 	struct tcp_congctlent *tccp;
    365  1.12.6.2  yamt 	const char *delim = " ";
    366  1.12.6.2  yamt 
    367  1.12.6.2  yamt 	tcp_congctl_avail[0] = '\0';
    368  1.12.6.2  yamt 	TAILQ_FOREACH(tccp, &tcp_congctlhd, congctl_ent) {
    369  1.12.6.2  yamt 		strlcat(tcp_congctl_avail, tccp->congctl_name,
    370  1.12.6.2  yamt 		    sizeof(tcp_congctl_avail) - 1);
    371  1.12.6.2  yamt 		if (TAILQ_NEXT(tccp, congctl_ent))
    372  1.12.6.2  yamt 			strlcat(tcp_congctl_avail, delim,
    373  1.12.6.2  yamt 			    sizeof(tcp_congctl_avail) - 1);
    374  1.12.6.2  yamt 	}
    375  1.12.6.2  yamt 
    376  1.12.6.2  yamt }
    377  1.12.6.2  yamt 
    378  1.12.6.2  yamt /* ------------------------------------------------------------------------ */
    379  1.12.6.2  yamt 
    380  1.12.6.2  yamt /*
    381  1.12.6.2  yamt  * TCP/Reno congestion control.
    382  1.12.6.2  yamt  */
    383  1.12.6.2  yamt static void
    384  1.12.6.2  yamt tcp_reno_congestion_exp(struct tcpcb *tp)
    385  1.12.6.2  yamt {
    386  1.12.6.2  yamt 	u_int win;
    387  1.12.6.2  yamt 
    388  1.12.6.2  yamt 	/*
    389  1.12.6.2  yamt 	 * Halve the congestion window and reduce the
    390  1.12.6.2  yamt 	 * slow start threshold.
    391  1.12.6.2  yamt 	 */
    392  1.12.6.2  yamt 	win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_segsz;
    393  1.12.6.2  yamt 	if (win < 2)
    394  1.12.6.2  yamt 		win = 2;
    395  1.12.6.2  yamt 
    396  1.12.6.2  yamt 	tp->snd_ssthresh = win * tp->t_segsz;
    397  1.12.6.2  yamt 	tp->snd_recover = tp->snd_max;
    398  1.12.6.2  yamt 	tp->snd_cwnd = tp->snd_ssthresh;
    399  1.12.6.2  yamt 
    400  1.12.6.2  yamt 	/*
    401  1.12.6.2  yamt 	 * When using TCP ECN, notify the peer that
    402  1.12.6.2  yamt 	 * we reduced the cwnd.
    403  1.12.6.2  yamt 	 */
    404  1.12.6.2  yamt 	if (TCP_ECN_ALLOWED(tp))
    405  1.12.6.2  yamt 		tp->t_flags |= TF_ECN_SND_CWR;
    406  1.12.6.2  yamt }
    407  1.12.6.2  yamt 
    408  1.12.6.2  yamt 
    409  1.12.6.2  yamt 
    410  1.12.6.2  yamt static int
    411  1.12.6.2  yamt tcp_reno_fast_retransmit(struct tcpcb *tp, const struct tcphdr *th)
    412  1.12.6.2  yamt {
    413  1.12.6.2  yamt 	/*
    414  1.12.6.2  yamt 	 * We know we're losing at the current
    415  1.12.6.2  yamt 	 * window size so do congestion avoidance
    416  1.12.6.2  yamt 	 * (set ssthresh to half the current window
    417  1.12.6.2  yamt 	 * and pull our congestion window back to
    418  1.12.6.2  yamt 	 * the new ssthresh).
    419  1.12.6.2  yamt 	 *
    420  1.12.6.2  yamt 	 * Dup acks mean that packets have left the
    421  1.12.6.2  yamt 	 * network (they're now cached at the receiver)
    422  1.12.6.2  yamt 	 * so bump cwnd by the amount in the receiver
    423  1.12.6.2  yamt 	 * to keep a constant cwnd packets in the
    424  1.12.6.2  yamt 	 * network.
    425  1.12.6.2  yamt 	 *
    426  1.12.6.2  yamt 	 * If we are using TCP/SACK, then enter
    427  1.12.6.2  yamt 	 * Fast Recovery if the receiver SACKs
    428  1.12.6.2  yamt 	 * data that is tcprexmtthresh * MSS
    429  1.12.6.2  yamt 	 * bytes past the last ACKed segment,
    430  1.12.6.2  yamt 	 * irrespective of the number of DupAcks.
    431  1.12.6.2  yamt 	 */
    432  1.12.6.2  yamt 
    433  1.12.6.2  yamt 	tcp_seq onxt;
    434  1.12.6.2  yamt 
    435  1.12.6.2  yamt 	onxt = tp->snd_nxt;
    436  1.12.6.2  yamt 	tcp_reno_congestion_exp(tp);
    437  1.12.6.2  yamt 	tp->t_partialacks = 0;
    438  1.12.6.2  yamt 	TCP_TIMER_DISARM(tp, TCPT_REXMT);
    439  1.12.6.2  yamt 	tp->t_rtttime = 0;
    440  1.12.6.2  yamt 	if (TCP_SACK_ENABLED(tp)) {
    441  1.12.6.2  yamt 		tp->t_dupacks = tcprexmtthresh;
    442  1.12.6.2  yamt 		tp->sack_newdata = tp->snd_nxt;
    443  1.12.6.2  yamt 		tp->snd_cwnd = tp->t_segsz;
    444  1.12.6.2  yamt 		(void) tcp_output(tp);
    445  1.12.6.2  yamt 		return 0;
    446  1.12.6.2  yamt 	}
    447  1.12.6.2  yamt 	tp->snd_nxt = th->th_ack;
    448  1.12.6.2  yamt 	tp->snd_cwnd = tp->t_segsz;
    449  1.12.6.2  yamt 	(void) tcp_output(tp);
    450  1.12.6.2  yamt 	tp->snd_cwnd = tp->snd_ssthresh + tp->t_segsz * tp->t_dupacks;
    451  1.12.6.2  yamt 	if (SEQ_GT(onxt, tp->snd_nxt))
    452  1.12.6.2  yamt 		tp->snd_nxt = onxt;
    453  1.12.6.2  yamt 
    454  1.12.6.2  yamt 	return 0;
    455  1.12.6.2  yamt }
    456  1.12.6.2  yamt 
    457  1.12.6.2  yamt static void
    458  1.12.6.2  yamt tcp_reno_slow_retransmit(struct tcpcb *tp)
    459  1.12.6.2  yamt {
    460  1.12.6.2  yamt 	u_int win;
    461  1.12.6.2  yamt 
    462  1.12.6.2  yamt 	/*
    463  1.12.6.2  yamt 	 * Close the congestion window down to one segment
    464  1.12.6.2  yamt 	 * (we'll open it by one segment for each ack we get).
    465  1.12.6.2  yamt 	 * Since we probably have a window's worth of unacked
    466  1.12.6.2  yamt 	 * data accumulated, this "slow start" keeps us from
    467  1.12.6.2  yamt 	 * dumping all that data as back-to-back packets (which
    468  1.12.6.2  yamt 	 * might overwhelm an intermediate gateway).
    469  1.12.6.2  yamt 	 *
    470  1.12.6.2  yamt 	 * There are two phases to the opening: Initially we
    471  1.12.6.2  yamt 	 * open by one mss on each ack.  This makes the window
    472  1.12.6.2  yamt 	 * size increase exponentially with time.  If the
    473  1.12.6.2  yamt 	 * window is larger than the path can handle, this
    474  1.12.6.2  yamt 	 * exponential growth results in dropped packet(s)
    475  1.12.6.2  yamt 	 * almost immediately.  To get more time between
    476  1.12.6.2  yamt 	 * drops but still "push" the network to take advantage
    477  1.12.6.2  yamt 	 * of improving conditions, we switch from exponential
    478  1.12.6.2  yamt 	 * to linear window opening at some threshhold size.
    479  1.12.6.2  yamt 	 * For a threshhold, we use half the current window
    480  1.12.6.2  yamt 	 * size, truncated to a multiple of the mss.
    481  1.12.6.2  yamt 	 *
    482  1.12.6.2  yamt 	 * (the minimum cwnd that will give us exponential
    483  1.12.6.2  yamt 	 * growth is 2 mss.  We don't allow the threshhold
    484  1.12.6.2  yamt 	 * to go below this.)
    485  1.12.6.2  yamt 	 */
    486  1.12.6.2  yamt 
    487  1.12.6.2  yamt 	win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_segsz;
    488  1.12.6.2  yamt 	if (win < 2)
    489  1.12.6.2  yamt 		win = 2;
    490  1.12.6.2  yamt 	/* Loss Window MUST be one segment. */
    491  1.12.6.2  yamt 	tp->snd_cwnd = tp->t_segsz;
    492  1.12.6.2  yamt 	tp->snd_ssthresh = win * tp->t_segsz;
    493  1.12.6.2  yamt 	tp->t_partialacks = -1;
    494  1.12.6.2  yamt 	tp->t_dupacks = 0;
    495  1.12.6.2  yamt 	tp->t_bytes_acked = 0;
    496  1.12.6.2  yamt }
    497  1.12.6.2  yamt 
    498  1.12.6.2  yamt static void
    499  1.12.6.2  yamt tcp_reno_fast_retransmit_newack(struct tcpcb *tp,
    500  1.12.6.2  yamt     const struct tcphdr *th)
    501  1.12.6.2  yamt {
    502  1.12.6.2  yamt 	if (tp->t_partialacks < 0) {
    503  1.12.6.2  yamt 		/*
    504  1.12.6.2  yamt 		 * We were not in fast recovery.  Reset the duplicate ack
    505  1.12.6.2  yamt 		 * counter.
    506  1.12.6.2  yamt 		 */
    507  1.12.6.2  yamt 		tp->t_dupacks = 0;
    508  1.12.6.2  yamt 	} else {
    509  1.12.6.2  yamt 		/*
    510  1.12.6.2  yamt 		 * Clamp the congestion window to the crossover point and
    511  1.12.6.2  yamt 		 * exit fast recovery.
    512  1.12.6.2  yamt 		 */
    513  1.12.6.2  yamt 		if (tp->snd_cwnd > tp->snd_ssthresh)
    514  1.12.6.2  yamt 			tp->snd_cwnd = tp->snd_ssthresh;
    515  1.12.6.2  yamt 		tp->t_partialacks = -1;
    516  1.12.6.2  yamt 		tp->t_dupacks = 0;
    517  1.12.6.2  yamt 		tp->t_bytes_acked = 0;
    518  1.12.6.2  yamt 	}
    519  1.12.6.2  yamt }
    520  1.12.6.2  yamt 
    521  1.12.6.2  yamt static void
    522  1.12.6.2  yamt tcp_reno_newack(struct tcpcb *tp, const struct tcphdr *th)
    523  1.12.6.2  yamt {
    524  1.12.6.2  yamt 	/*
    525  1.12.6.2  yamt 	 * When new data is acked, open the congestion window.
    526  1.12.6.2  yamt 	 */
    527  1.12.6.2  yamt 
    528  1.12.6.2  yamt 	u_int cw = tp->snd_cwnd;
    529  1.12.6.2  yamt 	u_int incr = tp->t_segsz;
    530  1.12.6.2  yamt 
    531  1.12.6.2  yamt 	if (tcp_do_abc) {
    532  1.12.6.2  yamt 
    533  1.12.6.2  yamt 		/*
    534  1.12.6.2  yamt 		 * RFC 3465 Appropriate Byte Counting (ABC)
    535  1.12.6.2  yamt 		 */
    536  1.12.6.2  yamt 
    537  1.12.6.2  yamt 		int acked = th->th_ack - tp->snd_una;
    538  1.12.6.2  yamt 
    539  1.12.6.2  yamt 		if (cw >= tp->snd_ssthresh) {
    540  1.12.6.2  yamt 			tp->t_bytes_acked += acked;
    541  1.12.6.2  yamt 			if (tp->t_bytes_acked >= cw) {
    542  1.12.6.2  yamt 				/* Time to increase the window. */
    543  1.12.6.2  yamt 				tp->t_bytes_acked -= cw;
    544  1.12.6.2  yamt 			} else {
    545  1.12.6.2  yamt 				/* No need to increase yet. */
    546  1.12.6.2  yamt 				incr = 0;
    547  1.12.6.2  yamt 			}
    548  1.12.6.2  yamt 		} else {
    549  1.12.6.2  yamt 			/*
    550  1.12.6.2  yamt 			 * use 2*SMSS or 1*SMSS for the "L" param,
    551  1.12.6.2  yamt 			 * depending on sysctl setting.
    552  1.12.6.2  yamt 			 *
    553  1.12.6.2  yamt 			 * (See RFC 3465 2.3 Choosing the Limit)
    554  1.12.6.2  yamt 			 */
    555  1.12.6.2  yamt 			u_int abc_lim;
    556  1.12.6.2  yamt 
    557  1.12.6.2  yamt 			abc_lim = (tcp_abc_aggressive == 0 ||
    558  1.12.6.2  yamt 			    tp->snd_nxt != tp->snd_max) ? incr : incr * 2;
    559  1.12.6.2  yamt 			incr = min(acked, abc_lim);
    560  1.12.6.2  yamt 		}
    561  1.12.6.2  yamt 	} else {
    562  1.12.6.2  yamt 
    563  1.12.6.2  yamt 		/*
    564  1.12.6.2  yamt 		 * If the window gives us less than ssthresh packets
    565  1.12.6.2  yamt 		 * in flight, open exponentially (segsz per packet).
    566  1.12.6.2  yamt 		 * Otherwise open linearly: segsz per window
    567  1.12.6.2  yamt 		 * (segsz^2 / cwnd per packet).
    568  1.12.6.2  yamt 		 */
    569  1.12.6.2  yamt 
    570  1.12.6.2  yamt 		if (cw >= tp->snd_ssthresh) {
    571  1.12.6.2  yamt 			incr = incr * incr / cw;
    572  1.12.6.2  yamt 		}
    573  1.12.6.2  yamt 	}
    574  1.12.6.2  yamt 
    575  1.12.6.2  yamt 	tp->snd_cwnd = min(cw + incr, TCP_MAXWIN << tp->snd_scale);
    576  1.12.6.2  yamt }
    577  1.12.6.2  yamt 
    578  1.12.6.2  yamt struct tcp_congctl tcp_reno_ctl = {
    579  1.12.6.2  yamt 	.fast_retransmit = tcp_reno_fast_retransmit,
    580  1.12.6.2  yamt 	.slow_retransmit = tcp_reno_slow_retransmit,
    581  1.12.6.2  yamt 	.fast_retransmit_newack = tcp_reno_fast_retransmit_newack,
    582  1.12.6.2  yamt 	.newack = tcp_reno_newack,
    583  1.12.6.2  yamt 	.cong_exp = tcp_reno_congestion_exp,
    584  1.12.6.2  yamt };
    585  1.12.6.2  yamt 
    586  1.12.6.2  yamt /*
    587  1.12.6.2  yamt  * TCP/NewReno Congestion control.
    588  1.12.6.2  yamt  */
    589  1.12.6.2  yamt static int
    590  1.12.6.2  yamt tcp_newreno_fast_retransmit(struct tcpcb *tp, const struct tcphdr *th)
    591  1.12.6.2  yamt {
    592  1.12.6.2  yamt 	if (SEQ_LT(th->th_ack, tp->snd_high)) {
    593  1.12.6.2  yamt 		/*
    594  1.12.6.2  yamt 		 * False fast retransmit after timeout.
    595  1.12.6.2  yamt 		 * Do not enter fast recovery
    596  1.12.6.2  yamt 		 */
    597  1.12.6.2  yamt 		tp->t_dupacks = 0;
    598  1.12.6.2  yamt 		return 1;
    599  1.12.6.2  yamt 	} else {
    600  1.12.6.2  yamt 		/*
    601  1.12.6.2  yamt 		 * Fast retransmit is same as reno.
    602  1.12.6.2  yamt 		 */
    603  1.12.6.2  yamt 		return tcp_reno_fast_retransmit(tp, th);
    604  1.12.6.2  yamt 	}
    605  1.12.6.2  yamt 
    606  1.12.6.2  yamt 	return 0;
    607  1.12.6.2  yamt }
    608  1.12.6.2  yamt 
    609  1.12.6.2  yamt /*
    610  1.12.6.2  yamt  * Implement the NewReno response to a new ack, checking for partial acks in
    611  1.12.6.2  yamt  * fast recovery.
    612  1.12.6.2  yamt  */
    613  1.12.6.2  yamt static void
    614  1.12.6.2  yamt tcp_newreno_fast_retransmit_newack(struct tcpcb *tp, const struct tcphdr *th)
    615  1.12.6.2  yamt {
    616  1.12.6.2  yamt 	if (tp->t_partialacks < 0) {
    617  1.12.6.2  yamt 		/*
    618  1.12.6.2  yamt 		 * We were not in fast recovery.  Reset the duplicate ack
    619  1.12.6.2  yamt 		 * counter.
    620  1.12.6.2  yamt 		 */
    621  1.12.6.2  yamt 		tp->t_dupacks = 0;
    622  1.12.6.2  yamt 	} else if (SEQ_LT(th->th_ack, tp->snd_recover)) {
    623  1.12.6.2  yamt 		/*
    624  1.12.6.2  yamt 		 * This is a partial ack.  Retransmit the first unacknowledged
    625  1.12.6.2  yamt 		 * segment and deflate the congestion window by the amount of
    626  1.12.6.2  yamt 		 * acknowledged data.  Do not exit fast recovery.
    627  1.12.6.2  yamt 		 */
    628  1.12.6.2  yamt 		tcp_seq onxt = tp->snd_nxt;
    629  1.12.6.2  yamt 		u_long ocwnd = tp->snd_cwnd;
    630  1.12.6.2  yamt 
    631  1.12.6.2  yamt 		/*
    632  1.12.6.2  yamt 		 * snd_una has not yet been updated and the socket's send
    633  1.12.6.2  yamt 		 * buffer has not yet drained off the ACK'd data, so we
    634  1.12.6.2  yamt 		 * have to leave snd_una as it was to get the correct data
    635  1.12.6.2  yamt 		 * offset in tcp_output().
    636  1.12.6.2  yamt 		 */
    637  1.12.6.2  yamt 		if (++tp->t_partialacks == 1)
    638  1.12.6.2  yamt 			TCP_TIMER_DISARM(tp, TCPT_REXMT);
    639  1.12.6.2  yamt 		tp->t_rtttime = 0;
    640  1.12.6.2  yamt 		tp->snd_nxt = th->th_ack;
    641  1.12.6.2  yamt 		/*
    642  1.12.6.2  yamt 		 * Set snd_cwnd to one segment beyond ACK'd offset.  snd_una
    643  1.12.6.2  yamt 		 * is not yet updated when we're called.
    644  1.12.6.2  yamt 		 */
    645  1.12.6.2  yamt 		tp->snd_cwnd = tp->t_segsz + (th->th_ack - tp->snd_una);
    646  1.12.6.2  yamt 		(void) tcp_output(tp);
    647  1.12.6.2  yamt 		tp->snd_cwnd = ocwnd;
    648  1.12.6.2  yamt 		if (SEQ_GT(onxt, tp->snd_nxt))
    649  1.12.6.2  yamt 			tp->snd_nxt = onxt;
    650  1.12.6.2  yamt 		/*
    651  1.12.6.2  yamt 		 * Partial window deflation.  Relies on fact that tp->snd_una
    652  1.12.6.2  yamt 		 * not updated yet.
    653  1.12.6.2  yamt 		 */
    654  1.12.6.2  yamt 		tp->snd_cwnd -= (th->th_ack - tp->snd_una - tp->t_segsz);
    655  1.12.6.2  yamt 	} else {
    656  1.12.6.2  yamt 		/*
    657  1.12.6.2  yamt 		 * Complete ack.  Inflate the congestion window to ssthresh
    658  1.12.6.2  yamt 		 * and exit fast recovery.
    659  1.12.6.2  yamt 		 *
    660  1.12.6.2  yamt 		 * Window inflation should have left us with approx.
    661  1.12.6.2  yamt 		 * snd_ssthresh outstanding data.  But in case we
    662  1.12.6.2  yamt 		 * would be inclined to send a burst, better to do
    663  1.12.6.2  yamt 		 * it via the slow start mechanism.
    664  1.12.6.2  yamt 		 */
    665  1.12.6.2  yamt 		if (SEQ_SUB(tp->snd_max, th->th_ack) < tp->snd_ssthresh)
    666  1.12.6.2  yamt 			tp->snd_cwnd = SEQ_SUB(tp->snd_max, th->th_ack)
    667  1.12.6.2  yamt 			    + tp->t_segsz;
    668  1.12.6.2  yamt 		else
    669  1.12.6.2  yamt 			tp->snd_cwnd = tp->snd_ssthresh;
    670  1.12.6.2  yamt 		tp->t_partialacks = -1;
    671  1.12.6.2  yamt 		tp->t_dupacks = 0;
    672  1.12.6.2  yamt 		tp->t_bytes_acked = 0;
    673  1.12.6.2  yamt 	}
    674  1.12.6.2  yamt }
    675  1.12.6.2  yamt 
    676  1.12.6.2  yamt static void
    677  1.12.6.2  yamt tcp_newreno_newack(struct tcpcb *tp, const struct tcphdr *th)
    678  1.12.6.2  yamt {
    679  1.12.6.2  yamt 	/*
    680  1.12.6.2  yamt 	 * If we are still in fast recovery (meaning we are using
    681  1.12.6.2  yamt 	 * NewReno and we have only received partial acks), do not
    682  1.12.6.2  yamt 	 * inflate the window yet.
    683  1.12.6.2  yamt 	 */
    684  1.12.6.2  yamt 	if (tp->t_partialacks < 0)
    685  1.12.6.2  yamt 		tcp_reno_newack(tp, th);
    686  1.12.6.2  yamt }
    687  1.12.6.2  yamt 
    688  1.12.6.2  yamt 
    689  1.12.6.2  yamt struct tcp_congctl tcp_newreno_ctl = {
    690  1.12.6.2  yamt 	.fast_retransmit = tcp_newreno_fast_retransmit,
    691  1.12.6.2  yamt 	.slow_retransmit = tcp_reno_slow_retransmit,
    692  1.12.6.2  yamt 	.fast_retransmit_newack = tcp_newreno_fast_retransmit_newack,
    693  1.12.6.2  yamt 	.newack = tcp_newreno_newack,
    694  1.12.6.2  yamt 	.cong_exp = tcp_reno_congestion_exp,
    695  1.12.6.2  yamt };
    696  1.12.6.2  yamt 
    697  1.12.6.2  yamt 
    698