diff options
-rw-r--r-- | usr.sbin/bgpd/session.c | 54 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/timer.c | 14 |
3 files changed, 48 insertions, 23 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 729afaf1a8f..031312f19cc 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.280 2008/05/08 06:52:13 henning Exp $ */ +/* $OpenBSD: session.c,v 1.281 2008/05/08 07:43:02 henning Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -407,29 +407,41 @@ session_main(struct bgpd_config *config, struct peer *cpeers, for (p = peers; p != NULL; p = p->next) { time_t nextaction; + struct peer_timer *pt; /* check timers */ - if (timer_due(p, Timer_Hold)) - bgp_fsm(p, EVNT_TIMER_HOLDTIME); - if (timer_due(p, Timer_ConnectRetry)) - bgp_fsm(p, EVNT_TIMER_CONNRETRY); - if (timer_due(p, Timer_Keepalive)) - bgp_fsm(p, EVNT_TIMER_KEEPALIVE); - if (timer_due(p, Timer_IdleHold)) - bgp_fsm(p, EVNT_START); - if (timer_due(p, Timer_IdleHoldReset)) { - p->IdleHoldTime /= 2; - if (p->IdleHoldTime <= - INTERVAL_IDLE_HOLD_INITIAL) { - p->IdleHoldTime = - INTERVAL_IDLE_HOLD_INITIAL; - timer_stop(p, Timer_IdleHoldReset); - p->errcnt = 0; - } else - timer_set(p, Timer_IdleHoldReset, - p->IdleHoldTime); + if ((pt = timer_nextisdue(p)) != NULL) { + switch (pt->type) { + case Timer_Hold: + bgp_fsm(p, EVNT_TIMER_HOLDTIME); + break; + case Timer_ConnectRetry: + bgp_fsm(p, EVNT_TIMER_CONNRETRY); + break; + case Timer_Keepalive: + bgp_fsm(p, EVNT_TIMER_KEEPALIVE); + break; + case Timer_IdleHold: + bgp_fsm(p, EVNT_START); + break; + case Timer_IdleHoldReset: + p->IdleHoldTime /= 2; + if (p->IdleHoldTime <= + INTERVAL_IDLE_HOLD_INITIAL) { + p->IdleHoldTime = + INTERVAL_IDLE_HOLD_INITIAL; + timer_stop(p, + Timer_IdleHoldReset); + p->errcnt = 0; + } else + timer_set(p, + Timer_IdleHoldReset, + p->IdleHoldTime); + break; + default: + fatalx("King Bula lost in time"); + } } - if ((nextaction = timer_nextduein(p)) != -1 && nextaction < timeout) timeout = nextaction; diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 25bada9c5b3..38ca2ffe1fa 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.96 2008/05/08 06:52:13 henning Exp $ */ +/* $OpenBSD: session.h,v 1.97 2008/05/08 07:43:03 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -282,6 +282,7 @@ int carp_demote_set(char *, int); /* timer.c */ struct peer_timer *timer_get(struct peer *, enum Timer); int timer_due(struct peer *, enum Timer); +struct peer_timer *timer_nextisdue(struct peer *); time_t timer_nextduein(struct peer *); int timer_running(struct peer *, enum Timer, time_t *); void timer_set(struct peer *, enum Timer, u_int); diff --git a/usr.sbin/bgpd/timer.c b/usr.sbin/bgpd/timer.c index b2dce26e63a..ad07f5da073 100644 --- a/usr.sbin/bgpd/timer.c +++ b/usr.sbin/bgpd/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.6 2008/05/08 07:40:03 henning Exp $ */ +/* $OpenBSD: timer.c,v 1.7 2008/05/08 07:43:03 henning Exp $ */ /* * Copyright (c) 2003-2007 Henning Brauer <henning@openbsd.org> @@ -45,6 +45,18 @@ timer_due(struct peer *p, enum Timer timer) return (0); } +struct peer_timer * +timer_nextisdue(struct peer *p) +{ + struct peer_timer *pt; + + pt = TAILQ_FIRST(&p->timers); + + if (pt != NULL && pt->val > 0 && pt->val <= time(NULL)) + return (pt); + return (NULL); +} + time_t timer_nextduein(struct peer *p) { |