Print this page
10096 kstat update routines shouldn't check for NULL kstat


   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 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 




  26 #include <sys/types.h>
  27 #include <sys/stream.h>
  28 #include <sys/cmn_err.h>
  29 #define _SUN_TPI_VERSION 2
  30 #include <sys/tihdr.h>
  31 #include <sys/ddi.h>
  32 #include <sys/sunddi.h>
  33 #include <sys/tsol/tndb.h>
  34 
  35 #include <netinet/in.h>
  36 
  37 #include <inet/common.h>
  38 #include <inet/ip.h>
  39 #include <inet/mib2.h>
  40 #include <inet/snmpcom.h>
  41 #include <inet/kstatcom.h>
  42 #include <inet/ipclassifier.h>
  43 #include "sctp_impl.h"
  44 #include "sctp_addr.h"
  45 
  46 static void sctp_clr_kstats2(sctp_kstat_t *);
  47 static void sctp_add_kstats2(sctp_kstat_counter_t *, sctp_kstat_t *);
  48 static int sctp_snmp_state(sctp_t *);
  49 static void sctp_sum_mib(sctp_stack_t *, mib2_sctp_t *);
  50 static void sctp_add_mib(mib2_sctp_t *, mib2_sctp_t *);
  51 
  52 static int
  53 sctp_kstat_update(kstat_t *kp, int rw)
  54 {
  55         sctp_named_kstat_t      *sctpkp;
  56         sctp_t                  *sctp, *sctp_prev;
  57         zoneid_t        myzoneid;
  58         netstackid_t    stackid = (netstackid_t)(uintptr_t)kp->ks_private;
  59         netstack_t      *ns;
  60         sctp_stack_t    *sctps;
  61         mib2_sctp_t     sctp_mib;
  62 
  63         if (kp == NULL|| kp->ks_data == NULL)
  64                 return (EIO);
  65 
  66         if (rw == KSTAT_WRITE)
  67                 return (EACCES);
  68 
  69         ns = netstack_find_by_stackid(stackid);
  70         if (ns == NULL)
  71                 return (-1);
  72         sctps = ns->netstack_sctp;
  73         if (sctps == NULL) {
  74                 netstack_rele(ns);
  75                 return (-1);
  76         }
  77 
  78         /*
  79          * For all exclusive netstacks, the zone ID is always GLOBAL_ZONEID.
  80          */
  81         if (stackid != GLOBAL_NETSTACKID)
  82                 myzoneid = GLOBAL_ZONEID;
  83         else




   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 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 #include <sys/types.h>
  31 #include <sys/stream.h>
  32 #include <sys/cmn_err.h>
  33 #define _SUN_TPI_VERSION 2
  34 #include <sys/tihdr.h>
  35 #include <sys/ddi.h>
  36 #include <sys/sunddi.h>
  37 #include <sys/tsol/tndb.h>
  38 
  39 #include <netinet/in.h>
  40 
  41 #include <inet/common.h>
  42 #include <inet/ip.h>
  43 #include <inet/mib2.h>
  44 #include <inet/snmpcom.h>
  45 #include <inet/kstatcom.h>
  46 #include <inet/ipclassifier.h>
  47 #include "sctp_impl.h"
  48 #include "sctp_addr.h"
  49 
  50 static void sctp_clr_kstats2(sctp_kstat_t *);
  51 static void sctp_add_kstats2(sctp_kstat_counter_t *, sctp_kstat_t *);
  52 static int sctp_snmp_state(sctp_t *);
  53 static void sctp_sum_mib(sctp_stack_t *, mib2_sctp_t *);
  54 static void sctp_add_mib(mib2_sctp_t *, mib2_sctp_t *);
  55 
  56 static int
  57 sctp_kstat_update(kstat_t *kp, int rw)
  58 {
  59         sctp_named_kstat_t      *sctpkp;
  60         sctp_t                  *sctp, *sctp_prev;
  61         zoneid_t        myzoneid;
  62         netstackid_t    stackid = (netstackid_t)(uintptr_t)kp->ks_private;
  63         netstack_t      *ns;
  64         sctp_stack_t    *sctps;
  65         mib2_sctp_t     sctp_mib;
  66 
  67         if (kp->ks_data == NULL)
  68                 return (EIO);
  69 
  70         if (rw == KSTAT_WRITE)
  71                 return (EACCES);
  72 
  73         ns = netstack_find_by_stackid(stackid);
  74         if (ns == NULL)
  75                 return (-1);
  76         sctps = ns->netstack_sctp;
  77         if (sctps == NULL) {
  78                 netstack_rele(ns);
  79                 return (-1);
  80         }
  81 
  82         /*
  83          * For all exclusive netstacks, the zone ID is always GLOBAL_ZONEID.
  84          */
  85         if (stackid != GLOBAL_NETSTACKID)
  86                 myzoneid = GLOBAL_ZONEID;
  87         else