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>


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #include <sys/types.h>
  26 #include <sys/stream.h>
  27 #include <sys/strsun.h>
  28 #include <sys/strsubr.h>
  29 #include <sys/debug.h>
  30 #include <sys/sdt.h>
  31 #include <sys/cmn_err.h>
  32 #include <sys/tihdr.h>
  33 
  34 #include <inet/common.h>
  35 #include <inet/optcom.h>
  36 #include <inet/ip.h>
  37 #include <inet/ip_if.h>
  38 #include <inet/ip_impl.h>
  39 #include <inet/tcp.h>
  40 #include <inet/tcp_impl.h>
  41 #include <inet/ipsec_impl.h>
  42 #include <inet/ipclassifier.h>


 628                     uint_t, send_size, uint_t, peer_tcp->tcp_rcv_cnt);
 629         } else if (flow_stopped && !peer_data_queued &&
 630             (TCP_UNSENT_BYTES(tcp) <= connp->conn_sndlowat)) {
 631                 tcp_clrqfull(tcp);
 632                 TCP_STAT(tcps, tcp_fusion_backenabled);
 633                 flow_stopped = B_FALSE;
 634         }
 635         mutex_exit(&tcp->tcp_non_sq_lock);
 636 
 637         ipst->ips_loopback_packets++;
 638         tcp->tcp_last_sent_len = send_size;
 639 
 640         /* Need to adjust the following SNMP MIB-related variables */
 641         tcp->tcp_snxt += send_size;
 642         tcp->tcp_suna = tcp->tcp_snxt;
 643         peer_tcp->tcp_rnxt += recv_size;
 644         peer_tcp->tcp_last_recv_len = recv_size;
 645         peer_tcp->tcp_rack = peer_tcp->tcp_rnxt;
 646 
 647         TCPS_BUMP_MIB(tcps, tcpOutDataSegs);

 648         TCPS_UPDATE_MIB(tcps, tcpOutDataBytes, send_size);


 649 
 650         TCPS_BUMP_MIB(tcps, tcpHCInSegs);
 651         TCPS_BUMP_MIB(tcps, tcpInDataInorderSegs);
 652         TCPS_UPDATE_MIB(tcps, tcpInDataInorderBytes, send_size);


 653 
 654         BUMP_LOCAL(tcp->tcp_obsegs);
 655         BUMP_LOCAL(peer_tcp->tcp_ibsegs);
 656 
 657         DTRACE_TCP5(send, void, NULL, ip_xmit_attr_t *, connp->conn_ixa,
 658             __dtrace_tcp_void_ip_t *, NULL, tcp_t *, tcp,
 659             __dtrace_tcp_tcph_t *, NULL);
 660         DTRACE_TCP5(receive, void, NULL, ip_xmit_attr_t *,
 661             peer_connp->conn_ixa, __dtrace_tcp_void_ip_t *, NULL,
 662             tcp_t *, peer_tcp, __dtrace_tcp_tcph_t *, NULL);
 663 
 664         if (!IPCL_IS_NONSTR(peer_tcp->tcp_connp) &&
 665             !TCP_IS_DETACHED(peer_tcp)) {
 666                 /*
 667                  * Drain the peer's receive queue it has urgent data or if
 668                  * we're not flow-controlled.
 669                  */
 670                 if (urgent || !flow_stopped) {
 671                         ASSERT(peer_tcp->tcp_rcv_list != NULL);
 672                         /*
 673                          * For TLI-based streams, a thread in tcp_accept_swap()
 674                          * can race with us.  That thread will ensure that the
 675                          * correct peer_connp->conn_rq is globally visible
 676                          * before peer_tcp->tcp_detached is visible as clear,




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2015 by Delphix. All rights reserved.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/stream.h>
  28 #include <sys/strsun.h>
  29 #include <sys/strsubr.h>
  30 #include <sys/debug.h>
  31 #include <sys/sdt.h>
  32 #include <sys/cmn_err.h>
  33 #include <sys/tihdr.h>
  34 
  35 #include <inet/common.h>
  36 #include <inet/optcom.h>
  37 #include <inet/ip.h>
  38 #include <inet/ip_if.h>
  39 #include <inet/ip_impl.h>
  40 #include <inet/tcp.h>
  41 #include <inet/tcp_impl.h>
  42 #include <inet/ipsec_impl.h>
  43 #include <inet/ipclassifier.h>


 629                     uint_t, send_size, uint_t, peer_tcp->tcp_rcv_cnt);
 630         } else if (flow_stopped && !peer_data_queued &&
 631             (TCP_UNSENT_BYTES(tcp) <= connp->conn_sndlowat)) {
 632                 tcp_clrqfull(tcp);
 633                 TCP_STAT(tcps, tcp_fusion_backenabled);
 634                 flow_stopped = B_FALSE;
 635         }
 636         mutex_exit(&tcp->tcp_non_sq_lock);
 637 
 638         ipst->ips_loopback_packets++;
 639         tcp->tcp_last_sent_len = send_size;
 640 
 641         /* Need to adjust the following SNMP MIB-related variables */
 642         tcp->tcp_snxt += send_size;
 643         tcp->tcp_suna = tcp->tcp_snxt;
 644         peer_tcp->tcp_rnxt += recv_size;
 645         peer_tcp->tcp_last_recv_len = recv_size;
 646         peer_tcp->tcp_rack = peer_tcp->tcp_rnxt;
 647 
 648         TCPS_BUMP_MIB(tcps, tcpOutDataSegs);
 649         TCPS_BUMP_MIB(tcps, tcpHCOutSegs);
 650         TCPS_UPDATE_MIB(tcps, tcpOutDataBytes, send_size);
 651         tcp->tcp_cs.tcp_out_data_bytes += send_size;
 652         tcp->tcp_cs.tcp_out_data_segs++;
 653 
 654         TCPS_BUMP_MIB(tcps, tcpHCInSegs);
 655         TCPS_BUMP_MIB(tcps, tcpInDataInorderSegs);
 656         TCPS_UPDATE_MIB(tcps, tcpInDataInorderBytes, send_size);
 657         peer_tcp->tcp_cs.tcp_in_data_inorder_bytes += send_size;
 658         peer_tcp->tcp_cs.tcp_in_data_inorder_segs++;
 659 



 660         DTRACE_TCP5(send, void, NULL, ip_xmit_attr_t *, connp->conn_ixa,
 661             __dtrace_tcp_void_ip_t *, NULL, tcp_t *, tcp,
 662             __dtrace_tcp_tcph_t *, NULL);
 663         DTRACE_TCP5(receive, void, NULL, ip_xmit_attr_t *,
 664             peer_connp->conn_ixa, __dtrace_tcp_void_ip_t *, NULL,
 665             tcp_t *, peer_tcp, __dtrace_tcp_tcph_t *, NULL);
 666 
 667         if (!IPCL_IS_NONSTR(peer_tcp->tcp_connp) &&
 668             !TCP_IS_DETACHED(peer_tcp)) {
 669                 /*
 670                  * Drain the peer's receive queue it has urgent data or if
 671                  * we're not flow-controlled.
 672                  */
 673                 if (urgent || !flow_stopped) {
 674                         ASSERT(peer_tcp->tcp_rcv_list != NULL);
 675                         /*
 676                          * For TLI-based streams, a thread in tcp_accept_swap()
 677                          * can race with us.  That thread will ensure that the
 678                          * correct peer_connp->conn_rq is globally visible
 679                          * before peer_tcp->tcp_detached is visible as clear,