usr/src/uts/common/inet/tcp/tcp_timers.c
author Garrett D'Amore <garrett@nexenta.com>
Wed, 17 Aug 2011 16:31:10 -0700
changeset 13435 3185061eadee
parent 12881 fb36eaeb6ee0
child 13551 022a137cd76d
permissions -rw-r--r--
1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL Reviewed by: Pavan <[email protected]> Reviewed by: Dan McDonald <danmcd at nexenta.com> Reviewed by: Garrett D'Amore <[email protected]> Approved by: Garrett D'Amore <[email protected]>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     1
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     2
 * CDDL HEADER START
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     3
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     7
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    11
 * and limitations under the License.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    12
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    18
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    19
 * CDDL HEADER END
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    20
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    21
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    22
/*
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
    23
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
13435
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
    24
 * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    25
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    26
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    27
#include <sys/types.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    28
#include <sys/strlog.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    29
#include <sys/strsun.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    30
#include <sys/squeue_impl.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    31
#include <sys/squeue.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    32
#include <sys/callo.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    33
#include <sys/strsubr.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    34
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    35
#include <inet/common.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    36
#include <inet/ip.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    37
#include <inet/ip_ire.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    38
#include <inet/ip_rts.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    39
#include <inet/tcp.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    40
#include <inet/tcp_impl.h>
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    41
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    42
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    43
 * Implementation of TCP Timers.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    44
 * =============================
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    45
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    46
 * INTERFACE:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    47
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    48
 * There are two basic functions dealing with tcp timers:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    49
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    50
 *	timeout_id_t	tcp_timeout(connp, func, time)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    51
 * 	clock_t		tcp_timeout_cancel(connp, timeout_id)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    52
 *	TCP_TIMER_RESTART(tcp, intvl)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    53
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    54
 * tcp_timeout() starts a timer for the 'tcp' instance arranging to call 'func'
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    55
 * after 'time' ticks passed. The function called by timeout() must adhere to
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    56
 * the same restrictions as a driver soft interrupt handler - it must not sleep
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    57
 * or call other functions that might sleep. The value returned is the opaque
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    58
 * non-zero timeout identifier that can be passed to tcp_timeout_cancel() to
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    59
 * cancel the request. The call to tcp_timeout() may fail in which case it
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    60
 * returns zero. This is different from the timeout(9F) function which never
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    61
 * fails.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    62
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    63
 * The call-back function 'func' always receives 'connp' as its single
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    64
 * argument. It is always executed in the squeue corresponding to the tcp
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    65
 * structure. The tcp structure is guaranteed to be present at the time the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    66
 * call-back is called.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    67
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    68
 * NOTE: The call-back function 'func' is never called if tcp is in
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    69
 * 	the TCPS_CLOSED state.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    70
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    71
 * tcp_timeout_cancel() attempts to cancel a pending tcp_timeout()
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    72
 * request. locks acquired by the call-back routine should not be held across
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    73
 * the call to tcp_timeout_cancel() or a deadlock may result.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    74
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    75
 * tcp_timeout_cancel() returns -1 if it can not cancel the timeout request.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    76
 * Otherwise, it returns an integer value greater than or equal to 0. In
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    77
 * particular, if the call-back function is already placed on the squeue, it can
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    78
 * not be canceled.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    79
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    80
 * NOTE: both tcp_timeout() and tcp_timeout_cancel() should always be called
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    81
 * 	within squeue context corresponding to the tcp instance. Since the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    82
 *	call-back is also called via the same squeue, there are no race
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    83
 *	conditions described in untimeout(9F) manual page since all calls are
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    84
 *	strictly serialized.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    85
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    86
 *      TCP_TIMER_RESTART() is a macro that attempts to cancel a pending timeout
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    87
 *	stored in tcp_timer_tid and starts a new one using
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    88
 *	MSEC_TO_TICK(intvl). It always uses tcp_timer() function as a call-back
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    89
 *	and stores the return value of tcp_timeout() in the tcp->tcp_timer_tid
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    90
 *	field.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    91
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    92
 * NOTE: since the timeout cancellation is not guaranteed, the cancelled
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    93
 *	call-back may still be called, so it is possible tcp_timer() will be
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    94
 *	called several times. This should not be a problem since tcp_timer()
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    95
 *	should always check the tcp instance state.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    96
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    97
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    98
 * IMPLEMENTATION:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
    99
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   100
 * TCP timers are implemented using three-stage process. The call to
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   101
 * tcp_timeout() uses timeout(9F) function to call tcp_timer_callback() function
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   102
 * when the timer expires. The tcp_timer_callback() arranges the call of the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   103
 * tcp_timer_handler() function via squeue corresponding to the tcp
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   104
 * instance. The tcp_timer_handler() calls actual requested timeout call-back
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   105
 * and passes tcp instance as an argument to it. Information is passed between
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   106
 * stages using the tcp_timer_t structure which contains the connp pointer, the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   107
 * tcp call-back to call and the timeout id returned by the timeout(9F).
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   108
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   109
 * The tcp_timer_t structure is not used directly, it is embedded in an mblk_t -
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   110
 * like structure that is used to enter an squeue. The mp->b_rptr of this pseudo
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   111
 * mblk points to the beginning of tcp_timer_t structure. The tcp_timeout()
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   112
 * returns the pointer to this mblk.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   113
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   114
 * The pseudo mblk is allocated from a special tcp_timer_cache kmem cache. It
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   115
 * looks like a normal mblk without actual dblk attached to it.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   116
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   117
 * To optimize performance each tcp instance holds a small cache of timer
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   118
 * mblocks. In the current implementation it caches up to two timer mblocks per
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   119
 * tcp instance. The cache is preserved over tcp frees and is only freed when
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   120
 * the whole tcp structure is destroyed by its kmem destructor. Since all tcp
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   121
 * timer processing happens on a corresponding squeue, the cache manipulation
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   122
 * does not require any locks. Experiments show that majority of timer mblocks
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   123
 * allocations are satisfied from the tcp cache and do not involve kmem calls.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   124
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   125
 * The tcp_timeout() places a refhold on the connp instance which guarantees
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   126
 * that it will be present at the time the call-back function fires. The
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   127
 * tcp_timer_handler() drops the reference after calling the call-back, so the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   128
 * call-back function does not need to manipulate the references explicitly.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   129
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   130
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   131
kmem_cache_t *tcp_timercache;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   132
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   133
static void	tcp_ip_notify(tcp_t *);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   134
static void	tcp_timer_callback(void *);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   135
static void	tcp_timer_free(tcp_t *, mblk_t *);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   136
static void	tcp_timer_handler(void *, mblk_t *, void *, ip_recv_attr_t *);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   137
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   138
/*
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   139
 * tim is in millisec.
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   140
 */
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   141
timeout_id_t
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   142
tcp_timeout(conn_t *connp, void (*f)(void *), hrtime_t tim)
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   143
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   144
	mblk_t *mp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   145
	tcp_timer_t *tcpt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   146
	tcp_t *tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   147
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   148
	ASSERT(connp->conn_sqp != NULL);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   149
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   150
	TCP_DBGSTAT(tcp->tcp_tcps, tcp_timeout_calls);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   151
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   152
	if (tcp->tcp_timercache == NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   153
		mp = tcp_timermp_alloc(KM_NOSLEEP | KM_PANIC);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   154
	} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   155
		TCP_DBGSTAT(tcp->tcp_tcps, tcp_timeout_cached_alloc);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   156
		mp = tcp->tcp_timercache;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   157
		tcp->tcp_timercache = mp->b_next;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   158
		mp->b_next = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   159
		ASSERT(mp->b_wptr == NULL);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   160
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   161
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   162
	CONN_INC_REF(connp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   163
	tcpt = (tcp_timer_t *)mp->b_rptr;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   164
	tcpt->connp = connp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   165
	tcpt->tcpt_proc = f;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   166
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   167
	 * TCP timers are normal timeouts. Plus, they do not require more than
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   168
	 * a 10 millisecond resolution. By choosing a coarser resolution and by
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   169
	 * rounding up the expiration to the next resolution boundary, we can
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   170
	 * batch timers in the callout subsystem to make TCP timers more
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   171
	 * efficient. The roundup also protects short timers from expiring too
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   172
	 * early before they have a chance to be cancelled.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   173
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   174
	tcpt->tcpt_tid = timeout_generic(CALLOUT_NORMAL, tcp_timer_callback, mp,
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   175
	    tim * MICROSEC, CALLOUT_TCP_RESOLUTION, CALLOUT_FLAG_ROUNDUP);
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   176
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   177
	return ((timeout_id_t)mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   178
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   179
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   180
static void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   181
tcp_timer_callback(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   182
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   183
	mblk_t *mp = (mblk_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   184
	tcp_timer_t *tcpt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   185
	conn_t	*connp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   186
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   187
	tcpt = (tcp_timer_t *)mp->b_rptr;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   188
	connp = tcpt->connp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   189
	SQUEUE_ENTER_ONE(connp->conn_sqp, mp, tcp_timer_handler, connp,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   190
	    NULL, SQ_FILL, SQTAG_TCP_TIMER);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   191
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   192
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   193
/* ARGSUSED */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   194
static void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   195
tcp_timer_handler(void *arg, mblk_t *mp, void *arg2, ip_recv_attr_t *dummy)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   196
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   197
	tcp_timer_t *tcpt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   198
	conn_t *connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   199
	tcp_t *tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   200
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   201
	tcpt = (tcp_timer_t *)mp->b_rptr;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   202
	ASSERT(connp == tcpt->connp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   203
	ASSERT((squeue_t *)arg2 == connp->conn_sqp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   204
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   205
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   206
	 * If the TCP has reached the closed state, don't proceed any
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   207
	 * further. This TCP logically does not exist on the system.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   208
	 * tcpt_proc could for example access queues, that have already
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   209
	 * been qprocoff'ed off.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   210
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   211
	if (tcp->tcp_state != TCPS_CLOSED) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   212
		(*tcpt->tcpt_proc)(connp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   213
	} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   214
		tcp->tcp_timer_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   215
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   216
	tcp_timer_free(connp->conn_tcp, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   217
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   218
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   219
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   220
 * There is potential race with untimeout and the handler firing at the same
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   221
 * time. The mblock may be freed by the handler while we are trying to use
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   222
 * it. But since both should execute on the same squeue, this race should not
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   223
 * occur.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   224
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   225
clock_t
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   226
tcp_timeout_cancel(conn_t *connp, timeout_id_t id)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   227
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   228
	mblk_t	*mp = (mblk_t *)id;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   229
	tcp_timer_t *tcpt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   230
	clock_t delta;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   231
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   232
	TCP_DBGSTAT(connp->conn_tcp->tcp_tcps, tcp_timeout_cancel_reqs);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   233
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   234
	if (mp == NULL)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   235
		return (-1);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   236
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   237
	tcpt = (tcp_timer_t *)mp->b_rptr;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   238
	ASSERT(tcpt->connp == connp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   239
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   240
	delta = untimeout_default(tcpt->tcpt_tid, 0);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   241
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   242
	if (delta >= 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   243
		TCP_DBGSTAT(connp->conn_tcp->tcp_tcps, tcp_timeout_canceled);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   244
		tcp_timer_free(connp->conn_tcp, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   245
		CONN_DEC_REF(connp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   246
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   247
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   248
	return (TICK_TO_MSEC(delta));
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   249
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   250
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   251
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   252
 * Allocate space for the timer event. The allocation looks like mblk, but it is
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   253
 * not a proper mblk. To avoid confusion we set b_wptr to NULL.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   254
 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   255
 * Dealing with failures: If we can't allocate from the timer cache we try
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   256
 * allocating from dblock caches using allocb_tryhard(). In this case b_wptr
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   257
 * points to b_rptr.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   258
 * If we can't allocate anything using allocb_tryhard(), we perform a last
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   259
 * attempt and use kmem_alloc_tryhard(). In this case we set b_wptr to -1 and
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   260
 * save the actual allocation size in b_datap.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   261
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   262
mblk_t *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   263
tcp_timermp_alloc(int kmflags)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   264
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   265
	mblk_t *mp = (mblk_t *)kmem_cache_alloc(tcp_timercache,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   266
	    kmflags & ~KM_PANIC);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   267
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   268
	if (mp != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   269
		mp->b_next = mp->b_prev = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   270
		mp->b_rptr = (uchar_t *)(&mp[1]);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   271
		mp->b_wptr = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   272
		mp->b_datap = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   273
		mp->b_queue = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   274
		mp->b_cont = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   275
	} else if (kmflags & KM_PANIC) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   276
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   277
		 * Failed to allocate memory for the timer. Try allocating from
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   278
		 * dblock caches.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   279
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   280
		/* ipclassifier calls this from a constructor - hence no tcps */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   281
		TCP_G_STAT(tcp_timermp_allocfail);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   282
		mp = allocb_tryhard(sizeof (tcp_timer_t));
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   283
		if (mp == NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   284
			size_t size = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   285
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   286
			 * Memory is really low. Try tryhard allocation.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   287
			 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   288
			 * ipclassifier calls this from a constructor -
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   289
			 * hence no tcps
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   290
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   291
			TCP_G_STAT(tcp_timermp_allocdblfail);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   292
			mp = kmem_alloc_tryhard(sizeof (mblk_t) +
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   293
			    sizeof (tcp_timer_t), &size, kmflags);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   294
			mp->b_rptr = (uchar_t *)(&mp[1]);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   295
			mp->b_next = mp->b_prev = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   296
			mp->b_wptr = (uchar_t *)-1;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   297
			mp->b_datap = (dblk_t *)size;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   298
			mp->b_queue = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   299
			mp->b_cont = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   300
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   301
		ASSERT(mp->b_wptr != NULL);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   302
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   303
	/* ipclassifier calls this from a constructor - hence no tcps */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   304
	TCP_G_DBGSTAT(tcp_timermp_alloced);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   305
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   306
	return (mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   307
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   308
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   309
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   310
 * Free per-tcp timer cache.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   311
 * It can only contain entries from tcp_timercache.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   312
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   313
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   314
tcp_timermp_free(tcp_t *tcp)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   315
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   316
	mblk_t *mp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   317
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   318
	while ((mp = tcp->tcp_timercache) != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   319
		ASSERT(mp->b_wptr == NULL);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   320
		tcp->tcp_timercache = tcp->tcp_timercache->b_next;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   321
		kmem_cache_free(tcp_timercache, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   322
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   323
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   324
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   325
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   326
 * Free timer event. Put it on the per-tcp timer cache if there is not too many
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   327
 * events there already (currently at most two events are cached).
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   328
 * If the event is not allocated from the timer cache, free it right away.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   329
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   330
static void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   331
tcp_timer_free(tcp_t *tcp, mblk_t *mp)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   332
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   333
	mblk_t *mp1 = tcp->tcp_timercache;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   334
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   335
	if (mp->b_wptr != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   336
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   337
		 * This allocation is not from a timer cache, free it right
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   338
		 * away.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   339
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   340
		if (mp->b_wptr != (uchar_t *)-1)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   341
			freeb(mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   342
		else
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   343
			kmem_free(mp, (size_t)mp->b_datap);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   344
	} else if (mp1 == NULL || mp1->b_next == NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   345
		/* Cache this timer block for future allocations */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   346
		mp->b_rptr = (uchar_t *)(&mp[1]);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   347
		mp->b_next = mp1;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   348
		tcp->tcp_timercache = mp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   349
	} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   350
		kmem_cache_free(tcp_timercache, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   351
		TCP_DBGSTAT(tcp->tcp_tcps, tcp_timermp_freed);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   352
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   353
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   354
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   355
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   356
 * Stop all TCP timers.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   357
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   358
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   359
tcp_timers_stop(tcp_t *tcp)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   360
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   361
	if (tcp->tcp_timer_tid != 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   362
		(void) TCP_TIMER_CANCEL(tcp, tcp->tcp_timer_tid);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   363
		tcp->tcp_timer_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   364
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   365
	if (tcp->tcp_ka_tid != 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   366
		(void) TCP_TIMER_CANCEL(tcp, tcp->tcp_ka_tid);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   367
		tcp->tcp_ka_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   368
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   369
	if (tcp->tcp_ack_tid != 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   370
		(void) TCP_TIMER_CANCEL(tcp, tcp->tcp_ack_tid);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   371
		tcp->tcp_ack_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   372
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   373
	if (tcp->tcp_push_tid != 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   374
		(void) TCP_TIMER_CANCEL(tcp, tcp->tcp_push_tid);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   375
		tcp->tcp_push_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   376
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   377
	if (tcp->tcp_reass_tid != 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   378
		(void) TCP_TIMER_CANCEL(tcp, tcp->tcp_reass_tid);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   379
		tcp->tcp_reass_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   380
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   381
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   382
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   383
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   384
 * Timer callback routine for keepalive probe.  We do a fake resend of
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   385
 * last ACKed byte.  Then set a timer using RTO.  When the timer expires,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   386
 * check to see if we have heard anything from the other end for the last
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   387
 * RTO period.  If we have, set the timer to expire for another
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   388
 * tcp_keepalive_intrvl and check again.  If we have not, set a timer using
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   389
 * RTO << 1 and check again when it expires.  Keep exponentially increasing
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   390
 * the timeout if we have not heard from the other side.  If for more than
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   391
 * (tcp_ka_interval + tcp_ka_abort_thres) we have not heard anything,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   392
 * kill the connection unless the keepalive abort threshold is 0.  In
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   393
 * that case, we will probe "forever."
13435
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   394
 * If tcp_ka_cnt and tcp_ka_rinterval are non-zero, then we do not follow
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   395
 * the exponential backoff, but send probes tcp_ka_cnt times in regular
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   396
 * intervals of tcp_ka_rinterval milliseconds until we hear back from peer.
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   397
 * Kill the connection if we don't hear back from peer after tcp_ka_cnt
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   398
 * probes are sent.
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   399
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   400
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   401
tcp_keepalive_timer(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   402
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   403
	mblk_t	*mp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   404
	conn_t	*connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   405
	tcp_t  	*tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   406
	int32_t	firetime;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   407
	int32_t	idletime;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   408
	int32_t	ka_intrvl;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   409
	tcp_stack_t	*tcps = tcp->tcp_tcps;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   410
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   411
	tcp->tcp_ka_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   412
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   413
	if (tcp->tcp_fused)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   414
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   415
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   416
	TCPS_BUMP_MIB(tcps, tcpTimKeepalive);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   417
	ka_intrvl = tcp->tcp_ka_interval;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   418
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   419
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   420
	 * Keepalive probe should only be sent if the application has not
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   421
	 * done a close on the connection.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   422
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   423
	if (tcp->tcp_state > TCPS_CLOSE_WAIT) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   424
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   425
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   426
	/* Timer fired too early, restart it. */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   427
	if (tcp->tcp_state < TCPS_ESTABLISHED) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   428
		tcp->tcp_ka_tid = TCP_TIMER(tcp, tcp_keepalive_timer,
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   429
		    ka_intrvl);
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   430
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   431
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   432
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   433
	idletime = TICK_TO_MSEC(ddi_get_lbolt() - tcp->tcp_last_recv_time);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   434
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   435
	 * If we have not heard from the other side for a long
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   436
	 * time, kill the connection unless the keepalive abort
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   437
	 * threshold is 0.  In that case, we will probe "forever."
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   438
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   439
	if (tcp->tcp_ka_abort_thres != 0 &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   440
	    idletime > (ka_intrvl + tcp->tcp_ka_abort_thres)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   441
		TCPS_BUMP_MIB(tcps, tcpTimKeepaliveDrop);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   442
		(void) tcp_clean_death(tcp, tcp->tcp_client_errno ?
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   443
		    tcp->tcp_client_errno : ETIMEDOUT);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   444
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   445
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   446
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   447
	if (tcp->tcp_snxt == tcp->tcp_suna &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   448
	    idletime >= ka_intrvl) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   449
		/* Fake resend of last ACKed byte. */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   450
		mblk_t	*mp1 = allocb(1, BPRI_LO);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   451
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   452
		if (mp1 != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   453
			*mp1->b_wptr++ = '\0';
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   454
			mp = tcp_xmit_mp(tcp, mp1, 1, NULL, NULL,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   455
			    tcp->tcp_suna - 1, B_FALSE, NULL, B_TRUE);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   456
			freeb(mp1);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   457
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   458
			 * if allocation failed, fall through to start the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   459
			 * timer back.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   460
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   461
			if (mp != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   462
				tcp_send_data(tcp, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   463
				TCPS_BUMP_MIB(tcps, tcpTimKeepaliveProbe);
13435
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   464
				if (tcp->tcp_ka_rinterval) {
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   465
					firetime = tcp->tcp_ka_rinterval;
3185061eadee 1361 Add support for socket options TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Garrett D'Amore <garrett@nexenta.com>
parents: 12881
diff changeset
   466
				} else if (tcp->tcp_ka_last_intrvl != 0) {
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   467
					int max;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   468
					/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   469
					 * We should probe again at least
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   470
					 * in ka_intrvl, but not more than
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   471
					 * tcp_rto_max.
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   472
					 */
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   473
					max = tcp->tcp_rto_max;
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   474
					firetime = MIN(ka_intrvl - 1,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   475
					    tcp->tcp_ka_last_intrvl << 1);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   476
					if (firetime > max)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   477
						firetime = max;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   478
				} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   479
					firetime = tcp->tcp_rto;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   480
				}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   481
				tcp->tcp_ka_tid = TCP_TIMER(tcp,
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   482
				    tcp_keepalive_timer, firetime);
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   483
				tcp->tcp_ka_last_intrvl = firetime;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   484
				return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   485
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   486
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   487
	} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   488
		tcp->tcp_ka_last_intrvl = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   489
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   490
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   491
	/* firetime can be negative if (mp1 == NULL || mp == NULL) */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   492
	if ((firetime = ka_intrvl - idletime) < 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   493
		firetime = ka_intrvl;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   494
	}
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
   495
	tcp->tcp_ka_tid = TCP_TIMER(tcp, tcp_keepalive_timer, firetime);
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   496
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   497
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   498
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   499
tcp_reass_timer(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   500
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   501
	conn_t *connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   502
	tcp_t *tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   503
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   504
	tcp->tcp_reass_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   505
	if (tcp->tcp_reass_head == NULL)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   506
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   507
	ASSERT(tcp->tcp_reass_tail != NULL);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   508
	if (tcp->tcp_snd_sack_ok && tcp->tcp_num_sack_blk > 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   509
		tcp_sack_remove(tcp->tcp_sack_list,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   510
		    TCP_REASS_END(tcp->tcp_reass_tail), &tcp->tcp_num_sack_blk);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   511
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   512
	tcp_close_mpp(&tcp->tcp_reass_head);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   513
	tcp->tcp_reass_tail = NULL;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   514
	TCP_STAT(tcp->tcp_tcps, tcp_reass_timeout);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   515
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   516
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   517
/* This function handles the push timeout. */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   518
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   519
tcp_push_timer(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   520
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   521
	conn_t	*connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   522
	tcp_t *tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   523
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   524
	TCP_DBGSTAT(tcp->tcp_tcps, tcp_push_timer_cnt);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   525
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   526
	ASSERT(tcp->tcp_listener == NULL);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   527
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   528
	ASSERT(!IPCL_IS_NONSTR(connp));
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   529
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   530
	tcp->tcp_push_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   531
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   532
	if (tcp->tcp_rcv_list != NULL &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   533
	    tcp_rcv_drain(tcp) == TH_ACK_NEEDED)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   534
		tcp_xmit_ctl(NULL, tcp, tcp->tcp_snxt, tcp->tcp_rnxt, TH_ACK);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   535
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   536
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   537
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   538
 * This function handles delayed ACK timeout.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   539
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   540
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   541
tcp_ack_timer(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   542
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   543
	conn_t	*connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   544
	tcp_t *tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   545
	mblk_t *mp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   546
	tcp_stack_t	*tcps = tcp->tcp_tcps;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   547
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   548
	TCP_DBGSTAT(tcps, tcp_ack_timer_cnt);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   549
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   550
	tcp->tcp_ack_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   551
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   552
	if (tcp->tcp_fused)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   553
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   554
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   555
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   556
	 * Do not send ACK if there is no outstanding unack'ed data.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   557
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   558
	if (tcp->tcp_rnxt == tcp->tcp_rack) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   559
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   560
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   561
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   562
	if ((tcp->tcp_rnxt - tcp->tcp_rack) > tcp->tcp_mss) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   563
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   564
		 * Make sure we don't allow deferred ACKs to result in
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   565
		 * timer-based ACKing.  If we have held off an ACK
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   566
		 * when there was more than an mss here, and the timer
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   567
		 * goes off, we have to worry about the possibility
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   568
		 * that the sender isn't doing slow-start, or is out
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   569
		 * of step with us for some other reason.  We fall
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   570
		 * permanently back in the direction of
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   571
		 * ACK-every-other-packet as suggested in RFC 1122.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   572
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   573
		if (tcp->tcp_rack_abs_max > 2)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   574
			tcp->tcp_rack_abs_max--;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   575
		tcp->tcp_rack_cur_max = 2;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   576
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   577
	mp = tcp_ack_mp(tcp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   578
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   579
	if (mp != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   580
		BUMP_LOCAL(tcp->tcp_obsegs);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   581
		TCPS_BUMP_MIB(tcps, tcpOutAck);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   582
		TCPS_BUMP_MIB(tcps, tcpOutAckDelayed);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   583
		tcp_send_data(tcp, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   584
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   585
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   586
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   587
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   588
 * Notify IP that we are having trouble with this connection.  IP should
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   589
 * make note so it can potentially use a different IRE.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   590
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   591
static void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   592
tcp_ip_notify(tcp_t *tcp)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   593
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   594
	conn_t		*connp = tcp->tcp_connp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   595
	ire_t		*ire;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   596
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   597
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   598
	 * Note: in the case of source routing we want to blow away the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   599
	 * route to the first source route hop.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   600
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   601
	ire = connp->conn_ixa->ixa_ire;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   602
	if (ire != NULL && !(ire->ire_flags & (RTF_REJECT|RTF_BLACKHOLE))) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   603
		if (ire->ire_ipversion == IPV4_VERSION) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   604
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   605
			 * As per RFC 1122, we send an RTM_LOSING to inform
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   606
			 * routing protocols.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   607
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   608
			ip_rts_change(RTM_LOSING, ire->ire_addr,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   609
			    ire->ire_gateway_addr, ire->ire_mask,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   610
			    connp->conn_laddr_v4,  0, 0, 0,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   611
			    (RTA_DST | RTA_GATEWAY | RTA_NETMASK | RTA_IFA),
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   612
			    ire->ire_ipst);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   613
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   614
		(void) ire_no_good(ire);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   615
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   616
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   617
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   618
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   619
 * tcp_timer is the timer service routine.  It handles the retransmission,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   620
 * FIN_WAIT_2 flush, and zero window probe timeout events.  It figures out
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   621
 * from the state of the tcp instance what kind of action needs to be done
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   622
 * at the time it is called.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   623
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   624
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   625
tcp_timer(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   626
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   627
	mblk_t		*mp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   628
	clock_t		first_threshold;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   629
	clock_t		second_threshold;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   630
	clock_t		ms;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   631
	uint32_t	mss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   632
	conn_t		*connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   633
	tcp_t		*tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   634
	tcp_stack_t	*tcps = tcp->tcp_tcps;
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   635
	boolean_t	dont_timeout = B_FALSE;
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   636
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   637
	tcp->tcp_timer_tid = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   638
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   639
	if (tcp->tcp_fused)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   640
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   641
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   642
	first_threshold =  tcp->tcp_first_timer_threshold;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   643
	second_threshold = tcp->tcp_second_timer_threshold;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   644
	switch (tcp->tcp_state) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   645
	case TCPS_IDLE:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   646
	case TCPS_BOUND:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   647
	case TCPS_LISTEN:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   648
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   649
	case TCPS_SYN_RCVD: {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   650
		tcp_t	*listener = tcp->tcp_listener;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   651
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   652
		if (tcp->tcp_syn_rcvd_timeout == 0 && (listener != NULL)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   653
			/* it's our first timeout */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   654
			tcp->tcp_syn_rcvd_timeout = 1;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   655
			mutex_enter(&listener->tcp_eager_lock);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   656
			listener->tcp_syn_rcvd_timeout++;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   657
			if (!tcp->tcp_dontdrop && !tcp->tcp_closemp_used) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   658
				/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   659
				 * Make this eager available for drop if we
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   660
				 * need to drop one to accomodate a new
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   661
				 * incoming SYN request.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   662
				 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   663
				MAKE_DROPPABLE(listener, tcp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   664
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   665
			if (!listener->tcp_syn_defense &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   666
			    (listener->tcp_syn_rcvd_timeout >
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   667
			    (tcps->tcps_conn_req_max_q0 >> 2)) &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   668
			    (tcps->tcps_conn_req_max_q0 > 200)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   669
				/* We may be under attack. Put on a defense. */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   670
				listener->tcp_syn_defense = B_TRUE;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   671
				cmn_err(CE_WARN, "High TCP connect timeout "
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   672
				    "rate! System (port %d) may be under a "
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   673
				    "SYN flood attack!",
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   674
				    ntohs(listener->tcp_connp->conn_lport));
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   675
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   676
				listener->tcp_ip_addr_cache = kmem_zalloc(
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   677
				    IP_ADDR_CACHE_SIZE * sizeof (ipaddr_t),
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   678
				    KM_NOSLEEP);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   679
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   680
			mutex_exit(&listener->tcp_eager_lock);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   681
		} else if (listener != NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   682
			mutex_enter(&listener->tcp_eager_lock);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   683
			tcp->tcp_syn_rcvd_timeout++;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   684
			if (tcp->tcp_syn_rcvd_timeout > 1 &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   685
			    !tcp->tcp_closemp_used) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   686
				/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   687
				 * This is our second timeout. Put the tcp in
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   688
				 * the list of droppable eagers to allow it to
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   689
				 * be dropped, if needed. We don't check
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   690
				 * whether tcp_dontdrop is set or not to
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   691
				 * protect ourselve from a SYN attack where a
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   692
				 * remote host can spoof itself as one of the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   693
				 * good IP source and continue to hold
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   694
				 * resources too long.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   695
				 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   696
				MAKE_DROPPABLE(listener, tcp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   697
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   698
			mutex_exit(&listener->tcp_eager_lock);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   699
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   700
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   701
		/* FALLTHRU */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   702
	case TCPS_SYN_SENT:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   703
		first_threshold =  tcp->tcp_first_ctimer_threshold;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   704
		second_threshold = tcp->tcp_second_ctimer_threshold;
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   705
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   706
		/*
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   707
		 * If an app has set the second_threshold to 0, it means that
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   708
		 * we need to retransmit forever, unless this is a passive
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   709
		 * open.  We need to set second_threshold back to a normal
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   710
		 * value such that later comparison with it still makes
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   711
		 * sense.  But we set dont_timeout to B_TRUE so that we will
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   712
		 * never time out.
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   713
		 */
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   714
		if (second_threshold == 0) {
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   715
			second_threshold = tcps->tcps_ip_abort_linterval;
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   716
			if (tcp->tcp_active_open)
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   717
				dont_timeout = B_TRUE;
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   718
		}
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   719
		break;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   720
	case TCPS_ESTABLISHED:
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   721
	case TCPS_CLOSE_WAIT:
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   722
		/*
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   723
		 * If the end point has not been closed, TCP can retransmit
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   724
		 * forever.  But if the end point is closed, the normal
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   725
		 * timeout applies.
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   726
		 */
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   727
		if (second_threshold == 0) {
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   728
			second_threshold = tcps->tcps_ip_abort_linterval;
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   729
			dont_timeout = B_TRUE;
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   730
		}
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   731
		/* FALLTHRU */
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   732
	case TCPS_FIN_WAIT_1:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   733
	case TCPS_CLOSING:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   734
	case TCPS_LAST_ACK:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   735
		/* If we have data to rexmit */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   736
		if (tcp->tcp_suna != tcp->tcp_snxt) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   737
			clock_t	time_to_wait;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   738
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   739
			TCPS_BUMP_MIB(tcps, tcpTimRetrans);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   740
			if (!tcp->tcp_xmit_head)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   741
				break;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   742
			time_to_wait = ddi_get_lbolt() -
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   743
			    (clock_t)tcp->tcp_xmit_head->b_prev;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   744
			time_to_wait = tcp->tcp_rto -
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   745
			    TICK_TO_MSEC(time_to_wait);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   746
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   747
			 * If the timer fires too early, 1 clock tick earlier,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   748
			 * restart the timer.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   749
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   750
			if (time_to_wait > msec_per_tick) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   751
				TCP_STAT(tcps, tcp_timer_fire_early);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   752
				TCP_TIMER_RESTART(tcp, time_to_wait);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   753
				return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   754
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   755
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   756
			 * When we probe zero windows, we force the swnd open.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   757
			 * If our peer acks with a closed window swnd will be
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   758
			 * set to zero by tcp_rput(). As long as we are
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   759
			 * receiving acks tcp_rput will
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   760
			 * reset 'tcp_ms_we_have_waited' so as not to trip the
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   761
			 * first and second interval actions.  NOTE: the timer
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   762
			 * interval is allowed to continue its exponential
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   763
			 * backoff.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   764
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   765
			if (tcp->tcp_swnd == 0 || tcp->tcp_zero_win_probe) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   766
				if (connp->conn_debug) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   767
					(void) strlog(TCP_MOD_ID, 0, 1,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   768
					    SL_TRACE, "tcp_timer: zero win");
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   769
				}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   770
			} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   771
				/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   772
				 * After retransmission, we need to do
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   773
				 * slow start.  Set the ssthresh to one
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   774
				 * half of current effective window and
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   775
				 * cwnd to one MSS.  Also reset
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   776
				 * tcp_cwnd_cnt.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   777
				 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   778
				 * Note that if tcp_ssthresh is reduced because
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   779
				 * of ECN, do not reduce it again unless it is
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   780
				 * already one window of data away (tcp_cwr
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   781
				 * should then be cleared) or this is a
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   782
				 * timeout for a retransmitted segment.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   783
				 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   784
				uint32_t npkt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   785
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   786
				if (!tcp->tcp_cwr || tcp->tcp_rexmit) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   787
					npkt = ((tcp->tcp_timer_backoff ?
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   788
					    tcp->tcp_cwnd_ssthresh :
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   789
					    tcp->tcp_snxt -
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   790
					    tcp->tcp_suna) >> 1) / tcp->tcp_mss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   791
					tcp->tcp_cwnd_ssthresh = MAX(npkt, 2) *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   792
					    tcp->tcp_mss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   793
				}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   794
				tcp->tcp_cwnd = tcp->tcp_mss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   795
				tcp->tcp_cwnd_cnt = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   796
				if (tcp->tcp_ecn_ok) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   797
					tcp->tcp_cwr = B_TRUE;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   798
					tcp->tcp_cwr_snd_max = tcp->tcp_snxt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   799
					tcp->tcp_ecn_cwr_sent = B_FALSE;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   800
				}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   801
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   802
			break;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   803
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   804
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   805
		 * We have something to send yet we cannot send.  The
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   806
		 * reason can be:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   807
		 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   808
		 * 1. Zero send window: we need to do zero window probe.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   809
		 * 2. Zero cwnd: because of ECN, we need to "clock out
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   810
		 * segments.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   811
		 * 3. SWS avoidance: receiver may have shrunk window,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   812
		 * reset our knowledge.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   813
		 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   814
		 * Note that condition 2 can happen with either 1 or
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   815
		 * 3.  But 1 and 3 are exclusive.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   816
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   817
		if (tcp->tcp_unsent != 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   818
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   819
			 * Should not hold the zero-copy messages for too long.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   820
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   821
			if (tcp->tcp_snd_zcopy_aware && !tcp->tcp_xmit_zc_clean)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   822
				tcp->tcp_xmit_head = tcp_zcopy_backoff(tcp,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   823
				    tcp->tcp_xmit_head, B_TRUE);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   824
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   825
			if (tcp->tcp_cwnd == 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   826
				/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   827
				 * Set tcp_cwnd to 1 MSS so that a
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   828
				 * new segment can be sent out.  We
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   829
				 * are "clocking out" new data when
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   830
				 * the network is really congested.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   831
				 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   832
				ASSERT(tcp->tcp_ecn_ok);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   833
				tcp->tcp_cwnd = tcp->tcp_mss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   834
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   835
			if (tcp->tcp_swnd == 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   836
				/* Extend window for zero window probe */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   837
				tcp->tcp_swnd++;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   838
				tcp->tcp_zero_win_probe = B_TRUE;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   839
				TCPS_BUMP_MIB(tcps, tcpOutWinProbe);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   840
			} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   841
				/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   842
				 * Handle timeout from sender SWS avoidance.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   843
				 * Reset our knowledge of the max send window
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   844
				 * since the receiver might have reduced its
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   845
				 * receive buffer.  Avoid setting tcp_max_swnd
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   846
				 * to one since that will essentially disable
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   847
				 * the SWS checks.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   848
				 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   849
				 * Note that since we don't have a SWS
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   850
				 * state variable, if the timeout is set
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   851
				 * for ECN but not for SWS, this
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   852
				 * code will also be executed.  This is
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   853
				 * fine as tcp_max_swnd is updated
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   854
				 * constantly and it will not affect
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   855
				 * anything.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   856
				 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   857
				tcp->tcp_max_swnd = MAX(tcp->tcp_swnd, 2);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   858
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   859
			tcp_wput_data(tcp, NULL, B_FALSE);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   860
			return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   861
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   862
		/* Is there a FIN that needs to be to re retransmitted? */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   863
		if ((tcp->tcp_valid_bits & TCP_FSS_VALID) &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   864
		    !tcp->tcp_fin_acked)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   865
			break;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   866
		/* Nothing to do, return without restarting timer. */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   867
		TCP_STAT(tcps, tcp_timer_fire_miss);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   868
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   869
	case TCPS_FIN_WAIT_2:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   870
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   871
		 * User closed the TCP endpoint and peer ACK'ed our FIN.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   872
		 * We waited some time for for peer's FIN, but it hasn't
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   873
		 * arrived.  We flush the connection now to avoid
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   874
		 * case where the peer has rebooted.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   875
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   876
		if (TCP_IS_DETACHED(tcp)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   877
			(void) tcp_clean_death(tcp, 0);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   878
		} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   879
			TCP_TIMER_RESTART(tcp,
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   880
			    tcp->tcp_fin_wait_2_flush_interval);
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   881
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   882
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   883
	case TCPS_TIME_WAIT:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   884
		(void) tcp_clean_death(tcp, 0);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   885
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   886
	default:
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   887
		if (connp->conn_debug) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   888
			(void) strlog(TCP_MOD_ID, 0, 1, SL_TRACE|SL_ERROR,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   889
			    "tcp_timer: strange state (%d) %s",
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   890
			    tcp->tcp_state, tcp_display(tcp, NULL,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   891
			    DISP_PORT_ONLY));
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   892
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   893
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   894
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   895
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   896
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   897
	 * If the system is under memory pressure or the max number of
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   898
	 * connections have been established for the listener, be more
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   899
	 * aggressive in aborting connections.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   900
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   901
	if (tcps->tcps_reclaim || (tcp->tcp_listen_cnt != NULL &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   902
	    tcp->tcp_listen_cnt->tlc_cnt > tcp->tcp_listen_cnt->tlc_max)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   903
		second_threshold = tcp_early_abort * SECONDS;
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   904
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   905
		/* We will ignore the never timeout promise in this case... */
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   906
		dont_timeout = B_FALSE;
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   907
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   908
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   909
	ASSERT(second_threshold != 0);
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   910
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   911
	if ((ms = tcp->tcp_ms_we_have_waited) > second_threshold) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   912
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   913
		 * Should not hold the zero-copy messages for too long.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   914
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   915
		if (tcp->tcp_snd_zcopy_aware && !tcp->tcp_xmit_zc_clean)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   916
			tcp->tcp_xmit_head = tcp_zcopy_backoff(tcp,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   917
			    tcp->tcp_xmit_head, B_TRUE);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   918
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   919
		if (dont_timeout) {
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   920
			/*
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   921
			 * Reset tcp_ms_we_have_waited to avoid overflow since
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   922
			 * we are going to retransmit forever.
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   923
			 */
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   924
			tcp->tcp_ms_we_have_waited = second_threshold;
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   925
			goto timer_rexmit;
12881
fb36eaeb6ee0 6910078 SCTP should have similar memory handling mechanism as TCP
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12544
diff changeset
   926
		}
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   927
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   928
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   929
		 * For zero window probe, we need to send indefinitely,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   930
		 * unless we have not heard from the other side for some
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   931
		 * time...
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   932
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   933
		if ((tcp->tcp_zero_win_probe == 0) ||
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   934
		    (TICK_TO_MSEC(ddi_get_lbolt() - tcp->tcp_last_recv_time) >
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   935
		    second_threshold)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   936
			TCPS_BUMP_MIB(tcps, tcpTimRetransDrop);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   937
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   938
			 * If TCP is in SYN_RCVD state, send back a
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   939
			 * RST|ACK as BSD does.  Note that tcp_zero_win_probe
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   940
			 * should be zero in TCPS_SYN_RCVD state.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   941
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   942
			if (tcp->tcp_state == TCPS_SYN_RCVD) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   943
				tcp_xmit_ctl("tcp_timer: RST sent on timeout "
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   944
				    "in SYN_RCVD",
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   945
				    tcp, tcp->tcp_snxt,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   946
				    tcp->tcp_rnxt, TH_RST | TH_ACK);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   947
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   948
			(void) tcp_clean_death(tcp,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   949
			    tcp->tcp_client_errno ?
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   950
			    tcp->tcp_client_errno : ETIMEDOUT);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   951
			return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   952
		} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   953
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   954
			 * If the system is under memory pressure, we also
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   955
			 * abort connection in zero window probing.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   956
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   957
			if (tcps->tcps_reclaim) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   958
				(void) tcp_clean_death(tcp,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   959
				    tcp->tcp_client_errno ?
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   960
				    tcp->tcp_client_errno : ETIMEDOUT);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   961
				TCP_STAT(tcps, tcp_zwin_mem_drop);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   962
				return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   963
			}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   964
			/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   965
			 * Set tcp_ms_we_have_waited to second_threshold
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   966
			 * so that in next timeout, we will do the above
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   967
			 * check (ddi_get_lbolt() - tcp_last_recv_time).
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   968
			 * This is also to avoid overflow.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   969
			 *
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   970
			 * We don't need to decrement tcp_timer_backoff
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   971
			 * to avoid overflow because it will be decremented
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   972
			 * later if new timeout value is greater than
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   973
			 * tcp_rto_max.  In the case when tcp_rto_max is
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   974
			 * greater than second_threshold, it means that we
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   975
			 * will wait longer than second_threshold to send
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
   976
			 * the next
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   977
			 * window probe.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   978
			 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   979
			tcp->tcp_ms_we_have_waited = second_threshold;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   980
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   981
	} else if (ms > first_threshold) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   982
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   983
		 * Should not hold the zero-copy messages for too long.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   984
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   985
		if (tcp->tcp_snd_zcopy_aware && !tcp->tcp_xmit_zc_clean)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   986
			tcp->tcp_xmit_head = tcp_zcopy_backoff(tcp,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   987
			    tcp->tcp_xmit_head, B_TRUE);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   988
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   989
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   990
		 * We have been retransmitting for too long...  The RTT
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   991
		 * we calculated is probably incorrect.  Reinitialize it.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   992
		 * Need to compensate for 0 tcp_rtt_sa.  Reset
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   993
		 * tcp_rtt_update so that we won't accidentally cache a
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   994
		 * bad value.  But only do this if this is not a zero
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   995
		 * window probe.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   996
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   997
		if (tcp->tcp_rtt_sa != 0 && tcp->tcp_zero_win_probe == 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   998
			tcp->tcp_rtt_sd += (tcp->tcp_rtt_sa >> 3) +
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
   999
			    (tcp->tcp_rtt_sa >> 5);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1000
			tcp->tcp_rtt_sa = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1001
			tcp_ip_notify(tcp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1002
			tcp->tcp_rtt_update = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1003
		}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1004
	}
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
  1005
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
  1006
timer_rexmit:
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1007
	tcp->tcp_timer_backoff++;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1008
	if ((ms = (tcp->tcp_rtt_sa >> 3) + tcp->tcp_rtt_sd +
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1009
	    tcps->tcps_rexmit_interval_extra + (tcp->tcp_rtt_sa >> 5)) <
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
  1010
	    tcp->tcp_rto_min) {
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1011
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1012
		 * This means the original RTO is tcp_rexmit_interval_min.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1013
		 * So we will use tcp_rexmit_interval_min as the RTO value
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1014
		 * and do the backoff.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1015
		 */
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
  1016
		ms = tcp->tcp_rto_min << tcp->tcp_timer_backoff;
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1017
	} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1018
		ms <<= tcp->tcp_timer_backoff;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1019
	}
12544
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
  1020
	if (ms > tcp->tcp_rto_max) {
88a11088cbce PSARC 2010/151 new socket options for TCP timers
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 12056
diff changeset
  1021
		ms = tcp->tcp_rto_max;
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1022
		/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1023
		 * ms is at max, decrement tcp_timer_backoff to avoid
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1024
		 * overflow.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1025
		 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1026
		tcp->tcp_timer_backoff--;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1027
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1028
	tcp->tcp_ms_we_have_waited += ms;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1029
	if (tcp->tcp_zero_win_probe == 0) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1030
		tcp->tcp_rto = ms;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1031
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1032
	TCP_TIMER_RESTART(tcp, ms);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1033
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1034
	 * This is after a timeout and tcp_rto is backed off.  Set
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1035
	 * tcp_set_timer to 1 so that next time RTO is updated, we will
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1036
	 * restart the timer with a correct value.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1037
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1038
	tcp->tcp_set_timer = 1;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1039
	mss = tcp->tcp_snxt - tcp->tcp_suna;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1040
	if (mss > tcp->tcp_mss)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1041
		mss = tcp->tcp_mss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1042
	if (mss > tcp->tcp_swnd && tcp->tcp_swnd != 0)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1043
		mss = tcp->tcp_swnd;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1044
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1045
	if ((mp = tcp->tcp_xmit_head) != NULL)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1046
		mp->b_prev = (mblk_t *)ddi_get_lbolt();
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1047
	mp = tcp_xmit_mp(tcp, mp, mss, NULL, NULL, tcp->tcp_suna, B_TRUE, &mss,
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1048
	    B_TRUE);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1049
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1050
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1051
	 * When slow start after retransmission begins, start with
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1052
	 * this seq no.  tcp_rexmit_max marks the end of special slow
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1053
	 * start phase.  tcp_snd_burst controls how many segments
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1054
	 * can be sent because of an ack.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1055
	 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1056
	tcp->tcp_rexmit_nxt = tcp->tcp_suna;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1057
	tcp->tcp_snd_burst = TCP_CWND_SS;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1058
	if ((tcp->tcp_valid_bits & TCP_FSS_VALID) &&
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1059
	    (tcp->tcp_unsent == 0)) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1060
		tcp->tcp_rexmit_max = tcp->tcp_fss;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1061
	} else {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1062
		tcp->tcp_rexmit_max = tcp->tcp_snxt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1063
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1064
	tcp->tcp_rexmit = B_TRUE;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1065
	tcp->tcp_dupack_cnt = 0;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1066
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1067
	/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1068
	 * Remove all rexmit SACK blk to start from fresh.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1069
	 */
12056
4811a59c20b7 6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents: 11754
diff changeset
  1070
	if (tcp->tcp_snd_sack_ok)
11754
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1071
		TCP_NOTSACK_REMOVE_ALL(tcp->tcp_notsack_list, tcp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1072
	if (mp == NULL) {
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1073
		return;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1074
	}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1075
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1076
	tcp->tcp_csuna = tcp->tcp_snxt;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1077
	TCPS_BUMP_MIB(tcps, tcpRetransSegs);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1078
	TCPS_UPDATE_MIB(tcps, tcpRetransBytes, mss);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1079
	tcp_send_data(tcp, mp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1080
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1081
}
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1082
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1083
/*
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1084
 * Handle lingering timeouts. This function is called when the SO_LINGER timeout
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1085
 * expires.
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1086
 */
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1087
void
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1088
tcp_close_linger_timeout(void *arg)
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1089
{
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1090
	conn_t	*connp = (conn_t *)arg;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1091
	tcp_t 	*tcp = connp->conn_tcp;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1092
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1093
	tcp->tcp_client_errno = ETIMEDOUT;
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1094
	tcp_stop_lingering(tcp);
251da8f4caaa PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff changeset
  1095
}