| 1657 | } |
| 1658 | |
| 1659 | static struct carp_if* |
| 1660 | carp_alloc_if(struct ifnet *ifp) |
| 1661 | { |
| 1662 | struct carp_if *cif; |
| 1663 | int error; |
| 1664 | |
| 1665 | cif = malloc(sizeof(*cif), M_CARP, M_WAITOK|M_ZERO); |
| 1666 | |
| 1667 | if ((error = ifpromisc(ifp, 1)) != 0) |
| 1668 | printf("%s: ifpromisc(%s) failed: %d\n", |
| 1669 | __func__, ifp->if_xname, error); |
| 1670 | else |
| 1671 | cif->cif_flags |= CIF_PROMISC; |
| 1672 | |
| 1673 | CIF_LOCK_INIT(cif); |
| 1674 | cif->cif_ifp = ifp; |
| 1675 | TAILQ_INIT(&cif->cif_vrs); |
| 1676 | |
| 1677 | IF_ADDR_WLOCK(ifp); |
| 1678 | ifp->if_carp = cif; |
| 1679 | if_ref(ifp); |
| 1680 | IF_ADDR_WUNLOCK(ifp); |
| 1681 | |
| 1682 | return (cif); |
| 1683 | } |
| 1684 | |
| 1685 | static void |
| 1686 | carp_free_if(struct carp_if *cif) |
no test coverage detected