xref: /onnv-gate/usr/src/uts/common/inet/ip/ipdrop.c (revision 11042:2d6e217af1b4)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53055Sdanmcd  * Common Development and Distribution License (the "License").
63055Sdanmcd  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
2210824SMark.Fenwick@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/stream.h>
280Sstevel@tonic-gate #include <sys/strsun.h>
290Sstevel@tonic-gate #include <sys/sunddi.h>
300Sstevel@tonic-gate #include <sys/kstat.h>
310Sstevel@tonic-gate #include <sys/kmem.h>
32*11042SErik.Nordmark@Sun.COM #include <sys/sdt.h>
330Sstevel@tonic-gate #include <net/pfkeyv2.h>
340Sstevel@tonic-gate #include <inet/common.h>
350Sstevel@tonic-gate #include <inet/ip.h>
360Sstevel@tonic-gate #include <inet/ip6.h>
373448Sdh155122 #include <inet/ipsec_impl.h>
380Sstevel@tonic-gate #include <inet/ipdrop.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * Packet drop facility.
420Sstevel@tonic-gate  */
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * Initialize drop facility kstats.
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate void
483448Sdh155122 ip_drop_init(ipsec_stack_t *ipss)
490Sstevel@tonic-gate {
503448Sdh155122 	ipss->ipsec_ip_drop_kstat = kstat_create_netstack("ip", 0, "ipdrop",
513448Sdh155122 	    "net", KSTAT_TYPE_NAMED,
523448Sdh155122 	    sizeof (struct ip_dropstats) / sizeof (kstat_named_t),
533448Sdh155122 	    KSTAT_FLAG_PERSISTENT, ipss->ipsec_netstack->netstack_stackid);
540Sstevel@tonic-gate 
553448Sdh155122 	if (ipss->ipsec_ip_drop_kstat == NULL ||
563448Sdh155122 	    ipss->ipsec_ip_drop_kstat->ks_data == NULL)
570Sstevel@tonic-gate 		return;
580Sstevel@tonic-gate 
593448Sdh155122 	/*
603448Sdh155122 	 * Note: here ipss->ipsec_ip_drop_types is initialized, however,
613448Sdh155122 	 * if the previous kstat_create_netstack failed, it will remain
623448Sdh155122 	 * NULL. Note this is done for all stack instances, so it *could*
633448Sdh155122 	 * be NULL. Hence a non-NULL checking is added where
643448Sdh155122 	 * ipss->ipsec_ip_drop_types is used. This checking is hidden in
653448Sdh155122 	 * the DROPPER macro.
663448Sdh155122 	 */
673448Sdh155122 	ipss->ipsec_ip_drop_types = ipss->ipsec_ip_drop_kstat->ks_data;
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 	/* TCP IPsec drop statistics. */
703448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_tcp_clear,
713448Sdh155122 	    "tcp_clear", KSTAT_DATA_UINT64);
723448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_tcp_secure,
733448Sdh155122 	    "tcp_secure", KSTAT_DATA_UINT64);
743448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_tcp_mismatch,
753448Sdh155122 	    "tcp_mismatch", KSTAT_DATA_UINT64);
763448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_tcp_ipsec_alloc,
773448Sdh155122 	    "tcp_ipsec_alloc", KSTAT_DATA_UINT64);
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	/* SADB-specific drop statistics. */
803448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_inlarval_timeout,
810Sstevel@tonic-gate 	    "sadb_inlarval_timeout", KSTAT_DATA_UINT64);
823448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_inlarval_replace,
830Sstevel@tonic-gate 	    "sadb_inlarval_replace", KSTAT_DATA_UINT64);
847749SThejaswini.Singarajipura@Sun.COM 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_inidle_overflow,
857749SThejaswini.Singarajipura@Sun.COM 	    "sadb_inidle_overflow", KSTAT_DATA_UINT64);
867749SThejaswini.Singarajipura@Sun.COM 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_inidle_timeout,
877749SThejaswini.Singarajipura@Sun.COM 	    "sadb_inidle_timeout", KSTAT_DATA_UINT64);
883448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_acquire_nomem,
890Sstevel@tonic-gate 	    "sadb_acquire_nomem", KSTAT_DATA_UINT64);
903448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_acquire_toofull,
910Sstevel@tonic-gate 	    "sadb_acquire_toofull", KSTAT_DATA_UINT64);
923448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_sadb_acquire_timeout,
930Sstevel@tonic-gate 	    "sadb_acquire_timeout", KSTAT_DATA_UINT64);
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 	/* SPD drop statistics. */
963448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_ahesp_diffid,
973448Sdh155122 	    "spd_ahesp_diffid", KSTAT_DATA_UINT64);
983448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_loopback_mismatch,
990Sstevel@tonic-gate 	    "spd_loopback_mismatch", KSTAT_DATA_UINT64);
1003448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_explicit,
1013448Sdh155122 	    "spd_explicit", KSTAT_DATA_UINT64);
1023448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_got_secure,
1033448Sdh155122 	    "spd_got_secure", KSTAT_DATA_UINT64);
1043448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_got_clear,
1053448Sdh155122 	    "spd_got_clear", KSTAT_DATA_UINT64);
1063448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_bad_ahalg,
1073448Sdh155122 	    "spd_bad_ahalg", KSTAT_DATA_UINT64);
1083448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_got_ah,
1093448Sdh155122 	    "spd_got_ah", KSTAT_DATA_UINT64);
1103448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_bad_espealg,
1113448Sdh155122 	    "spd_bad_espealg", KSTAT_DATA_UINT64);
1123448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_bad_espaalg,
1133448Sdh155122 	    "spd_bad_espaalg", KSTAT_DATA_UINT64);
1143448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_got_esp,
1153448Sdh155122 	    "spd_got_esp", KSTAT_DATA_UINT64);
1163448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_got_selfencap,
1173448Sdh155122 	    "spd_got_selfencap", KSTAT_DATA_UINT64);
1183448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_bad_selfencap,
1193448Sdh155122 	    "spd_bad_selfencap", KSTAT_DATA_UINT64);
1203448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_nomem,
1213448Sdh155122 	    "spd_nomem", KSTAT_DATA_UINT64);
1223448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_ah_badid,
1233448Sdh155122 	    "spd_ah_badid", KSTAT_DATA_UINT64);
1243448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_ah_innermismatch,
125691Ssommerfe 	    "spd_ah_innermismatch", KSTAT_DATA_UINT64);
1263448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_esp_innermismatch,
127691Ssommerfe 	    "spd_esp_innermismatch", KSTAT_DATA_UINT64);
1283448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_esp_badid,
1293448Sdh155122 	    "spd_esp_badid", KSTAT_DATA_UINT64);
1303448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_no_policy,
1313448Sdh155122 	    "spd_no_policy", KSTAT_DATA_UINT64);
1323448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_malformed_packet,
1333448Sdh155122 	    "spd_malformed_packet", KSTAT_DATA_UINT64);
1343448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_malformed_frag,
1353448Sdh155122 	    "spd_malformed_frag", KSTAT_DATA_UINT64);
1363448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_overlap_frag,
1373448Sdh155122 	    "spd_overlap_frag", KSTAT_DATA_UINT64);
1383448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_evil_frag,
1393448Sdh155122 	    "spd_evil_frag", KSTAT_DATA_UINT64);
1403448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_spd_max_frags,
1413448Sdh155122 	    "spd_max_frags", KSTAT_DATA_UINT64);
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 	/* ESP-specific drop statistics. */
1440Sstevel@tonic-gate 
1453448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_nomem,
1463448Sdh155122 	    "esp_nomem", KSTAT_DATA_UINT64);
1473448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_no_sa,
1483448Sdh155122 	    "esp_no_sa", KSTAT_DATA_UINT64);
1493448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_early_replay,
1503448Sdh155122 	    "esp_early_replay", KSTAT_DATA_UINT64);
1513448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_replay,
1523448Sdh155122 	    "esp_replay", KSTAT_DATA_UINT64);
1533448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_bytes_expire,
1543448Sdh155122 	    "esp_bytes_expire", KSTAT_DATA_UINT64);
1553448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_bad_padlen,
1563448Sdh155122 	    "esp_bad_padlen", KSTAT_DATA_UINT64);
1573448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_bad_padding,
1583448Sdh155122 	    "esp_bad_padding", KSTAT_DATA_UINT64);
1593448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_bad_auth,
1603448Sdh155122 	    "esp_bad_auth", KSTAT_DATA_UINT64);
1613448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_crypto_failed,
1623448Sdh155122 	    "esp_crypto_failed", KSTAT_DATA_UINT64);
1633448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_icmp,
1643448Sdh155122 	    "esp_icmp", KSTAT_DATA_UINT64);
1654987Sdanmcd 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_nat_t_ipsec,
1664987Sdanmcd 	    "esp_nat_t_ipsec", KSTAT_DATA_UINT64);
1674987Sdanmcd 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_nat_t_ka,
1684987Sdanmcd 	    "esp_nat_t_ka", KSTAT_DATA_UINT64);
16910824SMark.Fenwick@Sun.COM 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_esp_iv_wrap,
17010824SMark.Fenwick@Sun.COM 	    "esp_iv_wrap", KSTAT_DATA_UINT64);
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate 	/* AH-specific drop statistics. */
1733448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_nomem,
1743448Sdh155122 	    "ah_nomem", KSTAT_DATA_UINT64);
1753448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_bad_v6_hdrs,
1763448Sdh155122 	    "ah_bad_v6_hdrs", KSTAT_DATA_UINT64);
1773448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_bad_v4_opts,
1783448Sdh155122 	    "ah_bad_v4_opts", KSTAT_DATA_UINT64);
1793448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_no_sa,
1803448Sdh155122 	    "ah_no_sa", KSTAT_DATA_UINT64);
1813448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_bad_length,
1823448Sdh155122 	    "ah_bad_length", KSTAT_DATA_UINT64);
1833448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_bad_auth,
1843448Sdh155122 	    "ah_bad_auth", KSTAT_DATA_UINT64);
1853448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_crypto_failed,
1863448Sdh155122 	    "ah_crypto_failed", KSTAT_DATA_UINT64);
1873448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_early_replay,
1883448Sdh155122 	    "ah_early_replay", KSTAT_DATA_UINT64);
1893448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_replay,
1903448Sdh155122 	    "ah_replay", KSTAT_DATA_UINT64);
1913448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ah_bytes_expire,
1923448Sdh155122 	    "ah_bytes_expire", KSTAT_DATA_UINT64);
1930Sstevel@tonic-gate 
1940Sstevel@tonic-gate 	/* IP-specific drop statistics. */
1953448Sdh155122 	kstat_named_init(&ipss->ipsec_ip_drop_types->ipds_ip_ipsec_not_loaded,
1963448Sdh155122 	    "ip_ipsec_not_loaded", KSTAT_DATA_UINT64);
1970Sstevel@tonic-gate 
1983448Sdh155122 	kstat_install(ipss->ipsec_ip_drop_kstat);
1990Sstevel@tonic-gate }
2000Sstevel@tonic-gate 
2010Sstevel@tonic-gate void
2023448Sdh155122 ip_drop_destroy(ipsec_stack_t *ipss)
2030Sstevel@tonic-gate {
2043448Sdh155122 	kstat_delete_netstack(ipss->ipsec_ip_drop_kstat,
2053448Sdh155122 	    ipss->ipsec_netstack->netstack_stackid);
2063448Sdh155122 	ipss->ipsec_ip_drop_kstat = NULL;
2073448Sdh155122 	ipss->ipsec_ip_drop_types = NULL;
2080Sstevel@tonic-gate }
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate /*
2110Sstevel@tonic-gate  * Register a packet dropper.
2120Sstevel@tonic-gate  */
2130Sstevel@tonic-gate void
2140Sstevel@tonic-gate ip_drop_register(ipdropper_t *ipd, char *name)
2150Sstevel@tonic-gate {
2160Sstevel@tonic-gate 	if (ipd->ipd_name != NULL) {
2170Sstevel@tonic-gate 		cmn_err(CE_WARN,
2180Sstevel@tonic-gate 		    "ip_drop_register: ipdropper %s already registered with %s",
2190Sstevel@tonic-gate 		    name, ipd->ipd_name);
2200Sstevel@tonic-gate 		return;
2210Sstevel@tonic-gate 	}
2220Sstevel@tonic-gate 
2230Sstevel@tonic-gate 	/* Assume that name is reasonable in length.  This isn't user-land. */
2240Sstevel@tonic-gate 	ipd->ipd_name = kmem_alloc(strlen(name) + 1, KM_SLEEP);
2250Sstevel@tonic-gate 	(void) strcpy(ipd->ipd_name, name);
2260Sstevel@tonic-gate }
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate /*
2290Sstevel@tonic-gate  * Un-register a packet dropper.
2300Sstevel@tonic-gate  */
2310Sstevel@tonic-gate void
2320Sstevel@tonic-gate ip_drop_unregister(ipdropper_t *ipd)
2330Sstevel@tonic-gate {
2343448Sdh155122 	if (ipd->ipd_name == NULL) {
2353448Sdh155122 		cmn_err(CE_WARN,
2363448Sdh155122 		    "ip_drop_unregister: not registered (%p)\n",
2373448Sdh155122 		    (void *)ipd);
2383448Sdh155122 		return;
2393448Sdh155122 	}
2400Sstevel@tonic-gate 	kmem_free(ipd->ipd_name, strlen(ipd->ipd_name) + 1);
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate 	ipd->ipd_name = NULL;
2430Sstevel@tonic-gate }
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate /*
2460Sstevel@tonic-gate  * Actually drop a packet.  Many things could happen here, but at the least,
2470Sstevel@tonic-gate  * the packet will be freemsg()ed.
2480Sstevel@tonic-gate  */
2490Sstevel@tonic-gate void
250*11042SErik.Nordmark@Sun.COM ip_drop_packet(mblk_t *mp, boolean_t inbound, ill_t *ill,
251*11042SErik.Nordmark@Sun.COM     struct kstat_named *counter, ipdropper_t *who_called)
2520Sstevel@tonic-gate {
253*11042SErik.Nordmark@Sun.COM 	char *str;
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate 	if (mp == NULL) {
2560Sstevel@tonic-gate 		/*
2570Sstevel@tonic-gate 		 * Return immediately - NULL packets should not affect any
2580Sstevel@tonic-gate 		 * statistics.
2590Sstevel@tonic-gate 		 */
2600Sstevel@tonic-gate 		return;
2610Sstevel@tonic-gate 	}
2620Sstevel@tonic-gate 
263*11042SErik.Nordmark@Sun.COM 	ASSERT(mp->b_datap->db_type == M_DATA);
2640Sstevel@tonic-gate 
2650Sstevel@tonic-gate 	/* Increment the bean counter, if available. */
2660Sstevel@tonic-gate 	if (counter != NULL) {
2670Sstevel@tonic-gate 		switch (counter->data_type) {
2680Sstevel@tonic-gate 		case KSTAT_DATA_INT32:
2690Sstevel@tonic-gate 			counter->value.i32++;
2700Sstevel@tonic-gate 			break;
2710Sstevel@tonic-gate 		case KSTAT_DATA_UINT32:
2720Sstevel@tonic-gate 			counter->value.ui32++;
2730Sstevel@tonic-gate 			break;
2740Sstevel@tonic-gate 		case KSTAT_DATA_INT64:
2750Sstevel@tonic-gate 			counter->value.i64++;
2760Sstevel@tonic-gate 			break;
2770Sstevel@tonic-gate 		case KSTAT_DATA_UINT64:
2780Sstevel@tonic-gate 			counter->value.ui64++;
2790Sstevel@tonic-gate 			break;
2800Sstevel@tonic-gate 		/* Other types we can't handle for now. */
2810Sstevel@tonic-gate 		}
2820Sstevel@tonic-gate 	}
2830Sstevel@tonic-gate 
284*11042SErik.Nordmark@Sun.COM 	if (counter != NULL)
285*11042SErik.Nordmark@Sun.COM 		str = counter->name;
286*11042SErik.Nordmark@Sun.COM 	else if (who_called != NULL)
287*11042SErik.Nordmark@Sun.COM 		str = who_called->ipd_name;
288*11042SErik.Nordmark@Sun.COM 	else
289*11042SErik.Nordmark@Sun.COM 		str = "Unspecified IPsec drop";
290*11042SErik.Nordmark@Sun.COM 
291*11042SErik.Nordmark@Sun.COM 	if (inbound)
292*11042SErik.Nordmark@Sun.COM 		ip_drop_input(str, mp, ill);
293*11042SErik.Nordmark@Sun.COM 	else
294*11042SErik.Nordmark@Sun.COM 		ip_drop_output(str, mp, ill);
295*11042SErik.Nordmark@Sun.COM 
2960Sstevel@tonic-gate 	/* TODO: queue the packet onto a snoop-friendly queue. */
2970Sstevel@tonic-gate 
2983055Sdanmcd 	/*
2993055Sdanmcd 	 * ASSERT this isn't a b_next linked mblk chain where a
3003055Sdanmcd 	 * chained dropper should be used instead
3013055Sdanmcd 	 */
3023055Sdanmcd 	ASSERT(mp->b_prev == NULL && mp->b_next == NULL);
3030Sstevel@tonic-gate 	freemsg(mp);
3040Sstevel@tonic-gate }
305*11042SErik.Nordmark@Sun.COM 
306*11042SErik.Nordmark@Sun.COM /*
307*11042SErik.Nordmark@Sun.COM  * This is just a convinient place for dtrace to see dropped packets
308*11042SErik.Nordmark@Sun.COM  */
309*11042SErik.Nordmark@Sun.COM /*ARGSUSED*/
310*11042SErik.Nordmark@Sun.COM void
311*11042SErik.Nordmark@Sun.COM ip_drop_input(char *str, mblk_t *mp, ill_t *ill)
312*11042SErik.Nordmark@Sun.COM {
313*11042SErik.Nordmark@Sun.COM 	if (mp == NULL)
314*11042SErik.Nordmark@Sun.COM 		return;
315*11042SErik.Nordmark@Sun.COM 
316*11042SErik.Nordmark@Sun.COM 	if (IPH_HDR_VERSION(mp->b_rptr) == IPV4_VERSION) {
317*11042SErik.Nordmark@Sun.COM 		ipha_t *ipha = (ipha_t *)mp->b_rptr;
318*11042SErik.Nordmark@Sun.COM 
319*11042SErik.Nordmark@Sun.COM 		DTRACE_IP7(drop__in, mblk_t *, mp, conn_t *, NULL, void_ip_t *,
320*11042SErik.Nordmark@Sun.COM 		    ipha, __dtrace_ipsr_ill_t *, ill, ipha_t *, ipha,
321*11042SErik.Nordmark@Sun.COM 		    ip6_t *, NULL, int, 0);
322*11042SErik.Nordmark@Sun.COM 	} else {
323*11042SErik.Nordmark@Sun.COM 		ip6_t *ip6h = (ip6_t *)mp->b_rptr;
324*11042SErik.Nordmark@Sun.COM 
325*11042SErik.Nordmark@Sun.COM 		DTRACE_IP7(drop__in, mblk_t *, mp, conn_t *, NULL, void_ip_t *,
326*11042SErik.Nordmark@Sun.COM 		    ip6h, __dtrace_ipsr_ill_t *, ill, ipha_t *, NULL,
327*11042SErik.Nordmark@Sun.COM 		    ip6_t *, ip6h, int, 0);
328*11042SErik.Nordmark@Sun.COM 	}
329*11042SErik.Nordmark@Sun.COM }
330*11042SErik.Nordmark@Sun.COM 
331*11042SErik.Nordmark@Sun.COM /*ARGSUSED*/
332*11042SErik.Nordmark@Sun.COM void
333*11042SErik.Nordmark@Sun.COM ip_drop_output(char *str, mblk_t *mp, ill_t *ill)
334*11042SErik.Nordmark@Sun.COM {
335*11042SErik.Nordmark@Sun.COM 	if (mp == NULL)
336*11042SErik.Nordmark@Sun.COM 		return;
337*11042SErik.Nordmark@Sun.COM 
338*11042SErik.Nordmark@Sun.COM 	if (IPH_HDR_VERSION(mp->b_rptr) == IPV4_VERSION) {
339*11042SErik.Nordmark@Sun.COM 		ipha_t *ipha = (ipha_t *)mp->b_rptr;
340*11042SErik.Nordmark@Sun.COM 
341*11042SErik.Nordmark@Sun.COM 		DTRACE_IP7(drop__out, mblk_t *, mp, conn_t *, NULL, void_ip_t *,
342*11042SErik.Nordmark@Sun.COM 		    ipha, __dtrace_ipsr_ill_t *, ill, ipha_t *, ipha,
343*11042SErik.Nordmark@Sun.COM 		    ip6_t *, NULL, int, 0);
344*11042SErik.Nordmark@Sun.COM 	} else {
345*11042SErik.Nordmark@Sun.COM 		ip6_t *ip6h = (ip6_t *)mp->b_rptr;
346*11042SErik.Nordmark@Sun.COM 
347*11042SErik.Nordmark@Sun.COM 		DTRACE_IP7(drop__out, mblk_t *, mp, conn_t *, NULL, void_ip_t *,
348*11042SErik.Nordmark@Sun.COM 		    ip6h, __dtrace_ipsr_ill_t *, ill, ipha_t *, NULL,
349*11042SErik.Nordmark@Sun.COM 		    ip6_t *, ip6h, int, 0);
350*11042SErik.Nordmark@Sun.COM 	}
351*11042SErik.Nordmark@Sun.COM }
352