xref: /illumos-gate/usr/src/uts/common/inet/ipdrop.h (revision 35a5a3587fd94b666239c157d3722745250ccbd7)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _INET_IPDROP_H
27 #define	_INET_IPDROP_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #ifdef _KERNEL
34 /*
35  * Opaque data type which will contain state about an entity that is dropping
36  * a packet (e.g. IPsec SPD, IPsec SADB, TCP, IP forwarding, etc.).
37  */
38 typedef struct ipdropper_s {
39 	char *ipd_name;
40 } ipdropper_t;
41 
42 void ip_drop_register(ipdropper_t *, char *);
43 void ip_drop_unregister(ipdropper_t *);
44 void ip_drop_packet(mblk_t *, boolean_t, ill_t *, struct kstat_named *,
45     ipdropper_t *);
46 void ip_drop_input(char *, mblk_t *, ill_t *);
47 void ip_drop_output(char *, mblk_t *, ill_t *);
48 
49 /*
50  * ip_dropstats - When a protocol developer comes up with a new reason to
51  * drop a packet, it should have a bean counter placed here in this structure,
52  * and an initializer in ipdrop.c's ip_drop_init().
53  *
54  * This will suffice until we come up with a more dynamic way of adding
55  * named kstats to a single kstat instance (if that is possible).
56  */
57 struct ip_dropstats {
58 	/* TCP IPsec drop statistics. */
59 	kstat_named_t ipds_tcp_clear;
60 	kstat_named_t ipds_tcp_secure;
61 	kstat_named_t ipds_tcp_mismatch;
62 	kstat_named_t ipds_tcp_ipsec_alloc;
63 
64 	/* SADB-specific drop statistics. */
65 	kstat_named_t ipds_sadb_inlarval_timeout;
66 	kstat_named_t ipds_sadb_inlarval_replace;
67 	kstat_named_t ipds_sadb_inidle_timeout;
68 	kstat_named_t ipds_sadb_inidle_overflow;
69 	kstat_named_t ipds_sadb_acquire_nomem;
70 	kstat_named_t ipds_sadb_acquire_toofull;
71 	kstat_named_t ipds_sadb_acquire_timeout;
72 
73 	/* SPD drop statistics. */
74 	kstat_named_t ipds_spd_ahesp_diffid;
75 	kstat_named_t ipds_spd_loopback_mismatch;
76 	kstat_named_t ipds_spd_explicit;
77 	kstat_named_t ipds_spd_got_secure;
78 	kstat_named_t ipds_spd_got_clear;
79 	kstat_named_t ipds_spd_bad_ahalg;
80 	kstat_named_t ipds_spd_got_ah;
81 	kstat_named_t ipds_spd_bad_espealg;
82 	kstat_named_t ipds_spd_bad_espaalg;
83 	kstat_named_t ipds_spd_got_esp;
84 	kstat_named_t ipds_spd_got_selfencap;
85 	kstat_named_t ipds_spd_bad_selfencap;
86 	kstat_named_t ipds_spd_nomem;
87 	kstat_named_t ipds_spd_ah_badid;
88 	kstat_named_t ipds_spd_esp_badid;
89 	kstat_named_t ipds_spd_ah_innermismatch;
90 	kstat_named_t ipds_spd_esp_innermismatch;
91 	kstat_named_t ipds_spd_no_policy;
92 	kstat_named_t ipds_spd_malformed_packet;
93 	kstat_named_t ipds_spd_malformed_frag;
94 	kstat_named_t ipds_spd_overlap_frag;
95 	kstat_named_t ipds_spd_evil_frag;
96 	kstat_named_t ipds_spd_max_frags;
97 
98 	/* ESP-specific drop statistics. */
99 	kstat_named_t ipds_esp_nomem;
100 	kstat_named_t ipds_esp_no_sa;
101 	kstat_named_t ipds_esp_early_replay;
102 	kstat_named_t ipds_esp_replay;
103 	kstat_named_t ipds_esp_bytes_expire;
104 	kstat_named_t ipds_esp_bad_padlen;
105 	kstat_named_t ipds_esp_bad_padding;
106 	kstat_named_t ipds_esp_bad_auth;
107 	kstat_named_t ipds_esp_crypto_failed;
108 	kstat_named_t ipds_esp_icmp;
109 	kstat_named_t ipds_esp_nat_t_ipsec;
110 	kstat_named_t ipds_esp_nat_t_ka;
111 	kstat_named_t ipds_esp_iv_wrap;
112 
113 	/* AH-specific drop statistics. */
114 	kstat_named_t ipds_ah_nomem;
115 	kstat_named_t ipds_ah_bad_v6_hdrs;
116 	kstat_named_t ipds_ah_bad_v4_opts;
117 	kstat_named_t ipds_ah_no_sa;
118 	kstat_named_t ipds_ah_bad_length;
119 	kstat_named_t ipds_ah_bad_auth;
120 	kstat_named_t ipds_ah_crypto_failed;
121 	kstat_named_t ipds_ah_early_replay;
122 	kstat_named_t ipds_ah_replay;
123 	kstat_named_t ipds_ah_bytes_expire;
124 
125 	/* IP-specific drop statistics. */
126 	kstat_named_t ipds_ip_ipsec_not_loaded;
127 };
128 
129 #endif /* _KERNEL */
130 #ifdef	__cplusplus
131 }
132 #endif
133 
134 #endif	/* _INET_IPDROP_H */
135