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


14058 static void
14059 ip_kstat_fini(netstackid_t stackid, kstat_t *ksp)
14060 {
14061         if (ksp != NULL) {
14062                 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
14063                 kstat_delete_netstack(ksp, stackid);
14064         }
14065 }
14066 
14067 static int
14068 ip_kstat_update(kstat_t *kp, int rw)
14069 {
14070         ip_named_kstat_t *ipkp;
14071         mib2_ipIfStatsEntry_t ipmib;
14072         ill_walk_context_t ctx;
14073         ill_t *ill;
14074         netstackid_t    stackid = (zoneid_t)(uintptr_t)kp->ks_private;
14075         netstack_t      *ns;
14076         ip_stack_t      *ipst;
14077 
14078         if (kp == NULL || kp->ks_data == NULL)
14079                 return (EIO);
14080 
14081         if (rw == KSTAT_WRITE)
14082                 return (EACCES);
14083 
14084         ns = netstack_find_by_stackid(stackid);
14085         if (ns == NULL)
14086                 return (-1);
14087         ipst = ns->netstack_ip;
14088         if (ipst == NULL) {
14089                 netstack_rele(ns);
14090                 return (-1);
14091         }
14092         ipkp = (ip_named_kstat_t *)kp->ks_data;
14093 
14094         bcopy(&ipst->ips_ip_mib, &ipmib, sizeof (ipmib));
14095         rw_enter(&ipst->ips_ill_g_lock, RW_READER);
14096         ill = ILL_START_WALK_V4(&ctx, ipst);
14097         for (; ill != NULL; ill = ill_next(&ctx, ill))
14098                 ip_mib2_add_ip_stats(&ipmib, ill->ill_ip_mib);


14195         return (ksp);
14196 }
14197 
14198 static void
14199 icmp_kstat_fini(netstackid_t stackid, kstat_t *ksp)
14200 {
14201         if (ksp != NULL) {
14202                 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
14203                 kstat_delete_netstack(ksp, stackid);
14204         }
14205 }
14206 
14207 static int
14208 icmp_kstat_update(kstat_t *kp, int rw)
14209 {
14210         icmp_named_kstat_t *icmpkp;
14211         netstackid_t    stackid = (zoneid_t)(uintptr_t)kp->ks_private;
14212         netstack_t      *ns;
14213         ip_stack_t      *ipst;
14214 
14215         if ((kp == NULL) || (kp->ks_data == NULL))
14216                 return (EIO);
14217 
14218         if (rw == KSTAT_WRITE)
14219                 return (EACCES);
14220 
14221         ns = netstack_find_by_stackid(stackid);
14222         if (ns == NULL)
14223                 return (-1);
14224         ipst = ns->netstack_ip;
14225         if (ipst == NULL) {
14226                 netstack_rele(ns);
14227                 return (-1);
14228         }
14229         icmpkp = (icmp_named_kstat_t *)kp->ks_data;
14230 
14231         icmpkp->inMsgs.value.ui32 =      ipst->ips_icmp_mib.icmpInMsgs;
14232         icmpkp->inErrors.value.ui32 =            ipst->ips_icmp_mib.icmpInErrors;
14233         icmpkp->inDestUnreachs.value.ui32 =
14234             ipst->ips_icmp_mib.icmpInDestUnreachs;
14235         icmpkp->inTimeExcds.value.ui32 =    ipst->ips_icmp_mib.icmpInTimeExcds;




14058 static void
14059 ip_kstat_fini(netstackid_t stackid, kstat_t *ksp)
14060 {
14061         if (ksp != NULL) {
14062                 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
14063                 kstat_delete_netstack(ksp, stackid);
14064         }
14065 }
14066 
14067 static int
14068 ip_kstat_update(kstat_t *kp, int rw)
14069 {
14070         ip_named_kstat_t *ipkp;
14071         mib2_ipIfStatsEntry_t ipmib;
14072         ill_walk_context_t ctx;
14073         ill_t *ill;
14074         netstackid_t    stackid = (zoneid_t)(uintptr_t)kp->ks_private;
14075         netstack_t      *ns;
14076         ip_stack_t      *ipst;
14077 
14078         if (kp->ks_data == NULL)
14079                 return (EIO);
14080 
14081         if (rw == KSTAT_WRITE)
14082                 return (EACCES);
14083 
14084         ns = netstack_find_by_stackid(stackid);
14085         if (ns == NULL)
14086                 return (-1);
14087         ipst = ns->netstack_ip;
14088         if (ipst == NULL) {
14089                 netstack_rele(ns);
14090                 return (-1);
14091         }
14092         ipkp = (ip_named_kstat_t *)kp->ks_data;
14093 
14094         bcopy(&ipst->ips_ip_mib, &ipmib, sizeof (ipmib));
14095         rw_enter(&ipst->ips_ill_g_lock, RW_READER);
14096         ill = ILL_START_WALK_V4(&ctx, ipst);
14097         for (; ill != NULL; ill = ill_next(&ctx, ill))
14098                 ip_mib2_add_ip_stats(&ipmib, ill->ill_ip_mib);


14195         return (ksp);
14196 }
14197 
14198 static void
14199 icmp_kstat_fini(netstackid_t stackid, kstat_t *ksp)
14200 {
14201         if (ksp != NULL) {
14202                 ASSERT(stackid == (netstackid_t)(uintptr_t)ksp->ks_private);
14203                 kstat_delete_netstack(ksp, stackid);
14204         }
14205 }
14206 
14207 static int
14208 icmp_kstat_update(kstat_t *kp, int rw)
14209 {
14210         icmp_named_kstat_t *icmpkp;
14211         netstackid_t    stackid = (zoneid_t)(uintptr_t)kp->ks_private;
14212         netstack_t      *ns;
14213         ip_stack_t      *ipst;
14214 
14215         if (kp->ks_data == NULL)
14216                 return (EIO);
14217 
14218         if (rw == KSTAT_WRITE)
14219                 return (EACCES);
14220 
14221         ns = netstack_find_by_stackid(stackid);
14222         if (ns == NULL)
14223                 return (-1);
14224         ipst = ns->netstack_ip;
14225         if (ipst == NULL) {
14226                 netstack_rele(ns);
14227                 return (-1);
14228         }
14229         icmpkp = (icmp_named_kstat_t *)kp->ks_data;
14230 
14231         icmpkp->inMsgs.value.ui32 =      ipst->ips_icmp_mib.icmpInMsgs;
14232         icmpkp->inErrors.value.ui32 =            ipst->ips_icmp_mib.icmpInErrors;
14233         icmpkp->inDestUnreachs.value.ui32 =
14234             ipst->ips_icmp_mib.icmpInDestUnreachs;
14235         icmpkp->inTimeExcds.value.ui32 =    ipst->ips_icmp_mib.icmpInTimeExcds;