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 52074Smeem * Common Development and Distribution License (the "License"). 62074Smeem * 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 /* 22*4770Smeem * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _MPD_TABLES_H 270Sstevel@tonic-gate #define _MPD_TABLES_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * Terminology: 370Sstevel@tonic-gate * 380Sstevel@tonic-gate * phyint: A NIC eg. hme0. This is represented as 'struct phyint' 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * phyint instance: A protocol instance of a phyint. Eg. the IPv4 instance of 410Sstevel@tonic-gate * hme0 or the IPv6 instance of hme0. (struct phyint_instance) 420Sstevel@tonic-gate * 430Sstevel@tonic-gate * logint: A logical interface eg. hme0:1 (struct logint) 440Sstevel@tonic-gate * 450Sstevel@tonic-gate * phyint_group: A group of phyints i.e. physical interfaces that are 460Sstevel@tonic-gate * (i) connected to the same level 2 topology e.g. the same ethernet 470Sstevel@tonic-gate * switch AND 480Sstevel@tonic-gate * (ii) share the same phyint group name. 490Sstevel@tonic-gate * Load spreading and failover occur across members of the same phyint group. 500Sstevel@tonic-gate * phyint group members must be homogenous. i.e. if a phyint belonging to a 510Sstevel@tonic-gate * phyint group has a IPv6 protocol instance, then all members of the phyint 520Sstevel@tonic-gate * group, must have IPv6 protocol instances. (struct phyint_group) 530Sstevel@tonic-gate */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * Parameter passed to try_failover(), indicating the type of failover 570Sstevel@tonic-gate * that is requested. 580Sstevel@tonic-gate */ 590Sstevel@tonic-gate #define FAILOVER_NORMAL 1 /* Failover to another phyint */ 600Sstevel@tonic-gate /* that is preferably a standby */ 610Sstevel@tonic-gate #define FAILOVER_TO_NONSTANDBY 2 /* Failover to non-standby phyint */ 620Sstevel@tonic-gate #define FAILOVER_TO_ANY 3 /* Failover to any available phyint */ 630Sstevel@tonic-gate 640Sstevel@tonic-gate #define MAXDEFERREDRTT 1 /* Maximum number of deferred rtts */ 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * Status of the phyint, expressed by the return code of failure_state() 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate #define PHYINT_OK 0 /* No failure detected */ 700Sstevel@tonic-gate #define PHYINT_FAILURE 1 /* NIC failure detected */ 710Sstevel@tonic-gate #define GROUP_FAILURE 2 /* All NICs have failed */ 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * Return values of phyint_inst_update_from_k() 750Sstevel@tonic-gate */ 760Sstevel@tonic-gate #define PI_OK 1 /* Phyint matches in the kernel */ 770Sstevel@tonic-gate #define PI_DELETED 2 /* Phyint has vanished in the kernel */ 780Sstevel@tonic-gate #define PI_IFINDEX_CHANGED 3 /* Phyint's ifindex has changed */ 790Sstevel@tonic-gate #define PI_IOCTL_ERROR 4 /* Some ioctl error */ 800Sstevel@tonic-gate #define PI_GROUP_CHANGED 5 /* The phyint has changed group. */ 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * Though IFF_POINTOPOINT is a logint property, for the purpose of 840Sstevel@tonic-gate * failover, we treat it as a phyint property. Note that we cannot failover 850Sstevel@tonic-gate * individual logints. 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate #define PHYINT_FLAGS(flags) \ 880Sstevel@tonic-gate (((flags) & (IFF_STANDBY | IFF_INACTIVE | IFF_FAILED | IFF_OFFLINE | \ 890Sstevel@tonic-gate IFF_POINTOPOINT | IFF_RUNNING)) | (handle_link_notifications ? \ 900Sstevel@tonic-gate 0 : IFF_RUNNING)) 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* A Phyint can have up to 2 instances, the IPv4 and the IPv6 instance */ 930Sstevel@tonic-gate #define PHYINT_INSTANCE(pi, af) \ 940Sstevel@tonic-gate ((af) == AF_INET ? (pi)->pi_v4 : (pi)->pi_v6) 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 972496Smeem * A phyint instance is probe *enabled* if it has been configured with a 982496Smeem * unique probe address (i.e., an IFF_NOFAILOVER address). It is probe 992496Smeem * *capable* if it is also able to send probes (i.e., has one or more 1002496Smeem * targets available). 1010Sstevel@tonic-gate */ 1020Sstevel@tonic-gate #define PROBE_ENABLED(pii) \ 1032496Smeem (((pii) != NULL) && ((pii)->pii_probe_sock != -1) && \ 1042496Smeem ((pii)->pii_probe_logint != NULL) && \ 1052496Smeem (((pii)->pii_probe_logint->li_dupaddr == 0))) 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate #define PROBE_CAPABLE(pii) \ 1080Sstevel@tonic-gate (PROBE_ENABLED(pii) && ((pii)->pii_ntargets != 0)) 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* Subtract b from a modulo n. i.e. (a - b) mod n */ 1110Sstevel@tonic-gate #define MOD_SUB(a, b, n) \ 1120Sstevel@tonic-gate ((((a) + (n)) - (b)) % (n)) 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate /* Increment modulo n */ 1150Sstevel@tonic-gate #define MOD_INCR(a, n) \ 1160Sstevel@tonic-gate (((a) + 1) % (n)) 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* Decrement modulo n */ 1190Sstevel@tonic-gate #define MOD_DCR(a, n) \ 1200Sstevel@tonic-gate MOD_SUB(a, 1, n) 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* 1230Sstevel@tonic-gate * 'index' represents an index into the circular probe stats array of 1240Sstevel@tonic-gate * size PROBE_STATS_COUNT. 0 <= index < PROBE_STATS_COUNT. This is used 1250Sstevel@tonic-gate * to access members of the pii_probes[] array defined in the phyint_instance 1260Sstevel@tonic-gate * structure. 1270Sstevel@tonic-gate */ 1280Sstevel@tonic-gate #define PROBE_INDEX_PREV(index) \ 1290Sstevel@tonic-gate MOD_DCR(index, PROBE_STATS_COUNT) 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate #define PROBE_INDEX_NEXT(index) \ 1320Sstevel@tonic-gate MOD_INCR(index, PROBE_STATS_COUNT) 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* 1360Sstevel@tonic-gate * If we receive more than LINK_UP_PERMIN "link up" notifications in a minute, 1370Sstevel@tonic-gate * then don't actually perform the repair operation until we've dropped back 1380Sstevel@tonic-gate * below the threshold (or we have a probe address and our probes indicate 1390Sstevel@tonic-gate * that the link is functioning again). This is to prevent link flapping in 1400Sstevel@tonic-gate * the case where we don't have a probe address. 1410Sstevel@tonic-gate */ 1420Sstevel@tonic-gate #define LINK_UP_PERMIN 2 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate #define LINK_DOWN(pi) ((pi)->pi_link_state == 0) 1450Sstevel@tonic-gate #define LINK_UP(pi) (!LINK_DOWN(pi)) 1460Sstevel@tonic-gate #define FLAGS_TO_LINK_STATE(pi) (((pi)->pi_flags & IFF_RUNNING) != 0) 1470Sstevel@tonic-gate #define UPDATE_LINK_STATE(pi) ((pi)->pi_link_state = \ 1480Sstevel@tonic-gate FLAGS_TO_LINK_STATE(pi) ? 1 : 0) 1490Sstevel@tonic-gate #define INIT_LINK_STATE(pi) ((pi)->pi_link_state = 1) 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * Phyint group states; see below for the phyint group definition. 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate enum pg_state { 1550Sstevel@tonic-gate PG_RUNNING = 1, /* at least one interface in group is working */ 1560Sstevel@tonic-gate PG_FAILED = 2 /* group has failed completely */ 1570Sstevel@tonic-gate }; 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * Convenience macro to check if the whole group has failed. 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate #define GROUP_FAILED(pg) ((pg)->pg_groupfailed) 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * A doubly linked list of all phyint groups in the system. 1660Sstevel@tonic-gate * A phyint group is identified by its group name. 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate struct phyint_group { 1690Sstevel@tonic-gate char pg_name[LIFNAMSIZ + 1]; /* Phyint group name */ 1700Sstevel@tonic-gate struct phyint *pg_phyint; /* List of phyints in this group */ 1710Sstevel@tonic-gate struct phyint_group *pg_next; /* Next phyint group */ 1720Sstevel@tonic-gate struct phyint_group *pg_prev; /* Prev phyint group */ 1730Sstevel@tonic-gate uint64_t pg_sig; /* Current signature of this group */ 1740Sstevel@tonic-gate int pg_probeint; /* Interval between probes */ 1750Sstevel@tonic-gate int pg_fdt; /* Time needed to detect failure */ 1760Sstevel@tonic-gate uint_t 1770Sstevel@tonic-gate pg_groupfailed : 1; /* The whole group has failed */ 1780Sstevel@tonic-gate }; 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate /* 1810Sstevel@tonic-gate * Phyint states; see below for the phyint definition. 1820Sstevel@tonic-gate */ 1830Sstevel@tonic-gate enum pi_state { 1840Sstevel@tonic-gate PI_NOTARGETS = 1, /* Phyint has no targets */ 1850Sstevel@tonic-gate PI_RUNNING = 2, /* Phyint is functioning */ 1860Sstevel@tonic-gate PI_FAILED = 3, /* Phyint is failed */ 1870Sstevel@tonic-gate PI_OFFLINE = 4 /* Phyint is offline */ 1880Sstevel@tonic-gate }; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate /* 1910Sstevel@tonic-gate * Representation of a NIC or a phyint. There is a list of all known phyints. 1920Sstevel@tonic-gate * There is also a list of phyints belonging to a phyint group, one list 1930Sstevel@tonic-gate * per phyint group. 1940Sstevel@tonic-gate */ 1950Sstevel@tonic-gate struct phyint { 1960Sstevel@tonic-gate char pi_name[LIFNAMSIZ + 1]; /* Phyint name eg. le0 */ 1970Sstevel@tonic-gate struct phyint_instance *pi_v4; /* The IPv4 instance */ 1980Sstevel@tonic-gate struct phyint_instance *pi_v6; /* The IPv6 instance */ 1990Sstevel@tonic-gate struct phyint_group *pi_group; /* Pointer to the group */ 2000Sstevel@tonic-gate struct phyint *pi_next; /* List of all phyints */ 2010Sstevel@tonic-gate struct phyint *pi_prev; /* List of all phyints */ 2020Sstevel@tonic-gate struct phyint *pi_pgnext; /* List of phyints in this group */ 2030Sstevel@tonic-gate struct phyint *pi_pgprev; /* List of phyints in this group */ 2040Sstevel@tonic-gate uint_t pi_ifindex; /* interface index */ 2050Sstevel@tonic-gate enum pi_state pi_state; /* State of the phyint */ 2060Sstevel@tonic-gate uint64_t pi_flags; /* Phyint flags from kernel */ 2070Sstevel@tonic-gate uint16_t pi_icmpid; /* icmp id in icmp echo request */ 208*4770Smeem uint64_t pi_taddrthresh; /* time (in secs) to delay logging */ 209*4770Smeem /* about missing test addresses */ 2100Sstevel@tonic-gate /* 2110Sstevel@tonic-gate * The pi_whenup array is a circular buffer of the most recent 2120Sstevel@tonic-gate * times (in milliseconds since some arbitrary point of time in 2130Sstevel@tonic-gate * the past) that the interface was brought up; pi_whendx identifies 2140Sstevel@tonic-gate * the oldest element of the array. 2150Sstevel@tonic-gate */ 2160Sstevel@tonic-gate uint_t pi_whenup[LINK_UP_PERMIN]; 2170Sstevel@tonic-gate unsigned int pi_whendx; 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate uint_t 2200Sstevel@tonic-gate pi_empty : 1, /* failover done, empty */ 2210Sstevel@tonic-gate pi_full : 1, /* failback done, full */ 2220Sstevel@tonic-gate /* More details in probe.c */ 2230Sstevel@tonic-gate pi_taddrmsg_printed : 1, /* testaddr msg printed */ 224*4770Smeem pi_duptaddrmsg_printed : 1, /* dup testaddr msg printed */ 2250Sstevel@tonic-gate pi_cfgmsg_printed : 1, /* bad config msg printed */ 2260Sstevel@tonic-gate pi_lfmsg_printed : 1, /* link-flapping msg printed */ 2270Sstevel@tonic-gate pi_link_state : 1; /* interface link state */ 2280Sstevel@tonic-gate }; 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate /* 2310Sstevel@tonic-gate * A doubly linked list of all phyint_instances each of which contains a 2320Sstevel@tonic-gate * doubly linked list of logical interfaces and targets. For eg. if both 2330Sstevel@tonic-gate * IPv4 and IPv6 are used over hme0, we have 2 phyint instances, 1 for each 2340Sstevel@tonic-gate * protocol. 2350Sstevel@tonic-gate */ 2360Sstevel@tonic-gate struct phyint_instance { 2370Sstevel@tonic-gate struct phyint_instance *pii_next; /* List of all phyint insts */ 2380Sstevel@tonic-gate struct phyint_instance *pii_prev; /* List of all phyint insts */ 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate struct phyint *pii_phyint; /* Back pointer to the phyint */ 2410Sstevel@tonic-gate struct target *pii_targets; /* List of targets on this link */ 2420Sstevel@tonic-gate struct logint *pii_probe_logint; /* IFF_NOFAILOVER addr for probing */ 2430Sstevel@tonic-gate struct logint *pii_logint; /* Doubly linked list of logical ifs */ 2440Sstevel@tonic-gate 2450Sstevel@tonic-gate int pii_probe_sock; /* Socket for ICMP Probe packets */ 2460Sstevel@tonic-gate int pii_af; /* Address family */ 2470Sstevel@tonic-gate uint16_t pii_rack; /* highest acknowledged seq number */ 2480Sstevel@tonic-gate uint16_t pii_snxt; /* sequence number of next probe */ 2490Sstevel@tonic-gate uint_t pii_snxt_time; /* actual next probe time that */ 2500Sstevel@tonic-gate /* includes some randomness */ 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate uint_t pii_snxt_basetime; /* strictly periodic base probe time */ 2530Sstevel@tonic-gate /* for all periodic probes */ 2540Sstevel@tonic-gate uint_t pii_fd_snxt_basetime; /* strictly periodic base probe time */ 2550Sstevel@tonic-gate /* for failure detection probes */ 2560Sstevel@tonic-gate 2570Sstevel@tonic-gate hrtime_t pii_fd_hrtime; /* hrtime_t before which we should */ 2580Sstevel@tonic-gate /* not send probes out this pii */ 2590Sstevel@tonic-gate 2600Sstevel@tonic-gate uint64_t pii_flags; /* Phyint flags from kernel */ 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate struct probe_stats { 2630Sstevel@tonic-gate struct target *pr_target; /* Probe Target */ 2640Sstevel@tonic-gate uint_t pr_time_sent; /* Time probe was sent */ 2650Sstevel@tonic-gate uint_t pr_status; /* probe status as below */ 2660Sstevel@tonic-gate #define PR_UNUSED 0 /* Probe slot unused */ 2670Sstevel@tonic-gate #define PR_UNACKED 1 /* Probe is unacknowledged */ 2680Sstevel@tonic-gate #define PR_ACKED 2 /* Probe has been acknowledged */ 2690Sstevel@tonic-gate #define PR_LOST 3 /* Probe is declared lost */ 2700Sstevel@tonic-gate union { 2710Sstevel@tonic-gate uint_t tl; /* time probe is declared lost */ 2720Sstevel@tonic-gate uint_t ta; /* time probe is acked */ 2730Sstevel@tonic-gate } prt; 2740Sstevel@tonic-gate #define pr_time_lost prt.tl 2750Sstevel@tonic-gate #define pr_time_acked prt.ta 2760Sstevel@tonic-gate } pii_probes[PROBE_STATS_COUNT]; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate uint_t 2790Sstevel@tonic-gate pii_in_use : 1, /* To detect removed phyints */ 2800Sstevel@tonic-gate pii_basetime_inited : 1, /* probe time initialized */ 2810Sstevel@tonic-gate pii_targets_are_routers : 1; /* routers or hosts ? */ 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate uint_t pii_probe_next; /* next index to use in pii_probes[] */ 2840Sstevel@tonic-gate struct target *pii_target_next; /* next target for probing */ 2850Sstevel@tonic-gate struct target *pii_rtt_target_next; 2860Sstevel@tonic-gate /* next target for rtt probes */ 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate int pii_ntargets; /* Number of active targets */ 2890Sstevel@tonic-gate struct stats { /* Cumulative statistics */ 2900Sstevel@tonic-gate uint64_t lost; /* Number of probes lost */ 2910Sstevel@tonic-gate uint64_t acked; /* Number of probes acked */ 2920Sstevel@tonic-gate uint64_t sent; /* Number of probes sent */ 2930Sstevel@tonic-gate uint64_t unknown; /* Number of ambiguous */ 2940Sstevel@tonic-gate /* probe acks */ 2950Sstevel@tonic-gate } pii_cum_stats; 2960Sstevel@tonic-gate }; 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate #define pii_name pii_phyint->pi_name 2990Sstevel@tonic-gate #define pii_ifindex pii_phyint->pi_ifindex 3000Sstevel@tonic-gate #define pii_state pii_phyint->pi_state 3010Sstevel@tonic-gate #define pii_icmpid pii_phyint->pi_icmpid 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate #define PR_STATUS_VALID(status) ((status) <= PR_LOST) 3040Sstevel@tonic-gate 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate /* 3070Sstevel@tonic-gate * A doubly linked list of prefixes or logicals, hanging off the 3080Sstevel@tonic-gate * phyint instance. 3090Sstevel@tonic-gate */ 3100Sstevel@tonic-gate struct logint { 3110Sstevel@tonic-gate struct logint *li_next; /* Next logint of this phyint inst. */ 3120Sstevel@tonic-gate struct logint *li_prev; /* Prev logint of this phyint inst. */ 3130Sstevel@tonic-gate struct phyint_instance *li_phyint_inst; 3140Sstevel@tonic-gate /* Back pointer to phyint inst. */ 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate char li_name[LIFNAMSIZ + 1]; /* name Eg. hme0:1 */ 3170Sstevel@tonic-gate struct in6_addr li_addr; /* IP address */ 3180Sstevel@tonic-gate struct in6_addr li_dstaddr; /* Dst IP address for pointopoint */ 3190Sstevel@tonic-gate struct in6_addr li_subnet; /* prefix / subnet */ 3200Sstevel@tonic-gate uint_t li_subnet_len; /* prefix / subnet length */ 3210Sstevel@tonic-gate uint64_t li_flags; /* IFF_* flags */ 3220Sstevel@tonic-gate uint_t li_oifindex; /* original ifindex (SIOCGLIFOINDEX) */ 3230Sstevel@tonic-gate uint_t 3240Sstevel@tonic-gate li_in_use : 1, /* flag to detect deleted logints */ 325*4770Smeem li_dupaddr : 1; /* test address is not unique */ 3260Sstevel@tonic-gate }; 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate /* 3300Sstevel@tonic-gate * Doubly-linked list of probe targets on a phyint instance. Probe targets are 3310Sstevel@tonic-gate * usually onlink routers. If no onlink routers can be found, onlink hosts 3320Sstevel@tonic-gate * are used. 3330Sstevel@tonic-gate */ 3340Sstevel@tonic-gate struct target { 3350Sstevel@tonic-gate struct target *tg_next; /* Next target for this phyint inst. */ 3360Sstevel@tonic-gate struct target *tg_prev; /* Prev target for this phyint inst. */ 3370Sstevel@tonic-gate struct phyint_instance *tg_phyint_inst; 3380Sstevel@tonic-gate /* Back pointer to phyint instance */ 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate struct in6_addr tg_address; /* Target IP address */ 3410Sstevel@tonic-gate int tg_status; /* Status of the target below */ 3420Sstevel@tonic-gate #define TG_ACTIVE 1 /* active probe target */ 3430Sstevel@tonic-gate #define TG_UNUSED 2 /* target not in use now */ 3440Sstevel@tonic-gate #define TG_SLOW 3 /* rtt is high - Not in use now */ 3450Sstevel@tonic-gate #define TG_DEAD 4 /* Target is not responding */ 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate hrtime_t tg_latime; /* Target's last active time */ 3480Sstevel@tonic-gate int tg_rtt_sa; /* Scaled round trip time(RTT) avg. */ 3490Sstevel@tonic-gate int tg_rtt_sd; /* Scaled RTT deviation */ 3500Sstevel@tonic-gate int tg_crtt; /* Conservative RTT = A + 4D */ 3510Sstevel@tonic-gate uint32_t 3520Sstevel@tonic-gate tg_in_use : 1; /* In use flag */ 3530Sstevel@tonic-gate int tg_deferred[MAXDEFERREDRTT + 1]; 3540Sstevel@tonic-gate /* Deferred rtt data points */ 3550Sstevel@tonic-gate int tg_num_deferred; 3560Sstevel@tonic-gate /* Number of deferred rtt data points */ 3570Sstevel@tonic-gate }; 3580Sstevel@tonic-gate 3590Sstevel@tonic-gate #define TG_STATUS_VALID(status) \ 3600Sstevel@tonic-gate (((status) >= TG_ACTIVE) && ((status) <= TG_DEAD)) 3610Sstevel@tonic-gate 3620Sstevel@tonic-gate /* 3630Sstevel@tonic-gate * Statistics about consecutive probe failures are passed around between 3640Sstevel@tonic-gate * functions in this structure. 3650Sstevel@tonic-gate */ 3660Sstevel@tonic-gate struct probe_fail_count 3670Sstevel@tonic-gate { 3680Sstevel@tonic-gate uint_t pf_tff; /* Earliest time of failure in a series */ 3690Sstevel@tonic-gate int pf_nfail; /* Number of consecutive probe failures */ 3700Sstevel@tonic-gate int pf_nfail_tg; /* Number of consecutive probe fails for */ 3710Sstevel@tonic-gate /* some given target 'tg' */ 3720Sstevel@tonic-gate }; 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate /* 3750Sstevel@tonic-gate * Statistics about consecutive probe successes is passed around between 3760Sstevel@tonic-gate * functions in this structure. 3770Sstevel@tonic-gate */ 3780Sstevel@tonic-gate struct probe_success_count 3790Sstevel@tonic-gate { 3800Sstevel@tonic-gate uint_t ps_tls; /* Most recent time of probe success */ 3810Sstevel@tonic-gate boolean_t ps_tls_valid; /* is ps_tls valid */ 3820Sstevel@tonic-gate int ps_nsucc; /* Number of consecutive probe successes */ 3830Sstevel@tonic-gate /* starting from the most recent */ 3840Sstevel@tonic-gate int ps_nsucc_tg; /* Number of consecutive probe successes */ 3850Sstevel@tonic-gate /* for some given target 'tg' */ 3860Sstevel@tonic-gate }; 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate /* 3890Sstevel@tonic-gate * Statistics about missed probes that were never sent. 3900Sstevel@tonic-gate * Happens due to scheduling delay. 3910Sstevel@tonic-gate */ 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate struct probes_missed 3940Sstevel@tonic-gate { 3950Sstevel@tonic-gate uint_t pm_nprobes; /* Cumulative number of missed probes */ 3960Sstevel@tonic-gate uint_t pm_ntimes; /* Total number of occassions */ 3970Sstevel@tonic-gate }; 3980Sstevel@tonic-gate 3992250Srk129064 struct local_addr 4002250Srk129064 { 4012250Srk129064 struct in6_addr addr; 4022250Srk129064 struct local_addr *next; 4032250Srk129064 }; 4042250Srk129064 4050Sstevel@tonic-gate /* 4060Sstevel@tonic-gate * Globals 4070Sstevel@tonic-gate */ 4082250Srk129064 extern struct local_addr *laddr_list; 4092250Srk129064 /* List of all local addresses, including local zones */ 4100Sstevel@tonic-gate extern struct phyint *phyints; /* List of all phyints */ 4110Sstevel@tonic-gate extern struct phyint_group *phyint_groups; /* List of all phyint groups */ 4120Sstevel@tonic-gate extern struct phyint_group *phyint_anongroup; /* Pointer to the anon group */ 4130Sstevel@tonic-gate extern struct phyint_instance *phyint_instances; 4140Sstevel@tonic-gate /* List of all phyint instances */ 4150Sstevel@tonic-gate extern struct probes_missed probes_missed; 4160Sstevel@tonic-gate /* statistics about missed probes */ 4170Sstevel@tonic-gate 4180Sstevel@tonic-gate /* 4190Sstevel@tonic-gate * Function prototypes 4200Sstevel@tonic-gate */ 4210Sstevel@tonic-gate extern int phyint_init(void); 4220Sstevel@tonic-gate extern struct phyint *phyint_lookup(const char *name); 4230Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_lookup(int af, char *name); 4240Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_init_from_k(int af, char *name); 4250Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_other(struct phyint_instance *pii); 4260Sstevel@tonic-gate extern int phyint_inst_update_from_k(struct phyint_instance *pii); 4270Sstevel@tonic-gate extern void phyint_inst_delete(struct phyint_instance *pii); 4280Sstevel@tonic-gate extern uint_t phyint_inst_timer(struct phyint_instance *pii); 4290Sstevel@tonic-gate extern boolean_t phyint_inst_sockinit(struct phyint_instance *pii); 4300Sstevel@tonic-gate 4310Sstevel@tonic-gate extern void phyint_newtype(struct phyint *pi); 4320Sstevel@tonic-gate extern void phyint_chstate(struct phyint *pi, enum pi_state state); 4330Sstevel@tonic-gate extern void phyint_group_chstate(struct phyint_group *pg, enum pg_state state); 4340Sstevel@tonic-gate extern void phyint_check_for_repair(struct phyint *pi); 4350Sstevel@tonic-gate 4360Sstevel@tonic-gate extern void logint_init_from_k(struct phyint_instance *pii, char *li_name); 4370Sstevel@tonic-gate extern void logint_delete(struct logint *li); 4380Sstevel@tonic-gate 4390Sstevel@tonic-gate extern struct target *target_lookup(struct phyint_instance *pii, 4400Sstevel@tonic-gate struct in6_addr addr); 4410Sstevel@tonic-gate extern void target_create(struct phyint_instance *pii, 4420Sstevel@tonic-gate struct in6_addr addr, boolean_t is_router); 4430Sstevel@tonic-gate extern void target_delete(struct target *tg); 4440Sstevel@tonic-gate extern struct target *target_next(struct target *tg); 4450Sstevel@tonic-gate extern void target_add(struct phyint_instance *pii, struct in6_addr addr, 4460Sstevel@tonic-gate boolean_t is_router); 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate extern void in_data(struct phyint_instance *pii); 4490Sstevel@tonic-gate extern void in6_data(struct phyint_instance *pii); 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate extern int try_failover(struct phyint *pi, int failover_type); 4522496Smeem extern int try_failback(struct phyint *pi); 4532496Smeem extern int do_failback(struct phyint *pi); 4540Sstevel@tonic-gate extern boolean_t change_lif_flags(struct phyint *pi, uint64_t flags, 4550Sstevel@tonic-gate boolean_t setfl); 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate extern void logperror_pii(struct phyint_instance *pii, char *str); 4580Sstevel@tonic-gate extern void logperror_li(struct logint *li, char *str); 4590Sstevel@tonic-gate extern char *pr_addr(int af, struct in6_addr addr, char *abuf, int len); 4600Sstevel@tonic-gate extern void phyint_inst_print_all(void); 4610Sstevel@tonic-gate 4620Sstevel@tonic-gate extern int logint_upcount(struct phyint *pi); 4630Sstevel@tonic-gate extern void restore_phyint(struct phyint *pi); 4640Sstevel@tonic-gate extern void reset_crtt_all(struct phyint *pi); 4650Sstevel@tonic-gate extern int failure_state(struct phyint_instance *pii); 4660Sstevel@tonic-gate extern void process_link_state_changes(void); 4670Sstevel@tonic-gate extern void clear_pii_probe_stats(struct phyint_instance *pii); 4680Sstevel@tonic-gate extern void start_timer(struct phyint_instance *pii); 4690Sstevel@tonic-gate 4702250Srk129064 extern boolean_t own_address(struct in6_addr addr); 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate extern void close_probe_socket(struct phyint_instance *pii, boolean_t flag); 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate extern unsigned int getifinfo(const char *, ipmp_ifinfo_t **); 4750Sstevel@tonic-gate extern unsigned int getgroupinfo(const char *, ipmp_groupinfo_t **); 4760Sstevel@tonic-gate extern unsigned int getgrouplist(ipmp_grouplist_t **); 4770Sstevel@tonic-gate extern unsigned int getsnap(ipmp_snap_t **); 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate #ifdef __cplusplus 4800Sstevel@tonic-gate } 4810Sstevel@tonic-gate #endif 4820Sstevel@tonic-gate 4830Sstevel@tonic-gate #endif /* _MPD_TABLES_H */ 484