summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_carp.c
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2011-04-29 12:36:32 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2011-04-29 12:36:32 +0000
commit4cf3f9b22f46d04b1dd9e7cf2b4ea7417c0079e8 (patch)
tree9f854634bc4b7688529a33ab113eb370d54c3b73 /sys/netinet/ip_carp.c
parent2f459c4a92065cda8b75678215cb5df1f8a33695 (diff)
The previous reconfiguration change broke IPv6 only setups.
The address hook was only registered for v4 addresses. We now call hook_establish at interface creation time. The hook is now disestablished upon interface destroy, which plugs a tiny memleak. While there remove redundancy in carp_set_addr6 and sync it with carp_set_addr. Bug noticed by todd@. OK sthen, mikeb (on an earlier version) OK and some hints by camield@
Diffstat (limited to 'sys/netinet/ip_carp.c')
-rw-r--r--sys/netinet/ip_carp.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index ee246172507..18612047086 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.182 2011/04/04 14:25:16 mikeb Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.183 2011/04/29 12:36:31 mpf Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -902,6 +902,11 @@ carp_clone_create(ifc, unit)
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, ETHER_HDR_LEN);
#endif
+
+ /* Hook carp_addr_updated to cope with address and route changes. */
+ sc->ah_cookie = hook_establish(sc->sc_if.if_addrhooks, 0,
+ carp_addr_updated, sc);
+
return (0);
}
@@ -984,6 +989,8 @@ carpdetach(struct carp_softc *sc)
carp_multicast_cleanup(sc);
s = splnet();
+ if (sc->ah_cookie != NULL)
+ hook_disestablish(sc->sc_if.if_addrhooks, sc->ah_cookie);
if (sc->sc_carpdev != NULL) {
if (sc->lh_cookie != NULL)
hook_disestablish(sc->sc_carpdev->if_linkstatehooks,
@@ -2045,14 +2052,6 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
carp_set_state_all(sc, INIT);
- /*
- * Hook if_addrhooks so that we get a callback after in_ifinit has run,
- * to correct any inappropriate routes that it inserted.
- */
- if (sc->ah_cookie == NULL)
- sc->ah_cookie = hook_establish(sc->sc_if.if_addrhooks, 0,
- carp_addr_updated, sc);
-
return (0);
}
@@ -2137,10 +2136,10 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
if (sc->sc_naddrs6 == 0 && (error = carp_join_multicast6(sc)) != 0)
return (error);
- if (sc->sc_carpdev != NULL && sc->sc_naddrs6)
+ if (sc->sc_carpdev != NULL)
sc->sc_if.if_flags |= IFF_UP;
+
carp_set_state_all(sc, INIT);
- carp_setrun_all(sc, 0);
return (0);
}