diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2008-09-11 14:49:59 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2008-09-11 14:49:59 +0000 |
commit | 76bf9feda8bb1ef3a76fba15c2be74ac4c0f4bea (patch) | |
tree | ddee409b0cc2e09a4ed1db03f6371b365b28dbdb /usr.sbin | |
parent | b8732efbae97ae121cdc548c853e65cef134629e (diff) |
remove hackery to un-demote after the session has been established for
a while, we can now just use a timer (since i rewrote the timer code)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 22 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 3 |
3 files changed, 14 insertions, 14 deletions
diff --git a/usr.sbin/bgpd/log.h b/usr.sbin/bgpd/log.h index 884ff1584e2..deb480ab453 100644 --- a/usr.sbin/bgpd/log.h +++ b/usr.sbin/bgpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.10 2007/12/23 18:26:13 henning Exp $ */ +/* $OpenBSD: log.h,v 1.11 2008/09/11 14:49:58 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -119,5 +119,6 @@ static const char * const timernames[] = { "HoldTimer", "IdleHoldTimer", "IdleHoldResetTimer", + "CarpUndemoteTimer", "" }; diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 8ae17ce80ef..b763e35814e 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.283 2008/09/05 10:38:12 henning Exp $ */ +/* $OpenBSD: session.c,v 1.284 2008/09/11 14:49:58 henning Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -438,6 +438,12 @@ session_main(struct bgpd_config *config, struct peer *cpeers, Timer_IdleHoldReset, p->IdleHoldTime); break; + case Timer_CarpUndemote: + timer_stop(p, Timer_CarpUndemote); + if (p->demoted && + p->state == STATE_ESTABLISHED) + session_demote(p, -1); + break; default: fatalx("King Bula lost in time"); } @@ -446,17 +452,6 @@ session_main(struct bgpd_config *config, struct peer *cpeers, nextaction < timeout) timeout = nextaction; - /* XXX carp demotion */ - if (p->demoted && p->state == STATE_ESTABLISHED) { - if (time(NULL) - p->stats.last_updown >= - INTERVAL_HOLD_DEMOTED) - session_demote(p, -1); - if (p->stats.last_updown + INTERVAL_HOLD_DEMOTED - - time(NULL) < timeout) - timeout = p->stats.last_updown + - INTERVAL_HOLD_DEMOTED - time(NULL); - } - /* are we waiting for a write? */ events = POLLIN; if (p->wbuf.queued > 0 || p->state == STATE_CONNECT) @@ -953,6 +948,9 @@ change_state(struct peer *peer, enum session_state state, break; case STATE_ESTABLISHED: timer_set(peer, Timer_IdleHoldReset, peer->IdleHoldTime); + if (peer->demoted) + timer_set(peer, Timer_CarpUndemote, + INTERVAL_HOLD_DEMOTED); session_up(peer); break; default: /* something seriously fucked */ diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 09dc542114f..b1f8553444b 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.98 2008/05/08 09:53:12 henning Exp $ */ +/* $OpenBSD: session.h,v 1.99 2008/09/11 14:49:58 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -171,6 +171,7 @@ enum Timer { Timer_Hold, Timer_IdleHold, Timer_IdleHoldReset, + Timer_CarpUndemote, Timer_Max }; |