Lines Matching +full:chg +full:- +full:done
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
101 hifp = AHASH(ifp->int_addr); in if_link()
102 ifp->int_ahash_prev = hifp; in if_link()
103 if ((ifp->int_ahash = *hifp) != NULL) in if_link()
104 (*hifp)->int_ahash_prev = &ifp->int_ahash; in if_link()
107 if (ifp->int_if_flags & IFF_BROADCAST) { in if_link()
108 hifp = BHASH(ifp->int_brdaddr); in if_link()
109 ifp->int_bhash_prev = hifp; in if_link()
110 if ((ifp->int_bhash = *hifp) != NULL) in if_link()
111 (*hifp)->int_bhash_prev = &ifp->int_bhash; in if_link()
115 if (ifp->int_state & IS_REMOTE) in if_link()
118 hifp = nhash(ifp->int_name); in if_link()
119 if (ifp->int_state & IS_ALIAS) { in if_link()
122 hifp = &(*hifp)->int_nhash; in if_link()
124 ifp->int_nhash_prev = hifp; in if_link()
125 if ((ifp->int_nhash = *hifp) != NULL) in if_link()
126 (*hifp)->int_nhash_prev = &ifp->int_nhash; in if_link()
142 for (ifp = *AHASH(addr); ifp; ifp = ifp->int_ahash) { in ifwithaddr()
143 if (ifp->int_addr != addr) in ifwithaddr()
145 if ((ifp->int_state & remote) != 0) in ifwithaddr()
147 if ((ifp->int_state & (IS_BROKE | IS_PASSIVE)) == 0) in ifwithaddr()
155 for (ifp = *BHASH(addr); ifp; ifp = ifp->int_bhash) { in ifwithaddr()
156 if (ifp->int_brdaddr != addr) in ifwithaddr()
158 if ((ifp->int_state & remote) != 0) in ifwithaddr()
160 if ((ifp->int_state & (IS_BROKE | IS_PASSIVE)) == 0) in ifwithaddr()
178 for (ifp = *nhash(name); ifp != NULL; ifp = ifp->int_nhash) { in ifwithname()
183 if (!strcmp(ifp->int_name, name) in ifwithname()
184 && ((addr == 0 && !(ifp->int_state & IS_ALIAS)) in ifwithname()
185 || (ifp->int_addr == addr))) in ifwithname()
207 if (ifp->int_index == ifindex) in ifwithindex()
235 if (ifp->int_if_flags & IFF_POINTOPOINT) { in iflookup()
237 if (ifp->int_dstaddr == addr) in iflookup()
242 if (ifp->int_addr == addr) in iflookup()
247 if (on_net(addr, ifp->int_net, ifp->int_mask) in iflookup()
249 || ifp->int_mask > maybe->int_mask)) in iflookup()
297 if (ifp != NULL && ifp->int_ripv1_mask != HOST_MASK) { in ripv1_mask_net()
301 if (on_net(addr, ifp->int_net, ifp->int_std_mask)) in ripv1_mask_net()
302 mask = ifp->int_ripv1_mask; in ripv1_mask_net()
312 if (on_net(addr, ifp->int_std_net, ifp->int_std_mask) in ripv1_mask_net()
313 && ifp->int_ripv1_mask > mask in ripv1_mask_net()
314 && ifp->int_ripv1_mask != HOST_MASK) in ripv1_mask_net()
315 mask = ifp->int_ripv1_mask; in ripv1_mask_net()
322 for (r1p = r1nets; r1p != NULL; r1p = r1p->r1net_next) { in ripv1_mask_net()
323 if (on_net(addr, r1p->r1net_net, r1p->r1net_match) in ripv1_mask_net()
324 && r1p->r1net_mask > mask) in ripv1_mask_net()
325 mask = r1p->r1net_mask; in ripv1_mask_net()
384 if (ifp->int_mask != mask) in check_dup()
387 if (!iff_up(ifp->int_if_flags)) in check_dup()
390 /* The local address can only be shared with a point-to-point in check_dup()
393 if ((!(ifp->int_state & IS_REMOTE) || !(if_flags & IS_REMOTE)) in check_dup()
394 && ifp->int_addr == addr in check_dup()
395 && (((if_flags|ifp->int_if_flags) & IFF_POINTOPOINT) == 0)) in check_dup()
398 if (on_net(ifp->int_dstaddr, ntohl(dstaddr),mask)) in check_dup()
414 if (!(ifp->int_state & IS_REMOTE)) in check_remote()
417 rt = rtfind(ifp->int_addr); in check_remote()
419 && rt->rt_ifp != 0 in check_remote()
420 &&on_net(ifp->int_addr, in check_remote()
421 rt->rt_ifp->int_net, rt->rt_ifp->int_mask)) in check_remote()
427 if (!(ifp->int_state & IS_BROKE)) { in check_remote()
429 naddr_ntoa(ifp->int_addr)); in check_remote()
446 ifp->int_state |= IS_BROKE; in ifdel()
449 *ifp->int_ahash_prev = ifp->int_ahash; in ifdel()
450 if (ifp->int_ahash != 0) in ifdel()
451 ifp->int_ahash->int_ahash_prev = ifp->int_ahash_prev; in ifdel()
452 *ifp->int_nhash_prev = ifp->int_nhash; in ifdel()
453 if (ifp->int_nhash != 0) in ifdel()
454 ifp->int_nhash->int_nhash_prev = ifp->int_nhash_prev; in ifdel()
455 if (ifp->int_if_flags & IFF_BROADCAST) { in ifdel()
456 *ifp->int_bhash_prev = ifp->int_bhash; in ifdel()
457 if (ifp->int_bhash != 0) in ifdel()
458 ifp->int_bhash->int_bhash_prev = ifp->int_bhash_prev; in ifdel()
460 if (ifp->int_state & IS_REMOTE) in ifdel()
463 if (!(ifp->int_state & IS_ALIAS)) { in ifdel()
468 && !strcmp(ifp->int_name, ifp1->int_name)) in ifdel()
472 if ((ifp->int_if_flags & IFF_MULTICAST) && rip_sock >= 0) { in ifdel()
477 gr.gr_interface = ifp->int_index; in ifdel()
479 sin->sin_family = AF_INET; in ifdel()
481 sin->sin_len = sizeof(struct sockaddr_in); in ifdel()
483 sin->sin_addr.s_addr = htonl(INADDR_RIP_GROUP); in ifdel()
492 if (ifp->int_rip_sock >= 0) { in ifdel()
493 (void)close(ifp->int_rip_sock); in ifdel()
494 ifp->int_rip_sock = -1; in ifdel()
498 tot_interfaces--; in ifdel()
499 if (!IS_RIP_OFF(ifp->int_state)) in ifdel()
500 rip_interfaces--; in ifdel()
521 if (0 == (ifp->int_state & (IS_SICK | IS_BROKE))) { in if_sick()
522 ifp->int_state |= IS_SICK; in if_sick()
523 ifp->int_act_time = NEVER; in if_sick()
524 trace_if("Chg", ifp); in if_sick()
539 if (ifp->int_state & IS_BROKE) in if_bad()
544 ifp->int_state |= (IS_BROKE | IS_SICK); in if_bad()
545 ifp->int_act_time = NEVER; in if_bad()
546 ifp->int_query_time = NEVER; in if_bad()
547 ifp->int_data.ts = now.tv_sec; in if_bad()
549 trace_if("Chg", ifp); in if_bad()
551 if (!(ifp->int_state & IS_ALIAS)) { in if_bad()
554 && !strcmp(ifp->int_name, ifp1->int_name)) in if_bad()
572 if (!(ifp->int_state & IS_BROKE)) { in if_ok()
573 if (ifp->int_state & IS_SICK) { in if_ok()
576 ifp->int_name, naddr_ntoa(ifp->int_dstaddr)); in if_ok()
577 ifp->int_state &= ~IS_SICK; in if_ok()
583 type, ifp->int_name, naddr_ntoa(ifp->int_dstaddr)); in if_ok()
584 ifp->int_state &= ~(IS_BROKE | IS_SICK); in if_ok()
585 ifp->int_data.ts = 0; in if_ok()
587 if (!(ifp->int_state & IS_ALIAS)) { in if_ok()
590 && !strcmp(ifp->int_name, ifp1->int_name)) in if_ok()
596 if (ifp->int_state & IS_REMOTE) { in if_ok()
618 info->rti_addrs = addrs; in rt_xaddrs()
622 info->rti_info[i] = (sa->sa_len != 0) ? sa : &sa_zero; in rt_xaddrs()
629 * This must be done regularly, if only for extra addresses
671 ifp->int_state &= ~(IS_CHECKED | IS_DUP); in ifinit()
702 ifam2 = (struct ifa_msghdr*)((char*)ifam + ifam->ifam_msglen); in ifinit()
705 if (ifam->ifam_type == RTM_OIFINFO) in ifinit()
708 if (ifam->ifam_type == RTM_IFINFO) { in ifinit()
715 ifs0.int_rip_sock = -1; in ifinit()
716 ifs0.int_index = ifm->ifm_index; in ifinit()
717 ifs0.int_if_flags = ifm->ifm_flags; in ifinit()
722 ifs0.int_data.ipackets = ifm->ifm_data.ifi_ipackets; in ifinit()
723 ifs0.int_data.ierrors = ifm->ifm_data.ifi_ierrors; in ifinit()
724 ifs0.int_data.opackets = ifm->ifm_data.ifi_opackets; in ifinit()
725 ifs0.int_data.oerrors = ifm->ifm_data.ifi_oerrors; in ifinit()
727 sdl->sdl_data[sdl->sdl_nlen] = 0; in ifinit()
728 strncpy(ifs0.int_name, sdl->sdl_data, in ifinit()
729 MIN(sizeof(ifs0.int_name), sdl->sdl_nlen)); in ifinit()
732 if (ifam->ifam_type != RTM_NEWADDR) { in ifinit()
738 ifam->ifam_addrs); in ifinit()
742 * Do not output RIP or Router-Discovery packets via aliases. in ifinit()
756 if (INFO_IFA(&info)->sa_family != AF_INET) { in ifinit()
797 || INFO_BRD(&info)->sa_family != AF_INET) { in ifinit()
876 ifs.int_metric = ifam->ifam_metric; in ifinit()
897 ifp->int_state |= IS_CHECKED; in ifinit()
899 if (0 != ((ifp->int_if_flags ^ ifs.int_if_flags) in ifinit()
904 || 0 != ((ifp->int_state ^ ifs.int_state) in ifinit()
906 || ifp->int_addr != ifs.int_addr in ifinit()
907 || ifp->int_brdaddr != ifs.int_brdaddr in ifinit()
908 || ifp->int_dstaddr != ifs.int_dstaddr in ifinit()
909 || ifp->int_mask != ifs.int_mask in ifinit()
910 || ifp->int_metric != ifs.int_metric) { in ifinit()
915 ifp->int_name); in ifinit()
925 if (ifp->int_state & IS_ALIAS) in ifinit()
931 if (iff_up(ifp->int_if_flags)) { in ifinit()
933 ifp->int_name, in ifinit()
934 naddr_ntoa(ifp->int_dstaddr)); in ifinit()
936 ifp->int_if_flags &= ~IFF_UP; in ifinit()
937 } else if (now.tv_sec>(ifp->int_data.ts in ifinit()
941 ifp->int_name, in ifinit()
942 (intmax_t)now.tv_sec - in ifinit()
943 ifp->int_data.ts); in ifinit()
950 if (!iff_up(ifp->int_if_flags)) { in ifinit()
951 ifp->int_if_flags |= IFF_UP; in ifinit()
958 if (now.tv_sec < ifp->int_data.ts+CHECK_BAD_INTERVAL) in ifinit()
961 in = ifs.int_data.ipackets - ifp->int_data.ipackets; in ifinit()
962 ierr = ifs.int_data.ierrors - ifp->int_data.ierrors; in ifinit()
963 out = ifs.int_data.opackets - ifp->int_data.opackets; in ifinit()
964 oerr = ifs.int_data.oerrors - ifp->int_data.oerrors; in ifinit()
967 if (ifp->int_data.ts == 0) { in ifinit()
968 ifp->int_data = ifs.int_data; in ifinit()
971 ifp->int_data = ifs.int_data; in ifinit()
992 if (!(ifp->int_state & IS_SICK)) { in ifinit()
996 ifp->int_name, in ifinit()
997 naddr_ntoa(ifp->int_dstaddr), in ifinit()
1002 if (!(ifp->int_state & IS_BROKE)) { in ifinit()
1005 ifp->int_name, in ifinit()
1006 naddr_ntoa(ifp->int_dstaddr), in ifinit()
1015 ifp->int_act_time = now.tv_sec; in ifinit()
1036 if (!strcmp(ifp->int_name, ifs.int_name)) in ifinit()
1046 ? "-->" : ""), in ifinit()
1049 ifp->int_name, in ifinit()
1050 addrname(ifp->int_addr,ifp->int_mask,1), in ifinit()
1051 ((ifp->int_if_flags & IFF_POINTOPOINT) in ifinit()
1052 ? "-->" : ""), in ifinit()
1053 ((ifp->int_if_flags & IFF_POINTOPOINT) in ifinit()
1054 ? naddr_ntoa(ifp->int_dstaddr) : "")); in ifinit()
1056 ifp->int_state |= IS_DUP; in ifinit()
1061 trace_act("%s is neither broadcast, point-to-point," in ifinit()
1080 && !(ifp->int_if_flags & IFF_POINTOPOINT) in ifinit()
1081 && ifp->int_addr != RIP_DEFAULT) { in ifinit()
1083 if (ifp1->int_mask == ifp->int_mask) in ifinit()
1085 if (ifp1->int_if_flags & IFF_POINTOPOINT) in ifinit()
1087 if (ifp1->int_dstaddr == RIP_DEFAULT) in ifinit()
1090 if (!strcmp(ifp->int_name, ifp1->int_name)) in ifinit()
1092 if (on_net(ifp->int_dstaddr, in ifinit()
1093 ifp1->int_net, ifp1->int_mask) in ifinit()
1094 || on_net(ifp1->int_dstaddr, in ifinit()
1095 ifp->int_net, ifp->int_mask)) { in ifinit()
1098 ifp->int_name, in ifinit()
1099 addrname(htonl(ifp->int_net), in ifinit()
1100 ifp->int_mask, 1), in ifinit()
1101 ifp1->int_name, in ifinit()
1102 addrname(htonl(ifp1->int_net), in ifinit()
1103 ifp1->int_mask, 1)); in ifinit()
1109 if (!(ifp->int_state & IS_ALIAS)) { in ifinit()
1112 if (!(ifp->int_if_flags & IFF_LOOPBACK)) in ifinit()
1114 if (!IS_RIP_OFF(ifp->int_state)) in ifinit()
1123 /* If we are multi-homed and have at least two interfaces in ifinit()
1129 /* If we are multi-homed, optionally advertise a route to in ifinit()
1140 if (rt->rt_ifp != ifp in ifinit()
1141 || rt->rt_router != loopaddr) { in ifinit()
1147 loop_rts.rts_time = rt->rt_time; in ifinit()
1148 rtchange(rt, rt->rt_state | RS_MHOME, in ifinit()
1162 if (!(ifp->int_state & (IS_CHECKED | IS_REMOTE))) { in ifinit()
1164 ifp->int_name); in ifinit()
1169 if ((ifp->int_state & IS_BROKE) in ifinit()
1170 && !(ifp->int_state & IS_PASSIVE)) in ifinit()
1176 if (!(ifp->int_state & IS_NO_RIPV1_OUT) && supplier) in ifinit()
1178 if (!(ifp->int_state & IS_NO_RIPV1_IN)) in ifinit()
1185 * might affect routes for point-to-point links. in ifinit()
1190 /* Add routes to the local end of point-to-point interfaces in ifinit()
1193 if ((ifp->int_if_flags & IFF_POINTOPOINT) in ifinit()
1194 && !(ifp->int_state & IS_REMOTE) in ifinit()
1199 del_static(ifp->int_addr, HOST_MASK, 0, 0); in ifinit()
1200 rt = rtget(ifp->int_addr, HOST_MASK); in ifinit()
1201 if (rt != NULL && rt->rt_router != loopaddr) { in ifinit()
1206 if (!(rt->rt_state & RS_LOCAL) in ifinit()
1207 || rt->rt_metric > ifp->int_metric) { in ifinit()
1210 ifp1 = rt->rt_ifp; in ifinit()
1214 loop_rts.rts_time = rt->rt_time; in ifinit()
1215 rtchange(rt, ((rt->rt_state & ~RS_NET_SYN) in ifinit()
1221 rtadd(ifp->int_addr, HOST_MASK, in ifinit()
1229 intnetp = intnetp->intnet_next) { in ifinit()
1230 rt = rtget(intnetp->intnet_addr, intnetp->intnet_mask); in ifinit()
1232 && !(rt->rt_state & RS_NO_NET_SYN) in ifinit()
1233 && !(rt->rt_state & RS_NET_INT)) { in ifinit()
1239 loop_rts.rts_metric = intnetp->intnet_metric-1; in ifinit()
1240 rtadd(intnetp->intnet_addr, intnetp->intnet_mask, in ifinit()
1258 * interface that is on a different class-A,B,or C network. in check_net_syn()
1261 ifp->int_state |= IS_NEED_NET_SYN; in check_net_syn()
1262 rt = rtget(ifp->int_std_addr, ifp->int_std_mask); in check_net_syn()
1264 && 0 == (rt->rt_state & RS_NO_NET_SYN) in check_net_syn()
1265 && (!(rt->rt_state & RS_NET_SYN) in check_net_syn()
1266 || rt->rt_metric > ifp->int_metric)) { in check_net_syn()
1272 new.rts_gate = ifp->int_addr; in check_net_syn()
1273 new.rts_router = ifp->int_addr; in check_net_syn()
1274 new.rts_metric = ifp->int_metric; in check_net_syn()
1275 rtadd(ifp->int_std_addr, ifp->int_std_mask, in check_net_syn()
1280 ifp->int_state &= ~IS_NEED_NET_SYN; in check_net_syn()
1282 rt = rtget(ifp->int_std_addr, in check_net_syn()
1283 ifp->int_std_mask); in check_net_syn()
1285 && (rt->rt_state & RS_NET_SYN) in check_net_syn()
1286 && rt->rt_ifp == ifp) in check_net_syn()
1293 * Create route to other end if a point-to-point link,
1306 if (ifp->int_state & IS_BROKE) in addrouteforif()
1312 if (ifp->int_state & IS_SUBNET) in addrouteforif()
1315 dst = (0 != (ifp->int_if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) in addrouteforif()
1316 ? ifp->int_dstaddr in addrouteforif()
1317 : htonl(ifp->int_net)); in addrouteforif()
1320 new.rts_router = ifp->int_addr; in addrouteforif()
1321 new.rts_gate = ifp->int_addr; in addrouteforif()
1322 new.rts_metric = ifp->int_metric; in addrouteforif()
1328 if ((ifp->int_state & IS_REMOTE) in addrouteforif()
1329 && !(ifp->int_state & IS_EXTERNAL) in addrouteforif()
1337 del_static(dst, ifp->int_mask, 0, 0); in addrouteforif()
1338 rt = rtget(dst, ifp->int_mask); in addrouteforif()
1340 if ((rt->rt_ifp != ifp in addrouteforif()
1341 || rt->rt_router != ifp->int_addr) in addrouteforif()
1342 && (!(ifp->int_state & IS_DUP) in addrouteforif()
1343 || rt->rt_ifp == 0 in addrouteforif()
1344 || (rt->rt_ifp->int_state & IS_BROKE))) { in addrouteforif()
1348 rtchange(rt, ((rt->rt_state | RS_IF) in addrouteforif()
1354 if (ifp->int_transitions++ > 0) in addrouteforif()
1355 trace_act("re-install interface %s", in addrouteforif()
1356 ifp->int_name); in addrouteforif()
1358 rtadd(dst, ifp->int_mask, RS_IF, &new); in addrouteforif()