author | Kacheong Poon <Kacheong.Poon@Sun.COM> |
Thu, 01 Apr 2010 10:24:19 -0700 | |
changeset 12056 | 4811a59c20b7 |
parent 11754 | 251da8f4caaa |
child 12544 | 88a11088cbce |
permissions | -rw-r--r-- |
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. |
11754
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
24 |
*/ |
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 |
#include <sys/types.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
27 |
#include <sys/strlog.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
28 |
#include <sys/strsun.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
29 |
#include <sys/squeue_impl.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
30 |
#include <sys/squeue.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
31 |
#include <sys/callo.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
32 |
#include <sys/strsubr.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
33 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
34 |
#include <inet/common.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
35 |
#include <inet/ip.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
36 |
#include <inet/ip_ire.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
37 |
#include <inet/ip_rts.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
38 |
#include <inet/tcp.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
39 |
#include <inet/tcp_impl.h> |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
40 |
|
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 |
* Implementation of TCP Timers. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
43 |
* ============================= |
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 |
* INTERFACE: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
46 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
47 |
* 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
|
48 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
49 |
* 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
|
50 |
* 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
|
51 |
* TCP_TIMER_RESTART(tcp, intvl) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
52 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
53 |
* 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
|
54 |
* 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
|
55 |
* 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
|
56 |
* 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
|
57 |
* 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
|
58 |
* 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
|
59 |
* 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
|
60 |
* fails. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
61 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
62 |
* 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
|
63 |
* 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
|
64 |
* 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
|
65 |
* call-back is called. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
66 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
67 |
* 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
|
68 |
* the TCPS_CLOSED state. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
69 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
70 |
* 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
|
71 |
* 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
|
72 |
* 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
|
73 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
74 |
* 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
|
75 |
* 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
|
76 |
* 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
|
77 |
* not be canceled. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
78 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
79 |
* 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
|
80 |
* 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
|
81 |
* 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
|
82 |
* 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
|
83 |
* strictly serialized. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
84 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
85 |
* 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
|
86 |
* 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
|
87 |
* 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
|
88 |
* 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
|
89 |
* field. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
90 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
91 |
* 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
|
92 |
* 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
|
93 |
* 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
|
94 |
* 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
|
95 |
* |
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 |
* IMPLEMENTATION: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
98 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
99 |
* 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
|
100 |
* 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
|
101 |
* 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
|
102 |
* 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
|
103 |
* 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
|
104 |
* 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
|
105 |
* 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
|
106 |
* 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
|
107 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
108 |
* 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
|
109 |
* 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
|
110 |
* 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
|
111 |
* returns the pointer to this mblk. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
112 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
113 |
* 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
|
114 |
* 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
|
115 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
116 |
* 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
|
117 |
* 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
|
118 |
* 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
|
119 |
* 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
|
120 |
* 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
|
121 |
* 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
|
122 |
* 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
|
123 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
124 |
* 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
|
125 |
* 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
|
126 |
* 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
|
127 |
* 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
|
128 |
*/ |
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 |
kmem_cache_t *tcp_timercache; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
131 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
132 |
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
|
133 |
static void tcp_timer_callback(void *); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
|
12056
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
137 |
/* |
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
138 |
* tim is in millisec. |
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
139 |
*/ |
11754
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
140 |
timeout_id_t |
12056
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
141 |
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
|
142 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
143 |
mblk_t *mp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
144 |
tcp_timer_t *tcpt; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
145 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
146 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
147 |
ASSERT(connp->conn_sqp != NULL); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
148 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
149 |
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
|
150 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
151 |
if (tcp->tcp_timercache == NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
152 |
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
|
153 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
154 |
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
|
155 |
mp = tcp->tcp_timercache; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
156 |
tcp->tcp_timercache = mp->b_next; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
157 |
mp->b_next = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
158 |
ASSERT(mp->b_wptr == NULL); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
159 |
} |
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 |
CONN_INC_REF(connp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
162 |
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
|
163 |
tcpt->connp = connp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
164 |
tcpt->tcpt_proc = f; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
165 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
166 |
* 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
|
167 |
* 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
|
168 |
* 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
|
169 |
* 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
|
170 |
* 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
|
171 |
* 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
|
172 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
173 |
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
|
174 |
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
|
175 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
176 |
return ((timeout_id_t)mp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
177 |
} |
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 |
static void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
180 |
tcp_timer_callback(void *arg) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
181 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
182 |
mblk_t *mp = (mblk_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
183 |
tcp_timer_t *tcpt; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
184 |
conn_t *connp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
185 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
186 |
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
|
187 |
connp = tcpt->connp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
188 |
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
|
189 |
NULL, SQ_FILL, SQTAG_TCP_TIMER); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
190 |
} |
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 |
/* ARGSUSED */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
193 |
static void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
194 |
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
|
195 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
196 |
tcp_timer_t *tcpt; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
197 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
198 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
199 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
200 |
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
|
201 |
ASSERT(connp == tcpt->connp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
202 |
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
|
203 |
|
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 |
* 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
|
206 |
* 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
|
207 |
* 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
|
208 |
* been qprocoff'ed off. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
209 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
210 |
if (tcp->tcp_state != TCPS_CLOSED) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
211 |
(*tcpt->tcpt_proc)(connp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
212 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
213 |
tcp->tcp_timer_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
214 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
215 |
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
|
216 |
} |
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 |
* 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
|
220 |
* 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
|
221 |
* 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
|
222 |
* occur. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
223 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
224 |
clock_t |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
225 |
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
|
226 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
227 |
mblk_t *mp = (mblk_t *)id; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
228 |
tcp_timer_t *tcpt; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
229 |
clock_t delta; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
230 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
231 |
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
|
232 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
233 |
if (mp == NULL) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
234 |
return (-1); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
235 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
236 |
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
|
237 |
ASSERT(tcpt->connp == connp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
238 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
239 |
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
|
240 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
241 |
if (delta >= 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
242 |
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
|
243 |
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
|
244 |
CONN_DEC_REF(connp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
245 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
246 |
|
12056
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
247 |
return (TICK_TO_MSEC(delta)); |
11754
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
248 |
} |
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 |
* 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
|
252 |
* 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
|
253 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
254 |
* 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
|
255 |
* 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
|
256 |
* points to b_rptr. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
257 |
* 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
|
258 |
* 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
|
259 |
* 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
|
260 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
261 |
mblk_t * |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
262 |
tcp_timermp_alloc(int kmflags) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
263 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
264 |
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
|
265 |
kmflags & ~KM_PANIC); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
266 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
267 |
if (mp != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
mp->b_wptr = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
271 |
mp->b_datap = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
272 |
mp->b_queue = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
273 |
mp->b_cont = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
274 |
} else if (kmflags & KM_PANIC) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
275 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
276 |
* 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
|
277 |
* dblock caches. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
278 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
279 |
/* 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
|
280 |
TCP_G_STAT(tcp_timermp_allocfail); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
281 |
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
|
282 |
if (mp == NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
283 |
size_t size = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
284 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
285 |
* 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
|
286 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
287 |
* ipclassifier calls this from a constructor - |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
288 |
* hence no tcps |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
289 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
290 |
TCP_G_STAT(tcp_timermp_allocdblfail); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
291 |
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
|
292 |
sizeof (tcp_timer_t), &size, kmflags); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
293 |
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
|
294 |
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
|
295 |
mp->b_wptr = (uchar_t *)-1; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
296 |
mp->b_datap = (dblk_t *)size; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
297 |
mp->b_queue = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
298 |
mp->b_cont = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
299 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
300 |
ASSERT(mp->b_wptr != NULL); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
301 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
302 |
/* 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
|
303 |
TCP_G_DBGSTAT(tcp_timermp_alloced); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
304 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
305 |
return (mp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
306 |
} |
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 |
* Free per-tcp timer cache. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
310 |
* 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
|
311 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
312 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
313 |
tcp_timermp_free(tcp_t *tcp) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
314 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
315 |
mblk_t *mp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
316 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
317 |
while ((mp = tcp->tcp_timercache) != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
318 |
ASSERT(mp->b_wptr == NULL); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
319 |
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
|
320 |
kmem_cache_free(tcp_timercache, mp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
321 |
} |
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 |
* 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
|
326 |
* 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
|
327 |
* 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
|
328 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
329 |
static void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
330 |
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
|
331 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
332 |
mblk_t *mp1 = tcp->tcp_timercache; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
333 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
334 |
if (mp->b_wptr != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
335 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
336 |
* 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
|
337 |
* away. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
338 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
339 |
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
|
340 |
freeb(mp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
341 |
else |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
342 |
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
|
343 |
} 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
|
344 |
/* 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
|
345 |
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
|
346 |
mp->b_next = mp1; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
347 |
tcp->tcp_timercache = mp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
348 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
349 |
kmem_cache_free(tcp_timercache, mp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
350 |
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
|
351 |
} |
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 |
* Stop all TCP timers. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
356 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
357 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
358 |
tcp_timers_stop(tcp_t *tcp) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
359 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
360 |
if (tcp->tcp_timer_tid != 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
361 |
(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
|
362 |
tcp->tcp_timer_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
363 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
364 |
if (tcp->tcp_ka_tid != 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
365 |
(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
|
366 |
tcp->tcp_ka_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
367 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
368 |
if (tcp->tcp_ack_tid != 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
369 |
(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
|
370 |
tcp->tcp_ack_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
371 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
372 |
if (tcp->tcp_push_tid != 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
373 |
(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
|
374 |
tcp->tcp_push_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
375 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
376 |
if (tcp->tcp_reass_tid != 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
377 |
(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
|
378 |
tcp->tcp_reass_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
379 |
} |
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 |
* 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
|
384 |
* 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
|
385 |
* 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
|
386 |
* 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
|
387 |
* 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
|
388 |
* 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
|
389 |
* 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
|
390 |
* (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
|
391 |
* 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
|
392 |
* that case, we will probe "forever." |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
393 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
394 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
395 |
tcp_keepalive_timer(void *arg) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
396 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
397 |
mblk_t *mp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
398 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
399 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
400 |
int32_t firetime; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
401 |
int32_t idletime; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
402 |
int32_t ka_intrvl; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
403 |
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
|
404 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
405 |
tcp->tcp_ka_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
406 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
407 |
if (tcp->tcp_fused) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
408 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
409 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
410 |
TCPS_BUMP_MIB(tcps, tcpTimKeepalive); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
411 |
ka_intrvl = tcp->tcp_ka_interval; |
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 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
414 |
* 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
|
415 |
* done a close on the connection. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
416 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
417 |
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
|
418 |
return; |
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 |
/* Timer fired too early, restart it. */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
421 |
if (tcp->tcp_state < TCPS_ESTABLISHED) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
422 |
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
|
423 |
ka_intrvl); |
11754
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 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
427 |
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
|
428 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
429 |
* 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
|
430 |
* 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
|
431 |
* 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
|
432 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
433 |
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
|
434 |
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
|
435 |
TCPS_BUMP_MIB(tcps, tcpTimKeepaliveDrop); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
436 |
(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
|
437 |
tcp->tcp_client_errno : ETIMEDOUT); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
438 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
439 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
440 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
441 |
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
|
442 |
idletime >= ka_intrvl) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
443 |
/* Fake resend of last ACKed byte. */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
444 |
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
|
445 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
446 |
if (mp1 != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
447 |
*mp1->b_wptr++ = '\0'; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
448 |
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
|
449 |
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
|
450 |
freeb(mp1); |
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 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
|
453 |
* timer back. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
454 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
455 |
if (mp != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
456 |
tcp_send_data(tcp, mp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
457 |
TCPS_BUMP_MIB(tcps, tcpTimKeepaliveProbe); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
458 |
if (tcp->tcp_ka_last_intrvl != 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
459 |
int max; |
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 |
* We should probe again at least |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
462 |
* in ka_intrvl, but not more than |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
463 |
* tcp_rexmit_interval_max. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
464 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
465 |
max = tcps->tcps_rexmit_interval_max; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
466 |
firetime = MIN(ka_intrvl - 1, |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
467 |
tcp->tcp_ka_last_intrvl << 1); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
468 |
if (firetime > max) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
469 |
firetime = max; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
470 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
471 |
firetime = tcp->tcp_rto; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
472 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
473 |
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
|
474 |
tcp_keepalive_timer, firetime); |
11754
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
475 |
tcp->tcp_ka_last_intrvl = firetime; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
476 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
477 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
478 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
479 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
480 |
tcp->tcp_ka_last_intrvl = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
481 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
482 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
483 |
/* 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
|
484 |
if ((firetime = ka_intrvl - idletime) < 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
485 |
firetime = ka_intrvl; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
486 |
} |
12056
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
487 |
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
|
488 |
} |
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 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
491 |
tcp_reass_timer(void *arg) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
492 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
493 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
494 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
495 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
496 |
tcp->tcp_reass_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
497 |
if (tcp->tcp_reass_head == NULL) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
498 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
499 |
ASSERT(tcp->tcp_reass_tail != NULL); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
500 |
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
|
501 |
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
|
502 |
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
|
503 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
504 |
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
|
505 |
tcp->tcp_reass_tail = NULL; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
506 |
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
|
507 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
508 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
509 |
/* This function handles the push timeout. */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
510 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
511 |
tcp_push_timer(void *arg) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
512 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
513 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
514 |
tcp_t *tcp = connp->conn_tcp; |
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 |
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
|
517 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
518 |
ASSERT(tcp->tcp_listener == NULL); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
519 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
520 |
ASSERT(!IPCL_IS_NONSTR(connp)); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
521 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
522 |
tcp->tcp_push_tid = 0; |
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 |
if (tcp->tcp_rcv_list != NULL && |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
525 |
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
|
526 |
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
|
527 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
528 |
|
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 |
* This function handles delayed ACK timeout. |
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 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
533 |
tcp_ack_timer(void *arg) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
534 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
535 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
536 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
537 |
mblk_t *mp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
538 |
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
|
539 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
540 |
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
|
541 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
542 |
tcp->tcp_ack_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
543 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
544 |
if (tcp->tcp_fused) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
545 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
546 |
|
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 |
* 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
|
549 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
550 |
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
|
551 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
552 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
553 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
554 |
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
|
555 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
556 |
* 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
|
557 |
* 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
|
558 |
* 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
|
559 |
* 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
|
560 |
* 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
|
561 |
* 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
|
562 |
* permanently back in the direction of |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
563 |
* 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
|
564 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
565 |
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
|
566 |
tcp->tcp_rack_abs_max--; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
567 |
tcp->tcp_rack_cur_max = 2; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
568 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
569 |
mp = tcp_ack_mp(tcp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
570 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
571 |
if (mp != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
572 |
BUMP_LOCAL(tcp->tcp_obsegs); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
573 |
TCPS_BUMP_MIB(tcps, tcpOutAck); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
574 |
TCPS_BUMP_MIB(tcps, tcpOutAckDelayed); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
575 |
tcp_send_data(tcp, mp); |
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 |
} |
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 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
580 |
* 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
|
581 |
* 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
|
582 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
583 |
static void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
584 |
tcp_ip_notify(tcp_t *tcp) |
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 |
conn_t *connp = tcp->tcp_connp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
587 |
ire_t *ire; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
588 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
589 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
590 |
* 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
|
591 |
* 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
|
592 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
593 |
ire = connp->conn_ixa->ixa_ire; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
594 |
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
|
595 |
if (ire->ire_ipversion == IPV4_VERSION) { |
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 |
* 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
|
598 |
* routing protocols. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
599 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
600 |
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
|
601 |
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
|
602 |
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
|
603 |
(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
|
604 |
ire->ire_ipst); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
605 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
606 |
(void) ire_no_good(ire); |
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 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
609 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
610 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
611 |
* 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
|
612 |
* 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
|
613 |
* 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
|
614 |
* at the time it is called. |
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 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
617 |
tcp_timer(void *arg) |
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 |
mblk_t *mp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
620 |
clock_t first_threshold; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
621 |
clock_t second_threshold; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
622 |
clock_t ms; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
623 |
uint32_t mss; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
624 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
625 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
626 |
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
|
627 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
628 |
tcp->tcp_timer_tid = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
629 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
630 |
if (tcp->tcp_fused) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
631 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
632 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
633 |
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
|
634 |
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
|
635 |
switch (tcp->tcp_state) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
636 |
case TCPS_IDLE: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
637 |
case TCPS_BOUND: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
638 |
case TCPS_LISTEN: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
639 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
640 |
case TCPS_SYN_RCVD: { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
641 |
tcp_t *listener = tcp->tcp_listener; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
642 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
643 |
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
|
644 |
/* it's our first timeout */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
645 |
tcp->tcp_syn_rcvd_timeout = 1; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
646 |
mutex_enter(&listener->tcp_eager_lock); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
647 |
listener->tcp_syn_rcvd_timeout++; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
648 |
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
|
649 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
650 |
* 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
|
651 |
* 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
|
652 |
* incoming SYN request. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
653 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
654 |
MAKE_DROPPABLE(listener, tcp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
655 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
656 |
if (!listener->tcp_syn_defense && |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
657 |
(listener->tcp_syn_rcvd_timeout > |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
658 |
(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
|
659 |
(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
|
660 |
/* 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
|
661 |
listener->tcp_syn_defense = B_TRUE; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
662 |
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
|
663 |
"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
|
664 |
"SYN flood attack!", |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
665 |
ntohs(listener->tcp_connp->conn_lport)); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
666 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
667 |
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
|
668 |
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
|
669 |
KM_NOSLEEP); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
670 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
671 |
mutex_exit(&listener->tcp_eager_lock); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
672 |
} else if (listener != NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
673 |
mutex_enter(&listener->tcp_eager_lock); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
674 |
tcp->tcp_syn_rcvd_timeout++; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
675 |
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
|
676 |
!tcp->tcp_closemp_used) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
677 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
678 |
* 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
|
679 |
* 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
|
680 |
* 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
|
681 |
* 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
|
682 |
* 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
|
683 |
* 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
|
684 |
* 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
|
685 |
* resources too long. |
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 |
MAKE_DROPPABLE(listener, tcp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
688 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
689 |
mutex_exit(&listener->tcp_eager_lock); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
690 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
691 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
692 |
/* FALLTHRU */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
693 |
case TCPS_SYN_SENT: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
694 |
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
|
695 |
second_threshold = tcp->tcp_second_ctimer_threshold; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
696 |
break; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
697 |
case TCPS_ESTABLISHED: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
698 |
case TCPS_FIN_WAIT_1: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
699 |
case TCPS_CLOSING: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
700 |
case TCPS_CLOSE_WAIT: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
701 |
case TCPS_LAST_ACK: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
702 |
/* If we have data to rexmit */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
703 |
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
|
704 |
clock_t time_to_wait; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
705 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
706 |
TCPS_BUMP_MIB(tcps, tcpTimRetrans); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
707 |
if (!tcp->tcp_xmit_head) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
708 |
break; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
709 |
time_to_wait = ddi_get_lbolt() - |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
710 |
(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
|
711 |
time_to_wait = tcp->tcp_rto - |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
712 |
TICK_TO_MSEC(time_to_wait); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
713 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
714 |
* 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
|
715 |
* restart the timer. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
716 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
717 |
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
|
718 |
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
|
719 |
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
|
720 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
721 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
722 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
723 |
* 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
|
724 |
* 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
|
725 |
* 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
|
726 |
* receiving acks tcp_rput will |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
727 |
* 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
|
728 |
* 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
|
729 |
* 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
|
730 |
* backoff. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
731 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
732 |
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
|
733 |
if (connp->conn_debug) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
734 |
(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
|
735 |
SL_TRACE, "tcp_timer: zero win"); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
736 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
737 |
} else { |
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 |
* After retransmission, we need to do |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
740 |
* 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
|
741 |
* half of current effective window and |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
742 |
* cwnd to one MSS. Also reset |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
743 |
* tcp_cwnd_cnt. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
744 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
745 |
* 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
|
746 |
* 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
|
747 |
* 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
|
748 |
* 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
|
749 |
* timeout for a retransmitted segment. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
750 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
751 |
uint32_t npkt; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
752 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
753 |
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
|
754 |
npkt = ((tcp->tcp_timer_backoff ? |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
755 |
tcp->tcp_cwnd_ssthresh : |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
756 |
tcp->tcp_snxt - |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
757 |
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
|
758 |
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
|
759 |
tcp->tcp_mss; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
760 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
761 |
tcp->tcp_cwnd = tcp->tcp_mss; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
762 |
tcp->tcp_cwnd_cnt = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
763 |
if (tcp->tcp_ecn_ok) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
764 |
tcp->tcp_cwr = B_TRUE; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
765 |
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
|
766 |
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
|
767 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
768 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
769 |
break; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
770 |
} |
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 |
* 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
|
773 |
* reason can be: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
774 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
775 |
* 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
|
776 |
* 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
|
777 |
* segments. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
778 |
* 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
|
779 |
* reset our knowledge. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
780 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
781 |
* 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
|
782 |
* 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
|
783 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
784 |
if (tcp->tcp_unsent != 0) { |
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 |
* 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
|
787 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
788 |
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
|
789 |
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
|
790 |
tcp->tcp_xmit_head, B_TRUE); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
791 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
792 |
if (tcp->tcp_cwnd == 0) { |
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 |
* 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
|
795 |
* 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
|
796 |
* are "clocking out" new data when |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
797 |
* the network is really congested. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
798 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
799 |
ASSERT(tcp->tcp_ecn_ok); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
800 |
tcp->tcp_cwnd = tcp->tcp_mss; |
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 |
if (tcp->tcp_swnd == 0) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
803 |
/* Extend window for zero window probe */ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
804 |
tcp->tcp_swnd++; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
805 |
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
|
806 |
TCPS_BUMP_MIB(tcps, tcpOutWinProbe); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
807 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
808 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
809 |
* Handle timeout from sender SWS avoidance. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
810 |
* 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
|
811 |
* 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
|
812 |
* 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
|
813 |
* 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
|
814 |
* the SWS checks. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
815 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
816 |
* 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
|
817 |
* 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
|
818 |
* 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
|
819 |
* 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
|
820 |
* 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
|
821 |
* constantly and it will not affect |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
822 |
* anything. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
823 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
824 |
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
|
825 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
826 |
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
|
827 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
828 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
829 |
/* 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
|
830 |
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
|
831 |
!tcp->tcp_fin_acked) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
832 |
break; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
833 |
/* 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
|
834 |
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
|
835 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
836 |
case TCPS_FIN_WAIT_2: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
837 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
838 |
* 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
|
839 |
* 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
|
840 |
* 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
|
841 |
* case where the peer has rebooted. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
842 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
843 |
if (TCP_IS_DETACHED(tcp)) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
844 |
(void) tcp_clean_death(tcp, 0); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
845 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
846 |
TCP_TIMER_RESTART(tcp, |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
847 |
tcps->tcps_fin_wait_2_flush_interval); |
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 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
850 |
case TCPS_TIME_WAIT: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
851 |
(void) tcp_clean_death(tcp, 0); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
852 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
853 |
default: |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
854 |
if (connp->conn_debug) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
855 |
(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
|
856 |
"tcp_timer: strange state (%d) %s", |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
857 |
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
|
858 |
DISP_PORT_ONLY)); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
859 |
} |
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 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
863 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
864 |
* 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
|
865 |
* 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
|
866 |
* aggressive in aborting connections. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
867 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
868 |
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
|
869 |
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
|
870 |
second_threshold = tcp_early_abort * SECONDS; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
871 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
872 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
873 |
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
|
874 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
875 |
* 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
|
876 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
877 |
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
|
878 |
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
|
879 |
tcp->tcp_xmit_head, B_TRUE); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
880 |
|
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 |
* 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
|
883 |
* 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
|
884 |
* time... |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
885 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
886 |
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
|
887 |
(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
|
888 |
second_threshold)) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
889 |
TCPS_BUMP_MIB(tcps, tcpTimRetransDrop); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
890 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
891 |
* 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
|
892 |
* 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
|
893 |
* 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
|
894 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
895 |
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
|
896 |
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
|
897 |
"in SYN_RCVD", |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
898 |
tcp, tcp->tcp_snxt, |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
899 |
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
|
900 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
901 |
(void) tcp_clean_death(tcp, |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
902 |
tcp->tcp_client_errno ? |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
903 |
tcp->tcp_client_errno : ETIMEDOUT); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
904 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
905 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
906 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
907 |
* 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
|
908 |
* abort connection in zero window probing. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
909 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
910 |
if (tcps->tcps_reclaim) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
911 |
(void) tcp_clean_death(tcp, |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
912 |
tcp->tcp_client_errno ? |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
913 |
tcp->tcp_client_errno : ETIMEDOUT); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
914 |
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
|
915 |
return; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
916 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
917 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
918 |
* 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
|
919 |
* 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
|
920 |
* 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
|
921 |
* This is also to avoid overflow. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
922 |
* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
923 |
* 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
|
924 |
* 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
|
925 |
* later if new timeout value is greater than |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
926 |
* tcp_rexmit_interval_max. In the case when |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
927 |
* tcp_rexmit_interval_max is greater than |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
928 |
* second_threshold, it means that we will wait |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
929 |
* longer than second_threshold to send the next |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
930 |
* window probe. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
931 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
932 |
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
|
933 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
934 |
} else if (ms > first_threshold) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
935 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
936 |
* 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
|
937 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
938 |
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
|
939 |
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
|
940 |
tcp->tcp_xmit_head, B_TRUE); |
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 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
943 |
* 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
|
944 |
* 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
|
945 |
* 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
|
946 |
* 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
|
947 |
* 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
|
948 |
* window probe. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
949 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
950 |
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
|
951 |
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
|
952 |
(tcp->tcp_rtt_sa >> 5); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
953 |
tcp->tcp_rtt_sa = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
954 |
tcp_ip_notify(tcp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
955 |
tcp->tcp_rtt_update = 0; |
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 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
958 |
tcp->tcp_timer_backoff++; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
959 |
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
|
960 |
tcps->tcps_rexmit_interval_extra + (tcp->tcp_rtt_sa >> 5)) < |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
961 |
tcps->tcps_rexmit_interval_min) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
962 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
963 |
* 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
|
964 |
* 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
|
965 |
* and do the backoff. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
966 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
967 |
ms = tcps->tcps_rexmit_interval_min << tcp->tcp_timer_backoff; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
968 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
969 |
ms <<= tcp->tcp_timer_backoff; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
970 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
971 |
if (ms > tcps->tcps_rexmit_interval_max) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
972 |
ms = tcps->tcps_rexmit_interval_max; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
973 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
974 |
* 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
|
975 |
* overflow. |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
976 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
977 |
tcp->tcp_timer_backoff--; |
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 += ms; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
980 |
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
|
981 |
tcp->tcp_rto = ms; |
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 |
TCP_TIMER_RESTART(tcp, ms); |
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 |
* 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
|
986 |
* 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
|
987 |
* 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
|
988 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
989 |
tcp->tcp_set_timer = 1; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
990 |
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
|
991 |
if (mss > tcp->tcp_mss) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
992 |
mss = tcp->tcp_mss; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
993 |
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
|
994 |
mss = tcp->tcp_swnd; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
995 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
996 |
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
|
997 |
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
|
998 |
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
|
999 |
B_TRUE); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1000 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1001 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1002 |
* 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
|
1003 |
* 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
|
1004 |
* 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
|
1005 |
* 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
|
1006 |
*/ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1007 |
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
|
1008 |
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
|
1009 |
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
|
1010 |
(tcp->tcp_unsent == 0)) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1011 |
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
|
1012 |
} else { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1013 |
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
|
1014 |
} |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1015 |
tcp->tcp_rexmit = B_TRUE; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1016 |
tcp->tcp_dupack_cnt = 0; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1017 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1018 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1019 |
* 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
|
1020 |
*/ |
12056
4811a59c20b7
6935348 tcp_sack_info should always be there
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
11754
diff
changeset
|
1021 |
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
|
1022 |
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
|
1023 |
if (mp == NULL) { |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1024 |
return; |
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 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1027 |
tcp->tcp_csuna = tcp->tcp_snxt; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1028 |
TCPS_BUMP_MIB(tcps, tcpRetransSegs); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1029 |
TCPS_UPDATE_MIB(tcps, tcpRetransBytes, mss); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1030 |
tcp_send_data(tcp, mp); |
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 |
} |
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 |
/* |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1035 |
* 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
|
1036 |
* expires. |
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 |
void |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1039 |
tcp_close_linger_timeout(void *arg) |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1040 |
{ |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1041 |
conn_t *connp = (conn_t *)arg; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1042 |
tcp_t *tcp = connp->conn_tcp; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1043 |
|
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1044 |
tcp->tcp_client_errno = ETIMEDOUT; |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1045 |
tcp_stop_lingering(tcp); |
251da8f4caaa
PSARC 2010/042 increase max TCP_INIT_CWND
Kacheong Poon <Kacheong.Poon@Sun.COM>
parents:
diff
changeset
|
1046 |
} |