Print this page
11547 Want connstat(1M) command to display per-connection TCP statistics
Portions contributed by: Cody Peter Mello <cody.mello@joyent.com>
Portions contributed by: Ahmed G <ahmedg@delphix.com>
Reviewed by: Jason King <jason.king@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/tcp/tcp.c
          +++ new/usr/src/uts/common/inet/tcp/tcp.c
↓ open down ↓ 1223 lines elided ↑ open up ↑
1224 1224  void
1225 1225  tcp_closei_local(tcp_t *tcp)
1226 1226  {
1227 1227          conn_t          *connp = tcp->tcp_connp;
1228 1228          tcp_stack_t     *tcps = tcp->tcp_tcps;
1229 1229          int32_t         oldstate;
1230 1230  
1231 1231          if (!TCP_IS_SOCKET(tcp))
1232 1232                  tcp_acceptor_hash_remove(tcp);
1233 1233  
1234      -        TCPS_UPDATE_MIB(tcps, tcpHCInSegs, tcp->tcp_ibsegs);
1235      -        tcp->tcp_ibsegs = 0;
1236      -        TCPS_UPDATE_MIB(tcps, tcpHCOutSegs, tcp->tcp_obsegs);
1237      -        tcp->tcp_obsegs = 0;
1238      -
1239 1234          /*
1240 1235           * This can be called via tcp_time_wait_processing() if TCP gets a
1241 1236           * SYN with sequence number outside the TIME-WAIT connection's
1242 1237           * window.  So we need to check for TIME-WAIT state here as the
1243 1238           * connection counter is already decremented.  See SET_TIME_WAIT()
1244 1239           * macro
1245 1240           */
1246 1241          if (tcp->tcp_state >= TCPS_ESTABLISHED &&
1247 1242              tcp->tcp_state < TCPS_TIME_WAIT) {
1248 1243                  TCPS_CONN_DEC(tcps);
↓ open down ↓ 648 lines elided ↑ open up ↑
1897 1892          ASSERT(tcp->tcp_listener == NULL);
1898 1893          ASSERT((connp->conn_family == AF_INET &&
1899 1894              connp->conn_ipversion == IPV4_VERSION) ||
1900 1895              (connp->conn_family == AF_INET6 &&
1901 1896              (connp->conn_ipversion == IPV4_VERSION ||
1902 1897              connp->conn_ipversion == IPV6_VERSION)));
1903 1898  
1904 1899          /* Cancel outstanding timers */
1905 1900          tcp_timers_stop(tcp);
1906 1901  
1907      -        /*
1908      -         * Reset everything in the state vector, after updating global
1909      -         * MIB data from instance counters.
1910      -         */
1911      -        TCPS_UPDATE_MIB(tcps, tcpHCInSegs, tcp->tcp_ibsegs);
1912      -        tcp->tcp_ibsegs = 0;
1913      -        TCPS_UPDATE_MIB(tcps, tcpHCOutSegs, tcp->tcp_obsegs);
1914      -        tcp->tcp_obsegs = 0;
1915      -
1916 1902          tcp_close_mpp(&tcp->tcp_xmit_head);
1917 1903          if (tcp->tcp_snd_zcopy_aware)
1918 1904                  tcp_zcopy_notify(tcp);
1919 1905          tcp->tcp_xmit_last = tcp->tcp_xmit_tail = NULL;
1920 1906          tcp->tcp_unsent = tcp->tcp_xmit_tail_unsent = 0;
1921 1907          mutex_enter(&tcp->tcp_non_sq_lock);
1922 1908          if (tcp->tcp_flow_stopped &&
1923 1909              TCP_UNSENT_BYTES(tcp) <= connp->conn_sndlowat) {
1924 1910                  tcp_clrqfull(tcp);
1925 1911          }
↓ open down ↓ 151 lines elided ↑ open up ↑
2077 2063          ASSERT(tcp->tcp_xmit_last == NULL);
2078 2064          ASSERT(tcp->tcp_unsent == 0);
2079 2065          ASSERT(tcp->tcp_xmit_tail == NULL);
2080 2066          ASSERT(tcp->tcp_xmit_tail_unsent == 0);
2081 2067  
2082 2068          tcp->tcp_snxt = 0;                      /* Displayed in mib */
2083 2069          tcp->tcp_suna = 0;                      /* Displayed in mib */
2084 2070          tcp->tcp_swnd = 0;
2085 2071          DONTCARE(tcp->tcp_cwnd);        /* Init in tcp_process_options */
2086 2072  
2087      -        ASSERT(tcp->tcp_ibsegs == 0);
2088      -        ASSERT(tcp->tcp_obsegs == 0);
2089      -
2090 2073          if (connp->conn_ht_iphc != NULL) {
2091 2074                  kmem_free(connp->conn_ht_iphc, connp->conn_ht_iphc_allocated);
2092 2075                  connp->conn_ht_iphc = NULL;
2093 2076                  connp->conn_ht_iphc_allocated = 0;
2094 2077                  connp->conn_ht_iphc_len = 0;
2095 2078                  connp->conn_ht_ulp = NULL;
2096 2079                  connp->conn_ht_ulp_len = 0;
2097 2080                  tcp->tcp_ipha = NULL;
2098 2081                  tcp->tcp_ip6h = NULL;
2099 2082                  tcp->tcp_tcpha = NULL;
↓ open down ↓ 71 lines elided ↑ open up ↑
2171 2154          ASSERT(tcp->tcp_rcv_cnt == 0);
2172 2155  
2173 2156          DONTCARE(tcp->tcp_cwnd_ssthresh); /* Init in tcp_set_destination */
2174 2157          DONTCARE(tcp->tcp_cwnd_max);            /* Init in tcp_init_values */
2175 2158          tcp->tcp_csuna = 0;
2176 2159  
2177 2160          tcp->tcp_rto = 0;                       /* Displayed in MIB */
2178 2161          DONTCARE(tcp->tcp_rtt_sa);              /* Init in tcp_init_values */
2179 2162          DONTCARE(tcp->tcp_rtt_sd);              /* Init in tcp_init_values */
2180 2163          tcp->tcp_rtt_update = 0;
     2164 +        tcp->tcp_rtt_sum = 0;
     2165 +        tcp->tcp_rtt_cnt = 0;
2181 2166  
2182 2167          DONTCARE(tcp->tcp_swl1); /* Init in case TCPS_LISTEN/TCPS_SYN_SENT */
2183 2168          DONTCARE(tcp->tcp_swl2); /* Init in case TCPS_LISTEN/TCPS_SYN_SENT */
2184 2169  
2185 2170          tcp->tcp_rack = 0;                      /* Displayed in mib */
2186 2171          tcp->tcp_rack_cnt = 0;
2187 2172          tcp->tcp_rack_cur_max = 0;
2188 2173          tcp->tcp_rack_abs_max = 0;
2189 2174  
2190 2175          tcp->tcp_max_swnd = 0;
↓ open down ↓ 2282 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX