Lines Matching +full:chg +full:- +full:gone
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
52 EPOCH+MIN_WAITTIME-1, 0
92 for (cag = ag_avail; cag != NULL; cag = cag->ag_fine) \
94 for (cag = ag_corsest; cag != NULL; cag = cag->ag_fine) \
118 /* Forget it if this route should not be output for split-horizon. */ in ag_out()
119 if (ag->ag_state & AGS_SPLIT_HZ) in ag_out()
131 ag_cors = ag->ag_cors; in ag_out()
133 && ag_cors->ag_mask == ag->ag_mask<<1 in ag_out()
134 && ag_cors->ag_dst_h == (ag->ag_dst_h & ag_cors->ag_mask)) { in ag_out()
135 ag_cors->ag_state |= ((ag_cors->ag_dst_h == ag->ag_dst_h) in ag_out()
145 if (ag->ag_state & AGS_REDUN0) { in ag_out()
146 if (ag->ag_state & AGS_REDUN1) in ag_out()
148 /* make it finer if it is half-redundant */ in ag_out()
149 bit = (-ag->ag_mask) >> 1; in ag_out()
150 ag->ag_dst_h |= bit; in ag_out()
151 ag->ag_mask |= bit; in ag_out()
153 } else if (ag->ag_state & AGS_REDUN1) { in ag_out()
154 /* make it finer if it is half-redundant */ in ag_out()
155 bit = (-ag->ag_mask) >> 1; in ag_out()
156 ag->ag_mask |= bit; in ag_out()
167 if (ag->ag_cors == NULL) in ag_del()
168 ag_corsest = ag->ag_fine; in ag_del()
170 ag->ag_cors->ag_fine = ag->ag_fine; in ag_del()
172 if (ag->ag_fine == NULL) in ag_del()
173 ag_finest = ag->ag_cors; in ag_del()
175 ag->ag_fine->ag_cors = ag->ag_cors; in ag_del()
177 ag->ag_fine = ag_avail; in ag_del()
201 ag != NULL && ag->ag_mask >= lim_mask; in ag_flush()
203 ag_cors = ag->ag_cors; in ag_flush()
206 dst_h = ag->ag_dst_h; in ag_flush()
210 if (!(ag->ag_state & AGS_SUPPRESS)) in ag_flush()
213 else for ( ; ; ag_cors = ag_cors->ag_cors) { in ag_flush()
224 if ((dst_h & ag_cors->ag_mask) == ag_cors->ag_dst_h) { in ag_flush()
232 if (ag->ag_gate != ag_cors->ag_gate in ag_flush()
233 && !(ag->ag_state & AGS_FINE_GATE) in ag_flush()
234 && !(ag_cors->ag_state & AGS_CORS_GATE)) { in ag_flush()
244 if (ag_cors->ag_pref <= ag->ag_pref) { in ag_flush()
245 if (AG_IS_REDUN(ag->ag_state) in ag_flush()
246 && ag_cors->ag_mask==ag->ag_mask<<1) { in ag_flush()
247 if (ag_cors->ag_dst_h == dst_h) in ag_flush()
248 ag_cors->ag_state |= AGS_REDUN0; in ag_flush()
250 ag_cors->ag_state |= AGS_REDUN1; in ag_flush()
252 if (ag->ag_tag != ag_cors->ag_tag) in ag_flush()
253 ag_cors->ag_tag = 0; in ag_flush()
254 if (ag->ag_nhop != ag_cors->ag_nhop) in ag_flush()
255 ag_cors->ag_nhop = 0; in ag_flush()
262 ag_cors = ag->ag_cors; in ag_flush()
290 /* Punt non-contiguous subnet masks. in ag_check()
292 * (X & -X) contains a single bit if and only if X is a power of 2. in ag_check()
293 * (X + (X & -X)) == 0 if and only if X is a power of 2. in ag_check()
295 if ((mask & -mask) + mask != 0) { in ag_check()
316 if (ag->ag_mask >= mask) in ag_check()
329 && ag->ag_dst_h < dst in ag_check()
330 && (ag->ag_state & AGS_SUPPRESS) in ag_check()
331 && ag_cors->ag_pref <= ag->ag_pref in ag_check()
332 && (ag->ag_dst_h & ag_cors->ag_mask) == ag_cors->ag_dst_h in ag_check()
333 && (ag_cors->ag_gate == ag->ag_gate in ag_check()
334 || (ag->ag_state & AGS_FINE_GATE) in ag_check()
335 || (ag_cors->ag_state & AGS_CORS_GATE))) { in ag_check()
339 if (AG_IS_REDUN(ag->ag_state) in ag_check()
340 && ag_cors->ag_mask == ag->ag_mask<<1) { in ag_check()
341 if (ag_cors->ag_dst_h == dst) in ag_check()
342 ag_cors->ag_state |= AGS_REDUN0; in ag_check()
344 ag_cors->ag_state |= AGS_REDUN1; in ag_check()
346 if (ag->ag_tag != ag_cors->ag_tag) in ag_check()
347 ag_cors->ag_tag = 0; in ag_check()
348 if (ag->ag_nhop != ag_cors->ag_nhop) in ag_check()
349 ag_cors->ag_nhop = 0; in ag_check()
355 ag = ag_cors->ag_fine; in ag_check()
368 && ag->ag_mask == mask in ag_check()
369 && ((ag->ag_dst_h ^ dst) & (mask<<1)) == 0) { in ag_check()
376 if (ag->ag_dst_h == dst) { in ag_check()
386 * of longest-match rule. in ag_check()
388 if (pref <= ag->ag_pref) { in ag_check()
389 ag->ag_gate = gate; in ag_check()
390 ag->ag_nhop = nhop; in ag_check()
391 ag->ag_tag = tag; in ag_check()
392 ag->ag_metric = metric; in ag_check()
393 ag->ag_pref = pref; in ag_check()
394 if (ag->ag_seqno < new_seqno) in ag_check()
395 ag->ag_seqno = new_seqno; in ag_check()
396 x = ag->ag_state; in ag_check()
397 ag->ag_state = state; in ag_check()
404 if (!(ag->ag_state & AGS_IF)) in ag_check()
405 ag->ag_state |= (state & (AGS_AGGREGATE_EITHER in ag_check()
419 && (ag->ag_state & AGS_SUPPRESS)) in ag_check()
420 && !((ag->ag_state & AGS_AGGREGATE) in ag_check()
428 if (AG_IS_REDUN(ag->ag_state) in ag_check()
430 || (ag->ag_gate == gate in ag_check()
431 && ag->ag_pref == pref in ag_check()
432 && (state & ag->ag_state & AGS_AGGREGATE) != 0)) { in ag_check()
440 if (new_seqno < ag->ag_seqno) in ag_check()
441 new_seqno = ag->ag_seqno; in ag_check()
444 if (AG_IS_REDUN(ag->ag_state)) in ag_check()
448 state |= (ag->ag_state & AGS_AGGREGATE_EITHER); in ag_check()
449 if (ag->ag_tag != tag) in ag_check()
451 if (ag->ag_nhop != nhop) in ag_check()
459 } else if (ag->ag_pref >= pref in ag_check()
460 && (ag->ag_state & AGS_AGGREGATE)) { in ag_check()
467 ag->ag_dst_h = dst; in ag_check()
469 xaddr = ag->ag_gate; in ag_check()
470 ag->ag_gate = gate; in ag_check()
473 xaddr = ag->ag_nhop; in ag_check()
474 ag->ag_nhop = nhop; in ag_check()
477 x = ag->ag_tag; in ag_check()
478 ag->ag_tag = tag; in ag_check()
481 /* The promoted route is even-redundant only if the in ag_check()
483 * odd-redundant because the odd-twin will still be in ag_check()
486 x = ag->ag_state; in ag_check()
490 ag->ag_state = state; in ag_check()
493 x = ag->ag_metric; in ag_check()
494 ag->ag_metric = metric; in ag_check()
497 x = ag->ag_pref; in ag_check()
498 ag->ag_pref = pref; in ag_check()
502 if (new_seqno <= ag->ag_seqno) in ag_check()
503 new_seqno = ag->ag_seqno; in ag_check()
505 ag->ag_seqno = new_seqno; in ag_check()
513 * The promoted route is odd-redundant only if the in ag_check()
515 * even-redundant because the even twin is still in in ag_check()
521 if (new_seqno < ag->ag_seqno) in ag_check()
522 new_seqno = ag->ag_seqno; in ag_check()
524 ag->ag_seqno = new_seqno; in ag_check()
535 ag_cors = ag->ag_cors; in ag_check()
547 && ag->ag_mask < mask) { in ag_check()
549 ag = ag->ag_fine; in ag_check()
554 if (ag != NULL && ag->ag_mask == mask) { in ag_check()
555 ag_flush(ag->ag_dst_h, ag->ag_mask, out); in ag_check()
556 ag = (ag_cors == NULL) ? ag_corsest : ag_cors->ag_fine; in ag_check()
565 if (ag != NULL && ag->ag_cors != ag_cors) in ag_check()
567 if (ag_cors != NULL && ag_cors->ag_fine != ag) in ag_check()
575 ag_avail = nag->ag_fine; in ag_check()
577 nag->ag_dst_h = dst; in ag_check()
578 nag->ag_mask = mask; in ag_check()
579 nag->ag_gate = gate; in ag_check()
580 nag->ag_nhop = nhop; in ag_check()
581 nag->ag_metric = metric; in ag_check()
582 nag->ag_pref = pref; in ag_check()
583 nag->ag_tag = tag; in ag_check()
584 nag->ag_state = state; in ag_check()
585 nag->ag_seqno = new_seqno; in ag_check()
587 nag->ag_fine = ag; in ag_check()
589 ag->ag_cors = nag; in ag_check()
592 nag->ag_cors = ag_cors; in ag_check()
596 ag_cors->ag_fine = nag; in ag_check()
633 return rtm_types[type-1]; in rtm_type_name()
652 if (ap->sin_addr.s_addr == 0) { in masktrim()
653 ap->sin_len = 0; in masktrim()
656 cp = (char *)(&ap->sin_addr.s_addr+1); in masktrim()
657 while (*--cp == 0) in masktrim()
659 ap->sin_len = cp - (char*)ap + 1; in masktrim()
684 # define PAT " %-10s %s metric=%d flags=%#x" in rtioctl()
709 w.w_rtm.rtm_msglen -= sizeof(w.w_mask); in rtioctl()
717 w.w_rtm.rtm_msglen -= (sizeof(w.w_mask) - w.w_mask.sin_len); in rtioctl()
778 for (pk = &KHASH(dst,mask); (k = *pk) != NULL; pk = &k->k_next) { in kern_find()
779 if (k->k_dst == dst && k->k_mask == mask) in kern_find()
800 k->k_dst = dst; in kern_add()
801 k->k_mask = mask; in kern_add()
802 k->k_state = KS_NEW; in kern_add()
803 k->k_keep = now.tv_sec; in kern_add()
810 /* If a kernel route has a non-zero metric, check that it is still in the
820 if (k->k_metric == 0) in kern_check_static()
825 new.rts_gate = k->k_gate; in kern_check_static()
826 new.rts_router = (ifp != NULL) ? ifp->int_addr : loopaddr; in kern_check_static()
827 new.rts_metric = k->k_metric; in kern_check_static()
830 rt = rtget(k->k_dst, k->k_mask); in kern_check_static()
832 if (!(rt->rt_state & RS_STATIC)) in kern_check_static()
833 rtchange(rt, rt->rt_state | RS_STATIC, &new, 0); in kern_check_static()
835 rtadd(k->k_dst, k->k_mask, RS_STATIC, &new); in kern_check_static()
850 k->k_state &= ~KS_DYNAMIC; in kern_ioctl()
851 if (k->k_state & KS_DELETED) in kern_ioctl()
853 k->k_state |= KS_DELETED; in kern_ioctl()
856 k->k_state &= ~KS_DELETED; in kern_ioctl()
859 if (k->k_state & KS_DELETED) { in kern_ioctl()
861 k->k_state &= ~KS_DELETED; in kern_ioctl()
866 rtioctl(action, k->k_dst, k->k_gate, k->k_mask, k->k_metric, flags); in kern_ioctl()
882 if (rtm->rtm_flags & RTF_HOST) { in rtm_add()
887 msglog("ignore %s without mask", rtm_type_name(rtm->rtm_type)); in rtm_add()
892 if (k->k_state & KS_NEW) in rtm_add()
893 k->k_keep = now.tv_sec+keep; in rtm_add()
896 rtm_type_name(rtm->rtm_type)); in rtm_add()
897 k->k_metric = HOPCNT_INFINITY; in rtm_add()
898 } else if (INFO_GATE(info)->sa_family != AF_INET) { in rtm_add()
900 rtm_type_name(rtm->rtm_type), in rtm_add()
901 INFO_GATE(info)->sa_family); in rtm_add()
902 k->k_metric = HOPCNT_INFINITY; in rtm_add()
904 k->k_gate = S_ADDR(INFO_GATE(info)); in rtm_add()
905 k->k_metric = rtm->rtm_rmx.rmx_hopcount; in rtm_add()
906 if (k->k_metric < 0) in rtm_add()
907 k->k_metric = 0; in rtm_add()
908 else if (k->k_metric > HOPCNT_INFINITY-1) in rtm_add()
909 k->k_metric = HOPCNT_INFINITY-1; in rtm_add()
911 k->k_state &= ~(KS_DELETE | KS_ADD | KS_CHANGE | KS_DEL_ADD in rtm_add()
914 if (rtm->rtm_flags & RTF_GATEWAY) in rtm_add()
915 k->k_state |= KS_GATEWAY; in rtm_add()
916 if (rtm->rtm_flags & RTF_STATIC) in rtm_add()
917 k->k_state |= KS_STATIC; in rtm_add()
919 if (0 != (rtm->rtm_flags & (RTF_DYNAMIC | RTF_MODIFIED))) { in rtm_add()
921 && INFO_AUTHOR(info)->sa_family == AF_INET) in rtm_add()
926 && (ifp == NULL || !(ifp->int_state & IS_REDIRECT_OK))) { in rtm_add()
931 k->k_state &= ~KS_DYNAMIC; in rtm_add()
932 k->k_state |= KS_DELETE; in rtm_add()
934 trace_act("mark for deletion redirected %s --> %s" in rtm_add()
936 addrname(k->k_dst, k->k_mask, 0), in rtm_add()
937 naddr_ntoa(k->k_gate), in rtm_add()
938 ifp ? ifp->int_name : "unknown interface"); in rtm_add()
940 k->k_state |= KS_DYNAMIC; in rtm_add()
941 k->k_redirect_time = now.tv_sec; in rtm_add()
942 trace_act("accept redirected %s --> %s via %s", in rtm_add()
943 addrname(k->k_dst, k->k_mask, 0), in rtm_add()
944 naddr_ntoa(k->k_gate), in rtm_add()
945 ifp ? ifp->int_name : "unknown interface"); in rtm_add()
953 if (!(k->k_state & KS_STATIC)) { in rtm_add()
954 k->k_state |= KS_DELETE; in rtm_add()
955 LIM_SEC(need_kern, k->k_keep); in rtm_add()
964 ifp = iflookup(k->k_gate); in rtm_add()
966 msglog("static route %s --> %s impossibly lacks ifp", in rtm_add()
968 naddr_ntoa(k->k_gate)); in rtm_add()
981 || INFO_GATE(info)->sa_family != AF_INET) { in rtm_lose()
983 rtm_type_name(rtm->rtm_type)); in rtm_lose()
1006 if ((sdl)->sdl_family == AF_INET) in get_info_gate()
1008 if ((sdl)->sdl_family != AF_LINK) in get_info_gate()
1011 ifp = ifwithindex(sdl->sdl_index, 1); in get_info_gate()
1015 rsin->sin_addr.s_addr = ifp->int_addr; in get_info_gate()
1017 rsin->sin_len = sizeof(*rsin); in get_info_gate()
1019 rsin->sin_family = AF_INET; in get_info_gate()
1045 for (k = khash_bins[i]; k != NULL; k = k->k_next) { in flush_kern()
1046 k->k_state |= KS_CHECK; in flush_kern()
1077 for (next = sysctl_buf; next < lim; next += rtm->rtm_msglen) { in flush_kern()
1079 if (rtm->rtm_msglen == 0) { in flush_kern()
1088 (struct sockaddr *)(next + rtm->rtm_msglen), in flush_kern()
1089 rtm->rtm_addrs); in flush_kern()
1092 || INFO_DST(&info)->sa_family != AF_INET) in flush_kern()
1099 if (rtm->rtm_flags & RTF_LLINFO) in flush_kern()
1105 if (rtm->rtm_flags & RTF_WASCLONED) in flush_kern()
1121 * few seconds to allow a RIP or router-discovery in flush_kern()
1128 for (k = khash_bins[i]; k != NULL; k = k->k_next) { in flush_kern()
1129 if (k->k_state & KS_CHECK) { in flush_kern()
1130 msglog("%s --> %s disappeared from kernel", in flush_kern()
1131 addrname(k->k_dst, k->k_mask, 0), in flush_kern()
1132 naddr_ntoa(k->k_gate)); in flush_kern()
1133 del_static(k->k_dst, k->k_mask, k->k_gate, 1); in flush_kern()
1201 ifp->int_name); in read_rt()
1209 if (ifinit_timer.tv_sec-now.tv_sec>=CHECK_BAD_INTERVAL in read_rt()
1211 || ((ifp->int_if_flags ^ m.ifm.ifm_flags) in read_rt()
1243 if (INFO_DST(&info)->sa_family != AF_INET) { in read_rt()
1245 INFO_DST(&info)->sa_family); in read_rt()
1279 strp += sprintf(strp, " --> %s", naddr_ntoa(gate)); in read_rt()
1338 if (ag->ag_metric == HOPCNT_INFINITY) { in kern_out()
1339 k = kern_find(htonl(ag->ag_dst_h), ag->ag_mask, 0); in kern_out()
1343 k = kern_add(htonl(ag->ag_dst_h), ag->ag_mask); in kern_out()
1346 if (k->k_state & KS_NEW) { in kern_out()
1348 k->k_state = KS_ADD; in kern_out()
1349 if (ag->ag_state & AGS_GATEWAY) in kern_out()
1350 k->k_state |= KS_GATEWAY; in kern_out()
1351 k->k_gate = ag->ag_gate; in kern_out()
1352 k->k_metric = ag->ag_metric; in kern_out()
1356 if (k->k_state & KS_STATIC) in kern_out()
1360 if (k->k_gate != ag->ag_gate in kern_out()
1361 || k->k_metric != ag->ag_metric) { in kern_out()
1363 if (k->k_metric == HOPCNT_INFINITY) in kern_out()
1364 k->k_state |= KS_DEL_ADD; in kern_out()
1365 k->k_gate = ag->ag_gate; in kern_out()
1366 k->k_metric = ag->ag_metric; in kern_out()
1367 k->k_state |= KS_CHANGE; in kern_out()
1375 if ((k->k_state & (KS_DYNAMIC | KS_DELETED)) != 0) { in kern_out()
1376 k->k_state &= ~KS_DYNAMIC; in kern_out()
1377 k->k_state |= (KS_ADD | KS_DEL_ADD); in kern_out()
1380 if ((k->k_state & KS_GATEWAY) in kern_out()
1381 && !(ag->ag_state & AGS_GATEWAY)) { in kern_out()
1382 k->k_state &= ~KS_GATEWAY; in kern_out()
1383 k->k_state |= (KS_ADD | KS_DEL_ADD); in kern_out()
1384 } else if (!(k->k_state & KS_GATEWAY) in kern_out()
1385 && (ag->ag_state & AGS_GATEWAY)) { in kern_out()
1386 k->k_state |= KS_GATEWAY; in kern_out()
1387 k->k_state |= (KS_ADD | KS_DEL_ADD); in kern_out()
1390 /* Deleting-and-adding is necessary to change aspects of a route. in kern_out()
1394 if (k->k_metric == HOPCNT_INFINITY in kern_out()
1395 && (k->k_state & KS_DEL_ADD)) in kern_out()
1396 k->k_state |= KS_DELETE; in kern_out()
1398 k->k_state &= ~KS_DELETE; in kern_out()
1414 if (RT->rt_state & RS_NET_SYN) in walk_kern()
1417 if (!(RT->rt_state & RS_IF)) { in walk_kern()
1431 && ntohl(RT->rt_dst) == RT->rt_gate) in walk_kern()
1438 if (RT->rt_ifp != 0 && (RT->rt_ifp->int_state & IS_EXTERNAL)) in walk_kern()
1452 if (RT->rt_ifp == 0 in walk_kern()
1453 || (RT->rt_ifp->int_state & IS_REMOTE)) in walk_kern()
1459 * will time-out and be deleted. This reaches the steady-state in walk_kern()
1462 if ((RT->rt_state & RS_RDISC) && rip_sock < 0) in walk_kern()
1465 metric = RT->rt_metric; in walk_kern()
1473 ag_check(RT->rt_dst, RT->rt_mask, RT->rt_gate, 0, in walk_kern()
1499 if (k->k_state & KS_STATIC) { in fix_kern()
1501 pk = &k->k_next; in fix_kern()
1506 if (k->k_keep > now.tv_sec) { in fix_kern()
1508 LIM_SEC(need_kern, k->k_keep); in fix_kern()
1510 k->k_state |= KS_DELETE; in fix_kern()
1511 pk = &k->k_next; in fix_kern()
1515 if ((k->k_state & KS_DELETE) in fix_kern()
1516 && !(k->k_state & KS_DYNAMIC)) { in fix_kern()
1518 *pk = k->k_next; in fix_kern()
1523 if (k->k_state & KS_DEL_ADD) in fix_kern()
1526 if (k->k_state & KS_ADD) { in fix_kern()
1528 ((0 != (k->k_state & (KS_GATEWAY in fix_kern()
1531 } else if (k->k_state & KS_CHANGE) { in fix_kern()
1533 ((0 != (k->k_state & (KS_GATEWAY in fix_kern()
1537 k->k_state &= ~(KS_ADD|KS_CHANGE|KS_DEL_ADD); in fix_kern()
1545 k->k_state |= KS_DELETE; in fix_kern()
1546 pk = &k->k_next; in fix_kern()
1558 int gone) in del_static() argument
1566 * keep-timer so that it will not be deleted again for a while. in del_static()
1571 if (k != NULL && (gate == 0 || k->k_gate == gate)) { in del_static()
1572 k->k_state &= ~(KS_STATIC | KS_DYNAMIC | KS_CHECK); in del_static()
1573 k->k_state |= KS_DELETE; in del_static()
1574 if (gone) { in del_static()
1575 k->k_state |= KS_DELETED; in del_static()
1576 k->k_keep = now.tv_sec + K_KEEP_LIM; in del_static()
1581 if (rt != NULL && (rt->rt_state & RS_STATIC)) in del_static()
1598 for (k = khash_bins[i]; k != NULL; k = k->k_next) { in del_redirects()
1599 if (!(k->k_state & KS_DYNAMIC) in del_redirects()
1600 || (k->k_state & KS_STATIC)) in del_redirects()
1603 if (k->k_gate != bad_gate in del_redirects()
1604 && k->k_redirect_time > old in del_redirects()
1608 k->k_state |= KS_DELETE; in del_redirects()
1609 k->k_state &= ~KS_DYNAMIC; in del_redirects()
1611 trace_act("mark redirected %s --> %s for deletion", in del_redirects()
1612 addrname(k->k_dst, k->k_mask, 0), in del_redirects()
1613 naddr_ntoa(k->k_gate)); in del_redirects()
1637 ag->ag_fine = ag+1; in rtinit()
1675 rt = (struct rt_entry *)rhead->rnh_lookup(&dst_sock,&mask_sock,rhead); in rtget()
1677 || rt->rt_dst != dst in rtget()
1678 || rt->rt_mask != mask) in rtget()
1691 return (struct rt_entry *)rhead->rnh_matchaddr(&dst_sock, rhead); in rtfind()
1710 for (rts = rt->rt_spares, i = NUM_SPARES; i != 0; i--, rts++) in rtadd()
1711 rts->rts_metric = HOPCNT_INFINITY; in rtadd()
1713 rt->rt_nodes->rn_key = (caddr_t)&rt->rt_dst_sock; in rtadd()
1714 rt->rt_dst = dst; in rtadd()
1715 rt->rt_dst_sock.sin_family = AF_INET; in rtadd()
1717 rt->rt_dst_sock.sin_len = dst_sock.sin_len; in rtadd()
1726 rt->rt_mask = mask; in rtadd()
1727 rt->rt_state = state; in rtadd()
1728 rt->rt_spares[0] = *new; in rtadd()
1729 rt->rt_time = now.tv_sec; in rtadd()
1730 rt->rt_poison_metric = HOPCNT_INFINITY; in rtadd()
1731 rt->rt_seqno = update_seqno; in rtadd()
1741 if (0 == rhead->rnh_addaddr(&rt->rt_dst_sock, &mask_sock, in rtadd()
1742 rhead, rt->rt_nodes)) { in rtadd()
1758 if (rt->rt_metric != new->rts_metric) { in rtchange()
1760 * has gone bad, since there may be a working route that in rtchange()
1763 if (new->rts_metric == HOPCNT_INFINITY) { in rtchange()
1765 if (new->rts_time >= now.tv_sec - EXPIRE_TIME) in rtchange()
1766 new->rts_time = now.tv_sec - EXPIRE_TIME; in rtchange()
1768 rt->rt_seqno = update_seqno; in rtchange()
1772 if (rt->rt_gate != new->rts_gate) { in rtchange()
1774 rt->rt_seqno = update_seqno; in rtchange()
1778 state |= (rt->rt_state & RS_SUBNET); in rtchange()
1782 if (!AGE_RT(state, new->rts_ifp)) in rtchange()
1783 new->rts_time = now.tv_sec; in rtchange()
1787 label ? label : "Chg "); in rtchange()
1789 rt->rt_state = state; in rtchange()
1790 rt->rt_spares[0] = *new; in rtchange()
1803 rts = rt->rt_spares+1; in rts_better()
1804 for (i = NUM_SPARES, rts1 = rts+1; i > 2; i--, rts1++) { in rts_better()
1824 if (0 != (rt->rt_state & (RS_MHOME | RS_STATIC | RS_RDISC in rtswitch()
1834 if (!BETTER_LINK(rt, rts, rt->rt_spares)) in rtswitch()
1837 swap = rt->rt_spares[0]; in rtswitch()
1838 (void)sprintf(label, "Use #%d", (int)(rts - rt->rt_spares)); in rtswitch()
1839 rtchange(rt, rt->rt_state & ~(RS_NET_SYN | RS_RDISC), rts, label); in rtswitch()
1857 k = kern_find(rt->rt_dst, rt->rt_mask, 0); in rtdelete()
1859 k->k_state |= KS_DELETE; in rtdelete()
1863 dst_sock.sin_addr.s_addr = rt->rt_dst; in rtdelete()
1864 mask_sock.sin_addr.s_addr = htonl(rt->rt_mask); in rtdelete()
1866 if (rt != (struct rt_entry *)rhead->rnh_deladdr(&dst_sock, &mask_sock, in rtdelete()
1871 total_routes--; in rtdelete()
1893 new = rt->rt_spares[0]; in rtbad()
1895 rtchange(rt, rt->rt_state & ~(RS_IF | RS_LOCAL | RS_STATIC), &new, 0); in rtbad()
1914 if (rt->rt_state & RS_LOCAL) { in rtbad_sub()
1917 * as a point-to-point interface with the same local address. in rtbad_sub()
1922 if (ifp->int_addr == rt->rt_ifp->int_addr) { in rtbad_sub()
1935 if (rt->rt_state & RS_NET_SYN) { in rtbad_sub()
1937 if ((ifp->int_state & IS_NEED_NET_SYN) in rtbad_sub()
1938 && rt->rt_mask == ifp->int_std_mask in rtbad_sub()
1939 && rt->rt_dst == ifp->int_std_addr) { in rtbad_sub()
1950 intnetp = intnetp->intnet_next) { in rtbad_sub()
1951 if (intnetp->intnet_addr == rt->rt_dst in rtbad_sub()
1952 && intnetp->intnet_mask == rt->rt_mask) { in rtbad_sub()
1960 struct rt_spare new = rt->rt_spares[0]; in rtbad_sub()
1962 rtchange(rt, ((rt->rt_state & ~(RS_NET_SYN|RS_LOCAL)) | state), in rtbad_sub()
1985 rts = RT->rt_spares; in walk_bad()
1986 for (i = NUM_SPARES; i != 1; i--) { in walk_bad()
1988 if (rts->rts_metric < HOPCNT_INFINITY in walk_bad()
1989 && (rts->rts_ifp == NULL in walk_bad()
1990 || (rts->rts_ifp->int_state & IS_BROKE))) in walk_bad()
1998 if (RT->rt_ifp == 0 || !(RT->rt_ifp->int_state & IS_BROKE)) in walk_bad()
2003 if (0 == (RT->rt_state & (RS_IF | RS_NET_SYN | RS_LOCAL))) { in walk_bad()
2030 rts = RT->rt_spares; in walk_age()
2031 for (i = NUM_SPARES; i != 0; i--, rts++) { in walk_age()
2033 ifp = rts->rts_ifp; in walk_age()
2035 if (!AGE_RT(RT->rt_state, ifp)) { in walk_age()
2039 rts->rts_time = now.tv_sec; in walk_age()
2053 if (age_bad_gate == rts->rts_gate in walk_age()
2054 && rts->rts_time >= now_stale) { in walk_age()
2055 rts->rts_time -= SUPPLY_INTERVAL; in walk_age()
2059 if (rts->rts_metric < HOPCNT_INFINITY in walk_age()
2060 && now_garbage > rts->rts_time in walk_age()
2067 if (now_stale <= RT->rt_time) in walk_age()
2074 if (now_garbage > RT->rt_time) { in walk_age()
2080 if (now.tv_sec - RT->rt_time > EXPIRE_TIME) { in walk_age()
2081 struct rt_spare new = RT->rt_spares[0]; in walk_age()
2083 rtchange(RT, RT->rt_state, &new, 0); in walk_age()
2107 if (!(ifp->int_state & IS_REMOTE)) in age()
2116 if (ifp->int_state & IS_BROKE) in age()
2119 if (ifp->int_act_time != NEVER in age()
2120 && now.tv_sec - ifp->int_act_time > EXPIRE_TIME) { in age()
2123 ifp->int_name, in age()
2124 naddr_ntoa(ifp->int_dstaddr), in age()
2125 (long)(now.tv_sec - ifp->int_act_time)/60, in age()
2126 (long)(now.tv_sec - ifp->int_act_time)%60); in age()
2133 if (now.tv_sec >= ifp->int_query_time) { in age()
2134 ifp->int_query_time = NEVER; in age()
2146 del_redirects(bad_gate, now.tv_sec-STALE_TIME); in age()