ip_ire.h revision f60c536af082875d4fcb6a673c11fb80fd4b6952
/*
* 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.
*/
/* Copyright (c) 1990 Mentat Inc. */
#ifndef _INET_IP_IRE_H
#define _INET_IP_IRE_H
#ifdef __cplusplus
extern "C" {
#endif
#define IP_CACHE_TABLE_SIZE 256
#define IP6_CACHE_TABLE_SIZE 256
/*
* We use the common modulo hash function. In ip_ire_init(), we make
* sure that the cache table size is always a power of 2. That's why
* we can use & instead of %. Also note that we try hard to make sure
* the lower bits of an address capture most info from the whole address.
* The reason being that since our hash table is probably a lot smaller
* than 2^32 buckets so the lower bits are the most important.
*/
((table_size) - 1))
/*
* To make a byte-order neutral hash for IPv6, just take all the
* bytes in the bottom 32 bits into account.
*/
/* This assumes that the ftable size is a power of 2. */
/*
* match parameter definitions for IRE lookup routines.
*/
/* found. */
/* with RTF_REJECT or RTF_BLACKHOLE, */
/* return the ire. No recursive */
/* lookup should be done. */
/*
* MATCH_IRE_PARENT is used whenever we unconditionally want to get the
* parent IRE (sire) while recursively searching IREs for an offsubnet
* destination. With this flag, even if no IRE_CACHETABLE or IRE_INTERFACE
* is found to help resolving IRE_OFFSUBNET in lookup routines, the
* IRE_OFFSUBNET sire, if any, is returned to the caller.
*/
/* UNUSED 0x0800 */
/* even if ire is not matched. */
/* don't match IRE_LOCALs from other */
/* zones or shared IREs */
/* IRE_MARK_PRIVATE_ADDR. */
/* IRE_CACHE entry only if it is */
/* ND_REACHABLE */
/*
* Any ire to nce association is long term, and
* the refhold and refrele may be done by different
* threads. So all cases of making or breaking ire to
* nce association should all effectively use the NOTR variants.
* To understand the *effectively* part read on.
*
* ndp_lookup() and ndp_add_v4()/ndp_add_v6() implicitly do
* NCE_REFHOLD. So wherever we make ire to nce association after
* calling these functions, we effectively want to end up with
* NCE_REFHOLD_NOTR. We call this macro to achieve this effect. This
* macro changes a NCE_REFHOLD to a NCE_REFHOLD_NOTR. The macro's
* NCE_REFRELE cancels off ndp_lookup[ndp_add]'s implicit NCE_REFHOLD,
* and what you are left with is a NCE_REFHOLD_NOTR
*/
#define NCE_REFHOLD_TO_REFHOLD_NOTR(nce) { \
NCE_REFHOLD_NOTR(nce); \
NCE_REFRELE(nce); \
}
/*
* find the next ire_t entry in the ire_next chain starting at ire
* that is not CONDEMNED. ire is set to NULL if we reach the end of the list.
* Caller must hold the ire_bucket lock.
*/
#define IRE_FIND_NEXT_ORIGIN(ire) { \
}
/* Structure for ire_cache_count() */
typedef struct {
int icc_total; /* Total number of IRE_CACHE */
int icc_unused; /* # off/no PMTU unused since last reclaim */
int icc_offlink; /* # offlink without PMTU information */
int icc_pmtu; /* # offlink with PMTU information */
int icc_onlink; /* # onlink */
/*
* Structure for ire_cache_reclaim(). Each field is a fraction i.e. 1 meaning
* reclaim all, N meaning reclaim 1/Nth of all entries, 0 meaning reclaim none.
*
* The comment below (and for other netstack_t references) refers
* to the fact that we only do netstack_hold in particular cases,
* such as the references from open streams (ill_t and conn_t's
* pointers). Internally within IP we rely on IP's ability to cleanup e.g.
* ire_t's when an ill goes away.
*/
typedef struct {
int icr_unused; /* Fraction for unused since last reclaim */
int icr_offlink; /* Fraction for offlink without PMTU info */
int icr_pmtu; /* Fraction for offlink with PMTU info */
int icr_onlink; /* Fraction for onlink */
/*
* We use atomics so that we get an accurate accounting on the ires.
* Otherwise we can't determine leaks correctly.
*/
#ifdef _KERNEL
/*
* Structure for passing args for the IRE cache lookup functions.
*/
typedef struct ire_ctable_args_s {
void *ict_addr;
void *ict_gateway;
int ict_type;
const ts_label_t *ict_tsl;
int ict_flags;
struct ts_label_s;
struct nce_s;
extern void ip_ire_clookup_and_delete_v6(const in6_addr_t *,
ip_stack_t *);
extern int ip_mask_to_plen(ipaddr_t);
extern int ip_mask_to_plen_v6(const in6_addr_t *);
extern void ire_cache_count(ire_t *, char *);
const struct ts_label_s *, ip_stack_t *);
const struct ts_label_s *, ip_stack_t *);
extern void ire_cache_reclaim(ire_t *, char *);
ip_stack_t *);
tsol_gcgrp_t *, ip_stack_t *);
ire_t **, int);
tsol_gcgrp_t *, ip_stack_t *);
ip_stack_t *);
ip_stack_t *);
ip_stack_t *);
extern void ire_delete(ire_t *);
extern void ire_delete_cache_gw(ire_t *, char *);
extern void ire_delete_cache_gw_v6(ire_t *, char *);
extern void ire_delete_cache_v6(ire_t *, char *);
extern void ire_delete_v6(ire_t *);
extern void ire_expire(ire_t *, char *);
extern void ire_flush_cache_v4(ire_t *, int);
extern void ire_flush_cache_v6(ire_t *, int);
const struct ts_label_s *, ip_stack_t *);
ip_stack_t *);
extern void ire_refrele(ire_t *);
extern void ire_refrele_notr(ire_t *);
ip_stack_t *);
const struct ts_label_s *, int, ip_stack_t *);
const struct ts_label_s *, ip_stack_t *);
const struct ts_label_s *, ip_stack_t *);
const struct ts_label_s *, ip_stack_t *);
const struct ts_label_s *, ip_stack_t *);
extern void ire_arpresolve(ire_t *);
extern void ire_freemblk(ire_t *);
queue_t *);
zoneid_t, ip_stack_t *);
ip_stack_t *, queue_t *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _INET_IP_IRE_H */