diff options
author | 2017-05-27 21:55:52 +0000 | |
---|---|---|
committer | 2017-05-27 21:55:52 +0000 | |
commit | 2421eef4a1913f16a4663e471ad64575fd10013f (patch) | |
tree | dd97c4d9b0704082275d2b55f3b0637c455a9a67 | |
parent | fix previous as noted by mpi, thx florian (diff) | |
download | wireguard-openbsd-2421eef4a1913f16a4663e471ad64575fd10013f.tar.xz wireguard-openbsd-2421eef4a1913f16a4663e471ad64575fd10013f.zip |
Fix the carp mode 'balancing ip-stealth'. Set the link state UP
if at least one vhid is in state MASTER.
from Florian Riehm; OK florian@
-rw-r--r-- | sys/netinet/ip_carp.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 3c2f9914212..3b2ae3dff8d 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.309 2017/05/04 17:58:46 bluhm Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.310 2017/05/27 21:55:52 bluhm Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -2362,6 +2362,7 @@ carp_set_state(struct carp_vhost_entry *vhe, int state) struct carp_softc *sc = vhe->parent_sc; static const char *carp_states[] = { CARP_STATES }; int loglevel; + struct carp_vhost_entry *vhe0; KASSERT(vhe->state != state); @@ -2382,20 +2383,20 @@ carp_set_state(struct carp_vhost_entry *vhe, int state) vhe->state = state; carp_update_lsmask(sc); - /* only the master vhe creates link state messages */ - if (!vhe->vhe_leader) - return; + KERNEL_ASSERT_LOCKED(); /* touching carp_vhosts */ - switch (state) { - case BACKUP: - sc->sc_if.if_link_state = LINK_STATE_DOWN; - break; - case MASTER: - sc->sc_if.if_link_state = LINK_STATE_UP; - break; - default: - sc->sc_if.if_link_state = LINK_STATE_INVALID; - break; + sc->sc_if.if_link_state = LINK_STATE_INVALID; + SRPL_FOREACH_LOCKED(vhe0, &sc->carp_vhosts, vhost_entries) { + /* + * Link must be up if at least one vhe is in state MASTER to + * bring or keep route up. + */ + if (vhe0->state == MASTER) { + sc->sc_if.if_link_state = LINK_STATE_UP; + break; + } else if (vhe0->state == BACKUP) { + sc->sc_if.if_link_state = LINK_STATE_DOWN; + } } if_link_state_change(&sc->sc_if); } |