17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5f4b3ec61Sdh155122 * Common Development and Distribution License (the "License"). 6f4b3ec61Sdh155122 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22bd670b35SErik Nordmark * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 24*b7daf799SDan McDonald * Copyright (c) 2012 Nexenta Systems, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _INET_IPSECESP_H 287c478bd9Sstevel@tonic-gate #define _INET_IPSECESP_H 297c478bd9Sstevel@tonic-gate 30f4b3ec61Sdh155122 #include <inet/ip.h> 31f4b3ec61Sdh155122 #include <inet/ipdrop.h> 32f4b3ec61Sdh155122 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef _KERNEL 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 40f4b3ec61Sdh155122 typedef struct ipsecespparam_s { 417c478bd9Sstevel@tonic-gate uint_t ipsecesp_param_min; 427c478bd9Sstevel@tonic-gate uint_t ipsecesp_param_max; 437c478bd9Sstevel@tonic-gate uint_t ipsecesp_param_value; 447c478bd9Sstevel@tonic-gate char *ipsecesp_param_name; 457c478bd9Sstevel@tonic-gate } ipsecespparam_t; 467c478bd9Sstevel@tonic-gate 47f4b3ec61Sdh155122 /* 48*b7daf799SDan McDonald * Stats. This may eventually become a full-blown SNMP MIB once that spec 49*b7daf799SDan McDonald * stabilizes. 50*b7daf799SDan McDonald */ 51*b7daf799SDan McDonald 52*b7daf799SDan McDonald typedef struct esp_kstats_s { 53*b7daf799SDan McDonald kstat_named_t esp_stat_num_aalgs; 54*b7daf799SDan McDonald kstat_named_t esp_stat_good_auth; 55*b7daf799SDan McDonald kstat_named_t esp_stat_bad_auth; 56*b7daf799SDan McDonald kstat_named_t esp_stat_bad_padding; 57*b7daf799SDan McDonald kstat_named_t esp_stat_replay_failures; 58*b7daf799SDan McDonald kstat_named_t esp_stat_replay_early_failures; 59*b7daf799SDan McDonald kstat_named_t esp_stat_keysock_in; 60*b7daf799SDan McDonald kstat_named_t esp_stat_out_requests; 61*b7daf799SDan McDonald kstat_named_t esp_stat_acquire_requests; 62*b7daf799SDan McDonald kstat_named_t esp_stat_bytes_expired; 63*b7daf799SDan McDonald kstat_named_t esp_stat_out_discards; 64*b7daf799SDan McDonald kstat_named_t esp_stat_crypto_sync; 65*b7daf799SDan McDonald kstat_named_t esp_stat_crypto_async; 66*b7daf799SDan McDonald kstat_named_t esp_stat_crypto_failures; 67*b7daf799SDan McDonald kstat_named_t esp_stat_num_ealgs; 68*b7daf799SDan McDonald kstat_named_t esp_stat_bad_decrypt; 69*b7daf799SDan McDonald kstat_named_t esp_stat_sa_port_renumbers; 70*b7daf799SDan McDonald } esp_kstats_t; 71*b7daf799SDan McDonald 72*b7daf799SDan McDonald /* 73*b7daf799SDan McDonald * espstack->esp_kstats is equal to espstack->esp_ksp->ks_data if 74*b7daf799SDan McDonald * kstat_create_netstack for espstack->esp_ksp succeeds, but when it 75*b7daf799SDan McDonald * fails, it will be NULL. Note this is done for all stack instances, 76*b7daf799SDan McDonald * so it *could* fail. hence a non-NULL checking is done for 77*b7daf799SDan McDonald * ESP_BUMP_STAT and ESP_DEBUMP_STAT 78*b7daf799SDan McDonald */ 79*b7daf799SDan McDonald #define ESP_BUMP_STAT(espstack, x) \ 80*b7daf799SDan McDonald do { \ 81*b7daf799SDan McDonald if (espstack->esp_kstats != NULL) \ 82*b7daf799SDan McDonald (espstack->esp_kstats->esp_stat_ ## x).value.ui64++; \ 83*b7daf799SDan McDonald _NOTE(CONSTCOND) \ 84*b7daf799SDan McDonald } while (0) 85*b7daf799SDan McDonald 86*b7daf799SDan McDonald #define ESP_DEBUMP_STAT(espstack, x) \ 87*b7daf799SDan McDonald do { \ 88*b7daf799SDan McDonald if (espstack->esp_kstats != NULL) \ 89*b7daf799SDan McDonald (espstack->esp_kstats->esp_stat_ ## x).value.ui64--; \ 90*b7daf799SDan McDonald _NOTE(CONSTCOND) \ 91*b7daf799SDan McDonald } while (0) 92*b7daf799SDan McDonald 93*b7daf799SDan McDonald /* 94f4b3ec61Sdh155122 * IPSECESP stack instances 95f4b3ec61Sdh155122 */ 96f4b3ec61Sdh155122 struct ipsecesp_stack { 97f4b3ec61Sdh155122 netstack_t *ipsecesp_netstack; /* Common netstack */ 98f4b3ec61Sdh155122 99f4b3ec61Sdh155122 caddr_t ipsecesp_g_nd; 100f4b3ec61Sdh155122 struct ipsecespparam_s *ipsecesp_params; 101f4b3ec61Sdh155122 kmutex_t ipsecesp_param_lock; /* Protects params */ 102f4b3ec61Sdh155122 103f4b3ec61Sdh155122 /* Packet dropper for ESP drops. */ 104f4b3ec61Sdh155122 ipdropper_t esp_dropper; 105f4b3ec61Sdh155122 106f4b3ec61Sdh155122 kstat_t *esp_ksp; 107f4b3ec61Sdh155122 struct esp_kstats_s *esp_kstats; 108f4b3ec61Sdh155122 109f4b3ec61Sdh155122 /* 110f4b3ec61Sdh155122 * Keysock instance of ESP. There can be only one per stack instance. 11175d94465SJosef 'Jeff' Sipek * Use atomic_cas_ptr() on this because I don't set it until 11275d94465SJosef 'Jeff' Sipek * KEYSOCK_HELLO comes down. 113f4b3ec61Sdh155122 * Paired up with the esp_pfkey_q is the esp_event, which will age SAs. 114f4b3ec61Sdh155122 */ 115f4b3ec61Sdh155122 queue_t *esp_pfkey_q; 116f4b3ec61Sdh155122 timeout_id_t esp_event; 117f4b3ec61Sdh155122 118f4b3ec61Sdh155122 sadbp_t esp_sadb; 119f4b3ec61Sdh155122 }; 120f4b3ec61Sdh155122 typedef struct ipsecesp_stack ipsecesp_stack_t; 121f4b3ec61Sdh155122 122*b7daf799SDan McDonald #define ipsecesp_debug ipsecesp_params[0].ipsecesp_param_value 123*b7daf799SDan McDonald #define ipsecesp_age_interval ipsecesp_params[1].ipsecesp_param_value 124*b7daf799SDan McDonald #define ipsecesp_age_int_max ipsecesp_params[1].ipsecesp_param_max 125*b7daf799SDan McDonald #define ipsecesp_reap_delay ipsecesp_params[2].ipsecesp_param_value 126*b7daf799SDan McDonald #define ipsecesp_replay_size ipsecesp_params[3].ipsecesp_param_value 127*b7daf799SDan McDonald #define ipsecesp_acquire_timeout \ 128*b7daf799SDan McDonald ipsecesp_params[4].ipsecesp_param_value 129*b7daf799SDan McDonald #define ipsecesp_larval_timeout \ 130*b7daf799SDan McDonald ipsecesp_params[5].ipsecesp_param_value 131*b7daf799SDan McDonald #define ipsecesp_default_soft_bytes \ 132*b7daf799SDan McDonald ipsecesp_params[6].ipsecesp_param_value 133*b7daf799SDan McDonald #define ipsecesp_default_hard_bytes \ 134*b7daf799SDan McDonald ipsecesp_params[7].ipsecesp_param_value 135*b7daf799SDan McDonald #define ipsecesp_default_soft_addtime \ 136*b7daf799SDan McDonald ipsecesp_params[8].ipsecesp_param_value 137*b7daf799SDan McDonald #define ipsecesp_default_hard_addtime \ 138*b7daf799SDan McDonald ipsecesp_params[9].ipsecesp_param_value 139*b7daf799SDan McDonald #define ipsecesp_default_soft_usetime \ 140*b7daf799SDan McDonald ipsecesp_params[10].ipsecesp_param_value 141*b7daf799SDan McDonald #define ipsecesp_default_hard_usetime \ 142*b7daf799SDan McDonald ipsecesp_params[11].ipsecesp_param_value 143*b7daf799SDan McDonald #define ipsecesp_log_unknown_spi \ 144*b7daf799SDan McDonald ipsecesp_params[12].ipsecesp_param_value 145*b7daf799SDan McDonald #define ipsecesp_padding_check \ 146*b7daf799SDan McDonald ipsecesp_params[13].ipsecesp_param_value 147437220cdSdanmcd #define ipsecesp_nat_keepalive_interval \ 148437220cdSdanmcd ipsecesp_params[14].ipsecesp_param_value 149f4b3ec61Sdh155122 1507c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * For now, only provide "aligned" version of header. 1547c478bd9Sstevel@tonic-gate * If aligned version is needed, we'll go with the naming conventions then. 1557c478bd9Sstevel@tonic-gate */ 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate typedef struct esph { 1587c478bd9Sstevel@tonic-gate uint32_t esph_spi; 1597c478bd9Sstevel@tonic-gate uint32_t esph_replay; 1607c478bd9Sstevel@tonic-gate } esph_t; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* No need for "old" ESP, just point a uint32_t *. */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate #endif 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #endif /* _INET_IPSECESP_H */ 169