summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2012-06-28 13:59:22 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2012-06-28 13:59:22 +0000
commit7702ae4e624e48dd189dd3c0b99d949a9ef319ba (patch)
tree6c1836a8f8aa104c6212c3fe162705d0d07bcd24 /sys
parent240ec7872becfa3f6be838c07b5ae661fa93ea1d (diff)
Fix a number of problems introduced by the link state handling commit:
1) demote by 32 on the first bulk update to prevent failovers w/o having a full state table; 2) don't do any demotion adjustments on the link up event and undemote when bulk update finishes (or times out) preventing a race between nodes getting a link state update asynchronously. With phessler; tested by phessler and Kapetanakis Giannis. Thanks! Looked through by henning and dlg.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_pfsync.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index 534c9d34ed2..994aa184846 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.184 2012/04/11 17:42:53 mikeb Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.185 2012/06/28 13:59:21 mikeb Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -210,6 +210,8 @@ struct pfsync_softc {
struct pfsync_upd_reqs sc_upd_req_list;
+ int sc_link_demote;
+
int sc_defer;
struct pfsync_deferrals sc_deferrals;
u_int sc_deferred;
@@ -417,11 +419,13 @@ pfsync_syncdev_state(void *arg)
if (!sc->sc_sync_if)
return;
- if (sc->sc_sync_if->if_link_state == LINK_STATE_DOWN ||
- !(sc->sc_sync_if->if_flags & IFF_UP)) {
+ if (sc->sc_sync_if->if_link_state == LINK_STATE_DOWN) {
sc->sc_if.if_flags &= ~IFF_RUNNING;
#if NCARP > 0
- carp_group_demote_adj(&sc->sc_if, 1, "pfsyncdev");
+ if (!sc->sc_link_demote) {
+ carp_group_demote_adj(&sc->sc_if, 1, "pfsyncdev");
+ sc->sc_link_demote = 1;
+ }
#endif
/* drop everything */
timeout_del(&sc->sc_tmo);
@@ -433,10 +437,8 @@ pfsync_syncdev_state(void *arg)
sc->sc_bulk_last = NULL;
} else {
sc->sc_if.if_flags |= IFF_RUNNING;
+
pfsync_request_full_update(sc);
-#if NCARP > 0
- carp_group_demote_adj(&sc->sc_if, -1, "pfsyncdev");
-#endif
}
}
@@ -1150,6 +1152,11 @@ pfsync_in_bus(caddr_t buf, int len, int count, int flags)
if (!pfsync_sync_ok)
carp_group_demote_adj(&sc->sc_if, -1,
"pfsync bulk done");
+ if (sc->sc_link_demote) {
+ carp_group_demote_adj(&sc->sc_if, -1,
+ "pfsyncdev");
+ sc->sc_link_demote = 0;
+ }
#endif
pfsync_sync_ok = 1;
DPFPRINTF(LOG_INFO, "received valid bulk update end");
@@ -2275,6 +2282,10 @@ pfsync_bulk_fail(void *arg)
if (!pfsync_sync_ok)
carp_group_demote_adj(&sc->sc_if, -1,
"pfsync bulk fail");
+ if (sc->sc_link_demote) {
+ carp_group_demote_adj(&sc->sc_if, -1, "pfsyncdev");
+ sc->sc_link_demote = 0;
+ }
#endif
pfsync_sync_ok = 1;
DPFPRINTF(LOG_ERR, "failed to receive bulk update");