diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2003-11-03 05:09:40 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2003-11-03 05:09:40 +0000 |
commit | a9e6b9df274085a0f7f70048bdb9d230ad16b8ab (patch) | |
tree | e426c379ef0a602ac27c6d31e87e7bd4cd65f189 /sys | |
parent | 622f11cea23c37be063fc7a566b42a8582fc0775 (diff) |
Cleanups:
- missing #ifdef INET6.
- fix check for interface going down in carp_send_ad().
- fix memory leak which occurs when when ifpromisc() fails.
All from Max Laier, thanks.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_carp.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 50dd881213d..0ccfa1694c3 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.15 2003/11/03 03:19:27 deraadt Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.16 2003/11/03 05:09:39 mcbride Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -734,7 +734,8 @@ carp_send_ad(void *v) sc->sc_ac.ac_if.if_oerrors++; carpstats.carps_onomem++; /* XXX maybe less ? */ - timeout_add(&sc->sc_ad_tmo, tvtohz(&tv)); + if (advbase != 255 || advskew != 255) + timeout_add(&sc->sc_ad_tmo, tvtohz(&tv)); return; } len = sizeof(*ip6) + sizeof(ch); @@ -1007,7 +1008,9 @@ carp_setrun(struct carp_softc *sc, sa_family_t af) if (carp_opts[CARPCTL_PREEMPT]) { carp_send_ad(sc); carp_send_arp(sc); +#ifdef INET6 carp_send_na(sc); +#endif sc->sc_state = MASTER; } else { sc->sc_state = BACKUP; @@ -1123,8 +1126,10 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin) error = ENOBUFS; goto cleanup; } - if ((error = ifpromisc(ifp, 1))) + if ((error = ifpromisc(ifp, 1))) { + FREE(cif, M_IFADDR); goto cleanup; + } cif->vhif_ifp = ifp; TAILQ_INIT(&cif->vhif_vrs); @@ -1291,8 +1296,10 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6) error = ENOBUFS; goto cleanup; } - if ((error = ifpromisc(ifp, 1))) + if ((error = ifpromisc(ifp, 1))) { + FREE(cif, M_IFADDR); goto cleanup; + } cif->vhif_ifp = ifp; TAILQ_INIT(&cif->vhif_vrs); |