diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-05-13 05:49:07 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-05-13 05:49:07 +0000 |
commit | eb9ae5bf720298197b3a7d0a493749a79901eef2 (patch) | |
tree | 3a99d01d596a92747e0d1717f5757c7e7a3254bc /sys | |
parent | 5cbcf646d65f8632da9a177c1132783714718167 (diff) |
Add cloned interface destruction to carp (ifconfig carp0 destroy).
ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_carp.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 4ee2d3bb8c8..873f4e65993 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.48 2004/05/13 00:04:20 mcbride Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.49 2004/05/13 05:49:06 mcbride Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -179,9 +179,10 @@ int carp_set_addr6(struct carp_softc *, struct sockaddr_in6 *); int carp_del_addr6(struct carp_softc *, struct sockaddr_in6 *); #endif int carp_clone_create(struct if_clone *, int); +int carp_clone_destroy(struct ifnet *); struct if_clone carp_cloner = - IF_CLONE_INITIALIZER("carp", carp_clone_create, NULL); + IF_CLONE_INITIALIZER("carp", carp_clone_create, carp_clone_destroy); static __inline u_int16_t carp_cksum(struct mbuf *m, int len) @@ -646,6 +647,33 @@ carp_clone_create(ifc, unit) return (0); } +int +carp_clone_destroy(struct ifnet *ifp) +{ + struct carp_softc *sc = ifp->if_softc; + struct carp_if *cif; + + timeout_del(&sc->sc_ad_tmo); + timeout_del(&sc->sc_md_tmo); + timeout_del(&sc->sc_md6_tmo); + + if (sc->sc_ifp != NULL) { + cif = (struct carp_if *)sc->sc_ifp->if_carp; + TAILQ_REMOVE(&cif->vhif_vrs, sc, sc_list); + if (!--cif->vhif_nvrs) { + sc->sc_ifp->if_carp = NULL; + FREE(cif, M_IFADDR); + } + } + +#if NBPFILTER > 0 + bpfdetach(ifp); +#endif + if_detach(ifp); + + return (0); +} + void carpdetach(struct carp_softc *sc) { |