1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _MPD_TABLES_H 28*0Sstevel@tonic-gate #define _MPD_TABLES_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * Terminology: 38*0Sstevel@tonic-gate * 39*0Sstevel@tonic-gate * phyint: A NIC eg. hme0. This is represented as 'struct phyint' 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * phyint instance: A protocol instance of a phyint. Eg. the IPv4 instance of 42*0Sstevel@tonic-gate * hme0 or the IPv6 instance of hme0. (struct phyint_instance) 43*0Sstevel@tonic-gate * 44*0Sstevel@tonic-gate * logint: A logical interface eg. hme0:1 (struct logint) 45*0Sstevel@tonic-gate * 46*0Sstevel@tonic-gate * phyint_group: A group of phyints i.e. physical interfaces that are 47*0Sstevel@tonic-gate * (i) connected to the same level 2 topology e.g. the same ethernet 48*0Sstevel@tonic-gate * switch AND 49*0Sstevel@tonic-gate * (ii) share the same phyint group name. 50*0Sstevel@tonic-gate * Load spreading and failover occur across members of the same phyint group. 51*0Sstevel@tonic-gate * phyint group members must be homogenous. i.e. if a phyint belonging to a 52*0Sstevel@tonic-gate * phyint group has a IPv6 protocol instance, then all members of the phyint 53*0Sstevel@tonic-gate * group, must have IPv6 protocol instances. (struct phyint_group) 54*0Sstevel@tonic-gate */ 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate /* 57*0Sstevel@tonic-gate * Parameter passed to try_failover(), indicating the type of failover 58*0Sstevel@tonic-gate * that is requested. 59*0Sstevel@tonic-gate */ 60*0Sstevel@tonic-gate #define FAILOVER_NORMAL 1 /* Failover to another phyint */ 61*0Sstevel@tonic-gate /* that is preferably a standby */ 62*0Sstevel@tonic-gate #define FAILOVER_TO_NONSTANDBY 2 /* Failover to non-standby phyint */ 63*0Sstevel@tonic-gate #define FAILOVER_TO_ANY 3 /* Failover to any available phyint */ 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate #define MAXDEFERREDRTT 1 /* Maximum number of deferred rtts */ 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate /* 68*0Sstevel@tonic-gate * Status of the phyint, expressed by the return code of failure_state() 69*0Sstevel@tonic-gate */ 70*0Sstevel@tonic-gate #define PHYINT_OK 0 /* No failure detected */ 71*0Sstevel@tonic-gate #define PHYINT_FAILURE 1 /* NIC failure detected */ 72*0Sstevel@tonic-gate #define GROUP_FAILURE 2 /* All NICs have failed */ 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate /* 75*0Sstevel@tonic-gate * Return values of phyint_inst_update_from_k() 76*0Sstevel@tonic-gate */ 77*0Sstevel@tonic-gate #define PI_OK 1 /* Phyint matches in the kernel */ 78*0Sstevel@tonic-gate #define PI_DELETED 2 /* Phyint has vanished in the kernel */ 79*0Sstevel@tonic-gate #define PI_IFINDEX_CHANGED 3 /* Phyint's ifindex has changed */ 80*0Sstevel@tonic-gate #define PI_IOCTL_ERROR 4 /* Some ioctl error */ 81*0Sstevel@tonic-gate #define PI_GROUP_CHANGED 5 /* The phyint has changed group. */ 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate /* 84*0Sstevel@tonic-gate * Though IFF_POINTOPOINT is a logint property, for the purpose of 85*0Sstevel@tonic-gate * failover, we treat it as a phyint property. Note that we cannot failover 86*0Sstevel@tonic-gate * individual logints. 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate #define PHYINT_FLAGS(flags) \ 89*0Sstevel@tonic-gate (((flags) & (IFF_STANDBY | IFF_INACTIVE | IFF_FAILED | IFF_OFFLINE | \ 90*0Sstevel@tonic-gate IFF_POINTOPOINT | IFF_RUNNING)) | (handle_link_notifications ? \ 91*0Sstevel@tonic-gate 0 : IFF_RUNNING)) 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate /* A Phyint can have up to 2 instances, the IPv4 and the IPv6 instance */ 94*0Sstevel@tonic-gate #define PHYINT_INSTANCE(pi, af) \ 95*0Sstevel@tonic-gate ((af) == AF_INET ? (pi)->pi_v4 : (pi)->pi_v6) 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate /* 98*0Sstevel@tonic-gate * A phyint instance is probe *enabled* if it has been configured with a probe 99*0Sstevel@tonic-gate * address (i.e., an IFF_NOFAILOVER address). It is probe *capable* if it is 100*0Sstevel@tonic-gate * also able to send probes (i.e., has one or more targets available). 101*0Sstevel@tonic-gate */ 102*0Sstevel@tonic-gate #define PROBE_ENABLED(pii) \ 103*0Sstevel@tonic-gate (((pii) != NULL) && ((pii)->pii_probe_logint != NULL)) 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate #define PROBE_CAPABLE(pii) \ 106*0Sstevel@tonic-gate (PROBE_ENABLED(pii) && ((pii)->pii_ntargets != 0)) 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* Subtract b from a modulo n. i.e. (a - b) mod n */ 109*0Sstevel@tonic-gate #define MOD_SUB(a, b, n) \ 110*0Sstevel@tonic-gate ((((a) + (n)) - (b)) % (n)) 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate /* Increment modulo n */ 113*0Sstevel@tonic-gate #define MOD_INCR(a, n) \ 114*0Sstevel@tonic-gate (((a) + 1) % (n)) 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate /* Decrement modulo n */ 117*0Sstevel@tonic-gate #define MOD_DCR(a, n) \ 118*0Sstevel@tonic-gate MOD_SUB(a, 1, n) 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * 'index' represents an index into the circular probe stats array of 122*0Sstevel@tonic-gate * size PROBE_STATS_COUNT. 0 <= index < PROBE_STATS_COUNT. This is used 123*0Sstevel@tonic-gate * to access members of the pii_probes[] array defined in the phyint_instance 124*0Sstevel@tonic-gate * structure. 125*0Sstevel@tonic-gate */ 126*0Sstevel@tonic-gate #define PROBE_INDEX_PREV(index) \ 127*0Sstevel@tonic-gate MOD_DCR(index, PROBE_STATS_COUNT) 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate #define PROBE_INDEX_NEXT(index) \ 130*0Sstevel@tonic-gate MOD_INCR(index, PROBE_STATS_COUNT) 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate /* 134*0Sstevel@tonic-gate * If we receive more than LINK_UP_PERMIN "link up" notifications in a minute, 135*0Sstevel@tonic-gate * then don't actually perform the repair operation until we've dropped back 136*0Sstevel@tonic-gate * below the threshold (or we have a probe address and our probes indicate 137*0Sstevel@tonic-gate * that the link is functioning again). This is to prevent link flapping in 138*0Sstevel@tonic-gate * the case where we don't have a probe address. 139*0Sstevel@tonic-gate */ 140*0Sstevel@tonic-gate #define LINK_UP_PERMIN 2 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate #define LINK_DOWN(pi) ((pi)->pi_link_state == 0) 143*0Sstevel@tonic-gate #define LINK_UP(pi) (!LINK_DOWN(pi)) 144*0Sstevel@tonic-gate #define FLAGS_TO_LINK_STATE(pi) (((pi)->pi_flags & IFF_RUNNING) != 0) 145*0Sstevel@tonic-gate #define UPDATE_LINK_STATE(pi) ((pi)->pi_link_state = \ 146*0Sstevel@tonic-gate FLAGS_TO_LINK_STATE(pi) ? 1 : 0) 147*0Sstevel@tonic-gate #define INIT_LINK_STATE(pi) ((pi)->pi_link_state = 1) 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate #define SINGLETON_GROUP(pi) ((pi) != NULL && \ 150*0Sstevel@tonic-gate (pi)->pi_group->pg_name[0] != '\0' && \ 151*0Sstevel@tonic-gate (pi)->pi_group->pg_phyint == (pi) && (pi)->pi_pgnext == NULL) 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate /* 154*0Sstevel@tonic-gate * Phyint group states; see below for the phyint group definition. 155*0Sstevel@tonic-gate */ 156*0Sstevel@tonic-gate enum pg_state { 157*0Sstevel@tonic-gate PG_RUNNING = 1, /* at least one interface in group is working */ 158*0Sstevel@tonic-gate PG_FAILED = 2 /* group has failed completely */ 159*0Sstevel@tonic-gate }; 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate /* 162*0Sstevel@tonic-gate * Convenience macro to check if the whole group has failed. 163*0Sstevel@tonic-gate */ 164*0Sstevel@tonic-gate #define GROUP_FAILED(pg) ((pg)->pg_groupfailed) 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate /* 167*0Sstevel@tonic-gate * A doubly linked list of all phyint groups in the system. 168*0Sstevel@tonic-gate * A phyint group is identified by its group name. 169*0Sstevel@tonic-gate */ 170*0Sstevel@tonic-gate struct phyint_group { 171*0Sstevel@tonic-gate char pg_name[LIFNAMSIZ + 1]; /* Phyint group name */ 172*0Sstevel@tonic-gate struct phyint *pg_phyint; /* List of phyints in this group */ 173*0Sstevel@tonic-gate struct phyint_group *pg_next; /* Next phyint group */ 174*0Sstevel@tonic-gate struct phyint_group *pg_prev; /* Prev phyint group */ 175*0Sstevel@tonic-gate uint64_t pg_sig; /* Current signature of this group */ 176*0Sstevel@tonic-gate int pg_probeint; /* Interval between probes */ 177*0Sstevel@tonic-gate int pg_fdt; /* Time needed to detect failure */ 178*0Sstevel@tonic-gate uint_t 179*0Sstevel@tonic-gate pg_groupfailed : 1; /* The whole group has failed */ 180*0Sstevel@tonic-gate }; 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate /* 183*0Sstevel@tonic-gate * Phyint states; see below for the phyint definition. 184*0Sstevel@tonic-gate */ 185*0Sstevel@tonic-gate enum pi_state { 186*0Sstevel@tonic-gate PI_NOTARGETS = 1, /* Phyint has no targets */ 187*0Sstevel@tonic-gate PI_RUNNING = 2, /* Phyint is functioning */ 188*0Sstevel@tonic-gate PI_FAILED = 3, /* Phyint is failed */ 189*0Sstevel@tonic-gate PI_OFFLINE = 4 /* Phyint is offline */ 190*0Sstevel@tonic-gate }; 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate /* 193*0Sstevel@tonic-gate * Representation of a NIC or a phyint. There is a list of all known phyints. 194*0Sstevel@tonic-gate * There is also a list of phyints belonging to a phyint group, one list 195*0Sstevel@tonic-gate * per phyint group. 196*0Sstevel@tonic-gate */ 197*0Sstevel@tonic-gate struct phyint { 198*0Sstevel@tonic-gate char pi_name[LIFNAMSIZ + 1]; /* Phyint name eg. le0 */ 199*0Sstevel@tonic-gate struct phyint_instance *pi_v4; /* The IPv4 instance */ 200*0Sstevel@tonic-gate struct phyint_instance *pi_v6; /* The IPv6 instance */ 201*0Sstevel@tonic-gate struct phyint_group *pi_group; /* Pointer to the group */ 202*0Sstevel@tonic-gate struct phyint *pi_next; /* List of all phyints */ 203*0Sstevel@tonic-gate struct phyint *pi_prev; /* List of all phyints */ 204*0Sstevel@tonic-gate struct phyint *pi_pgnext; /* List of phyints in this group */ 205*0Sstevel@tonic-gate struct phyint *pi_pgprev; /* List of phyints in this group */ 206*0Sstevel@tonic-gate uint_t pi_ifindex; /* interface index */ 207*0Sstevel@tonic-gate enum pi_state pi_state; /* State of the phyint */ 208*0Sstevel@tonic-gate uint64_t pi_flags; /* Phyint flags from kernel */ 209*0Sstevel@tonic-gate uint16_t pi_icmpid; /* icmp id in icmp echo request */ 210*0Sstevel@tonic-gate /* 211*0Sstevel@tonic-gate * The pi_whenup array is a circular buffer of the most recent 212*0Sstevel@tonic-gate * times (in milliseconds since some arbitrary point of time in 213*0Sstevel@tonic-gate * the past) that the interface was brought up; pi_whendx identifies 214*0Sstevel@tonic-gate * the oldest element of the array. 215*0Sstevel@tonic-gate */ 216*0Sstevel@tonic-gate uint_t pi_whenup[LINK_UP_PERMIN]; 217*0Sstevel@tonic-gate unsigned int pi_whendx; 218*0Sstevel@tonic-gate 219*0Sstevel@tonic-gate uint_t 220*0Sstevel@tonic-gate pi_empty : 1, /* failover done, empty */ 221*0Sstevel@tonic-gate pi_full : 1, /* failback done, full */ 222*0Sstevel@tonic-gate /* More details in probe.c */ 223*0Sstevel@tonic-gate pi_taddrmsg_printed : 1, /* testaddr msg printed */ 224*0Sstevel@tonic-gate pi_cfgmsg_printed : 1, /* bad config msg printed */ 225*0Sstevel@tonic-gate pi_lfmsg_printed : 1, /* link-flapping msg printed */ 226*0Sstevel@tonic-gate pi_link_state : 1; /* interface link state */ 227*0Sstevel@tonic-gate }; 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate /* 230*0Sstevel@tonic-gate * A doubly linked list of all phyint_instances each of which contains a 231*0Sstevel@tonic-gate * doubly linked list of logical interfaces and targets. For eg. if both 232*0Sstevel@tonic-gate * IPv4 and IPv6 are used over hme0, we have 2 phyint instances, 1 for each 233*0Sstevel@tonic-gate * protocol. 234*0Sstevel@tonic-gate */ 235*0Sstevel@tonic-gate struct phyint_instance { 236*0Sstevel@tonic-gate struct phyint_instance *pii_next; /* List of all phyint insts */ 237*0Sstevel@tonic-gate struct phyint_instance *pii_prev; /* List of all phyint insts */ 238*0Sstevel@tonic-gate 239*0Sstevel@tonic-gate struct phyint *pii_phyint; /* Back pointer to the phyint */ 240*0Sstevel@tonic-gate struct target *pii_targets; /* List of targets on this link */ 241*0Sstevel@tonic-gate struct logint *pii_probe_logint; /* IFF_NOFAILOVER addr for probing */ 242*0Sstevel@tonic-gate struct logint *pii_logint; /* Doubly linked list of logical ifs */ 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate int pii_probe_sock; /* Socket for ICMP Probe packets */ 245*0Sstevel@tonic-gate int pii_af; /* Address family */ 246*0Sstevel@tonic-gate uint16_t pii_rack; /* highest acknowledged seq number */ 247*0Sstevel@tonic-gate uint16_t pii_snxt; /* sequence number of next probe */ 248*0Sstevel@tonic-gate uint_t pii_snxt_time; /* actual next probe time that */ 249*0Sstevel@tonic-gate /* includes some randomness */ 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate uint_t pii_snxt_basetime; /* strictly periodic base probe time */ 252*0Sstevel@tonic-gate /* for all periodic probes */ 253*0Sstevel@tonic-gate uint_t pii_fd_snxt_basetime; /* strictly periodic base probe time */ 254*0Sstevel@tonic-gate /* for failure detection probes */ 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate hrtime_t pii_fd_hrtime; /* hrtime_t before which we should */ 257*0Sstevel@tonic-gate /* not send probes out this pii */ 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate uint64_t pii_flags; /* Phyint flags from kernel */ 260*0Sstevel@tonic-gate 261*0Sstevel@tonic-gate struct probe_stats { 262*0Sstevel@tonic-gate struct target *pr_target; /* Probe Target */ 263*0Sstevel@tonic-gate uint_t pr_time_sent; /* Time probe was sent */ 264*0Sstevel@tonic-gate uint_t pr_status; /* probe status as below */ 265*0Sstevel@tonic-gate #define PR_UNUSED 0 /* Probe slot unused */ 266*0Sstevel@tonic-gate #define PR_UNACKED 1 /* Probe is unacknowledged */ 267*0Sstevel@tonic-gate #define PR_ACKED 2 /* Probe has been acknowledged */ 268*0Sstevel@tonic-gate #define PR_LOST 3 /* Probe is declared lost */ 269*0Sstevel@tonic-gate union { 270*0Sstevel@tonic-gate uint_t tl; /* time probe is declared lost */ 271*0Sstevel@tonic-gate uint_t ta; /* time probe is acked */ 272*0Sstevel@tonic-gate } prt; 273*0Sstevel@tonic-gate #define pr_time_lost prt.tl 274*0Sstevel@tonic-gate #define pr_time_acked prt.ta 275*0Sstevel@tonic-gate } pii_probes[PROBE_STATS_COUNT]; 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate uint_t 278*0Sstevel@tonic-gate pii_in_use : 1, /* To detect removed phyints */ 279*0Sstevel@tonic-gate pii_basetime_inited : 1, /* probe time initialized */ 280*0Sstevel@tonic-gate pii_targets_are_routers : 1; /* routers or hosts ? */ 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate uint_t pii_probe_next; /* next index to use in pii_probes[] */ 283*0Sstevel@tonic-gate struct target *pii_target_next; /* next target for probing */ 284*0Sstevel@tonic-gate struct target *pii_rtt_target_next; 285*0Sstevel@tonic-gate /* next target for rtt probes */ 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate int pii_ntargets; /* Number of active targets */ 288*0Sstevel@tonic-gate struct stats { /* Cumulative statistics */ 289*0Sstevel@tonic-gate uint64_t lost; /* Number of probes lost */ 290*0Sstevel@tonic-gate uint64_t acked; /* Number of probes acked */ 291*0Sstevel@tonic-gate uint64_t sent; /* Number of probes sent */ 292*0Sstevel@tonic-gate uint64_t unknown; /* Number of ambiguous */ 293*0Sstevel@tonic-gate /* probe acks */ 294*0Sstevel@tonic-gate } pii_cum_stats; 295*0Sstevel@tonic-gate }; 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate #define pii_name pii_phyint->pi_name 298*0Sstevel@tonic-gate #define pii_ifindex pii_phyint->pi_ifindex 299*0Sstevel@tonic-gate #define pii_state pii_phyint->pi_state 300*0Sstevel@tonic-gate #define pii_icmpid pii_phyint->pi_icmpid 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate #define PR_STATUS_VALID(status) ((status) <= PR_LOST) 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate /* 306*0Sstevel@tonic-gate * A doubly linked list of prefixes or logicals, hanging off the 307*0Sstevel@tonic-gate * phyint instance. 308*0Sstevel@tonic-gate */ 309*0Sstevel@tonic-gate struct logint { 310*0Sstevel@tonic-gate struct logint *li_next; /* Next logint of this phyint inst. */ 311*0Sstevel@tonic-gate struct logint *li_prev; /* Prev logint of this phyint inst. */ 312*0Sstevel@tonic-gate struct phyint_instance *li_phyint_inst; 313*0Sstevel@tonic-gate /* Back pointer to phyint inst. */ 314*0Sstevel@tonic-gate 315*0Sstevel@tonic-gate char li_name[LIFNAMSIZ + 1]; /* name Eg. hme0:1 */ 316*0Sstevel@tonic-gate struct in6_addr li_addr; /* IP address */ 317*0Sstevel@tonic-gate struct in6_addr li_dstaddr; /* Dst IP address for pointopoint */ 318*0Sstevel@tonic-gate struct in6_addr li_subnet; /* prefix / subnet */ 319*0Sstevel@tonic-gate uint_t li_subnet_len; /* prefix / subnet length */ 320*0Sstevel@tonic-gate uint64_t li_flags; /* IFF_* flags */ 321*0Sstevel@tonic-gate uint_t li_oifindex; /* original ifindex (SIOCGLIFOINDEX) */ 322*0Sstevel@tonic-gate uint_t 323*0Sstevel@tonic-gate li_in_use : 1, /* flag to detect deleted logints */ 324*0Sstevel@tonic-gate li_dupaddr : 1, /* This test address is not unique */ 325*0Sstevel@tonic-gate li_dupaddrmsg_printed : 1; 326*0Sstevel@tonic-gate /* Error has been logged to console */ 327*0Sstevel@tonic-gate }; 328*0Sstevel@tonic-gate 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate /* 331*0Sstevel@tonic-gate * Doubly-linked list of probe targets on a phyint instance. Probe targets are 332*0Sstevel@tonic-gate * usually onlink routers. If no onlink routers can be found, onlink hosts 333*0Sstevel@tonic-gate * are used. 334*0Sstevel@tonic-gate */ 335*0Sstevel@tonic-gate struct target { 336*0Sstevel@tonic-gate struct target *tg_next; /* Next target for this phyint inst. */ 337*0Sstevel@tonic-gate struct target *tg_prev; /* Prev target for this phyint inst. */ 338*0Sstevel@tonic-gate struct phyint_instance *tg_phyint_inst; 339*0Sstevel@tonic-gate /* Back pointer to phyint instance */ 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gate struct in6_addr tg_address; /* Target IP address */ 342*0Sstevel@tonic-gate int tg_status; /* Status of the target below */ 343*0Sstevel@tonic-gate #define TG_ACTIVE 1 /* active probe target */ 344*0Sstevel@tonic-gate #define TG_UNUSED 2 /* target not in use now */ 345*0Sstevel@tonic-gate #define TG_SLOW 3 /* rtt is high - Not in use now */ 346*0Sstevel@tonic-gate #define TG_DEAD 4 /* Target is not responding */ 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate hrtime_t tg_latime; /* Target's last active time */ 349*0Sstevel@tonic-gate int tg_rtt_sa; /* Scaled round trip time(RTT) avg. */ 350*0Sstevel@tonic-gate int tg_rtt_sd; /* Scaled RTT deviation */ 351*0Sstevel@tonic-gate int tg_crtt; /* Conservative RTT = A + 4D */ 352*0Sstevel@tonic-gate uint32_t 353*0Sstevel@tonic-gate tg_in_use : 1; /* In use flag */ 354*0Sstevel@tonic-gate int tg_deferred[MAXDEFERREDRTT + 1]; 355*0Sstevel@tonic-gate /* Deferred rtt data points */ 356*0Sstevel@tonic-gate int tg_num_deferred; 357*0Sstevel@tonic-gate /* Number of deferred rtt data points */ 358*0Sstevel@tonic-gate }; 359*0Sstevel@tonic-gate 360*0Sstevel@tonic-gate #define TG_STATUS_VALID(status) \ 361*0Sstevel@tonic-gate (((status) >= TG_ACTIVE) && ((status) <= TG_DEAD)) 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate /* 364*0Sstevel@tonic-gate * Statistics about consecutive probe failures are passed around between 365*0Sstevel@tonic-gate * functions in this structure. 366*0Sstevel@tonic-gate */ 367*0Sstevel@tonic-gate struct probe_fail_count 368*0Sstevel@tonic-gate { 369*0Sstevel@tonic-gate uint_t pf_tff; /* Earliest time of failure in a series */ 370*0Sstevel@tonic-gate int pf_nfail; /* Number of consecutive probe failures */ 371*0Sstevel@tonic-gate int pf_nfail_tg; /* Number of consecutive probe fails for */ 372*0Sstevel@tonic-gate /* some given target 'tg' */ 373*0Sstevel@tonic-gate }; 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate /* 376*0Sstevel@tonic-gate * Statistics about consecutive probe successes is passed around between 377*0Sstevel@tonic-gate * functions in this structure. 378*0Sstevel@tonic-gate */ 379*0Sstevel@tonic-gate struct probe_success_count 380*0Sstevel@tonic-gate { 381*0Sstevel@tonic-gate uint_t ps_tls; /* Most recent time of probe success */ 382*0Sstevel@tonic-gate boolean_t ps_tls_valid; /* is ps_tls valid */ 383*0Sstevel@tonic-gate int ps_nsucc; /* Number of consecutive probe successes */ 384*0Sstevel@tonic-gate /* starting from the most recent */ 385*0Sstevel@tonic-gate int ps_nsucc_tg; /* Number of consecutive probe successes */ 386*0Sstevel@tonic-gate /* for some given target 'tg' */ 387*0Sstevel@tonic-gate }; 388*0Sstevel@tonic-gate 389*0Sstevel@tonic-gate /* 390*0Sstevel@tonic-gate * Statistics about missed probes that were never sent. 391*0Sstevel@tonic-gate * Happens due to scheduling delay. 392*0Sstevel@tonic-gate */ 393*0Sstevel@tonic-gate 394*0Sstevel@tonic-gate struct probes_missed 395*0Sstevel@tonic-gate { 396*0Sstevel@tonic-gate uint_t pm_nprobes; /* Cumulative number of missed probes */ 397*0Sstevel@tonic-gate uint_t pm_ntimes; /* Total number of occassions */ 398*0Sstevel@tonic-gate }; 399*0Sstevel@tonic-gate 400*0Sstevel@tonic-gate /* 401*0Sstevel@tonic-gate * Globals 402*0Sstevel@tonic-gate */ 403*0Sstevel@tonic-gate extern struct phyint *phyints; /* List of all phyints */ 404*0Sstevel@tonic-gate extern struct phyint_group *phyint_groups; /* List of all phyint groups */ 405*0Sstevel@tonic-gate extern struct phyint_group *phyint_anongroup; /* Pointer to the anon group */ 406*0Sstevel@tonic-gate extern struct phyint_instance *phyint_instances; 407*0Sstevel@tonic-gate /* List of all phyint instances */ 408*0Sstevel@tonic-gate extern struct probes_missed probes_missed; 409*0Sstevel@tonic-gate /* statistics about missed probes */ 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate /* 412*0Sstevel@tonic-gate * Function prototypes 413*0Sstevel@tonic-gate */ 414*0Sstevel@tonic-gate extern int phyint_init(void); 415*0Sstevel@tonic-gate extern struct phyint *phyint_lookup(const char *name); 416*0Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_lookup(int af, char *name); 417*0Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_init_from_k(int af, char *name); 418*0Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_other(struct phyint_instance *pii); 419*0Sstevel@tonic-gate extern int phyint_inst_update_from_k(struct phyint_instance *pii); 420*0Sstevel@tonic-gate extern void phyint_inst_delete(struct phyint_instance *pii); 421*0Sstevel@tonic-gate extern uint_t phyint_inst_timer(struct phyint_instance *pii); 422*0Sstevel@tonic-gate extern boolean_t phyint_inst_sockinit(struct phyint_instance *pii); 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate extern void phyint_newtype(struct phyint *pi); 425*0Sstevel@tonic-gate extern void phyint_chstate(struct phyint *pi, enum pi_state state); 426*0Sstevel@tonic-gate extern void phyint_group_chstate(struct phyint_group *pg, enum pg_state state); 427*0Sstevel@tonic-gate extern void phyint_check_for_repair(struct phyint *pi); 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gate extern void logint_init_from_k(struct phyint_instance *pii, char *li_name); 430*0Sstevel@tonic-gate extern void logint_delete(struct logint *li); 431*0Sstevel@tonic-gate 432*0Sstevel@tonic-gate extern struct target *target_lookup(struct phyint_instance *pii, 433*0Sstevel@tonic-gate struct in6_addr addr); 434*0Sstevel@tonic-gate extern void target_create(struct phyint_instance *pii, 435*0Sstevel@tonic-gate struct in6_addr addr, boolean_t is_router); 436*0Sstevel@tonic-gate extern void target_delete(struct target *tg); 437*0Sstevel@tonic-gate extern struct target *target_next(struct target *tg); 438*0Sstevel@tonic-gate extern void target_add(struct phyint_instance *pii, struct in6_addr addr, 439*0Sstevel@tonic-gate boolean_t is_router); 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate extern void in_data(struct phyint_instance *pii); 442*0Sstevel@tonic-gate extern void in6_data(struct phyint_instance *pii); 443*0Sstevel@tonic-gate 444*0Sstevel@tonic-gate extern int try_failover(struct phyint *pi, int failover_type); 445*0Sstevel@tonic-gate extern int try_failback(struct phyint *pi, boolean_t check_only); 446*0Sstevel@tonic-gate extern int do_failback(struct phyint *pi, boolean_t check_only); 447*0Sstevel@tonic-gate extern boolean_t change_lif_flags(struct phyint *pi, uint64_t flags, 448*0Sstevel@tonic-gate boolean_t setfl); 449*0Sstevel@tonic-gate 450*0Sstevel@tonic-gate extern void logperror_pii(struct phyint_instance *pii, char *str); 451*0Sstevel@tonic-gate extern void logperror_li(struct logint *li, char *str); 452*0Sstevel@tonic-gate extern char *pr_addr(int af, struct in6_addr addr, char *abuf, int len); 453*0Sstevel@tonic-gate extern void phyint_inst_print_all(void); 454*0Sstevel@tonic-gate 455*0Sstevel@tonic-gate extern int logint_upcount(struct phyint *pi); 456*0Sstevel@tonic-gate extern void restore_phyint(struct phyint *pi); 457*0Sstevel@tonic-gate extern void reset_crtt_all(struct phyint *pi); 458*0Sstevel@tonic-gate extern int failure_state(struct phyint_instance *pii); 459*0Sstevel@tonic-gate extern void process_link_state_changes(void); 460*0Sstevel@tonic-gate extern void clear_pii_probe_stats(struct phyint_instance *pii); 461*0Sstevel@tonic-gate extern void start_timer(struct phyint_instance *pii); 462*0Sstevel@tonic-gate 463*0Sstevel@tonic-gate extern boolean_t own_address(int af, struct in6_addr addr); 464*0Sstevel@tonic-gate 465*0Sstevel@tonic-gate extern void close_probe_socket(struct phyint_instance *pii, boolean_t flag); 466*0Sstevel@tonic-gate 467*0Sstevel@tonic-gate extern unsigned int getifinfo(const char *, ipmp_ifinfo_t **); 468*0Sstevel@tonic-gate extern unsigned int getgroupinfo(const char *, ipmp_groupinfo_t **); 469*0Sstevel@tonic-gate extern unsigned int getgrouplist(ipmp_grouplist_t **); 470*0Sstevel@tonic-gate extern unsigned int getsnap(ipmp_snap_t **); 471*0Sstevel@tonic-gate 472*0Sstevel@tonic-gate #ifdef __cplusplus 473*0Sstevel@tonic-gate } 474*0Sstevel@tonic-gate #endif 475*0Sstevel@tonic-gate 476*0Sstevel@tonic-gate #endif /* _MPD_TABLES_H */ 477