From d1fa89c9f05fd4438d175d63dc28e6d3dbdf922f Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Wed, 15 Apr 2015 15:14:38 +0000 Subject: Use ether_ifattach() and ether_ifdetach() when cloning/destroying an interface instead of rewritting most of them. This change is also needed for upcoming if_input() conversion. As a bonus pseudo-driver attached on top of carp are now detached in the right order. ok claudio@, henning@ --- sys/netinet/ip_carp.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'sys') diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 5191edf5c4e..a77dc3824be 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.249 2015/04/07 10:46:20 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.250 2015/04/15 15:14:37 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -745,20 +745,12 @@ carp_clone_create(ifc, unit) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = carp_ioctl; ifp->if_start = carp_start; - ifp->if_output = carp_output; - ifp->if_type = IFT_CARP; - ifp->if_addrlen = ETHER_ADDR_LEN; - ifp->if_hdrlen = ETHER_HDR_LEN; - ifp->if_mtu = ETHERMTU; IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); IFQ_SET_READY(&ifp->if_snd); if_attach(ifp); - - if_alloc_sadl(ifp); - LIST_INIT(&sc->sc_ac.ac_multiaddrs); -#if NBPFILTER > 0 - bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, ETHER_HDR_LEN); -#endif + ether_ifattach(ifp); + ifp->if_type = IFT_CARP; + ifp->if_output = carp_output; /* Hook carp_addr_updated to cope with address and route changes. */ sc->ah_cookie = hook_establish(sc->sc_if.if_addrhooks, 0, @@ -805,19 +797,9 @@ int carp_clone_destroy(struct ifnet *ifp) { struct carp_softc *sc = ifp->if_softc; - struct arpcom *ac = (struct arpcom *)ifp; - struct ether_multi *enm; carpdetach(sc); - - /* XXX should be converted to ether_ifattach() and ether_ifdetach() */ - for (enm = LIST_FIRST(&ac->ac_multiaddrs); - enm != NULL; - enm = LIST_FIRST(&ac->ac_multiaddrs)) { - LIST_REMOVE(enm, enm_list); - free(enm, M_IFMADDR, 0); - } - + ether_ifdetach(ifp); if_detach(ifp); carp_destroy_vhosts(ifp->if_softc); free(sc->sc_imo.imo_membership, M_IPMOPTS, 0); -- cgit v1.2.3