Print this page
1915 IPsec kstats shouldn't be persistent


   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 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved.

  25  */
  26 
  27 #include <sys/types.h>
  28 #include <sys/stream.h>
  29 #include <sys/stropts.h>
  30 #include <sys/errno.h>
  31 #include <sys/strlog.h>
  32 #include <sys/tihdr.h>
  33 #include <sys/socket.h>
  34 #include <sys/ddi.h>
  35 #include <sys/sunddi.h>
  36 #include <sys/mkdev.h>
  37 #include <sys/kmem.h>
  38 #include <sys/zone.h>
  39 #include <sys/sysmacros.h>
  40 #include <sys/cmn_err.h>
  41 #include <sys/vtrace.h>
  42 #include <sys/debug.h>
  43 #include <sys/atomic.h>
  44 #include <sys/strsun.h>


 156 
 157 static struct qinit winit = {
 158         (pfi_t)ipsecah_wput, NULL, ipsecah_open, ipsecah_close, NULL, &info,
 159         NULL
 160 };
 161 
 162 struct streamtab ipsecahinfo = {
 163         &rinit, &winit, NULL, NULL
 164 };
 165 
 166 static int ah_kstat_update(kstat_t *, int);
 167 
 168 uint64_t ipsacq_maxpackets = IPSACQ_MAXPACKETS;
 169 
 170 static boolean_t
 171 ah_kstat_init(ipsecah_stack_t *ahstack, netstackid_t stackid)
 172 {
 173         ipsec_stack_t   *ipss = ahstack->ipsecah_netstack->netstack_ipsec;
 174 
 175         ahstack->ah_ksp = kstat_create_netstack("ipsecah", 0, "ah_stat", "net",
 176             KSTAT_TYPE_NAMED, sizeof (ah_kstats_t) / sizeof (kstat_named_t),
 177             KSTAT_FLAG_PERSISTENT, stackid);
 178 
 179         if (ahstack->ah_ksp == NULL || ahstack->ah_ksp->ks_data == NULL)
 180                 return (B_FALSE);
 181 
 182         ahstack->ah_kstats = ahstack->ah_ksp->ks_data;
 183 
 184         ahstack->ah_ksp->ks_update = ah_kstat_update;
 185         ahstack->ah_ksp->ks_private = (void *)(uintptr_t)stackid;
 186 
 187 #define K64 KSTAT_DATA_UINT64
 188 #define KI(x) kstat_named_init(&(ahstack->ah_kstats->ah_stat_##x), #x, K64)
 189 
 190         KI(num_aalgs);
 191         KI(good_auth);
 192         KI(bad_auth);
 193         KI(replay_failures);
 194         KI(replay_early_failures);
 195         KI(keysock_in);
 196         KI(out_requests);
 197         KI(acquire_requests);




   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 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright 2017 Joyent, Inc.
  26  */
  27 
  28 #include <sys/types.h>
  29 #include <sys/stream.h>
  30 #include <sys/stropts.h>
  31 #include <sys/errno.h>
  32 #include <sys/strlog.h>
  33 #include <sys/tihdr.h>
  34 #include <sys/socket.h>
  35 #include <sys/ddi.h>
  36 #include <sys/sunddi.h>
  37 #include <sys/mkdev.h>
  38 #include <sys/kmem.h>
  39 #include <sys/zone.h>
  40 #include <sys/sysmacros.h>
  41 #include <sys/cmn_err.h>
  42 #include <sys/vtrace.h>
  43 #include <sys/debug.h>
  44 #include <sys/atomic.h>
  45 #include <sys/strsun.h>


 157 
 158 static struct qinit winit = {
 159         (pfi_t)ipsecah_wput, NULL, ipsecah_open, ipsecah_close, NULL, &info,
 160         NULL
 161 };
 162 
 163 struct streamtab ipsecahinfo = {
 164         &rinit, &winit, NULL, NULL
 165 };
 166 
 167 static int ah_kstat_update(kstat_t *, int);
 168 
 169 uint64_t ipsacq_maxpackets = IPSACQ_MAXPACKETS;
 170 
 171 static boolean_t
 172 ah_kstat_init(ipsecah_stack_t *ahstack, netstackid_t stackid)
 173 {
 174         ipsec_stack_t   *ipss = ahstack->ipsecah_netstack->netstack_ipsec;
 175 
 176         ahstack->ah_ksp = kstat_create_netstack("ipsecah", 0, "ah_stat", "net",
 177             KSTAT_TYPE_NAMED, sizeof (ah_kstats_t) / sizeof (kstat_named_t), 0,
 178             stackid);
 179 
 180         if (ahstack->ah_ksp == NULL || ahstack->ah_ksp->ks_data == NULL)
 181                 return (B_FALSE);
 182 
 183         ahstack->ah_kstats = ahstack->ah_ksp->ks_data;
 184 
 185         ahstack->ah_ksp->ks_update = ah_kstat_update;
 186         ahstack->ah_ksp->ks_private = (void *)(uintptr_t)stackid;
 187 
 188 #define K64 KSTAT_DATA_UINT64
 189 #define KI(x) kstat_named_init(&(ahstack->ah_kstats->ah_stat_##x), #x, K64)
 190 
 191         KI(num_aalgs);
 192         KI(good_auth);
 193         KI(bad_auth);
 194         KI(replay_failures);
 195         KI(replay_early_failures);
 196         KI(keysock_in);
 197         KI(out_requests);
 198         KI(acquire_requests);