| 747 | } |
| 748 | |
| 749 | static void |
| 750 | defrouter_del(struct nd_defrouter *dr) |
| 751 | { |
| 752 | struct nd_defrouter *deldr = NULL; |
| 753 | struct nd_prefix *pr; |
| 754 | struct nd_pfxrouter *pfxrtr; |
| 755 | |
| 756 | ND6_UNLOCK_ASSERT(); |
| 757 | |
| 758 | /* |
| 759 | * Flush all the routing table entries that use the router |
| 760 | * as a next hop. |
| 761 | */ |
| 762 | if (ND_IFINFO(dr->ifp)->flags & ND6_IFF_ACCEPT_RTADV) |
| 763 | rt6_flush(&dr->rtaddr, dr->ifp); |
| 764 | |
| 765 | #ifdef EXPERIMENTAL |
| 766 | defrtr_ipv6_only_ifp(dr->ifp); |
| 767 | #endif |
| 768 | |
| 769 | if (dr->installed) { |
| 770 | deldr = dr; |
| 771 | defrouter_delreq(dr); |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | * Also delete all the pointers to the router in each prefix lists. |
| 776 | */ |
| 777 | ND6_WLOCK(); |
| 778 | LIST_FOREACH(pr, &V_nd_prefix, ndpr_entry) { |
| 779 | if ((pfxrtr = pfxrtr_lookup(pr, dr)) != NULL) |
| 780 | pfxrtr_del(pfxrtr); |
| 781 | } |
| 782 | ND6_WUNLOCK(); |
| 783 | |
| 784 | pfxlist_onlink_check(); |
| 785 | |
| 786 | /* |
| 787 | * If the router is the primary one, choose a new one. |
| 788 | * Note that defrouter_select_fib() will remove the current |
| 789 | * gateway from the routing table. |
| 790 | */ |
| 791 | if (deldr) |
| 792 | defrouter_select_fib(deldr->ifp->if_fib); |
| 793 | |
| 794 | /* |
| 795 | * Release the list reference. |
| 796 | */ |
| 797 | defrouter_rele(dr); |
| 798 | } |
| 799 | |
| 800 | struct nd_defrouter * |
| 801 | defrouter_lookup_locked(const struct in6_addr *addr, struct ifnet *ifp) |
no test coverage detected