Print this page
3065 some functions in the tcp module can be static


  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/tihdr.h>
  28 #include <sys/policy.h>
  29 #include <sys/tsol/tnet.h>
  30 
  31 #include <inet/common.h>
  32 #include <inet/ip.h>
  33 #include <inet/tcp.h>
  34 #include <inet/tcp_impl.h>
  35 #include <inet/tcp_stats.h>
  36 #include <inet/kstatcom.h>
  37 #include <inet/snmpcom.h>
  38 
  39 static int      tcp_kstat_update(kstat_t *kp, int rw);
  40 static int      tcp_kstat2_update(kstat_t *kp, int rw);

  41 static void     tcp_sum_mib(tcp_stack_t *, mib2_tcp_t *);
  42 
  43 static void     tcp_add_mib(mib2_tcp_t *, mib2_tcp_t *);
  44 static void     tcp_add_stats(tcp_stat_counter_t *, tcp_stat_t *);
  45 static void     tcp_clr_stats(tcp_stat_t *);
  46 
  47 tcp_g_stat_t    tcp_g_statistics;
  48 kstat_t         *tcp_g_kstat;
  49 
  50 /* Translate TCP state to MIB2 TCP state. */
  51 static int
  52 tcp_snmp_state(tcp_t *tcp)
  53 {
  54         if (tcp == NULL)
  55                 return (0);
  56 
  57         switch (tcp->tcp_state) {
  58         case TCPS_CLOSED:
  59         case TCPS_IDLE: /* RFC1213 doesn't have analogue for IDLE & BOUND */
  60         case TCPS_BOUND:


 784 
 785         stats = (tcp_stat_t *)kp->ks_data;
 786         tcp_clr_stats(stats);
 787 
 788         /*
 789          * tcps_sc_cnt may change in the middle of the loop.  It is better
 790          * to get its value first.
 791          */
 792         cnt = tcps->tcps_sc_cnt;
 793         for (i = 0; i < cnt; i++)
 794                 tcp_add_stats(&tcps->tcps_sc[i]->tcp_sc_stats, stats);
 795 
 796         netstack_rele(ns);
 797         return (0);
 798 }
 799 
 800 /*
 801  * To add stats from one mib2_tcp_t to another.  Static fields are not added.
 802  * The caller should set them up propertly.
 803  */
 804 void
 805 tcp_add_mib(mib2_tcp_t *from, mib2_tcp_t *to)
 806 {
 807         to->tcpActiveOpens += from->tcpActiveOpens;
 808         to->tcpPassiveOpens += from->tcpPassiveOpens;
 809         to->tcpAttemptFails += from->tcpAttemptFails;
 810         to->tcpEstabResets += from->tcpEstabResets;
 811         to->tcpInSegs += from->tcpInSegs;
 812         to->tcpOutSegs += from->tcpOutSegs;
 813         to->tcpRetransSegs += from->tcpRetransSegs;
 814         to->tcpOutRsts += from->tcpOutRsts;
 815 
 816         to->tcpOutDataSegs += from->tcpOutDataSegs;
 817         to->tcpOutDataBytes += from->tcpOutDataBytes;
 818         to->tcpRetransBytes += from->tcpRetransBytes;
 819         to->tcpOutAck += from->tcpOutAck;
 820         to->tcpOutAckDelayed += from->tcpOutAckDelayed;
 821         to->tcpOutUrg += from->tcpOutUrg;
 822         to->tcpOutWinUpdate += from->tcpOutWinUpdate;
 823         to->tcpOutWinProbe += from->tcpOutWinProbe;
 824         to->tcpOutControl += from->tcpOutControl;




  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/tihdr.h>
  28 #include <sys/policy.h>
  29 #include <sys/tsol/tnet.h>
  30 
  31 #include <inet/common.h>
  32 #include <inet/ip.h>
  33 #include <inet/tcp.h>
  34 #include <inet/tcp_impl.h>
  35 #include <inet/tcp_stats.h>
  36 #include <inet/kstatcom.h>
  37 #include <inet/snmpcom.h>
  38 
  39 static int      tcp_snmp_state(tcp_t *);
  40 static int      tcp_kstat_update(kstat_t *, int);
  41 static int      tcp_kstat2_update(kstat_t *, int);
  42 static void     tcp_sum_mib(tcp_stack_t *, mib2_tcp_t *);
  43 
  44 static void     tcp_add_mib(mib2_tcp_t *, mib2_tcp_t *);
  45 static void     tcp_add_stats(tcp_stat_counter_t *, tcp_stat_t *);
  46 static void     tcp_clr_stats(tcp_stat_t *);
  47 
  48 tcp_g_stat_t    tcp_g_statistics;
  49 kstat_t         *tcp_g_kstat;
  50 
  51 /* Translate TCP state to MIB2 TCP state. */
  52 static int
  53 tcp_snmp_state(tcp_t *tcp)
  54 {
  55         if (tcp == NULL)
  56                 return (0);
  57 
  58         switch (tcp->tcp_state) {
  59         case TCPS_CLOSED:
  60         case TCPS_IDLE: /* RFC1213 doesn't have analogue for IDLE & BOUND */
  61         case TCPS_BOUND:


 785 
 786         stats = (tcp_stat_t *)kp->ks_data;
 787         tcp_clr_stats(stats);
 788 
 789         /*
 790          * tcps_sc_cnt may change in the middle of the loop.  It is better
 791          * to get its value first.
 792          */
 793         cnt = tcps->tcps_sc_cnt;
 794         for (i = 0; i < cnt; i++)
 795                 tcp_add_stats(&tcps->tcps_sc[i]->tcp_sc_stats, stats);
 796 
 797         netstack_rele(ns);
 798         return (0);
 799 }
 800 
 801 /*
 802  * To add stats from one mib2_tcp_t to another.  Static fields are not added.
 803  * The caller should set them up propertly.
 804  */
 805 static void
 806 tcp_add_mib(mib2_tcp_t *from, mib2_tcp_t *to)
 807 {
 808         to->tcpActiveOpens += from->tcpActiveOpens;
 809         to->tcpPassiveOpens += from->tcpPassiveOpens;
 810         to->tcpAttemptFails += from->tcpAttemptFails;
 811         to->tcpEstabResets += from->tcpEstabResets;
 812         to->tcpInSegs += from->tcpInSegs;
 813         to->tcpOutSegs += from->tcpOutSegs;
 814         to->tcpRetransSegs += from->tcpRetransSegs;
 815         to->tcpOutRsts += from->tcpOutRsts;
 816 
 817         to->tcpOutDataSegs += from->tcpOutDataSegs;
 818         to->tcpOutDataBytes += from->tcpOutDataBytes;
 819         to->tcpRetransBytes += from->tcpRetransBytes;
 820         to->tcpOutAck += from->tcpOutAck;
 821         to->tcpOutAckDelayed += from->tcpOutAckDelayed;
 822         to->tcpOutUrg += from->tcpOutUrg;
 823         to->tcpOutWinUpdate += from->tcpOutWinUpdate;
 824         to->tcpOutWinProbe += from->tcpOutWinProbe;
 825         to->tcpOutControl += from->tcpOutControl;