| 619 | } |
| 620 | |
| 621 | static void |
| 622 | pfi_instance_add(struct ifnet *ifp, int net, int flags) |
| 623 | { |
| 624 | struct ifaddr *ia; |
| 625 | int got4 = 0, got6 = 0; |
| 626 | int net2, af; |
| 627 | |
| 628 | NET_EPOCH_ASSERT(); |
| 629 | |
| 630 | CK_STAILQ_FOREACH(ia, &ifp->if_addrhead, ifa_link) { |
| 631 | if (ia->ifa_addr == NULL) |
| 632 | continue; |
| 633 | af = ia->ifa_addr->sa_family; |
| 634 | if (af != AF_INET && af != AF_INET6) |
| 635 | continue; |
| 636 | /* |
| 637 | * XXX: For point-to-point interfaces, (ifname:0) and IPv4, |
| 638 | * jump over addresses without a proper route to work |
| 639 | * around a problem with ppp not fully removing the |
| 640 | * address used during IPCP. |
| 641 | */ |
| 642 | if ((ifp->if_flags & IFF_POINTOPOINT) && |
| 643 | !(ia->ifa_flags & IFA_ROUTE) && |
| 644 | (flags & PFI_AFLAG_NOALIAS) && (af == AF_INET)) |
| 645 | continue; |
| 646 | if ((flags & PFI_AFLAG_BROADCAST) && af == AF_INET6) |
| 647 | continue; |
| 648 | if ((flags & PFI_AFLAG_BROADCAST) && |
| 649 | !(ifp->if_flags & IFF_BROADCAST)) |
| 650 | continue; |
| 651 | if ((flags & PFI_AFLAG_PEER) && |
| 652 | !(ifp->if_flags & IFF_POINTOPOINT)) |
| 653 | continue; |
| 654 | if ((flags & (PFI_AFLAG_NETWORK | PFI_AFLAG_NOALIAS)) && |
| 655 | af == AF_INET6 && |
| 656 | IN6_IS_ADDR_LINKLOCAL( |
| 657 | &((struct sockaddr_in6 *)ia->ifa_addr)->sin6_addr)) |
| 658 | continue; |
| 659 | if (flags & PFI_AFLAG_NOALIAS) { |
| 660 | if (af == AF_INET && got4) |
| 661 | continue; |
| 662 | if (af == AF_INET6 && got6) |
| 663 | continue; |
| 664 | } |
| 665 | if (af == AF_INET) |
| 666 | got4 = 1; |
| 667 | else if (af == AF_INET6) |
| 668 | got6 = 1; |
| 669 | net2 = net; |
| 670 | if (net2 == 128 && (flags & PFI_AFLAG_NETWORK)) { |
| 671 | if (af == AF_INET) |
| 672 | net2 = pfi_unmask(&((struct sockaddr_in *) |
| 673 | ia->ifa_netmask)->sin_addr); |
| 674 | else if (af == AF_INET6) |
| 675 | net2 = pfi_unmask(&((struct sockaddr_in6 *) |
| 676 | ia->ifa_netmask)->sin6_addr); |
| 677 | } |
| 678 | if (af == AF_INET && net2 > 32) |
no test coverage detected