From 47d273e8832472e1944a8f92392018a2e3e9a67c Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 26 Mar 2024 12:45:29 +0000 Subject: [PATCH] Move the SendHoldTimer code into start_timer_sendholdtime() and ensure the timer is stopped if HoldTime is 0. OK tb@ --- usr.sbin/bgpd/session.c | 22 +++++++++++++++++----- 1 file 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 @@ -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); @@ -835,6 +836,20 @@ start_timer_holdtime(struct peer *peer) timer_stop(&peer->timers, Timer_Hold); } +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) { @@ -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"); -- 2.20.1