Lines Matching defs:pii
63 static void incoming_echo_reply(struct phyint_instance *pii,
65 static void incoming_rtt_reply(struct phyint_instance *pii,
67 static void incoming_mcast_reply(struct phyint_instance *pii,
71 static boolean_t check_pii_crtt_improved(struct phyint_instance *pii);
72 static boolean_t check_exception_target(struct phyint_instance *pii,
74 static void probe_fail_info(struct phyint_instance *pii,
76 static void probe_success_info(struct phyint_instance *pii,
215 probe(struct phyint_instance *pii, uint_t probe_type, hrtime_t start_hrtime)
222 int pr_ndx; /* probe index in pii->pii_probes[] */
227 logdebug("probe(%s %s %d %lld)\n", AF_STR(pii->pii_af),
228 pii->pii_name, probe_type, start_hrtime);
231 assert(pii->pii_probe_sock != -1);
235 probe_pkt.pr_icmp_type = (pii->pii_af == AF_INET) ?
239 probe_pkt.pr_icmp_seq = htons(pii->pii_snxt);
246 probe_pkt.pr_icmp_id = pii->pii_icmpid;
254 assert(probe_type == PROBE_MULTI || ((pii->pii_target_next != NULL) &&
255 pii->pii_rtt_target_next != NULL));
258 targ.ss_family = pii->pii_af;
260 if (pii->pii_af == AF_INET6) {
268 *addr6 = pii->pii_target_next->tg_address;
270 *addr6 = pii->pii_rtt_target_next->tg_address;
281 &pii->pii_target_next->tg_address, addr4);
284 &pii->pii_rtt_target_next->tg_address, addr4);
300 rval = sendto(pii->pii_probe_sock, &probe_pkt, sizeof (probe_pkt), 0,
312 logperror_pii(pii, "probe: probe sendto");
324 pr_ndx = pii->pii_probe_next;
328 if (pii->pii_probes[pr_ndx].pr_status == PR_LOST)
329 pii->pii_cum_stats.lost++;
330 else if (pii->pii_probes[pr_ndx].pr_status == PR_ACKED)
331 pii->pii_cum_stats.acked++;
332 pii->pii_cum_stats.sent++;
334 pii->pii_probes[pr_ndx].pr_id = pii->pii_snxt;
335 pii->pii_probes[pr_ndx].pr_tv_sent = sent_tv;
336 pii->pii_probes[pr_ndx].pr_hrtime_sent = sent_hrtime;
337 pii->pii_probes[pr_ndx].pr_hrtime_start = start_hrtime;
338 pii->pii_probes[pr_ndx].pr_target = pii->pii_target_next;
339 probe_chstate(&pii->pii_probes[pr_ndx], pii, PR_UNACKED);
341 pii->pii_probe_next = PROBE_INDEX_NEXT(pii->pii_probe_next);
342 pii->pii_target_next = target_next(pii->pii_target_next);
343 assert(pii->pii_target_next != NULL);
354 pii->pii_rtt_target_next = pii->pii_target_next;
355 pii->pii_snxt++;
357 pii->pii_rtt_target_next =
358 target_next(pii->pii_rtt_target_next);
359 assert(pii->pii_rtt_target_next != NULL);
367 in_data(struct phyint_instance *pii)
384 AF_STR(pii->pii_af), pii->pii_name);
400 if ((len = recvmsg(pii->pii_probe_sock, &msg, 0)) < 0) {
401 logperror_pii(pii, "in_data: recvmsg");
409 if (LINK_DOWN(pii->pii_phyint))
452 if (reply->pr_icmp_id != pii->pii_icmpid) {
459 reply->pr_icmp_code, abuf, pii->pii_name);
465 len, abuf, pii->pii_name);
472 abuf, pii->pii_name);
479 incoming_echo_reply(pii, reply, fromaddr, recv_tvp);
482 incoming_mcast_reply(pii, reply, fromaddr);
484 incoming_rtt_reply(pii, reply, fromaddr);
488 reply->pr_icmp_mtype, abuf, pii->pii_name);
497 in6_data(struct phyint_instance *pii)
512 AF_STR(pii->pii_af), pii->pii_name);
524 if ((len = recvmsg(pii->pii_probe_sock, &msg, 0)) < 0) {
525 logperror_pii(pii, "in6_data: recvmsg");
533 if (LINK_DOWN(pii->pii_phyint))
558 if (reply->pr_icmp_id != pii->pii_icmpid) {
568 "%s on %s\n", abuf, pii->pii_name);
575 abuf, pii->pii_name);
581 reply->pr_icmp_code, abuf, pii->pii_name);
586 len, abuf, pii->pii_name);
593 abuf, pii->pii_name);
598 incoming_echo_reply(pii, reply, from.sin6_addr, recv_tvp);
600 incoming_mcast_reply(pii, reply, from.sin6_addr);
602 incoming_rtt_reply(pii, reply, from.sin6_addr);
606 reply->pr_icmp_mtype, abuf, pii->pii_name);
617 incoming_rtt_reply(struct phyint_instance *pii, struct pr_icmp *reply,
626 (void) pr_addr(pii->pii_af, fromaddr, abuf, sizeof (abuf));
630 AF_STR(pii->pii_af), pii->pii_name, abuf);
634 target = target_lookup(pii, fromaddr);
649 pg = pii->pii_phyint->pi_group;
650 if ((pii->pii_state != PI_RUNNING) || GROUP_FAILED(pg))
678 if (pii->pii_phyint->pi_group != phyint_anongroup) {
681 pg->pg_fdt, AF_STR(pii->pii_af),
682 pii->pii_name,
683 pii->pii_phyint->pi_group->pg_name);
705 incoming_echo_reply(struct phyint_instance *pii, struct pr_icmp *reply,
717 struct phyint_group *pg = pii->pii_phyint->pi_group;
720 (void) pr_addr(pii->pii_af, fromaddr, abuf, sizeof (abuf));
724 AF_STR(pii->pii_af), pii->pii_name, abuf,
732 if (SEQ_GE(pr_icmp_seq, pii->pii_snxt) ||
733 SEQ_LT(pr_icmp_seq, pii->pii_snxt - PROBE_STATS_COUNT)) {
735 pr_icmp_seq, pii->pii_snxt, pii->pii_name, abuf);
736 pii->pii_cum_stats.unknown++;
753 * number in our pii->pii_probes[] array. The icmp sequence number
754 * pii_snxt corresponds to the probe index pii->pii_probe_next
756 pr_ndx = MOD_SUB(pii->pii_probe_next,
757 (uint16_t)(pii->pii_snxt - pr_icmp_seq), PROBE_STATS_COUNT);
759 assert(PR_STATUS_VALID(pii->pii_probes[pr_ndx].pr_status));
761 target = pii->pii_probes[pr_ndx].pr_target;
779 pii->pii_probes[pr_ndx].pr_status,
780 pr_icmp_seq, pii->pii_snxt, pii->pii_name, abuf);
781 pii->pii_cum_stats.unknown++;
783 } else if (pii->pii_probes[pr_ndx].pr_status == PR_ACKED) {
791 pii->pii_probes[pr_ndx].pr_status,
792 pr_icmp_seq, pii->pii_snxt, pii->pii_name, abuf);
793 pii->pii_cum_stats.unknown++;
800 assert(pii->pii_probes[pr_ndx].pr_status != PR_UNACKED);
801 if (pii->pii_probes[pr_ndx].pr_status == PR_UNUSED) {
809 pii->pii_probes[pr_ndx].pr_status,
810 pr_icmp_seq, pii->pii_snxt, pii->pii_name, abuf);
812 pii->pii_cum_stats.unknown++;
840 if ((pii->pii_state != PI_RUNNING) || GROUP_FAILED(pg))
864 exception = check_exception_target(pii, target);
872 if (pii->pii_targets_are_routers) {
882 pii->pii_ntargets--;
888 if (pii->pii_target_next == target) {
889 pii->pii_target_next =
898 * adjusts pii->pii_target_next
901 probe(pii, PROBE_MULTI, cur_hrtime);
917 AF_STR(pii->pii_af), pii->pii_name,
936 pg->pg_fdt, AF_STR(pii->pii_af),
937 pii->pii_name, pg->pg_name);
953 pr_statp = &pii->pii_probes[pr_ndx];
958 probe_chstate(pr_statp, pii, PR_ACKED);
961 * Update pii->pii_rack, i.e. the sequence number of the last received
965 * [pii->pii_snxt - PROBE_STATS_COUNT, pii->pii_snxt).
972 if (SEQ_GE(pii->pii_rack, pii->pii_snxt) ||
973 SEQ_LT(pii->pii_rack, pii->pii_snxt - PROBE_STATS_COUNT) ||
974 SEQ_GT(pr_icmp_seq, pii->pii_rack)) {
975 pii->pii_rack = pr_icmp_seq;
986 struct phyint_instance *pii;
990 pii = tg->tg_phyint_inst;
997 pr_ndx = PROBE_INDEX_PREV(pii->pii_probe_next);
998 pr_seq = pii->pii_snxt;
1005 for (; pr_ndx != pii->pii_probe_next;
1007 if (pii->pii_probes[pr_ndx].pr_target == tg &&
1008 pii->pii_probes[pr_ndx].pr_status == PR_ACKED) {
1044 * Returns _B_TRUE if there's no crtt information available, because pii
1048 check_pii_crtt_improved(struct phyint_instance *pii) {
1051 if (pii == NULL)
1054 if (!PROBE_CAPABLE(pii) ||
1055 pii->pii_phyint->pi_state == PI_FAILED)
1058 for (tg = pii->pii_targets; tg != NULL; tg = tg->tg_next) {
1061 if (tg->tg_crtt > (pii->pii_phyint->pi_group->pg_probeint /
1076 check_exception_target(struct phyint_instance *pii, struct target *target)
1083 AF_STR(pii->pii_af), pii->pii_name,
1084 pr_addr(pii->pii_af, target->tg_address,
1092 if (pii->pii_ntargets < MIN_PROBE_TARGETS + 1)
1102 for (tg = pii->pii_targets; tg != NULL; tg = tg->tg_next) {
1105 pii->pii_phyint->pi_group->pg_probeint /
1121 incoming_mcast_reply(struct phyint_instance *pii, struct pr_icmp *reply,
1131 AF_STR(pii->pii_af), pii->pii_name,
1132 pr_addr(pii->pii_af, fromaddr, abuf, sizeof (abuf)));
1140 assert(pii->pii_ntargets <= MAX_PROBE_TARGETS);
1141 if (pii->pii_targets != NULL) {
1142 if (pii->pii_targets_are_routers ||
1143 (pii->pii_ntargets == MAX_PROBE_TARGETS)) {
1155 pr_addr(pii->pii_af, fromaddr, abuf, sizeof (abuf)),
1156 pii->pii_name);
1164 af = pii->pii_af;
1174 pi = pii->pii_phyint;
1176 target_add(pii, fromaddr, _B_FALSE);
1260 struct phyint_instance *pii = tg->tg_phyint_inst;
1261 int probe_interval = pii->pii_phyint->pi_group->pg_probeint;
1283 pii->pii_probe_logint->li_name, new_crtt,
1523 phyint_inst_check_for_failure(struct phyint_instance *pii)
1525 struct phyint *pi = pii->pii_phyint;
1529 switch (failure_state(pii)) {
1536 pii->pii_name);
1539 " %s\n", pii->pii_name, pi->pi_group->pg_name);
1587 phyint_inst_timer(struct phyint_instance *pii)
1601 int probe_interval = pii->pii_phyint->pi_group->pg_probeint;
1608 AF_STR(pii->pii_af), pii->pii_name);
1611 pii_other = phyint_inst_other(pii);
1612 if (!PROBE_ENABLED(pii) && !PROBE_ENABLED(pii_other)) {
1619 pi = pii->pii_phyint;
1632 if (!PROBE_ENABLED(pii))
1640 if (TIME_LT(cur_time, pii->pii_snxt_time))
1641 return (pii->pii_snxt_time - cur_time);
1646 if (LINK_DOWN(pii->pii_phyint))
1657 pii->pii_snxt_time = pii->pii_snxt_basetime + interval;
1666 if (TIME_GT(cur_time, pii->pii_snxt_time)) {
1669 n = (cur_time - pii->pii_snxt_time) / user_probe_interval;
1670 pii->pii_snxt_time += (n + 1) * user_probe_interval;
1671 pii->pii_snxt_basetime += (n + 1) * user_probe_interval;
1673 " snxt_basetime %u\n", n + 1, cur_time, pii->pii_snxt_time,
1674 pii->pii_snxt_basetime);
1680 pii->pii_snxt_basetime += user_probe_interval;
1681 interval = pii->pii_snxt_time - cur_time;
1684 " interval %u\n", cur_time, pii->pii_snxt_time,
1685 pii->pii_snxt_basetime, interval);
1693 if (pii->pii_target_next == NULL) {
1694 assert(pii->pii_ntargets == 0);
1695 pii->pii_fd_snxt_basetime = pii->pii_snxt_basetime;
1696 probe(pii, PROBE_MULTI, cur_time);
1701 TIME_LT(pii->pii_snxt_time, pii->pii_fd_snxt_basetime)) {
1706 probe(pii, PROBE_RTT, cur_hrtime);
1720 pii->pii_fd_snxt_basetime = pii->pii_snxt_basetime;
1722 pii->pii_fd_snxt_basetime += probe_interval;
1723 if (TIME_GT(cur_time, pii->pii_fd_snxt_basetime)) {
1726 n = (cur_time - pii->pii_fd_snxt_basetime) /
1728 pii->pii_fd_snxt_basetime += (n + 1) * probe_interval;
1740 pr_ndx = PROBE_INDEX_PREV(pii->pii_probe_next);
1744 pr_statp = &pii->pii_probes[pr_ndx];
1745 cur_tg = pii->pii_probes[pr_ndx].pr_target;
1753 if (pii->pii_fd_hrtime > gethrtime()) {
1757 pii->pii_phyint->pi_name);
1759 pii->pii_fd_hrtime = gethrtime();
1779 probe_chstate(pr_statp, pii, PR_LOST);
1796 probe_chstate(pr_statp, pii, PR_LOST);
1827 switch (pii->pii_phyint->pi_state) {
1834 if (pii->pii_rack + valid_unack_count + 1 == pii->pii_snxt) {
1835 phyint_check_for_repair(pii->pii_phyint);
1845 if (pii->pii_fd_hrtime - cur_hrtime > 0)
1848 if (pii->pii_rack + valid_unack_count + 1 != pii->pii_snxt) {
1854 phyint_inst_check_for_failure(pii);
1860 pii->pii_phyint->pi_state);
1865 * Start the next probe. probe() will also set pii->pii_probe_time_left
1869 if (pii->pii_target_next != NULL) {
1870 probe(pii, PROBE_UNI, cur_hrtime);
1876 if (!pii->pii_targets_are_routers && pii->pii_ntargets == 1)
1877 probe(pii, PROBE_MULTI, cur_hrtime);
1879 probe(pii, PROBE_MULTI, cur_hrtime);
1888 start_timer(struct phyint_instance *pii)
1902 (int)pii->pii_phyint->pi_group->pg_probeint);
1904 pii->pii_snxt_basetime = getcurrenttime() + interval;
1905 pii->pii_fd_snxt_basetime = pii->pii_snxt_basetime;
1906 pii->pii_snxt_time = pii->pii_snxt_basetime;
1914 restart_timer(struct phyint_instance *pii)
1918 * the first place (pii->pii_basetime_inited not set), as the timer
1921 if (pii->pii_basetime_inited != 0) {
1925 "address family %s\n", pii->pii_phyint->pi_name,
1926 AF_STR(pii->pii_af));
1928 start_timer(pii);
2026 struct phyint_instance *pii;
2029 pii = pi->pi_v4;
2030 if (pii != NULL) {
2031 for (tg = pii->pii_targets; tg != NULL; tg = tg->tg_next) {
2038 pii = pi->pi_v6;
2039 if (pii != NULL) {
2040 for (tg = pii->pii_targets; tg != NULL; tg = tg->tg_next) {
2055 phyint_inst_probe_failure_state(struct phyint_instance *pii, uint_t *tff)
2068 pr_ndx = PROBE_INDEX_PREV(pii->pii_probe_next);
2069 cur_tg = pii->pii_probes[pr_ndx].pr_target;
2070 probe_fail_info(pii, cur_tg, &pfinfo);
2085 if (pii->pii_targets_are_routers) {
2087 pii->pii_ntargets--;
2092 if (pii->pii_target_next == cur_tg)
2093 pii->pii_target_next = target_next(cur_tg);
2096 probe(pii, PROBE_MULTI, gethrtime());
2110 pii_other = phyint_inst_other(pii);
2140 failure_state(struct phyint_instance *pii)
2152 logdebug("phyint_failed(%s)\n", pii->pii_name);
2154 pi = pii->pii_phyint;
2157 if (LINK_UP(pi) && phyint_inst_probe_failure_state(pii, &pi_tff) ==
2282 probe_success_info(struct phyint_instance *pii, struct target *cur_tg,
2296 logdebug("probe_success_info(%s)\n", pii->pii_name);
2306 most_recent = PROBE_INDEX_PREV(pii->pii_probe_next);
2309 for (i = most_recent; i != pii->pii_probe_next;
2311 pr_statp = &pii->pii_probes[i];
2333 pii->pii_phyint->pi_group->pg_probeint;
2342 probe_chstate(pr_statp, pii, PR_LOST);
2408 probe_fail_info(struct phyint_instance *pii, struct target *cur_tg,
2422 logdebug("probe_fail_info(%s)\n", pii->pii_name);
2432 most_recent = PROBE_INDEX_PREV(pii->pii_probe_next);
2435 for (i = most_recent; i != pii->pii_probe_next;
2437 pr_statp = &pii->pii_probes[i];
2464 pii->pii_phyint->pi_group->pg_probeint;
2471 probe_chstate(pr_statp, pii, PR_LOST);
2504 * Change the state of probe `pr' on phyint_instance `pii' to state `state'.
2507 probe_chstate(struct probe_stats *pr, struct phyint_instance *pii, int state)
2513 (void) probe_state_event(pr, pii);
2527 struct phyint_instance *pii;
2562 pii = pi->pi_v4;
2563 if (PROBE_CAPABLE(pii)) {
2564 pr_ndx = PROBE_INDEX_PREV(pii->pii_probe_next);
2565 cur_tg = pii->pii_probes[pr_ndx].pr_target;
2566 probe_success_info(pii, cur_tg, &psinfo);
2572 pii = pi->pi_v6;
2573 if (PROBE_CAPABLE(pii)) {
2574 pr_ndx = PROBE_INDEX_PREV(pii->pii_probe_next);
2575 cur_tg = pii->pii_probes[pr_ndx].pr_target;
2576 probe_success_info(pii, cur_tg, &psinfo);
2690 struct phyint_instance *pii;
2692 for (pii = phyint_instances; pii != NULL; pii = pii->pii_next) {
2693 pii->pii_fd_snxt_basetime = pii->pii_snxt_basetime;