Skip to content

Commit d0874d1

Browse files
committed
bgpd: Allow extending peer timeout in rare case
Currently the I/O pthread handles incoming/outgoing data communication with all peers. There is no attempt at modifying the hold timers. It's sole goal is to read/write data to appropriate channels. All this data is handled as *events* on the master pthread in BGP. The problem is that if the master pthread is extremely busy then any packet read that would be treated as a keepalive event may happen after the hold timer pops, due to the way thread events are handled in lib/thread.c. In a last gap attempt, if we notice that we have incoming data to proceses on the input Queue, slightly delay the hold timer. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
1 parent 1a5fc72 commit d0874d1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

bgpd/bgp_fsm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ static int bgp_connect_timer(struct thread *thread)
512512
/* BGP holdtime timer. */
513513
static int bgp_holdtime_timer(struct thread *thread)
514514
{
515+
atomic_size_t inq_count;
515516
struct peer *peer;
516517

517518
peer = THREAD_ARG(thread);
@@ -521,6 +522,25 @@ static int bgp_holdtime_timer(struct thread *thread)
521522
zlog_debug("%s [FSM] Timer (holdtime timer expire)",
522523
peer->host);
523524

525+
/*
526+
* Given that we do not have any expectation of ordering
527+
* for handling packets from a peer -vs- handling
528+
* the hold timer for a peer as that they are both
529+
* events on the peer. If we have incoming
530+
* data on the peers inq, let's give the system a chance
531+
* to handle that data. This can be especially true
532+
* for systems where we are heavily loaded for one
533+
* reason or another.
534+
*/
535+
inq_count = atomic_load_explicit(&peer->ibuf->count,
536+
memory_order_relaxed);
537+
if (inq_count) {
538+
BGP_TIMER_ON(peer->t_holdtime, bgp_holdtime_timer,
539+
peer->v_holdtime);
540+
541+
return 0;
542+
}
543+
524544
THREAD_VAL(thread) = Hold_Timer_expired;
525545
bgp_event(thread); /* bgp_event unlocks peer */
526546

0 commit comments

Comments
 (0)