diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2006-06-02 20:09:44 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2006-06-02 20:09:44 +0000 |
commit | 437144bba17f70757319673c06c66330b01b22a8 (patch) | |
tree | 374999fd3486ef2339a0f951f6e4362ce4904923 /usr.sbin/sasyncd/net_ctl.c | |
parent | 4f12f882878fb2ae5bb49fb20ff342efba5ced3f (diff) |
Make sasyncd fail back correctly with carp preemption enabled.
Hold the carp demotion when booting, to prevent carp from preempting until
we've sync'd with our peers. This adds a new CTL_ENDSNAP message to the
exchange between the sasync daemons to indicate when the complete snapshot
has been sent. Undemote after 60 seconds, or when recieve a CTL_ENDSNAP from
all our peers.
Syntax is slightly changed, removing the 'carp' keyword (so do
"interface carp0" rather than "carp interface carp0". Adds 'group <ifgroup>',
defaults to the 'carp' group.
ok moritz@
Diffstat (limited to 'usr.sbin/sasyncd/net_ctl.c')
-rw-r--r-- | usr.sbin/sasyncd/net_ctl.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.sbin/sasyncd/net_ctl.c b/usr.sbin/sasyncd/net_ctl.c index 811ed648ba5..fcd346a0ad5 100644 --- a/usr.sbin/sasyncd/net_ctl.c +++ b/usr.sbin/sasyncd/net_ctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: net_ctl.c,v 1.7 2006/06/01 22:43:12 mcbride Exp $ */ +/* $OpenBSD: net_ctl.c,v 1.8 2006/06/02 20:09:43 mcbride Exp $ */ /* * Copyright (c) 2005 Håkan Olsson. All rights reserved. @@ -50,6 +50,8 @@ struct ctlmsg { u_int32_t data2; }; +int snapcount = 0; + static int net_ctl_check_state(struct syncpeer *p, enum RUNSTATE nstate) { @@ -89,6 +91,18 @@ net_ctl_handle_msg(struct syncpeer *p, u_int8_t *msg, u_int32_t msglen) } switch (ntohl(ctl->type)) { + case CTL_ENDSNAP: + log_msg(4, "net_ctl: got CTL_ENDSNAP from peer \"%s\"", + p->name); + + /* XXX More sophistication required to handle multiple peers. */ + if (carp_demoted) { + snapcount++; + if (snapcount >= cfgstate.peercnt) + monitor_carpundemote(NULL); + } + break; + case CTL_STATE: log_msg(4, "net_ctl: got CTL_STATE from peer \"%s\"", p->name); nstate = (enum RUNSTATE)ntohl(ctl->data); @@ -174,6 +188,12 @@ net_ctl_send_error(struct syncpeer *p, enum CTLTYPE prevtype) return net_ctl_send(p, CTL_ERROR, (u_int32_t)prevtype, 0); } +int +net_ctl_send_endsnap(struct syncpeer *p) +{ + return net_ctl_send(p, CTL_ENDSNAP, 0, 0); +} + /* After a CARP tracker state change, send an state ctl msg to all peers. */ void net_ctl_update_state(void) |