iptun_impl.h revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _INET_IPTUN_IMPL_H
#define _INET_IPTUN_IMPL_H
#include <sys/dld_impl.h>
#include <sys/netstack.h>
#include <inet/ipclassifier.h>
#include <inet/ipsec_impl.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
#define IPTUN_MODID 5134
#define IPTUN_DRIVER_NAME "iptun"
typedef struct iptun_encaplim_s {
struct ip6_opt_tunnel iel_telopt;
typedef struct iptun_ipv6hdrs_s {
typedef union iptun_header_u {
typedef struct iptun_addr_s {
union {
} ia_addr;
} iptun_addr_t;
typedef struct iptun_typeinfo {
const char *iti_ident; /* MAC-Type plugin identifier */
/*
* An iptun_t represents an IP tunnel link. The iptun_lock protects the
* integrity of all fields except statistics which are updated atomically, and
* is also used by iptun_upcall_cv and iptun_enter_cv. Access to all fields
* must be done under the protection of iptun_lock with the following
* exceptions:
*
* The datapath reads certain fields without locks for performance reasons.
*
* - IPTUN_PMTU_TOO_OLD() is used without a lock to determine if the
* destination path-MTU should be queried. This reads iptun_flags
* IPTUN_RADDR, IPTUN_FIXED_MTU, and iptun_dpmtu_lastupdate. All of these
* can change without adversely affecting the tunnel, as the worst case
* scenario is that we launch a task that will ultimately either do nothing
* or needlessly query the destination path-MTU.
*
* - IPTUN_IS_RUNNING() is used (read access to iptun_flags IPTUN_BOUND and
* IPTUN_MAC_STARTED) to drop packets if they're sent while the tunnel is
* not running. This is harmless as the worst case scenario is that a
* packet will be needlessly sent down to ip and be dropped due to an
* unspecified source or destination.
*/
typedef struct iptun_s {
struct ipsec_tun_pol_s *iptun_itp;
/* statistics */
} iptun_t;
/* iptun_flags */
#define IS_IPTUN_RUNNING(iptun) \
/*
* We request ire information for the tunnel destination in order to obtain
* its path MTU information. We use that to calculate the initial link MTU of
* a tunnel.
*
* After that, if the path MTU of the tunnel destination becomes smaller
* than the link MTU of the tunnel, then we will receive a packet too big
* (aka fragmentation needed) ICMP error when we transmit a packet larger
* than the path MTU, and we will adjust the tunne's MTU based on the ICMP
* error's MTU information.
*
* In addition to that, we also need to request the ire information
* periodically to make sure the link MTU of a tunnel doesn't become stale
* if the path MTU of the tunnel destination becomes larger than the link
* MTU of the tunnel. The period for the requests is ten minutes in
* accordance with rfc1191.
*/
#define IPTUN_PMTU_TOO_OLD(ipt) \
/*
* iptuns_lock protects iptuns_iptunlist and iptuns_g_q.
*/
typedef struct iptun_stack {
extern dev_info_t *iptun_dip;
extern mod_hash_t *iptun_hash;
extern kmem_cache_t *iptun_cache;
extern ddi_taskq_t *iptun_taskq;
extern ldi_ident_t iptun_ldi_ident;
extern int iptun_ioc_init(void);
extern void iptun_ioc_fini(void);
extern uint_t iptun_count(void);
extern void iptun_clear_g_q(netstack_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _INET_IPTUN_IMPL_H */