mpd_tables.h revision e3e7cd2990d896de7fff76bc91b8cf570470d6ba
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _MPD_TABLES_H
#define _MPD_TABLES_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Terminology:
*
* phyint: A NIC eg. hme0. This is represented as 'struct phyint'
*
* phyint instance: A protocol instance of a phyint. Eg. the IPv4 instance of
* hme0 or the IPv6 instance of hme0. (struct phyint_instance)
*
* logint: A logical interface eg. hme0:1 (struct logint)
*
* phyint_group: A group of phyints i.e. physical interfaces that are
* (i) connected to the same level 2 topology e.g. the same ethernet
* switch AND
* (ii) share the same phyint group name.
* Load spreading and failover occur across members of the same phyint group.
* phyint group members must be homogenous. i.e. if a phyint belonging to a
* phyint group has a IPv6 protocol instance, then all members of the phyint
* group, must have IPv6 protocol instances. (struct phyint_group)
*/
/*
* Parameter passed to try_failover(), indicating the type of failover
* that is requested.
*/
/* that is preferably a standby */
/*
* Status of the phyint, expressed by the return code of failure_state()
*/
#define PHYINT_OK 0 /* No failure detected */
/*
* Return values of phyint_inst_update_from_k()
*/
/*
* Though IFF_POINTOPOINT is a logint property, for the purpose of
* failover, we treat it as a phyint property. Note that we cannot failover
* individual logints.
*/
#define PHYINT_FLAGS(flags) \
0 : IFF_RUNNING))
/* A Phyint can have up to 2 instances, the IPv4 and the IPv6 instance */
/*
* A phyint instance is probe *enabled* if it has been configured with a
* unique probe address (i.e., an IFF_NOFAILOVER address). It is probe
* *capable* if it is also able to send probes (i.e., has one or more
* targets available).
*/
#define PROBE_ENABLED(pii) \
#define PROBE_CAPABLE(pii) \
/* Subtract b from a modulo n. i.e. (a - b) mod n */
#define MOD_SUB(a, b, n) \
((((a) + (n)) - (b)) % (n))
/* Increment modulo n */
#define MOD_INCR(a, n) \
(((a) + 1) % (n))
/* Decrement modulo n */
#define MOD_DCR(a, n) \
MOD_SUB(a, 1, n)
/*
* 'index' represents an index into the circular probe stats array of
* size PROBE_STATS_COUNT. 0 <= index < PROBE_STATS_COUNT. This is used
* to access members of the pii_probes[] array defined in the phyint_instance
* structure.
*/
#define PROBE_INDEX_PREV(index) \
#define PROBE_INDEX_NEXT(index) \
/*
* If we receive more than LINK_UP_PERMIN "link up" notifications in a minute,
* then don't actually perform the repair operation until we've dropped back
* below the threshold (or we have a probe address and our probes indicate
* that the link is functioning again). This is to prevent link flapping in
* the case where we don't have a probe address.
*/
#define LINK_UP_PERMIN 2
/*
* Phyint group states; see below for the phyint group definition.
*/
enum pg_state {
};
/*
* Convenience macro to check if the whole group has failed.
*/
/*
* A doubly linked list of all phyint groups in the system.
* A phyint group is identified by its group name.
*/
struct phyint_group {
int pg_probeint; /* Interval between probes */
int pg_fdt; /* Time needed to detect failure */
};
/*
* Phyint states; see below for the phyint definition.
*/
enum pi_state {
};
/*
* Representation of a NIC or a phyint. There is a list of all known phyints.
* There is also a list of phyints belonging to a phyint group, one list
* per phyint group.
*/
struct phyint {
/* about missing test addresses */
/*
* The pi_whenup array is a circular buffer of the most recent
* times (in milliseconds since some arbitrary point of time in
* the past) that the interface was brought up; pi_whendx identifies
* the oldest element of the array.
*/
unsigned int pi_whendx;
/* More details in probe.c */
};
/*
* A doubly linked list of all phyint_instances each of which contains a
* doubly linked list of logical interfaces and targets. For eg. if both
* IPv4 and IPv6 are used over hme0, we have 2 phyint instances, 1 for each
* protocol.
*/
struct phyint_instance {
int pii_probe_sock; /* Socket for ICMP Probe packets */
int pii_af; /* Address family */
/* includes some randomness */
/* for all periodic probes */
/* for failure detection probes */
/* not send probes out this pii */
struct probe_stats {
#define PR_UNUSED 0 /* Probe slot unused */
union {
} prt;
struct target *pii_rtt_target_next;
/* next target for rtt probes */
int pii_ntargets; /* Number of active targets */
struct stats { /* Cumulative statistics */
/* probe acks */
};
/*
* A doubly linked list of prefixes or logicals, hanging off the
* phyint instance.
*/
struct logint {
struct phyint_instance *li_phyint_inst;
/* Back pointer to phyint inst. */
};
/*
* Doubly-linked list of probe targets on a phyint instance. Probe targets are
* usually onlink routers. If no onlink routers can be found, onlink hosts
* are used.
*/
struct target {
struct phyint_instance *tg_phyint_inst;
/* Back pointer to phyint instance */
int tg_status; /* Status of the target below */
int tg_rtt_sa; /* Scaled round trip time(RTT) avg. */
int tg_rtt_sd; /* Scaled RTT deviation */
int tg_crtt; /* Conservative RTT = A + 4D */
/* Deferred rtt data points */
int tg_num_deferred;
/* Number of deferred rtt data points */
};
#define TG_STATUS_VALID(status) \
/*
* Statistics about consecutive probe failures are passed around between
* functions in this structure.
*/
struct probe_fail_count
{
int pf_nfail; /* Number of consecutive probe failures */
int pf_nfail_tg; /* Number of consecutive probe fails for */
/* some given target 'tg' */
};
/*
* Statistics about consecutive probe successes is passed around between
* functions in this structure.
*/
struct probe_success_count
{
int ps_nsucc; /* Number of consecutive probe successes */
/* starting from the most recent */
int ps_nsucc_tg; /* Number of consecutive probe successes */
/* for some given target 'tg' */
};
/*
* Statistics about missed probes that were never sent.
* Happens due to scheduling delay.
*/
struct probes_missed
{
};
struct local_addr
{
struct local_addr *next;
};
/*
* Globals
*/
extern struct local_addr *laddr_list;
/* List of all local addresses, including local zones */
extern struct phyint_instance *phyint_instances;
/* List of all phyint instances */
extern struct probes_missed probes_missed;
/* statistics about missed probes */
/*
* Function prototypes
*/
extern int phyint_init(void);
extern void phyint_inst_print_all(void);
extern void process_link_state_changes(void);
extern unsigned int getifinfo(const char *, ipmp_ifinfo_t **);
extern unsigned int getgroupinfo(const char *, ipmp_groupinfo_t **);
extern unsigned int getgrouplist(ipmp_grouplist_t **);
extern unsigned int getsnap(ipmp_snap_t **);
#ifdef __cplusplus
}
#endif
#endif /* _MPD_TABLES_H */