1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _INET_IPDROP_H 28*7c478bd9Sstevel@tonic-gate #define _INET_IPDROP_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate /* 37*7c478bd9Sstevel@tonic-gate * Opaque data type which will contain state about an entity that is dropping 38*7c478bd9Sstevel@tonic-gate * a packet (e.g. IPsec SPD, IPsec SADB, TCP, IP forwarding, etc.). 39*7c478bd9Sstevel@tonic-gate */ 40*7c478bd9Sstevel@tonic-gate typedef struct ipdropper_s { 41*7c478bd9Sstevel@tonic-gate char *ipd_name; 42*7c478bd9Sstevel@tonic-gate } ipdropper_t; 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate void ip_drop_register(ipdropper_t *, char *); 45*7c478bd9Sstevel@tonic-gate void ip_drop_unregister(ipdropper_t *); 46*7c478bd9Sstevel@tonic-gate void ip_drop_packet(mblk_t *, boolean_t, ill_t *, ire_t *, struct kstat_named *, 47*7c478bd9Sstevel@tonic-gate ipdropper_t *); 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate extern kstat_t *ip_drop_kstat; 50*7c478bd9Sstevel@tonic-gate extern struct ip_dropstats *ip_drop_types; 51*7c478bd9Sstevel@tonic-gate void ip_drop_init(void); 52*7c478bd9Sstevel@tonic-gate void ip_drop_destroy(void); 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * ip_dropstats - When a protocol developer comes up with a new reason to 56*7c478bd9Sstevel@tonic-gate * drop a packet, it should have a bean counter placed here in this structure, 57*7c478bd9Sstevel@tonic-gate * an ipdrops_* definition for that bean counter, and an initializer in 58*7c478bd9Sstevel@tonic-gate * ipdrop.c's ip_drop_init(). 59*7c478bd9Sstevel@tonic-gate * 60*7c478bd9Sstevel@tonic-gate * This will suffice until we come up with a more dynamic way of adding 61*7c478bd9Sstevel@tonic-gate * named kstats to a single kstat instance (if that is possible). 62*7c478bd9Sstevel@tonic-gate */ 63*7c478bd9Sstevel@tonic-gate struct ip_dropstats { 64*7c478bd9Sstevel@tonic-gate /* TCP IPsec drop statistics. */ 65*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_tcp_clear; 66*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_tcp_secure; 67*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_tcp_mismatch; 68*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_tcp_ipsec_alloc; 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate /* SADB-specific drop statistics. */ 71*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_sadb_inlarval_timeout; 72*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_sadb_inlarval_replace; 73*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_sadb_acquire_nomem; 74*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_sadb_acquire_toofull; 75*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_sadb_acquire_timeout; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* SPD drop statistics. */ 78*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_ahesp_diffid; 79*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_loopback_mismatch; 80*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_explicit; 81*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_got_secure; 82*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_got_clear; 83*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_bad_ahalg; 84*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_got_ah; 85*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_bad_espealg; 86*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_bad_espaalg; 87*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_got_esp; 88*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_got_selfencap; 89*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_bad_selfencap; 90*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_nomem; 91*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_ah_badid; 92*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_spd_esp_badid; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* ESP-specific drop statistics. */ 95*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_nomem; 96*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_no_sa; 97*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_early_replay; 98*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_replay; 99*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_bytes_expire; 100*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_bad_padlen; 101*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_bad_padding; 102*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_bad_auth; 103*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_crypto_failed; 104*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_esp_icmp; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate /* AH-specific drop statistics. */ 107*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_nomem; 108*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_bad_v6_hdrs; 109*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_bad_v4_opts; 110*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_no_sa; 111*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_bad_length; 112*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_bad_auth; 113*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_crypto_failed; 114*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_early_replay; 115*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_replay; 116*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ah_bytes_expire; 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate /* IP-specific drop statistics. */ 119*7c478bd9Sstevel@tonic-gate kstat_named_t ipds_ip_ipsec_not_loaded; 120*7c478bd9Sstevel@tonic-gate }; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate /* 123*7c478bd9Sstevel@tonic-gate * Use this section to create easy-to-name definitions for specific IP Drop 124*7c478bd9Sstevel@tonic-gate * statistics. As a naming convention, prefix them with ipdrops_<foo>. 125*7c478bd9Sstevel@tonic-gate */ 126*7c478bd9Sstevel@tonic-gate /* TCP IPsec drop statistics. */ 127*7c478bd9Sstevel@tonic-gate #define ipdrops_tcp_clear ip_drop_types->ipds_tcp_clear 128*7c478bd9Sstevel@tonic-gate #define ipdrops_tcp_secure ip_drop_types->ipds_tcp_secure 129*7c478bd9Sstevel@tonic-gate #define ipdrops_tcp_mismatch ip_drop_types->ipds_tcp_mismatch 130*7c478bd9Sstevel@tonic-gate #define ipdrops_tcp_ipsec_alloc ip_drop_types->ipds_tcp_ipsec_alloc 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate /* SADB-specific drop statistics. */ 133*7c478bd9Sstevel@tonic-gate #define ipdrops_sadb_inlarval_timeout ip_drop_types->ipds_sadb_inlarval_timeout 134*7c478bd9Sstevel@tonic-gate #define ipdrops_sadb_inlarval_replace ip_drop_types->ipds_sadb_inlarval_replace 135*7c478bd9Sstevel@tonic-gate #define ipdrops_sadb_acquire_nomem ip_drop_types->ipds_sadb_acquire_nomem 136*7c478bd9Sstevel@tonic-gate #define ipdrops_sadb_acquire_toofull ip_drop_types->ipds_sadb_acquire_toofull 137*7c478bd9Sstevel@tonic-gate #define ipdrops_sadb_acquire_timeout ip_drop_types->ipds_sadb_acquire_timeout 138*7c478bd9Sstevel@tonic-gate 139*7c478bd9Sstevel@tonic-gate /* SPD drop statistics. */ 140*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_ahesp_diffid ip_drop_types->ipds_spd_ahesp_diffid 141*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_loopback_mismatch ip_drop_types->ipds_spd_loopback_mismatch 142*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_explicit ip_drop_types->ipds_spd_explicit 143*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_got_secure ip_drop_types->ipds_spd_got_secure 144*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_got_clear ip_drop_types->ipds_spd_got_clear 145*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_bad_ahalg ip_drop_types->ipds_spd_bad_ahalg 146*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_got_ah ip_drop_types->ipds_spd_got_ah 147*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_bad_espealg ip_drop_types->ipds_spd_bad_espealg 148*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_bad_espaalg ip_drop_types->ipds_spd_bad_espaalg 149*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_got_esp ip_drop_types->ipds_spd_got_esp 150*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_got_selfencap ip_drop_types->ipds_spd_got_selfencap 151*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_bad_selfencap ip_drop_types->ipds_spd_bad_selfencap 152*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_nomem ip_drop_types->ipds_spd_nomem 153*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_ah_badid ip_drop_types->ipds_spd_ah_badid 154*7c478bd9Sstevel@tonic-gate #define ipdrops_spd_esp_badid ip_drop_types->ipds_spd_esp_badid 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* ESP-specific drop statistics. */ 157*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_nomem ip_drop_types->ipds_esp_nomem 158*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_no_sa ip_drop_types->ipds_esp_no_sa 159*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_early_replay ip_drop_types->ipds_esp_early_replay 160*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_replay ip_drop_types->ipds_esp_replay 161*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_bytes_expire ip_drop_types->ipds_esp_bytes_expire 162*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_bad_padlen ip_drop_types->ipds_esp_bad_padlen 163*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_bad_padding ip_drop_types->ipds_esp_bad_padding 164*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_bad_auth ip_drop_types->ipds_esp_bad_auth 165*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_crypto_failed ip_drop_types->ipds_esp_crypto_failed 166*7c478bd9Sstevel@tonic-gate #define ipdrops_esp_icmp ip_drop_types->ipds_esp_icmp 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate /* AH-specific drop statistics. */ 169*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_nomem ip_drop_types->ipds_ah_nomem 170*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_bad_v6_hdrs ip_drop_types->ipds_ah_bad_v6_hdrs 171*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_bad_v4_opts ip_drop_types->ipds_ah_bad_v4_opts 172*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_no_sa ip_drop_types->ipds_ah_no_sa 173*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_bad_length ip_drop_types->ipds_ah_bad_length 174*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_bad_auth ip_drop_types->ipds_ah_bad_auth 175*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_crypto_failed ip_drop_types->ipds_ah_crypto_failed 176*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_early_replay ip_drop_types->ipds_ah_early_replay 177*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_replay ip_drop_types->ipds_ah_replay 178*7c478bd9Sstevel@tonic-gate #define ipdrops_ah_bytes_expire ip_drop_types->ipds_ah_bytes_expire 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate /* IP-specific drop statistics. */ 181*7c478bd9Sstevel@tonic-gate #define ipdrops_ip_ipsec_not_loaded ip_drop_types->ipds_ip_ipsec_not_loaded 182*7c478bd9Sstevel@tonic-gate 183*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 184*7c478bd9Sstevel@tonic-gate } 185*7c478bd9Sstevel@tonic-gate #endif 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate #endif /* _INET_IPDROP_H */ 188