Lines Matching refs:ifp

312 if_link(struct interface *ifp, uint32_t ifindex)
316 link_in((void **)&ifnet, ifp, offsetof(struct interface, int_link));
318 HADD(&ahash_tbl, ifp);
319 HADD(&nhash_tbl, ifp);
321 if (ifp->int_if_flags & IFF_BROADCAST)
322 HADD(&bhash_tbl, ifp);
339 size = strcspn(ifp->int_name, ":");
340 (void) strncpy(phyi->phyi_name, ifp->int_name,
345 link_in((void **)&phyi->phyi_interface, ifp,
347 ifp->int_phys = phyi;
357 struct interface *ifp, *possible = NULL;
362 for (ifp = HFIRST(&ahash_tbl, &addr); ifp != NULL;
363 ifp = ifp->int_ahash.hl_next) {
364 if (ifp->int_addr != addr)
366 if (ifp->int_state & remote_state)
368 if (!(ifp->int_state & (IS_BROKE | IS_PASSIVE)))
369 return (ifp);
370 possible = ifp;
376 for (ifp = HFIRST(&bhash_tbl, &addr); ifp != NULL;
377 ifp = ifp->int_bhash.hl_next) {
378 if (ifp->int_brdaddr != addr)
380 if (ifp->int_state & remote_state)
382 if (!(ifp->int_state & (IS_BROKE | IS_PASSIVE)))
383 return (ifp);
384 possible = ifp;
395 struct interface *ifp;
398 for (ifp = HFIRST(&nhash_tbl, name); ifp != NULL;
399 ifp = ifp->int_nhash.hl_next) {
400 if (strcmp(ifp->int_name, name) == 0)
401 return (ifp);
437 struct interface *ifp;
439 for (ifp = HFIRST(&ahash_tbl, &addr); ifp != NULL;
440 ifp = ifp->int_ahash.hl_next) {
441 if ((ifp->int_state & IS_REMOTE) && ifp->int_addr == addr)
442 return (ifp);
451 struct interface *ifp;
453 for (ifp = HFIRST(&ahash_tbl, &addr); ifp != NULL;
454 ifp = ifp->int_ahash.hl_next) {
455 if (ifp->int_addr == addr)
456 return (ifp);
490 * Returns true only if given ifp has the exact address else returns
491 * false and sets best if an ifp matches partially and is a better
495 addr_on_ifp(in_addr_t addr, struct interface *ifp,
503 if (ifp->int_state & IS_DUP)
506 if (ifp->int_if_flags & IFF_POINTOPOINT) {
507 if (ifp->int_dstaddr == addr) {
512 if (ifp->int_addr == addr) {
513 if (IS_PASSIVE_IFP(ifp))
516 ifp->int_name);
522 if (on_net(addr, ifp->int_net, ifp->int_mask) &&
524 ifp->int_mask > p_best->int_mask)) {
525 *best = ifp;
541 struct interface *ifp, *maybe;
545 for (ifp = ifnet; ifp != NULL; ifp = ifp->int_next) {
548 if (addr_on_ifp(addr, ifp, &maybe))
549 return (ifp);
576 const struct interface *ifp) /* as seen on this interface */
584 if (ifp != NULL && ifp->int_ripv1_mask != HOST_MASK) {
589 if (on_net(addr, ifp->int_net, ifp->int_std_mask))
590 mask = ifp->int_ripv1_mask;
600 for (ifp = ifnet; ifp != NULL; ifp = ifp->int_next) {
601 if (on_net(addr, ifp->int_std_net, ifp->int_std_mask) &&
602 ifp->int_ripv1_mask > mask &&
603 ifp->int_ripv1_mask != HOST_MASK)
604 mask = ifp->int_ripv1_mask;
636 const struct interface *ifp) /* as seen on this interface */
638 in_addr_t mask = ripv1_mask_net(addr, ifp);
692 struct interface *ifp;
697 for (ifp = ifnet; ifp != NULL; ifp = ifp->int_next) {
699 if (name != NULL && strcmp(name, ifp->int_name) == 0)
708 if (!allowdups && (ifp->int_state & IS_DUP))
711 if (ifp->int_mask != mask)
714 if (!IS_IFF_UP(ifp->int_if_flags))
721 if ((ifp->int_addr == addr &&
722 ((if_flags|ifp->int_if_flags) & IFF_POINTOPOINT) == 0) ||
723 on_net(ifp->int_dstaddr, dstaddr_h, mask)) {
725 if (!(ifp->int_state & IS_ALIAS))
727 if (!IS_RIP_OUT_OFF(ifp->int_state))
729 if (IS_IFF_ROUTING(ifp->int_if_flags))
733 best_ifp = ifp;
746 check_remote(struct interface *ifp)
751 if (!(ifp->int_state & IS_REMOTE))
754 rt = rtfind(ifp->int_addr);
757 on_net(ifp->int_addr, rt->rt_ifp->int_net, rt->rt_ifp->int_mask)) {
765 if (!(ifp->int_state & IS_BROKE)) {
767 naddr_ntoa(ifp->int_addr));
768 if_bad(ifp, _B_FALSE);
775 ifdel(struct interface *ifp)
781 trace_if("Del", ifp);
783 ifp->int_state |= IS_BROKE;
786 link_out(ifp, offsetof(struct interface, int_link));
787 hash_unlink(&ahash_tbl, ifp);
788 hash_unlink(&nhash_tbl, ifp);
789 if (ifp->int_if_flags & IFF_BROADCAST)
790 hash_unlink(&bhash_tbl, ifp);
793 if ((phyi = ifp->int_phys) != NULL) {
794 link_out(ifp, offsetof(struct interface, int_ilist));
807 if (!(ifp->int_state & IS_DUP) &&
808 (wire.if_new = check_dup(ifp->int_name, ifp->int_addr,
809 ifp->int_dstaddr, ifp->int_mask, ifp->int_if_flags,
814 wire.if_new->int_name, ifp->int_name);
817 wire.if_old = ifp;
818 wire.metric_delta = wire.if_new->int_metric - ifp->int_metric;
840 rip_mcast_off(ifp);
841 if (rip_sock_interface == ifp)
844 set_rdisc_mg(ifp, 0);
850 if (!(ifp->int_state & IS_DUP) && !IS_IFF_QUIET(ifp->int_if_flags)) {
852 if (!IS_RIP_OFF(ifp->int_state))
854 if (!IS_RIP_OUT_OFF(ifp->int_state))
856 if (IS_IFF_ROUTING(ifp->int_if_flags))
866 (void) rn_walktree(rhead, walk_bad, ifp);
867 kern_flush_ifp(ifp);
869 if_bad_rdisc(ifp);
872 free(ifp);
878 if_sick(struct interface *ifp, boolean_t recurse)
882 if (0 == (ifp->int_state & (IS_SICK | IS_BROKE))) {
883 ifp->int_state |= IS_SICK;
884 ifp->int_act_time = NEVER;
885 trace_if("Chg", ifp);
888 if (recurse && ifp->int_phys != NULL) {
890 for (ifp1 = ifp->int_phys->phyi_interface;
892 if (ifp1 != ifp)
902 if_bad(struct interface *ifp, boolean_t recurse)
907 if (ifp->int_state & IS_BROKE)
912 ifp->int_state |= (IS_BROKE | IS_SICK);
913 ifp->int_act_time = NEVER;
914 ifp->int_query_time = NEVER;
917 trace_if("Chg", ifp);
919 if (recurse && ifp->int_phys != NULL) {
921 for (ifp1 = ifp->int_phys->phyi_interface;
923 if (ifp1 != ifp)
929 if (!(ifp->int_state & IS_DUP) &&
930 (wire.if_new = check_dup(ifp->int_name, ifp->int_addr,
931 ifp->int_dstaddr, ifp->int_mask, ifp->int_if_flags,
935 wire.if_new->int_name, ifp->int_name);
936 wire.if_old = ifp;
937 wire.metric_delta = wire.if_new->int_metric - ifp->int_metric;
943 set_rdisc_mg(ifp, 0);
944 rip_mcast_off(ifp);
945 ifp->int_state |= IS_DUP;
951 if (rip_sock_interface == ifp)
954 (void) rn_walktree(rhead, walk_bad, ifp);
955 if_bad_rdisc(ifp);
962 if_ok(struct interface *ifp, const char *type, boolean_t recurse)
967 if (ifp->int_state & IS_BROKE) {
969 type, ifp->int_name, naddr_ntoa(ifp->int_dstaddr));
970 ifp->int_state &= ~(IS_BROKE | IS_SICK);
972 } else if (ifp->int_state & IS_SICK) {
974 type, ifp->int_name, naddr_ntoa(ifp->int_dstaddr));
975 ifp->int_state &= ~IS_SICK;
978 if (recurse && ifp->int_phys != NULL && IS_IFF_UP(ifp->int_if_flags)) {
979 ifp->int_phys->phyi_data.ts = 0;
982 for (ifp1 = ifp->int_phys->phyi_interface;
984 if (ifp1 != ifp)
990 if (!(ifp->int_state & IS_DUP))
991 if_ok_rdisc(ifp);
993 if (ifp->int_state & IS_REMOTE)
994 (void) addrouteforif(ifp);
999 remote_address_ok(struct interface *ifp, in_addr_t addr)
1001 if (ifp->int_if_flags & IFF_POINTOPOINT) {
1002 if (addr == ifp->int_dstaddr)
1004 } else if (on_net(addr, ifp->int_net, ifp->int_mask)) {
1031 struct interface ifs, *ifp, *ifp1;
1056 for (ifp = ifnet; ifp != NULL; ifp = ifp->int_next)
1057 ifp->int_state &= ~IS_CHECKED;
1348 ifp = check_dup(ifs.int_name, ifs.int_addr, ifs.int_dstaddr,
1350 if (ifp != NULL) {
1358 ifp->int_name,
1359 addrname(ifp->int_addr, ifp->int_mask, 1),
1360 ((ifp->int_if_flags & IFF_POINTOPOINT) ?
1362 ((ifp->int_if_flags & IFF_POINTOPOINT) ?
1363 naddr_ntoa(ifp->int_dstaddr) : ""));
1376 ifp = ifwithname(ifs.int_name);
1377 if (ifp != NULL) {
1378 ifp->int_state |= IS_CHECKED;
1379 ifp->int_state = (ifp->int_state & ~IS_DUP) |
1382 if ((ifp->int_phys == NULL && ifindex != 0) ||
1383 (ifp->int_phys != NULL &&
1384 ifp->int_phys->phyi_index != ifindex) ||
1385 0 != ((ifp->int_if_flags ^ ifs.int_if_flags)
1389 ifp->int_addr != ifs.int_addr ||
1390 ifp->int_brdaddr != ifs.int_brdaddr ||
1391 ifp->int_dstaddr != ifs.int_dstaddr ||
1392 ifp->int_mask != ifs.int_mask ||
1393 ifp->int_metric != ifs.int_metric) {
1399 ifp->int_name);
1400 ifdel(ifp);
1401 ifp = NULL;
1405 if (ifp != NULL) {
1408 if (IS_IFF_UP(ifp->int_if_flags)) {
1411 ifp->int_name,
1412 naddr_ntoa(ifp->int_dstaddr));
1413 if_bad(ifp, _B_FALSE);
1414 ifp->int_if_flags &= ~IFF_UP;
1415 } else if (ifp->int_phys != NULL &&
1416 now.tv_sec > (ifp->int_phys->phyi_data.ts +
1420 ifp->int_name,
1422 ifp->int_phys->phyi_data.ts);
1423 ifdel(ifp);
1428 if (!IS_IFF_UP(ifp->int_if_flags)) {
1429 ifp->int_if_flags |= IFF_UP;
1430 if_ok(ifp, "", _B_FALSE);
1437 if ((phyi = ifp->int_phys) == NULL ||
1443 if (get_if_kstats(ifp, &newstats) == -1) {
1488 if (!(ifp->int_state & IS_SICK)) {
1492 ifp->int_name,
1493 naddr_ntoa(ifp->int_dstaddr),
1495 if_sick(ifp, _B_TRUE);
1498 if (!(ifp->int_state & IS_BROKE)) {
1502 ifp->int_name,
1503 naddr_ntoa(ifp->int_dstaddr),
1505 if_bad(ifp, _B_TRUE);
1511 ifp->int_act_time = now.tv_sec;
1512 if_ok(ifp, "", _B_TRUE);
1539 ifp = rtmalloc(sizeof (*ifp), "ifscan ifp");
1540 (void) memcpy(ifp, &ifs, sizeof (*ifp));
1541 get_parms(ifp);
1542 if_link(ifp, ifindex);
1543 trace_if("Add", ifp);
1545 if (ifp->int_phys != NULL &&
1546 get_if_kstats(ifp, &ifp->int_phys->phyi_data) == -1) {
1550 ifp->int_phys->phyi_name);
1555 if (!(ifp->int_if_flags & (IFF_POINTOPOINT|IFF_LOOPBACK))) {
1558 if (ifp1->int_mask == ifp->int_mask)
1571 if (ifp->int_phys == ifp1->int_phys)
1574 if (on_net(ifp->int_addr,
1577 ifp->int_net, ifp->int_mask)) {
1581 ifp->int_name,
1582 addrname(htonl(ifp->int_net),
1583 ifp->int_mask, 1),
1592 if (!(ifp->int_state & IS_DUP) &&
1593 !IS_IFF_QUIET(ifp->int_if_flags)) {
1596 if (!IS_RIP_OFF(ifp->int_state))
1598 if (!IS_RIP_OUT_OFF(ifp->int_state))
1600 if (IS_IFF_ROUTING(ifp->int_if_flags))
1603 if_ok_rdisc(ifp);
1604 rip_on(ifp);
1643 (ifp = ifwithaddr(myaddr, _B_FALSE, _B_FALSE)) != NULL &&
1648 if (rt->rt_ifp != ifp ||
1653 loop_rts.rts_ifp = ifp;
1662 loop_rts.rts_ifp = ifp;
1670 for (ifp = ifnet; ifp != NULL; ifp = ifp1) {
1671 ifp1 = ifp->int_next; /* because we may delete it */
1674 if (!(ifp->int_state & (IS_CHECKED | IS_REMOTE))) {
1676 ifp->int_name);
1677 ifdel(ifp);
1681 if ((ifp->int_state & IS_BROKE) &&
1682 !(ifp->int_state & IS_PASSIVE))
1689 if (!(ifp->int_state & (IS_NO_RIPV1_OUT | IS_DUP)) &&
1690 should_supply(ifp))
1692 if (!(ifp->int_state & IS_NO_RIPV1_IN))
1696 for (ifp = ifnet; ifp != NULL; ifp = ifp->int_next) {
1702 if (addrouteforif(ifp) == 0)
1709 if ((ifp->int_if_flags & IFF_POINTOPOINT) &&
1710 !(ifp->int_state & IS_REMOTE) && foundloopback) {
1715 del_static(ifp->int_addr, HOST_MASK, 0, ifp, 0);
1716 rt = rtget(ifp->int_addr, HOST_MASK);
1723 rt->rt_metric > ifp->int_metric) {
1724 ifp1 = ifp;
1735 loop_rts.rts_ifp = ifp;
1738 rtadd(ifp->int_addr, HOST_MASK,
1768 check_net_syn(struct interface *ifp)
1779 ifp->int_state |= IS_NEED_NET_SYN;
1780 rt = rtget(ifp->int_std_addr, ifp->int_std_mask);
1784 rt->rt_metric > ifp->int_metric)) {
1790 new.rts_ifp = ifp;
1791 new.rts_gate = ifp->int_addr;
1792 new.rts_router = ifp->int_addr;
1793 new.rts_metric = ifp->int_metric;
1795 rtadd(ifp->int_std_addr, ifp->int_std_mask,
1800 ifp->int_state &= ~IS_NEED_NET_SYN;
1802 rt = rtget(ifp->int_std_addr, ifp->int_std_mask);
1805 rt->rt_ifp == ifp)
1817 addrouteforif(struct interface *ifp)
1826 if (ifp->int_state & IS_BROKE)
1833 if ((ifp->int_state & IS_DUP) ||
1834 ((ifp->int_if_flags & IFF_POINTOPOINT) && ifp->int_dstaddr == 0))
1841 if (ifp->int_state & IS_SUBNET)
1842 check_net_syn(ifp);
1844 dst = (0 != (ifp->int_if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) ?
1845 ifp->int_dstaddr : htonl(ifp->int_net));
1848 new.rts_ifp = ifp;
1849 new.rts_router = ifp->int_addr;
1850 new.rts_gate = ifp->int_addr;
1851 new.rts_metric = ifp->int_metric;
1853 if (ifp->int_if_flags & IFF_POINTOPOINT)
1855 else if (ifp->int_if_flags & IFF_LOOPBACK)
1864 if ((ifp->int_state & IS_REMOTE) &&
1865 !(ifp->int_state & IS_EXTERNAL) &&
1866 !check_remote(ifp))
1874 del_static(dst, ifp->int_mask, 0, ifp, 0);
1875 rt = rtget(dst, ifp->int_mask);
1876 if (!IS_IFF_ROUTING(ifp->int_if_flags))
1879 if ((rt->rt_ifp != ifp || rt->rt_router != ifp->int_addr) &&
1890 if (ifp->int_transitions++ > 0)
1893 ifp->int_name, ifp->int_transitions);
1895 rtadd(dst, ifp->int_mask, rt_newstate, &new);
1924 get_if_kstats(struct interface *ifp, struct phyi_data *newdata)
1926 struct physical_interface *phyi = ifp->int_phys;
1963 if (!(ifp->int_if_flags & IFF_LOOPBACK)) {
1987 should_supply(struct interface *ifp)
1989 if (ifp != NULL && !IS_IFF_ROUTING(ifp->int_if_flags))