diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-03-26 12:45:30 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-03-26 12:45:30 +0000 |
commit | 3acd094c5f02532540b2103e2ecc0fda21f18b2f (patch) | |
tree | 6b29989715e49193eee12c6bc28b790bc2dd7f0e /usr.sbin/bgpd/session.c | |
parent | 2a09182ea48ff83a61b744236f6323dbff068c64 (diff) |
Move the SendHoldTimer code into start_timer_sendholdtime() and ensure
the timer is stopped if HoldTime is 0.
OK tb@
Diffstat (limited to 'usr.sbin/bgpd/session.c')
-rw-r--r-- | usr.sbin/bgpd/session.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index da3d0311c2b..a5ce338080f 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.466 2024/03/22 15:41:34 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.467 2024/03/26 12:45:29 claudio Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -58,6 +58,7 @@ void session_sighdlr(int); int setup_listeners(u_int *); void init_peer(struct peer *); void start_timer_holdtime(struct peer *); +void start_timer_sendholdtime(struct peer *); void start_timer_keepalive(struct peer *); void session_close_connection(struct peer *); void change_state(struct peer *, enum session_state, enum session_events); @@ -836,6 +837,20 @@ start_timer_holdtime(struct peer *peer) } void +start_timer_sendholdtime(struct peer *peer) +{ + uint16_t holdtime = INTERVAL_HOLD; + + if (peer->holdtime > INTERVAL_HOLD) + holdtime = peer->holdtime; + + if (peer->holdtime > 0) + timer_set(&peer->timers, Timer_SendHold, holdtime); + else + timer_stop(&peer->timers, Timer_SendHold); +} + +void start_timer_keepalive(struct peer *peer) { if (peer->holdtime > 0) @@ -1929,10 +1944,7 @@ session_dispatch_msg(struct pollfd *pfd, struct peer *p) return (1); } p->stats.last_write = getmonotime(); - if (p->holdtime > 0) - timer_set(&p->timers, Timer_SendHold, - p->holdtime < INTERVAL_HOLD ? INTERVAL_HOLD : - p->holdtime); + start_timer_sendholdtime(p); if (p->throttled && p->wbuf.queued < SESS_MSG_LOW_MARK) { if (imsg_rde(IMSG_XON, p->conf.id, NULL, 0) == -1) log_peer_warn(&p->conf, "imsg_compose XON"); |