17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*921e7e07Smeem * Common Development and Distribution License (the "License"). 6*921e7e07Smeem * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*921e7e07Smeem * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _MPD_TABLES_H 277c478bd9Sstevel@tonic-gate #define _MPD_TABLES_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * Terminology: 377c478bd9Sstevel@tonic-gate * 387c478bd9Sstevel@tonic-gate * phyint: A NIC eg. hme0. This is represented as 'struct phyint' 397c478bd9Sstevel@tonic-gate * 407c478bd9Sstevel@tonic-gate * phyint instance: A protocol instance of a phyint. Eg. the IPv4 instance of 417c478bd9Sstevel@tonic-gate * hme0 or the IPv6 instance of hme0. (struct phyint_instance) 427c478bd9Sstevel@tonic-gate * 437c478bd9Sstevel@tonic-gate * logint: A logical interface eg. hme0:1 (struct logint) 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * phyint_group: A group of phyints i.e. physical interfaces that are 467c478bd9Sstevel@tonic-gate * (i) connected to the same level 2 topology e.g. the same ethernet 477c478bd9Sstevel@tonic-gate * switch AND 487c478bd9Sstevel@tonic-gate * (ii) share the same phyint group name. 497c478bd9Sstevel@tonic-gate * Load spreading and failover occur across members of the same phyint group. 507c478bd9Sstevel@tonic-gate * phyint group members must be homogenous. i.e. if a phyint belonging to a 517c478bd9Sstevel@tonic-gate * phyint group has a IPv6 protocol instance, then all members of the phyint 527c478bd9Sstevel@tonic-gate * group, must have IPv6 protocol instances. (struct phyint_group) 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Parameter passed to try_failover(), indicating the type of failover 577c478bd9Sstevel@tonic-gate * that is requested. 587c478bd9Sstevel@tonic-gate */ 597c478bd9Sstevel@tonic-gate #define FAILOVER_NORMAL 1 /* Failover to another phyint */ 607c478bd9Sstevel@tonic-gate /* that is preferably a standby */ 617c478bd9Sstevel@tonic-gate #define FAILOVER_TO_NONSTANDBY 2 /* Failover to non-standby phyint */ 627c478bd9Sstevel@tonic-gate #define FAILOVER_TO_ANY 3 /* Failover to any available phyint */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #define MAXDEFERREDRTT 1 /* Maximum number of deferred rtts */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * Status of the phyint, expressed by the return code of failure_state() 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate #define PHYINT_OK 0 /* No failure detected */ 707c478bd9Sstevel@tonic-gate #define PHYINT_FAILURE 1 /* NIC failure detected */ 717c478bd9Sstevel@tonic-gate #define GROUP_FAILURE 2 /* All NICs have failed */ 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate /* 747c478bd9Sstevel@tonic-gate * Return values of phyint_inst_update_from_k() 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate #define PI_OK 1 /* Phyint matches in the kernel */ 777c478bd9Sstevel@tonic-gate #define PI_DELETED 2 /* Phyint has vanished in the kernel */ 787c478bd9Sstevel@tonic-gate #define PI_IFINDEX_CHANGED 3 /* Phyint's ifindex has changed */ 797c478bd9Sstevel@tonic-gate #define PI_IOCTL_ERROR 4 /* Some ioctl error */ 807c478bd9Sstevel@tonic-gate #define PI_GROUP_CHANGED 5 /* The phyint has changed group. */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * Though IFF_POINTOPOINT is a logint property, for the purpose of 847c478bd9Sstevel@tonic-gate * failover, we treat it as a phyint property. Note that we cannot failover 857c478bd9Sstevel@tonic-gate * individual logints. 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate #define PHYINT_FLAGS(flags) \ 887c478bd9Sstevel@tonic-gate (((flags) & (IFF_STANDBY | IFF_INACTIVE | IFF_FAILED | IFF_OFFLINE | \ 897c478bd9Sstevel@tonic-gate IFF_POINTOPOINT | IFF_RUNNING)) | (handle_link_notifications ? \ 907c478bd9Sstevel@tonic-gate 0 : IFF_RUNNING)) 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* A Phyint can have up to 2 instances, the IPv4 and the IPv6 instance */ 937c478bd9Sstevel@tonic-gate #define PHYINT_INSTANCE(pi, af) \ 947c478bd9Sstevel@tonic-gate ((af) == AF_INET ? (pi)->pi_v4 : (pi)->pi_v6) 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * A phyint instance is probe *enabled* if it has been configured with a probe 987c478bd9Sstevel@tonic-gate * address (i.e., an IFF_NOFAILOVER address). It is probe *capable* if it is 997c478bd9Sstevel@tonic-gate * also able to send probes (i.e., has one or more targets available). 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate #define PROBE_ENABLED(pii) \ 1027c478bd9Sstevel@tonic-gate (((pii) != NULL) && ((pii)->pii_probe_logint != NULL)) 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate #define PROBE_CAPABLE(pii) \ 1057c478bd9Sstevel@tonic-gate (PROBE_ENABLED(pii) && ((pii)->pii_ntargets != 0)) 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* Subtract b from a modulo n. i.e. (a - b) mod n */ 1087c478bd9Sstevel@tonic-gate #define MOD_SUB(a, b, n) \ 1097c478bd9Sstevel@tonic-gate ((((a) + (n)) - (b)) % (n)) 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* Increment modulo n */ 1127c478bd9Sstevel@tonic-gate #define MOD_INCR(a, n) \ 1137c478bd9Sstevel@tonic-gate (((a) + 1) % (n)) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate /* Decrement modulo n */ 1167c478bd9Sstevel@tonic-gate #define MOD_DCR(a, n) \ 1177c478bd9Sstevel@tonic-gate MOD_SUB(a, 1, n) 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * 'index' represents an index into the circular probe stats array of 1217c478bd9Sstevel@tonic-gate * size PROBE_STATS_COUNT. 0 <= index < PROBE_STATS_COUNT. This is used 1227c478bd9Sstevel@tonic-gate * to access members of the pii_probes[] array defined in the phyint_instance 1237c478bd9Sstevel@tonic-gate * structure. 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate #define PROBE_INDEX_PREV(index) \ 1267c478bd9Sstevel@tonic-gate MOD_DCR(index, PROBE_STATS_COUNT) 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #define PROBE_INDEX_NEXT(index) \ 1297c478bd9Sstevel@tonic-gate MOD_INCR(index, PROBE_STATS_COUNT) 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate /* 1337c478bd9Sstevel@tonic-gate * If we receive more than LINK_UP_PERMIN "link up" notifications in a minute, 1347c478bd9Sstevel@tonic-gate * then don't actually perform the repair operation until we've dropped back 1357c478bd9Sstevel@tonic-gate * below the threshold (or we have a probe address and our probes indicate 1367c478bd9Sstevel@tonic-gate * that the link is functioning again). This is to prevent link flapping in 1377c478bd9Sstevel@tonic-gate * the case where we don't have a probe address. 1387c478bd9Sstevel@tonic-gate */ 1397c478bd9Sstevel@tonic-gate #define LINK_UP_PERMIN 2 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #define LINK_DOWN(pi) ((pi)->pi_link_state == 0) 1427c478bd9Sstevel@tonic-gate #define LINK_UP(pi) (!LINK_DOWN(pi)) 1437c478bd9Sstevel@tonic-gate #define FLAGS_TO_LINK_STATE(pi) (((pi)->pi_flags & IFF_RUNNING) != 0) 1447c478bd9Sstevel@tonic-gate #define UPDATE_LINK_STATE(pi) ((pi)->pi_link_state = \ 1457c478bd9Sstevel@tonic-gate FLAGS_TO_LINK_STATE(pi) ? 1 : 0) 1467c478bd9Sstevel@tonic-gate #define INIT_LINK_STATE(pi) ((pi)->pi_link_state = 1) 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* 1497c478bd9Sstevel@tonic-gate * Phyint group states; see below for the phyint group definition. 1507c478bd9Sstevel@tonic-gate */ 1517c478bd9Sstevel@tonic-gate enum pg_state { 1527c478bd9Sstevel@tonic-gate PG_RUNNING = 1, /* at least one interface in group is working */ 1537c478bd9Sstevel@tonic-gate PG_FAILED = 2 /* group has failed completely */ 1547c478bd9Sstevel@tonic-gate }; 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate /* 1577c478bd9Sstevel@tonic-gate * Convenience macro to check if the whole group has failed. 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate #define GROUP_FAILED(pg) ((pg)->pg_groupfailed) 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* 1627c478bd9Sstevel@tonic-gate * A doubly linked list of all phyint groups in the system. 1637c478bd9Sstevel@tonic-gate * A phyint group is identified by its group name. 1647c478bd9Sstevel@tonic-gate */ 1657c478bd9Sstevel@tonic-gate struct phyint_group { 1667c478bd9Sstevel@tonic-gate char pg_name[LIFNAMSIZ + 1]; /* Phyint group name */ 1677c478bd9Sstevel@tonic-gate struct phyint *pg_phyint; /* List of phyints in this group */ 1687c478bd9Sstevel@tonic-gate struct phyint_group *pg_next; /* Next phyint group */ 1697c478bd9Sstevel@tonic-gate struct phyint_group *pg_prev; /* Prev phyint group */ 1707c478bd9Sstevel@tonic-gate uint64_t pg_sig; /* Current signature of this group */ 1717c478bd9Sstevel@tonic-gate int pg_probeint; /* Interval between probes */ 1727c478bd9Sstevel@tonic-gate int pg_fdt; /* Time needed to detect failure */ 1737c478bd9Sstevel@tonic-gate uint_t 1747c478bd9Sstevel@tonic-gate pg_groupfailed : 1; /* The whole group has failed */ 1757c478bd9Sstevel@tonic-gate }; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* 1787c478bd9Sstevel@tonic-gate * Phyint states; see below for the phyint definition. 1797c478bd9Sstevel@tonic-gate */ 1807c478bd9Sstevel@tonic-gate enum pi_state { 1817c478bd9Sstevel@tonic-gate PI_NOTARGETS = 1, /* Phyint has no targets */ 1827c478bd9Sstevel@tonic-gate PI_RUNNING = 2, /* Phyint is functioning */ 1837c478bd9Sstevel@tonic-gate PI_FAILED = 3, /* Phyint is failed */ 1847c478bd9Sstevel@tonic-gate PI_OFFLINE = 4 /* Phyint is offline */ 1857c478bd9Sstevel@tonic-gate }; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* 1887c478bd9Sstevel@tonic-gate * Representation of a NIC or a phyint. There is a list of all known phyints. 1897c478bd9Sstevel@tonic-gate * There is also a list of phyints belonging to a phyint group, one list 1907c478bd9Sstevel@tonic-gate * per phyint group. 1917c478bd9Sstevel@tonic-gate */ 1927c478bd9Sstevel@tonic-gate struct phyint { 1937c478bd9Sstevel@tonic-gate char pi_name[LIFNAMSIZ + 1]; /* Phyint name eg. le0 */ 1947c478bd9Sstevel@tonic-gate struct phyint_instance *pi_v4; /* The IPv4 instance */ 1957c478bd9Sstevel@tonic-gate struct phyint_instance *pi_v6; /* The IPv6 instance */ 1967c478bd9Sstevel@tonic-gate struct phyint_group *pi_group; /* Pointer to the group */ 1977c478bd9Sstevel@tonic-gate struct phyint *pi_next; /* List of all phyints */ 1987c478bd9Sstevel@tonic-gate struct phyint *pi_prev; /* List of all phyints */ 1997c478bd9Sstevel@tonic-gate struct phyint *pi_pgnext; /* List of phyints in this group */ 2007c478bd9Sstevel@tonic-gate struct phyint *pi_pgprev; /* List of phyints in this group */ 2017c478bd9Sstevel@tonic-gate uint_t pi_ifindex; /* interface index */ 2027c478bd9Sstevel@tonic-gate enum pi_state pi_state; /* State of the phyint */ 2037c478bd9Sstevel@tonic-gate uint64_t pi_flags; /* Phyint flags from kernel */ 2047c478bd9Sstevel@tonic-gate uint16_t pi_icmpid; /* icmp id in icmp echo request */ 2057c478bd9Sstevel@tonic-gate /* 2067c478bd9Sstevel@tonic-gate * The pi_whenup array is a circular buffer of the most recent 2077c478bd9Sstevel@tonic-gate * times (in milliseconds since some arbitrary point of time in 2087c478bd9Sstevel@tonic-gate * the past) that the interface was brought up; pi_whendx identifies 2097c478bd9Sstevel@tonic-gate * the oldest element of the array. 2107c478bd9Sstevel@tonic-gate */ 2117c478bd9Sstevel@tonic-gate uint_t pi_whenup[LINK_UP_PERMIN]; 2127c478bd9Sstevel@tonic-gate unsigned int pi_whendx; 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate uint_t 2157c478bd9Sstevel@tonic-gate pi_empty : 1, /* failover done, empty */ 2167c478bd9Sstevel@tonic-gate pi_full : 1, /* failback done, full */ 2177c478bd9Sstevel@tonic-gate /* More details in probe.c */ 2187c478bd9Sstevel@tonic-gate pi_taddrmsg_printed : 1, /* testaddr msg printed */ 2197c478bd9Sstevel@tonic-gate pi_cfgmsg_printed : 1, /* bad config msg printed */ 2207c478bd9Sstevel@tonic-gate pi_lfmsg_printed : 1, /* link-flapping msg printed */ 2217c478bd9Sstevel@tonic-gate pi_link_state : 1; /* interface link state */ 2227c478bd9Sstevel@tonic-gate }; 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* 2257c478bd9Sstevel@tonic-gate * A doubly linked list of all phyint_instances each of which contains a 2267c478bd9Sstevel@tonic-gate * doubly linked list of logical interfaces and targets. For eg. if both 2277c478bd9Sstevel@tonic-gate * IPv4 and IPv6 are used over hme0, we have 2 phyint instances, 1 for each 2287c478bd9Sstevel@tonic-gate * protocol. 2297c478bd9Sstevel@tonic-gate */ 2307c478bd9Sstevel@tonic-gate struct phyint_instance { 2317c478bd9Sstevel@tonic-gate struct phyint_instance *pii_next; /* List of all phyint insts */ 2327c478bd9Sstevel@tonic-gate struct phyint_instance *pii_prev; /* List of all phyint insts */ 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate struct phyint *pii_phyint; /* Back pointer to the phyint */ 2357c478bd9Sstevel@tonic-gate struct target *pii_targets; /* List of targets on this link */ 2367c478bd9Sstevel@tonic-gate struct logint *pii_probe_logint; /* IFF_NOFAILOVER addr for probing */ 2377c478bd9Sstevel@tonic-gate struct logint *pii_logint; /* Doubly linked list of logical ifs */ 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate int pii_probe_sock; /* Socket for ICMP Probe packets */ 2407c478bd9Sstevel@tonic-gate int pii_af; /* Address family */ 2417c478bd9Sstevel@tonic-gate uint16_t pii_rack; /* highest acknowledged seq number */ 2427c478bd9Sstevel@tonic-gate uint16_t pii_snxt; /* sequence number of next probe */ 2437c478bd9Sstevel@tonic-gate uint_t pii_snxt_time; /* actual next probe time that */ 2447c478bd9Sstevel@tonic-gate /* includes some randomness */ 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate uint_t pii_snxt_basetime; /* strictly periodic base probe time */ 2477c478bd9Sstevel@tonic-gate /* for all periodic probes */ 2487c478bd9Sstevel@tonic-gate uint_t pii_fd_snxt_basetime; /* strictly periodic base probe time */ 2497c478bd9Sstevel@tonic-gate /* for failure detection probes */ 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate hrtime_t pii_fd_hrtime; /* hrtime_t before which we should */ 2527c478bd9Sstevel@tonic-gate /* not send probes out this pii */ 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate uint64_t pii_flags; /* Phyint flags from kernel */ 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate struct probe_stats { 2577c478bd9Sstevel@tonic-gate struct target *pr_target; /* Probe Target */ 2587c478bd9Sstevel@tonic-gate uint_t pr_time_sent; /* Time probe was sent */ 2597c478bd9Sstevel@tonic-gate uint_t pr_status; /* probe status as below */ 2607c478bd9Sstevel@tonic-gate #define PR_UNUSED 0 /* Probe slot unused */ 2617c478bd9Sstevel@tonic-gate #define PR_UNACKED 1 /* Probe is unacknowledged */ 2627c478bd9Sstevel@tonic-gate #define PR_ACKED 2 /* Probe has been acknowledged */ 2637c478bd9Sstevel@tonic-gate #define PR_LOST 3 /* Probe is declared lost */ 2647c478bd9Sstevel@tonic-gate union { 2657c478bd9Sstevel@tonic-gate uint_t tl; /* time probe is declared lost */ 2667c478bd9Sstevel@tonic-gate uint_t ta; /* time probe is acked */ 2677c478bd9Sstevel@tonic-gate } prt; 2687c478bd9Sstevel@tonic-gate #define pr_time_lost prt.tl 2697c478bd9Sstevel@tonic-gate #define pr_time_acked prt.ta 2707c478bd9Sstevel@tonic-gate } pii_probes[PROBE_STATS_COUNT]; 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate uint_t 2737c478bd9Sstevel@tonic-gate pii_in_use : 1, /* To detect removed phyints */ 2747c478bd9Sstevel@tonic-gate pii_basetime_inited : 1, /* probe time initialized */ 2757c478bd9Sstevel@tonic-gate pii_targets_are_routers : 1; /* routers or hosts ? */ 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate uint_t pii_probe_next; /* next index to use in pii_probes[] */ 2787c478bd9Sstevel@tonic-gate struct target *pii_target_next; /* next target for probing */ 2797c478bd9Sstevel@tonic-gate struct target *pii_rtt_target_next; 2807c478bd9Sstevel@tonic-gate /* next target for rtt probes */ 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate int pii_ntargets; /* Number of active targets */ 2837c478bd9Sstevel@tonic-gate struct stats { /* Cumulative statistics */ 2847c478bd9Sstevel@tonic-gate uint64_t lost; /* Number of probes lost */ 2857c478bd9Sstevel@tonic-gate uint64_t acked; /* Number of probes acked */ 2867c478bd9Sstevel@tonic-gate uint64_t sent; /* Number of probes sent */ 2877c478bd9Sstevel@tonic-gate uint64_t unknown; /* Number of ambiguous */ 2887c478bd9Sstevel@tonic-gate /* probe acks */ 2897c478bd9Sstevel@tonic-gate } pii_cum_stats; 2907c478bd9Sstevel@tonic-gate }; 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate #define pii_name pii_phyint->pi_name 2937c478bd9Sstevel@tonic-gate #define pii_ifindex pii_phyint->pi_ifindex 2947c478bd9Sstevel@tonic-gate #define pii_state pii_phyint->pi_state 2957c478bd9Sstevel@tonic-gate #define pii_icmpid pii_phyint->pi_icmpid 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate #define PR_STATUS_VALID(status) ((status) <= PR_LOST) 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate /* 3017c478bd9Sstevel@tonic-gate * A doubly linked list of prefixes or logicals, hanging off the 3027c478bd9Sstevel@tonic-gate * phyint instance. 3037c478bd9Sstevel@tonic-gate */ 3047c478bd9Sstevel@tonic-gate struct logint { 3057c478bd9Sstevel@tonic-gate struct logint *li_next; /* Next logint of this phyint inst. */ 3067c478bd9Sstevel@tonic-gate struct logint *li_prev; /* Prev logint of this phyint inst. */ 3077c478bd9Sstevel@tonic-gate struct phyint_instance *li_phyint_inst; 3087c478bd9Sstevel@tonic-gate /* Back pointer to phyint inst. */ 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate char li_name[LIFNAMSIZ + 1]; /* name Eg. hme0:1 */ 3117c478bd9Sstevel@tonic-gate struct in6_addr li_addr; /* IP address */ 3127c478bd9Sstevel@tonic-gate struct in6_addr li_dstaddr; /* Dst IP address for pointopoint */ 3137c478bd9Sstevel@tonic-gate struct in6_addr li_subnet; /* prefix / subnet */ 3147c478bd9Sstevel@tonic-gate uint_t li_subnet_len; /* prefix / subnet length */ 3157c478bd9Sstevel@tonic-gate uint64_t li_flags; /* IFF_* flags */ 3167c478bd9Sstevel@tonic-gate uint_t li_oifindex; /* original ifindex (SIOCGLIFOINDEX) */ 3177c478bd9Sstevel@tonic-gate uint_t 3187c478bd9Sstevel@tonic-gate li_in_use : 1, /* flag to detect deleted logints */ 3197c478bd9Sstevel@tonic-gate li_dupaddr : 1, /* This test address is not unique */ 3207c478bd9Sstevel@tonic-gate li_dupaddrmsg_printed : 1; 3217c478bd9Sstevel@tonic-gate /* Error has been logged to console */ 3227c478bd9Sstevel@tonic-gate }; 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate /* 3267c478bd9Sstevel@tonic-gate * Doubly-linked list of probe targets on a phyint instance. Probe targets are 3277c478bd9Sstevel@tonic-gate * usually onlink routers. If no onlink routers can be found, onlink hosts 3287c478bd9Sstevel@tonic-gate * are used. 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate struct target { 3317c478bd9Sstevel@tonic-gate struct target *tg_next; /* Next target for this phyint inst. */ 3327c478bd9Sstevel@tonic-gate struct target *tg_prev; /* Prev target for this phyint inst. */ 3337c478bd9Sstevel@tonic-gate struct phyint_instance *tg_phyint_inst; 3347c478bd9Sstevel@tonic-gate /* Back pointer to phyint instance */ 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate struct in6_addr tg_address; /* Target IP address */ 3377c478bd9Sstevel@tonic-gate int tg_status; /* Status of the target below */ 3387c478bd9Sstevel@tonic-gate #define TG_ACTIVE 1 /* active probe target */ 3397c478bd9Sstevel@tonic-gate #define TG_UNUSED 2 /* target not in use now */ 3407c478bd9Sstevel@tonic-gate #define TG_SLOW 3 /* rtt is high - Not in use now */ 3417c478bd9Sstevel@tonic-gate #define TG_DEAD 4 /* Target is not responding */ 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate hrtime_t tg_latime; /* Target's last active time */ 3447c478bd9Sstevel@tonic-gate int tg_rtt_sa; /* Scaled round trip time(RTT) avg. */ 3457c478bd9Sstevel@tonic-gate int tg_rtt_sd; /* Scaled RTT deviation */ 3467c478bd9Sstevel@tonic-gate int tg_crtt; /* Conservative RTT = A + 4D */ 3477c478bd9Sstevel@tonic-gate uint32_t 3487c478bd9Sstevel@tonic-gate tg_in_use : 1; /* In use flag */ 3497c478bd9Sstevel@tonic-gate int tg_deferred[MAXDEFERREDRTT + 1]; 3507c478bd9Sstevel@tonic-gate /* Deferred rtt data points */ 3517c478bd9Sstevel@tonic-gate int tg_num_deferred; 3527c478bd9Sstevel@tonic-gate /* Number of deferred rtt data points */ 3537c478bd9Sstevel@tonic-gate }; 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate #define TG_STATUS_VALID(status) \ 3567c478bd9Sstevel@tonic-gate (((status) >= TG_ACTIVE) && ((status) <= TG_DEAD)) 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * Statistics about consecutive probe failures are passed around between 3607c478bd9Sstevel@tonic-gate * functions in this structure. 3617c478bd9Sstevel@tonic-gate */ 3627c478bd9Sstevel@tonic-gate struct probe_fail_count 3637c478bd9Sstevel@tonic-gate { 3647c478bd9Sstevel@tonic-gate uint_t pf_tff; /* Earliest time of failure in a series */ 3657c478bd9Sstevel@tonic-gate int pf_nfail; /* Number of consecutive probe failures */ 3667c478bd9Sstevel@tonic-gate int pf_nfail_tg; /* Number of consecutive probe fails for */ 3677c478bd9Sstevel@tonic-gate /* some given target 'tg' */ 3687c478bd9Sstevel@tonic-gate }; 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate /* 3717c478bd9Sstevel@tonic-gate * Statistics about consecutive probe successes is passed around between 3727c478bd9Sstevel@tonic-gate * functions in this structure. 3737c478bd9Sstevel@tonic-gate */ 3747c478bd9Sstevel@tonic-gate struct probe_success_count 3757c478bd9Sstevel@tonic-gate { 3767c478bd9Sstevel@tonic-gate uint_t ps_tls; /* Most recent time of probe success */ 3777c478bd9Sstevel@tonic-gate boolean_t ps_tls_valid; /* is ps_tls valid */ 3787c478bd9Sstevel@tonic-gate int ps_nsucc; /* Number of consecutive probe successes */ 3797c478bd9Sstevel@tonic-gate /* starting from the most recent */ 3807c478bd9Sstevel@tonic-gate int ps_nsucc_tg; /* Number of consecutive probe successes */ 3817c478bd9Sstevel@tonic-gate /* for some given target 'tg' */ 3827c478bd9Sstevel@tonic-gate }; 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate /* 3857c478bd9Sstevel@tonic-gate * Statistics about missed probes that were never sent. 3867c478bd9Sstevel@tonic-gate * Happens due to scheduling delay. 3877c478bd9Sstevel@tonic-gate */ 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate struct probes_missed 3907c478bd9Sstevel@tonic-gate { 3917c478bd9Sstevel@tonic-gate uint_t pm_nprobes; /* Cumulative number of missed probes */ 3927c478bd9Sstevel@tonic-gate uint_t pm_ntimes; /* Total number of occassions */ 3937c478bd9Sstevel@tonic-gate }; 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate /* 3967c478bd9Sstevel@tonic-gate * Globals 3977c478bd9Sstevel@tonic-gate */ 3987c478bd9Sstevel@tonic-gate extern struct phyint *phyints; /* List of all phyints */ 3997c478bd9Sstevel@tonic-gate extern struct phyint_group *phyint_groups; /* List of all phyint groups */ 4007c478bd9Sstevel@tonic-gate extern struct phyint_group *phyint_anongroup; /* Pointer to the anon group */ 4017c478bd9Sstevel@tonic-gate extern struct phyint_instance *phyint_instances; 4027c478bd9Sstevel@tonic-gate /* List of all phyint instances */ 4037c478bd9Sstevel@tonic-gate extern struct probes_missed probes_missed; 4047c478bd9Sstevel@tonic-gate /* statistics about missed probes */ 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate /* 4077c478bd9Sstevel@tonic-gate * Function prototypes 4087c478bd9Sstevel@tonic-gate */ 4097c478bd9Sstevel@tonic-gate extern int phyint_init(void); 4107c478bd9Sstevel@tonic-gate extern struct phyint *phyint_lookup(const char *name); 4117c478bd9Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_lookup(int af, char *name); 4127c478bd9Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_init_from_k(int af, char *name); 4137c478bd9Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_other(struct phyint_instance *pii); 4147c478bd9Sstevel@tonic-gate extern int phyint_inst_update_from_k(struct phyint_instance *pii); 4157c478bd9Sstevel@tonic-gate extern void phyint_inst_delete(struct phyint_instance *pii); 4167c478bd9Sstevel@tonic-gate extern uint_t phyint_inst_timer(struct phyint_instance *pii); 4177c478bd9Sstevel@tonic-gate extern boolean_t phyint_inst_sockinit(struct phyint_instance *pii); 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate extern void phyint_newtype(struct phyint *pi); 4207c478bd9Sstevel@tonic-gate extern void phyint_chstate(struct phyint *pi, enum pi_state state); 4217c478bd9Sstevel@tonic-gate extern void phyint_group_chstate(struct phyint_group *pg, enum pg_state state); 4227c478bd9Sstevel@tonic-gate extern void phyint_check_for_repair(struct phyint *pi); 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate extern void logint_init_from_k(struct phyint_instance *pii, char *li_name); 4257c478bd9Sstevel@tonic-gate extern void logint_delete(struct logint *li); 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate extern struct target *target_lookup(struct phyint_instance *pii, 4287c478bd9Sstevel@tonic-gate struct in6_addr addr); 4297c478bd9Sstevel@tonic-gate extern void target_create(struct phyint_instance *pii, 4307c478bd9Sstevel@tonic-gate struct in6_addr addr, boolean_t is_router); 4317c478bd9Sstevel@tonic-gate extern void target_delete(struct target *tg); 4327c478bd9Sstevel@tonic-gate extern struct target *target_next(struct target *tg); 4337c478bd9Sstevel@tonic-gate extern void target_add(struct phyint_instance *pii, struct in6_addr addr, 4347c478bd9Sstevel@tonic-gate boolean_t is_router); 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate extern void in_data(struct phyint_instance *pii); 4377c478bd9Sstevel@tonic-gate extern void in6_data(struct phyint_instance *pii); 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate extern int try_failover(struct phyint *pi, int failover_type); 4407c478bd9Sstevel@tonic-gate extern int try_failback(struct phyint *pi, boolean_t check_only); 4417c478bd9Sstevel@tonic-gate extern int do_failback(struct phyint *pi, boolean_t check_only); 4427c478bd9Sstevel@tonic-gate extern boolean_t change_lif_flags(struct phyint *pi, uint64_t flags, 4437c478bd9Sstevel@tonic-gate boolean_t setfl); 4447c478bd9Sstevel@tonic-gate 4457c478bd9Sstevel@tonic-gate extern void logperror_pii(struct phyint_instance *pii, char *str); 4467c478bd9Sstevel@tonic-gate extern void logperror_li(struct logint *li, char *str); 4477c478bd9Sstevel@tonic-gate extern char *pr_addr(int af, struct in6_addr addr, char *abuf, int len); 4487c478bd9Sstevel@tonic-gate extern void phyint_inst_print_all(void); 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate extern int logint_upcount(struct phyint *pi); 4517c478bd9Sstevel@tonic-gate extern void restore_phyint(struct phyint *pi); 4527c478bd9Sstevel@tonic-gate extern void reset_crtt_all(struct phyint *pi); 4537c478bd9Sstevel@tonic-gate extern int failure_state(struct phyint_instance *pii); 4547c478bd9Sstevel@tonic-gate extern void process_link_state_changes(void); 4557c478bd9Sstevel@tonic-gate extern void clear_pii_probe_stats(struct phyint_instance *pii); 4567c478bd9Sstevel@tonic-gate extern void start_timer(struct phyint_instance *pii); 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate extern boolean_t own_address(int af, struct in6_addr addr); 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate extern void close_probe_socket(struct phyint_instance *pii, boolean_t flag); 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate extern unsigned int getifinfo(const char *, ipmp_ifinfo_t **); 4637c478bd9Sstevel@tonic-gate extern unsigned int getgroupinfo(const char *, ipmp_groupinfo_t **); 4647c478bd9Sstevel@tonic-gate extern unsigned int getgrouplist(ipmp_grouplist_t **); 4657c478bd9Sstevel@tonic-gate extern unsigned int getsnap(ipmp_snap_t **); 4667c478bd9Sstevel@tonic-gate 4677c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4687c478bd9Sstevel@tonic-gate } 4697c478bd9Sstevel@tonic-gate #endif 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate #endif /* _MPD_TABLES_H */ 472