2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2004-06-23 21:04:37 +00:00
|
|
|
* Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
|
2007-05-11 11:21:43 +00:00
|
|
|
* The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-06-23 21:04:37 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-11-20 19:43:44 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
2004-06-23 21:04:37 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)tcp_sack.c 8.12 (Berkeley) 5/24/95
|
|
|
|
*/
|
|
|
|
|
2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
2004-06-23 21:04:37 +00:00
|
|
|
* @@(#)COPYRIGHT 1.1 (NRL) 17 January 1995
|
|
|
|
*
|
|
|
|
* NRL grants permission for redistribution and use in source and binary
|
|
|
|
* forms, with or without modification, of the software and documentation
|
|
|
|
* created at NRL provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgements:
|
2004-08-16 18:32:07 +00:00
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* This product includes software developed at the Information
|
|
|
|
* Technology Division, US Naval Research Laboratory.
|
2004-06-23 21:04:37 +00:00
|
|
|
* 4. Neither the name of the NRL nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE PROVIDED BY NRL IS PROVIDED BY NRL AND CONTRIBUTORS ``AS
|
|
|
|
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NRL OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* The views and conclusions contained in the software and documentation
|
|
|
|
* are those of the authors and should not be interpreted as representing
|
|
|
|
* official policies, either expressed or implied, of the US Naval
|
|
|
|
* Research Laboratory (NRL).
|
|
|
|
*/
|
2007-05-11 11:21:43 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2004-06-23 21:04:37 +00:00
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "opt_inet6.h"
|
|
|
|
#include "opt_tcpdebug.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/proc.h> /* for proc0 declaration */
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
|
|
|
|
|
|
|
|
#include <vm/uma.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
2013-10-26 17:58:36 +00:00
|
|
|
#include <net/if_var.h>
|
2004-06-23 21:04:37 +00:00
|
|
|
#include <net/route.h>
|
2009-08-01 19:26:27 +00:00
|
|
|
#include <net/vnet.h>
|
2004-06-23 21:04:37 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/in_pcb.h>
|
|
|
|
#include <netinet/ip_var.h>
|
|
|
|
#include <netinet/ip6.h>
|
|
|
|
#include <netinet/icmp6.h>
|
|
|
|
#include <netinet6/nd6.h>
|
|
|
|
#include <netinet6/ip6_var.h>
|
|
|
|
#include <netinet6/in6_pcb.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <netinet/tcp_fsm.h>
|
|
|
|
#include <netinet/tcp_seq.h>
|
|
|
|
#include <netinet/tcp_timer.h>
|
|
|
|
#include <netinet/tcp_var.h>
|
|
|
|
#include <netinet6/tcp6_var.h>
|
|
|
|
#include <netinet/tcpip.h>
|
|
|
|
#ifdef TCPDEBUG
|
|
|
|
#include <netinet/tcp_debug.h>
|
|
|
|
#endif /* TCPDEBUG */
|
|
|
|
|
|
|
|
#include <machine/in_cksum.h>
|
|
|
|
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
VNET_DECLARE(struct uma_zone *, sack_hole_zone);
|
2009-07-16 21:13:04 +00:00
|
|
|
#define V_sack_hole_zone VNET(sack_hole_zone)
|
2008-11-19 09:39:34 +00:00
|
|
|
|
2004-10-05 18:36:24 +00:00
|
|
|
SYSCTL_NODE(_net_inet_tcp, OID_AUTO, sack, CTLFLAG_RW, 0, "TCP SACK");
|
2010-04-29 11:52:42 +00:00
|
|
|
VNET_DEFINE(int, tcp_do_sack) = 1;
|
|
|
|
#define V_tcp_do_sack VNET(tcp_do_sack)
|
2014-11-07 09:39:05 +00:00
|
|
|
SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, enable, CTLFLAG_VNET | CTLFLAG_RW,
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
&VNET_NAME(tcp_do_sack), 0, "Enable/Disable TCP SACK support");
|
2004-10-05 18:36:24 +00:00
|
|
|
|
2010-04-29 11:52:42 +00:00
|
|
|
VNET_DEFINE(int, tcp_sack_maxholes) = 128;
|
2014-11-07 09:39:05 +00:00
|
|
|
SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, maxholes, CTLFLAG_VNET | CTLFLAG_RW,
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
&VNET_NAME(tcp_sack_maxholes), 0,
|
2005-03-09 23:14:10 +00:00
|
|
|
"Maximum number of TCP SACK holes allowed per connection");
|
|
|
|
|
2010-04-29 11:52:42 +00:00
|
|
|
VNET_DEFINE(int, tcp_sack_globalmaxholes) = 65536;
|
2014-11-07 09:39:05 +00:00
|
|
|
SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, globalmaxholes, CTLFLAG_VNET | CTLFLAG_RW,
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
&VNET_NAME(tcp_sack_globalmaxholes), 0,
|
2005-03-09 23:14:10 +00:00
|
|
|
"Global maximum number of TCP SACK holes");
|
|
|
|
|
2010-04-29 11:52:42 +00:00
|
|
|
VNET_DEFINE(int, tcp_sack_globalholes) = 0;
|
2014-11-07 09:39:05 +00:00
|
|
|
SYSCTL_INT(_net_inet_tcp_sack, OID_AUTO, globalholes, CTLFLAG_VNET | CTLFLAG_RD,
|
Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.
Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.
Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.
This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.
Bump __FreeBSD_version and update UPDATING.
Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)
2009-07-14 22:48:30 +00:00
|
|
|
&VNET_NAME(tcp_sack_globalholes), 0,
|
2005-03-09 23:14:10 +00:00
|
|
|
"Global number of TCP SACK holes currently allocated");
|
2005-04-18 18:10:56 +00:00
|
|
|
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* This function is called upon receipt of new valid data (while not in
|
|
|
|
* header prediction mode), and it updates the ordered list of sacks.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
|
|
|
void
|
2005-04-18 18:10:56 +00:00
|
|
|
tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_start, tcp_seq rcv_end)
|
2004-06-23 21:04:37 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* First reported block MUST be the most recent one. Subsequent
|
|
|
|
* blocks SHOULD be in the order in which they arrived at the
|
|
|
|
* receiver. These two conditions make the implementation fully
|
|
|
|
* compliant with RFC 2018.
|
|
|
|
*/
|
2005-04-18 18:10:56 +00:00
|
|
|
struct sackblk head_blk, saved_blks[MAX_SACK_BLKS];
|
|
|
|
int num_head, num_saved, i;
|
2004-06-23 21:04:37 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2005-04-18 18:10:56 +00:00
|
|
|
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Check arguments. */
|
2005-04-18 18:10:56 +00:00
|
|
|
KASSERT(SEQ_LT(rcv_start, rcv_end), ("rcv_start < rcv_end"));
|
|
|
|
|
|
|
|
/* SACK block for the received segment. */
|
|
|
|
head_blk.start = rcv_start;
|
|
|
|
head_blk.end = rcv_end;
|
|
|
|
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Merge updated SACK blocks into head_blk, and save unchanged SACK
|
|
|
|
* blocks into saved_blks[]. num_saved will have the number of the
|
|
|
|
* saved SACK blocks.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
2005-04-18 18:10:56 +00:00
|
|
|
num_saved = 0;
|
2004-06-23 21:04:37 +00:00
|
|
|
for (i = 0; i < tp->rcv_numsacks; i++) {
|
2005-04-18 18:10:56 +00:00
|
|
|
tcp_seq start = tp->sackblks[i].start;
|
|
|
|
tcp_seq end = tp->sackblks[i].end;
|
|
|
|
if (SEQ_GEQ(start, end) || SEQ_LEQ(start, tp->rcv_nxt)) {
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
2005-04-18 18:10:56 +00:00
|
|
|
* Discard this SACK block.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
2005-04-18 18:10:56 +00:00
|
|
|
} else if (SEQ_LEQ(head_blk.start, end) &&
|
|
|
|
SEQ_GEQ(head_blk.end, start)) {
|
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Merge this SACK block into head_blk. This SACK
|
|
|
|
* block itself will be discarded.
|
2005-04-18 18:10:56 +00:00
|
|
|
*/
|
|
|
|
if (SEQ_GT(head_blk.start, start))
|
|
|
|
head_blk.start = start;
|
|
|
|
if (SEQ_LT(head_blk.end, end))
|
|
|
|
head_blk.end = end;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Save this SACK block.
|
|
|
|
*/
|
|
|
|
saved_blks[num_saved].start = start;
|
|
|
|
saved_blks[num_saved].end = end;
|
|
|
|
num_saved++;
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-18 18:10:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update SACK list in tp->sackblks[].
|
|
|
|
*/
|
|
|
|
num_head = 0;
|
|
|
|
if (SEQ_GT(head_blk.start, tp->rcv_nxt)) {
|
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* The received data segment is an out-of-order segment. Put
|
|
|
|
* head_blk at the top of SACK list.
|
2005-04-18 18:10:56 +00:00
|
|
|
*/
|
|
|
|
tp->sackblks[0] = head_blk;
|
|
|
|
num_head = 1;
|
|
|
|
/*
|
|
|
|
* If the number of saved SACK blocks exceeds its limit,
|
|
|
|
* discard the last SACK block.
|
|
|
|
*/
|
|
|
|
if (num_saved >= MAX_SACK_BLKS)
|
|
|
|
num_saved--;
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
2005-04-18 18:10:56 +00:00
|
|
|
if (num_saved > 0) {
|
|
|
|
/*
|
|
|
|
* Copy the saved SACK blocks back.
|
|
|
|
*/
|
|
|
|
bcopy(saved_blks, &tp->sackblks[num_head],
|
|
|
|
sizeof(struct sackblk) * num_saved);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the number of SACK blocks. */
|
|
|
|
tp->rcv_numsacks = num_head + num_saved;
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Delete all receiver-side SACK information.
|
|
|
|
*/
|
|
|
|
void
|
2007-05-10 15:58:48 +00:00
|
|
|
tcp_clean_sackreport(struct tcpcb *tp)
|
2004-06-23 21:04:37 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2004-06-23 21:04:37 +00:00
|
|
|
tp->rcv_numsacks = 0;
|
|
|
|
for (i = 0; i < MAX_SACK_BLKS; i++)
|
|
|
|
tp->sackblks[i].start = tp->sackblks[i].end=0;
|
|
|
|
}
|
|
|
|
|
2005-05-16 19:26:46 +00:00
|
|
|
/*
|
|
|
|
* Allocate struct sackhole.
|
|
|
|
*/
|
|
|
|
static struct sackhole *
|
|
|
|
tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end)
|
|
|
|
{
|
|
|
|
struct sackhole *hole;
|
|
|
|
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
if (tp->snd_numholes >= V_tcp_sack_maxholes ||
|
|
|
|
V_tcp_sack_globalholes >= V_tcp_sack_globalmaxholes) {
|
2009-04-11 22:07:19 +00:00
|
|
|
TCPSTAT_INC(tcps_sack_sboverflow);
|
2005-05-16 19:26:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
First pass at separating per-vnet initializer functions
from existing functions for initializing global state.
At this stage, the new per-vnet initializer functions are
directly called from the existing global initialization code,
which should in most cases result in compiler inlining those
new functions, hence yielding a near-zero functional change.
Modify the existing initializer functions which are invoked via
protosw, like ip_init() et. al., to allow them to be invoked
multiple times, i.e. per each vnet. Global state, if any,
is initialized only if such functions are called within the
context of vnet0, which will be determined via the
IS_DEFAULT_VNET(curvnet) check (currently always true).
While here, V_irtualize a few remaining global UMA zones
used by net/netinet/netipsec networking code. While it is
not yet clear to me or anybody else whether this is the right
thing to do, at this stage this makes the code more readable,
and makes it easier to track uncollected UMA-zone-backed
objects on vnet removal. In the long run, it's quite possible
that some form of shared use of UMA zone pools among multiple
vnets should be considered.
Bump __FreeBSD_version due to changes in layout of structs
vnet_ipfw, vnet_inet and vnet_net.
Approved by: julian (mentor)
2009-04-06 22:29:41 +00:00
|
|
|
hole = (struct sackhole *)uma_zalloc(V_sack_hole_zone, M_NOWAIT);
|
2005-05-16 19:26:46 +00:00
|
|
|
if (hole == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hole->start = start;
|
|
|
|
hole->end = end;
|
|
|
|
hole->rxmit = start;
|
|
|
|
|
|
|
|
tp->snd_numholes++;
|
2009-07-13 11:59:38 +00:00
|
|
|
atomic_add_int(&V_tcp_sack_globalholes, 1);
|
2005-05-16 19:26:46 +00:00
|
|
|
|
|
|
|
return hole;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free struct sackhole.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tcp_sackhole_free(struct tcpcb *tp, struct sackhole *hole)
|
|
|
|
{
|
2007-05-11 11:21:43 +00:00
|
|
|
|
First pass at separating per-vnet initializer functions
from existing functions for initializing global state.
At this stage, the new per-vnet initializer functions are
directly called from the existing global initialization code,
which should in most cases result in compiler inlining those
new functions, hence yielding a near-zero functional change.
Modify the existing initializer functions which are invoked via
protosw, like ip_init() et. al., to allow them to be invoked
multiple times, i.e. per each vnet. Global state, if any,
is initialized only if such functions are called within the
context of vnet0, which will be determined via the
IS_DEFAULT_VNET(curvnet) check (currently always true).
While here, V_irtualize a few remaining global UMA zones
used by net/netinet/netipsec networking code. While it is
not yet clear to me or anybody else whether this is the right
thing to do, at this stage this makes the code more readable,
and makes it easier to track uncollected UMA-zone-backed
objects on vnet removal. In the long run, it's quite possible
that some form of shared use of UMA zone pools among multiple
vnets should be considered.
Bump __FreeBSD_version due to changes in layout of structs
vnet_ipfw, vnet_inet and vnet_net.
Approved by: julian (mentor)
2009-04-06 22:29:41 +00:00
|
|
|
uma_zfree(V_sack_hole_zone, hole);
|
2005-05-16 19:26:46 +00:00
|
|
|
|
|
|
|
tp->snd_numholes--;
|
2009-07-13 11:59:38 +00:00
|
|
|
atomic_subtract_int(&V_tcp_sack_globalholes, 1);
|
2005-05-16 19:26:46 +00:00
|
|
|
|
|
|
|
KASSERT(tp->snd_numholes >= 0, ("tp->snd_numholes >= 0"));
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
KASSERT(V_tcp_sack_globalholes >= 0, ("tcp_sack_globalholes >= 0"));
|
2005-05-16 19:26:46 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 08:03:28 +00:00
|
|
|
/*
|
|
|
|
* Insert new SACK hole into scoreboard.
|
|
|
|
*/
|
|
|
|
static struct sackhole *
|
|
|
|
tcp_sackhole_insert(struct tcpcb *tp, tcp_seq start, tcp_seq end,
|
2007-03-21 19:37:55 +00:00
|
|
|
struct sackhole *after)
|
2005-06-04 08:03:28 +00:00
|
|
|
{
|
|
|
|
struct sackhole *hole;
|
|
|
|
|
|
|
|
/* Allocate a new SACK hole. */
|
|
|
|
hole = tcp_sackhole_alloc(tp, start, end);
|
|
|
|
if (hole == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Insert the new SACK hole into scoreboard. */
|
2005-06-04 08:03:28 +00:00
|
|
|
if (after != NULL)
|
|
|
|
TAILQ_INSERT_AFTER(&tp->snd_holes, after, hole, scblink);
|
|
|
|
else
|
|
|
|
TAILQ_INSERT_TAIL(&tp->snd_holes, hole, scblink);
|
|
|
|
|
|
|
|
/* Update SACK hint. */
|
|
|
|
if (tp->sackhint.nexthole == NULL)
|
|
|
|
tp->sackhint.nexthole = hole;
|
|
|
|
|
|
|
|
return hole;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove SACK hole from scoreboard.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
tcp_sackhole_remove(struct tcpcb *tp, struct sackhole *hole)
|
|
|
|
{
|
2007-05-11 11:21:43 +00:00
|
|
|
|
2005-06-04 08:03:28 +00:00
|
|
|
/* Update SACK hint. */
|
|
|
|
if (tp->sackhint.nexthole == hole)
|
|
|
|
tp->sackhint.nexthole = TAILQ_NEXT(hole, scblink);
|
|
|
|
|
|
|
|
/* Remove this SACK hole. */
|
|
|
|
TAILQ_REMOVE(&tp->snd_holes, hole, scblink);
|
|
|
|
|
|
|
|
/* Free this SACK hole. */
|
|
|
|
tcp_sackhole_free(tp, hole);
|
|
|
|
}
|
|
|
|
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
2005-06-27 22:27:42 +00:00
|
|
|
* Process cumulative ACK and the TCP SACK option to update the scoreboard.
|
|
|
|
* tp->snd_holes is an ordered list of holes (oldest to newest, in terms of
|
|
|
|
* the sequence space).
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
* Returns 1 if incoming ACK has previously unknown SACK information,
|
|
|
|
* 0 otherwise. Note: We treat (snd_una, th_ack) as a sack block so any changes
|
|
|
|
* to that (i.e. left edge moving) would also be considered a change in SACK
|
|
|
|
* information which is slightly different than rfc6675.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
int
|
2005-06-27 22:27:42 +00:00
|
|
|
tcp_sack_doack(struct tcpcb *tp, struct tcpopt *to, tcp_seq th_ack)
|
2004-06-23 21:04:37 +00:00
|
|
|
{
|
2005-04-21 20:11:01 +00:00
|
|
|
struct sackhole *cur, *temp;
|
2005-06-27 22:27:42 +00:00
|
|
|
struct sackblk sack, sack_blocks[TCP_MAX_SACK + 1], *sblkp;
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
int i, j, num_sack_blks, sack_changed;
|
2004-06-23 21:04:37 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2005-06-27 22:27:42 +00:00
|
|
|
|
|
|
|
num_sack_blks = 0;
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
sack_changed = 0;
|
2005-05-23 19:22:48 +00:00
|
|
|
/*
|
2005-06-27 22:27:42 +00:00
|
|
|
* If SND.UNA will be advanced by SEG.ACK, and if SACK holes exist,
|
|
|
|
* treat [SND.UNA, SEG.ACK) as if it is a SACK block.
|
2005-05-23 19:22:48 +00:00
|
|
|
*/
|
2005-06-27 22:27:42 +00:00
|
|
|
if (SEQ_LT(tp->snd_una, th_ack) && !TAILQ_EMPTY(&tp->snd_holes)) {
|
|
|
|
sack_blocks[num_sack_blks].start = tp->snd_una;
|
|
|
|
sack_blocks[num_sack_blks++].end = th_ack;
|
|
|
|
}
|
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Append received valid SACK blocks to sack_blocks[], but only if we
|
|
|
|
* received new blocks from the other side.
|
2005-06-27 22:27:42 +00:00
|
|
|
*/
|
2007-03-25 23:27:26 +00:00
|
|
|
if (to->to_flags & TOF_SACK) {
|
2015-10-28 22:57:51 +00:00
|
|
|
tp->sackhint.sacked_bytes = 0; /* reset */
|
2007-03-25 23:27:26 +00:00
|
|
|
for (i = 0; i < to->to_nsacks; i++) {
|
|
|
|
bcopy((to->to_sacks + i * TCPOLEN_SACK),
|
|
|
|
&sack, sizeof(sack));
|
|
|
|
sack.start = ntohl(sack.start);
|
|
|
|
sack.end = ntohl(sack.end);
|
|
|
|
if (SEQ_GT(sack.end, sack.start) &&
|
|
|
|
SEQ_GT(sack.start, tp->snd_una) &&
|
|
|
|
SEQ_GT(sack.start, th_ack) &&
|
|
|
|
SEQ_LT(sack.start, tp->snd_max) &&
|
|
|
|
SEQ_GT(sack.end, tp->snd_una) &&
|
2015-10-28 22:57:51 +00:00
|
|
|
SEQ_LEQ(sack.end, tp->snd_max)) {
|
2007-03-25 23:27:26 +00:00
|
|
|
sack_blocks[num_sack_blks++] = sack;
|
2015-10-28 22:57:51 +00:00
|
|
|
tp->sackhint.sacked_bytes +=
|
|
|
|
(sack.end-sack.start);
|
|
|
|
}
|
2007-03-25 23:27:26 +00:00
|
|
|
}
|
2005-05-23 19:22:48 +00:00
|
|
|
}
|
2005-06-27 22:27:42 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Return if SND.UNA is not advanced and no valid SACK block is
|
|
|
|
* received.
|
2005-06-27 22:27:42 +00:00
|
|
|
*/
|
2005-05-23 19:22:48 +00:00
|
|
|
if (num_sack_blks == 0)
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
return (sack_changed);
|
2005-06-27 22:27:42 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Sort the SACK blocks so we can update the scoreboard with just one
|
2016-05-03 18:05:43 +00:00
|
|
|
* pass. The overhead of sorting up to 4+1 elements is less than
|
|
|
|
* making up to 4+1 passes over the scoreboard.
|
2005-06-27 22:27:42 +00:00
|
|
|
*/
|
2005-05-23 19:22:48 +00:00
|
|
|
for (i = 0; i < num_sack_blks; i++) {
|
|
|
|
for (j = i + 1; j < num_sack_blks; j++) {
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_GT(sack_blocks[i].end, sack_blocks[j].end)) {
|
2005-05-23 19:22:48 +00:00
|
|
|
sack = sack_blocks[i];
|
|
|
|
sack_blocks[i] = sack_blocks[j];
|
|
|
|
sack_blocks[j] = sack;
|
|
|
|
}
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
2005-05-23 19:22:48 +00:00
|
|
|
}
|
|
|
|
if (TAILQ_EMPTY(&tp->snd_holes))
|
|
|
|
/*
|
2005-05-25 17:55:27 +00:00
|
|
|
* Empty scoreboard. Need to initialize snd_fack (it may be
|
2005-05-23 19:22:48 +00:00
|
|
|
* uninitialized or have a bogus value). Scoreboard holes
|
2007-05-11 11:21:43 +00:00
|
|
|
* (from the sack blocks received) are created later below
|
|
|
|
* (in the logic that adds holes to the tail of the
|
|
|
|
* scoreboard).
|
2005-05-23 19:22:48 +00:00
|
|
|
*/
|
2005-06-27 22:27:42 +00:00
|
|
|
tp->snd_fack = SEQ_MAX(tp->snd_una, th_ack);
|
2005-06-04 08:03:28 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* In the while-loop below, incoming SACK blocks (sack_blocks[]) and
|
|
|
|
* SACK holes (snd_holes) are traversed from their tails with just
|
|
|
|
* one pass in order to reduce the number of compares especially when
|
|
|
|
* the bandwidth-delay product is large.
|
|
|
|
*
|
2005-06-04 08:03:28 +00:00
|
|
|
* Note: Typically, in the first RTT of SACK recovery, the highest
|
|
|
|
* three or four SACK blocks with the same ack number are received.
|
|
|
|
* In the second RTT, if retransmitted data segments are not lost,
|
|
|
|
* the highest three or four SACK blocks with ack number advancing
|
|
|
|
* are received.
|
|
|
|
*/
|
|
|
|
sblkp = &sack_blocks[num_sack_blks - 1]; /* Last SACK block */
|
2010-12-28 03:27:20 +00:00
|
|
|
tp->sackhint.last_sack_ack = sblkp->end;
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_LT(tp->snd_fack, sblkp->start)) {
|
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* The highest SACK block is beyond fack. Append new SACK
|
|
|
|
* hole at the tail. If the second or later highest SACK
|
|
|
|
* blocks are also beyond the current fack, they will be
|
|
|
|
* inserted by way of hole splitting in the while-loop below.
|
2005-06-04 08:03:28 +00:00
|
|
|
*/
|
2005-06-09 14:01:04 +00:00
|
|
|
temp = tcp_sackhole_insert(tp, tp->snd_fack,sblkp->start,NULL);
|
2005-11-21 19:22:10 +00:00
|
|
|
if (temp != NULL) {
|
|
|
|
tp->snd_fack = sblkp->end;
|
|
|
|
/* Go to the previous sack block. */
|
|
|
|
sblkp--;
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
sack_changed = 1;
|
2005-11-21 19:22:10 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We failed to add a new hole based on the current
|
|
|
|
* sack block. Skip over all the sack blocks that
|
2007-05-11 11:21:43 +00:00
|
|
|
* fall completely to the right of snd_fack and
|
|
|
|
* proceed to trim the scoreboard based on the
|
|
|
|
* remaining sack blocks. This also trims the
|
|
|
|
* scoreboard for th_ack (which is sack_blocks[0]).
|
2005-11-21 19:22:10 +00:00
|
|
|
*/
|
|
|
|
while (sblkp >= sack_blocks &&
|
|
|
|
SEQ_LT(tp->snd_fack, sblkp->start))
|
|
|
|
sblkp--;
|
|
|
|
if (sblkp >= sack_blocks &&
|
|
|
|
SEQ_LT(tp->snd_fack, sblkp->end))
|
|
|
|
tp->snd_fack = sblkp->end;
|
|
|
|
}
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
} else if (SEQ_LT(tp->snd_fack, sblkp->end)) {
|
2005-06-04 08:03:28 +00:00
|
|
|
/* fack is advanced. */
|
|
|
|
tp->snd_fack = sblkp->end;
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
sack_changed = 1;
|
|
|
|
}
|
2007-05-11 11:21:43 +00:00
|
|
|
cur = TAILQ_LAST(&tp->snd_holes, sackhole_head); /* Last SACK hole. */
|
2005-05-23 19:22:48 +00:00
|
|
|
/*
|
|
|
|
* Since the incoming sack blocks are sorted, we can process them
|
|
|
|
* making one sweep of the scoreboard.
|
|
|
|
*/
|
2005-11-21 19:22:10 +00:00
|
|
|
while (sblkp >= sack_blocks && cur != NULL) {
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_GEQ(sblkp->start, cur->end)) {
|
2005-05-23 19:22:48 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* SACKs data beyond the current hole. Go to the
|
|
|
|
* previous sack block.
|
2005-05-23 19:22:48 +00:00
|
|
|
*/
|
2005-06-04 08:03:28 +00:00
|
|
|
sblkp--;
|
2004-06-23 21:04:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_LEQ(sblkp->end, cur->start)) {
|
2005-05-23 19:22:48 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* SACKs data before the current hole. Go to the
|
|
|
|
* previous hole.
|
2005-05-23 19:22:48 +00:00
|
|
|
*/
|
2005-06-04 08:03:28 +00:00
|
|
|
cur = TAILQ_PREV(cur, sackhole_head, scblink);
|
2005-05-23 19:22:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
tp->sackhint.sack_bytes_rexmit -= (cur->rxmit - cur->start);
|
|
|
|
KASSERT(tp->sackhint.sack_bytes_rexmit >= 0,
|
2007-05-11 11:21:43 +00:00
|
|
|
("sackhint bytes rtx >= 0"));
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
sack_changed = 1;
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_LEQ(sblkp->start, cur->start)) {
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Data acks at least the beginning of hole. */
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_GEQ(sblkp->end, cur->end)) {
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Acks entire hole, so delete hole. */
|
2005-05-23 19:22:48 +00:00
|
|
|
temp = cur;
|
2005-06-04 08:03:28 +00:00
|
|
|
cur = TAILQ_PREV(cur, sackhole_head, scblink);
|
|
|
|
tcp_sackhole_remove(tp, temp);
|
2005-05-23 19:22:48 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* The sack block may ack all or part of the
|
|
|
|
* next hole too, so continue onto the next
|
|
|
|
* hole.
|
2005-05-23 19:22:48 +00:00
|
|
|
*/
|
2004-06-23 21:04:37 +00:00
|
|
|
continue;
|
2005-05-23 19:22:48 +00:00
|
|
|
} else {
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Move start of hole forward. */
|
2005-06-04 08:03:28 +00:00
|
|
|
cur->start = sblkp->end;
|
2005-05-23 19:22:48 +00:00
|
|
|
cur->rxmit = SEQ_MAX(cur->rxmit, cur->start);
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
2005-05-23 19:22:48 +00:00
|
|
|
} else {
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Data acks at least the end of hole. */
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_GEQ(sblkp->end, cur->end)) {
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Move end of hole backward. */
|
2005-06-04 08:03:28 +00:00
|
|
|
cur->end = sblkp->start;
|
2004-06-23 21:04:37 +00:00
|
|
|
cur->rxmit = SEQ_MIN(cur->rxmit, cur->end);
|
2005-05-11 21:37:42 +00:00
|
|
|
} else {
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* ACKs some data in middle of a hole; need
|
|
|
|
* to split current hole
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
2005-06-04 08:03:28 +00:00
|
|
|
temp = tcp_sackhole_insert(tp, sblkp->end,
|
2007-05-11 11:21:43 +00:00
|
|
|
cur->end, cur);
|
2005-05-11 21:37:42 +00:00
|
|
|
if (temp != NULL) {
|
2005-06-04 08:03:28 +00:00
|
|
|
if (SEQ_GT(cur->rxmit, temp->rxmit)) {
|
2005-05-16 19:26:46 +00:00
|
|
|
temp->rxmit = cur->rxmit;
|
2005-06-04 08:03:28 +00:00
|
|
|
tp->sackhint.sack_bytes_rexmit
|
2007-05-11 11:21:43 +00:00
|
|
|
+= (temp->rxmit
|
|
|
|
- temp->start);
|
2005-06-04 08:03:28 +00:00
|
|
|
}
|
|
|
|
cur->end = sblkp->start;
|
|
|
|
cur->rxmit = SEQ_MIN(cur->rxmit,
|
2007-05-11 11:21:43 +00:00
|
|
|
cur->end);
|
2005-03-09 23:14:10 +00:00
|
|
|
}
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-23 19:22:48 +00:00
|
|
|
tp->sackhint.sack_bytes_rexmit += (cur->rxmit - cur->start);
|
2005-06-06 19:46:53 +00:00
|
|
|
/*
|
|
|
|
* Testing sblkp->start against cur->start tells us whether
|
|
|
|
* we're done with the sack block or the sack hole.
|
|
|
|
* Accordingly, we advance one or the other.
|
|
|
|
*/
|
|
|
|
if (SEQ_LEQ(sblkp->start, cur->start))
|
|
|
|
cur = TAILQ_PREV(cur, sackhole_head, scblink);
|
|
|
|
else
|
|
|
|
sblkp--;
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
One of the ways to detect loss is to count duplicate acks coming back from the
other end till it reaches predetermined threshold which is 3 for us right now.
Once that happens, we trigger fast-retransmit to do loss recovery.
Main problem with the current implementation is that we don't honor SACK
information well to detect whether an incoming ack is a dupack or not. RFC6675
has latest recommendations for that. According to it, dupack is a segment that
arrives carrying a SACK block that identifies previously unknown information
between snd_una and snd_max even if it carries new data, changes the advertised
window, or moves the cumulative acknowledgment point.
With the prevalence of Selective ACK (SACK) these days, improper handling can
lead to delayed loss recovery.
With the fix, new behavior looks like following:
0) th_ack < snd_una --> ignore
Old acks are ignored.
1) th_ack == snd_una, !sack_changed --> ignore
Acks with SACK enabled but without any new SACK info in them are ignored.
2) th_ack == snd_una, window == old_window --> increment
Increment on a good dupack.
3) th_ack == snd_una, window != old_window, sack_changed --> increment
When SACK enabled, it's okay to have advertized window changed if the ack has
new SACK info.
4) th_ack > snd_una --> reset to 0
Reset to 0 when left edge moves.
5) th_ack > snd_una, sack_changed --> increment
Increment if left edge moves but there is new SACK info.
Here, sack_changed is the indicator that incoming ack has previously unknown
SACK info in it.
Note: This fix is not fully compliant to RFC6675. That may require a few
changes to current implementation in order to keep per-sackhole dupack counter
and change to the way we mark/handle sack holes.
PR: 203663
Reviewed by: jtl
MFC after: 3 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D4225
2015-12-08 21:21:48 +00:00
|
|
|
return (sack_changed);
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-06-27 22:27:42 +00:00
|
|
|
* Free all SACK holes to clear the scoreboard.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
tcp_free_sackholes(struct tcpcb *tp)
|
|
|
|
{
|
2005-04-21 20:11:01 +00:00
|
|
|
struct sackhole *q;
|
2004-06-23 21:04:37 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2005-06-04 08:03:28 +00:00
|
|
|
while ((q = TAILQ_FIRST(&tp->snd_holes)) != NULL)
|
|
|
|
tcp_sackhole_remove(tp, q);
|
2005-05-11 21:37:42 +00:00
|
|
|
tp->sackhint.sack_bytes_rexmit = 0;
|
2005-05-16 19:26:46 +00:00
|
|
|
|
|
|
|
KASSERT(tp->snd_numholes == 0, ("tp->snd_numholes == 0"));
|
2005-06-04 08:03:28 +00:00
|
|
|
KASSERT(tp->sackhint.nexthole == NULL,
|
|
|
|
("tp->sackhint.nexthole == NULL"));
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Partial ack handling within a sack recovery episode. Keeping this very
|
|
|
|
* simple for now. When a partial ack is received, force snd_cwnd to a value
|
|
|
|
* that will allow the sender to transmit no more than 2 segments. If
|
|
|
|
* necessary, a better scheme can be adopted at a later point, but for now,
|
|
|
|
* the goal is to prevent the sender from bursting a large amount of data in
|
|
|
|
* the midst of sack recovery.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
|
|
|
void
|
2007-03-21 19:37:55 +00:00
|
|
|
tcp_sack_partialack(struct tcpcb *tp, struct tcphdr *th)
|
2004-06-23 21:04:37 +00:00
|
|
|
{
|
2005-02-14 21:01:08 +00:00
|
|
|
int num_segs = 1;
|
2004-06-23 21:04:37 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2007-04-11 09:45:16 +00:00
|
|
|
tcp_timer_activate(tp, TT_REXMT, 0);
|
2004-06-23 21:04:37 +00:00
|
|
|
tp->t_rtttime = 0;
|
2007-05-11 11:21:43 +00:00
|
|
|
/* Send one or 2 segments based on how much new data was acked. */
|
2011-03-28 19:03:56 +00:00
|
|
|
if ((BYTES_THIS_ACK(tp, th) / tp->t_maxseg) >= 2)
|
2005-02-14 21:01:08 +00:00
|
|
|
num_segs = 2;
|
2005-05-11 21:37:42 +00:00
|
|
|
tp->snd_cwnd = (tp->sackhint.sack_bytes_rexmit +
|
2007-05-11 11:21:43 +00:00
|
|
|
(tp->snd_nxt - tp->sack_newdata) + num_segs * tp->t_maxseg);
|
2005-04-14 20:09:52 +00:00
|
|
|
if (tp->snd_cwnd > tp->snd_ssthresh)
|
|
|
|
tp->snd_cwnd = tp->snd_ssthresh;
|
2004-06-23 21:04:37 +00:00
|
|
|
tp->t_flags |= TF_ACKNOW;
|
2015-12-16 00:56:45 +00:00
|
|
|
(void) tp->t_fb->tfb_tcp_output(tp);
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
|
|
|
|
2006-04-06 17:21:16 +00:00
|
|
|
#if 0
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
2007-05-11 11:21:43 +00:00
|
|
|
* Debug version of tcp_sack_output() that walks the scoreboard. Used for
|
2005-05-11 21:37:42 +00:00
|
|
|
* now to sanity check the hint.
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
2005-05-11 21:37:42 +00:00
|
|
|
static struct sackhole *
|
|
|
|
tcp_sack_output_debug(struct tcpcb *tp, int *sack_bytes_rexmt)
|
2004-06-23 21:04:37 +00:00
|
|
|
{
|
2005-04-21 20:11:01 +00:00
|
|
|
struct sackhole *p;
|
2004-06-23 21:04:37 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2004-10-05 18:36:24 +00:00
|
|
|
*sack_bytes_rexmt = 0;
|
2005-04-21 20:11:01 +00:00
|
|
|
TAILQ_FOREACH(p, &tp->snd_holes, scblink) {
|
2004-06-23 21:04:37 +00:00
|
|
|
if (SEQ_LT(p->rxmit, p->end)) {
|
|
|
|
if (SEQ_LT(p->rxmit, tp->snd_una)) {/* old SACK hole */
|
|
|
|
continue;
|
|
|
|
}
|
2004-10-05 18:36:24 +00:00
|
|
|
*sack_bytes_rexmt += (p->rxmit - p->start);
|
|
|
|
break;
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
2004-10-05 18:36:24 +00:00
|
|
|
*sack_bytes_rexmt += (p->rxmit - p->start);
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
2004-10-05 18:36:24 +00:00
|
|
|
return (p);
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|
2006-04-06 17:21:16 +00:00
|
|
|
#endif
|
2004-06-23 21:04:37 +00:00
|
|
|
|
2005-05-11 21:37:42 +00:00
|
|
|
/*
|
|
|
|
* Returns the next hole to retransmit and the number of retransmitted bytes
|
2007-05-11 11:21:43 +00:00
|
|
|
* from the scoreboard. We store both the next hole and the number of
|
2005-05-11 21:37:42 +00:00
|
|
|
* retransmitted bytes as hints (and recompute these on the fly upon SACK/ACK
|
2007-05-11 11:21:43 +00:00
|
|
|
* reception). This avoids scoreboard traversals completely.
|
2005-05-11 21:37:42 +00:00
|
|
|
*
|
2007-05-11 11:21:43 +00:00
|
|
|
* The loop here will traverse *at most* one link. Here's the argument. For
|
|
|
|
* the loop to traverse more than 1 link before finding the next hole to
|
|
|
|
* retransmit, we would need to have at least 1 node following the current
|
|
|
|
* hint with (rxmit == end). But, for all holes following the current hint,
|
|
|
|
* (start == rxmit), since we have not yet retransmitted from them.
|
|
|
|
* Therefore, in order to traverse more 1 link in the loop below, we need to
|
|
|
|
* have at least one node following the current hint with (start == rxmit ==
|
|
|
|
* end). But that can't happen, (start == end) means that all the data in
|
|
|
|
* that hole has been sacked, in which case, the hole would have been removed
|
|
|
|
* from the scoreboard.
|
2005-05-11 21:37:42 +00:00
|
|
|
*/
|
|
|
|
struct sackhole *
|
|
|
|
tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt)
|
|
|
|
{
|
2006-04-06 17:21:16 +00:00
|
|
|
struct sackhole *hole = NULL;
|
2005-05-11 21:37:42 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2005-05-11 21:37:42 +00:00
|
|
|
*sack_bytes_rexmt = tp->sackhint.sack_bytes_rexmit;
|
|
|
|
hole = tp->sackhint.nexthole;
|
|
|
|
if (hole == NULL || SEQ_LT(hole->rxmit, hole->end))
|
|
|
|
goto out;
|
|
|
|
while ((hole = TAILQ_NEXT(hole, scblink)) != NULL) {
|
|
|
|
if (SEQ_LT(hole->rxmit, hole->end)) {
|
|
|
|
tp->sackhint.nexthole = hole;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return (hole);
|
|
|
|
}
|
|
|
|
|
2004-06-23 21:04:37 +00:00
|
|
|
/*
|
|
|
|
* After a timeout, the SACK list may be rebuilt. This SACK information
|
|
|
|
* should be used to avoid retransmitting SACKed data. This function
|
|
|
|
* traverses the SACK list to see if snd_nxt should be moved forward.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
tcp_sack_adjust(struct tcpcb *tp)
|
|
|
|
{
|
2005-04-21 20:11:01 +00:00
|
|
|
struct sackhole *p, *cur = TAILQ_FIRST(&tp->snd_holes);
|
2005-04-18 18:10:56 +00:00
|
|
|
|
2008-04-17 21:38:18 +00:00
|
|
|
INP_WLOCK_ASSERT(tp->t_inpcb);
|
2004-06-23 21:04:37 +00:00
|
|
|
if (cur == NULL)
|
|
|
|
return; /* No holes */
|
2005-05-25 17:55:27 +00:00
|
|
|
if (SEQ_GEQ(tp->snd_nxt, tp->snd_fack))
|
2004-06-23 21:04:37 +00:00
|
|
|
return; /* We're already beyond any SACKed blocks */
|
2007-05-11 11:21:43 +00:00
|
|
|
/*-
|
2004-06-23 21:04:37 +00:00
|
|
|
* Two cases for which we want to advance snd_nxt:
|
|
|
|
* i) snd_nxt lies between end of one hole and beginning of another
|
2005-05-25 17:55:27 +00:00
|
|
|
* ii) snd_nxt lies between end of last hole and snd_fack
|
2004-06-23 21:04:37 +00:00
|
|
|
*/
|
2005-04-21 20:11:01 +00:00
|
|
|
while ((p = TAILQ_NEXT(cur, scblink)) != NULL) {
|
2004-06-23 21:04:37 +00:00
|
|
|
if (SEQ_LT(tp->snd_nxt, cur->end))
|
|
|
|
return;
|
2005-04-21 20:11:01 +00:00
|
|
|
if (SEQ_GEQ(tp->snd_nxt, p->start))
|
|
|
|
cur = p;
|
2004-06-23 21:04:37 +00:00
|
|
|
else {
|
2005-04-21 20:11:01 +00:00
|
|
|
tp->snd_nxt = p->start;
|
2004-06-23 21:04:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SEQ_LT(tp->snd_nxt, cur->end))
|
|
|
|
return;
|
2005-05-25 17:55:27 +00:00
|
|
|
tp->snd_nxt = tp->snd_fack;
|
2004-06-23 21:04:37 +00:00
|
|
|
}
|