From 91de6fa22c2039e5c86c6ae6267070debf0e1dd6 Mon Sep 17 00:00:00 2001 From: sudhanshukumar22 Date: Tue, 3 Nov 2020 21:21:42 -0800 Subject: [PATCH] bgpd: config connect timer is not applied immediately for peers in non-established state. Description: When user is config connect timer, it doesn't reflect immediately. It reflect when next time neighbor is tried to reconnect. Problem Description/Summary : When user is config connect timer, it doesn't reflect The network connection was aborted by the local system.d to reconnect. Fix is to update the connect timer immediately if BGP session is not in establish state. Expected Behavior : If neighbor is not yet established, we should immediately apply the config connect timer to the peer. Signed-off-by: sudhanshukumar22 --- bgpd/bgpd.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 368397d7aa..26e7552f5c 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -5305,9 +5305,14 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect) peer->v_connect = connect; /* Skip peer-group mechanics for regular peers. */ - if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) + if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { + if (peer->status != Established) { + if (peer_active(peer)) + BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer, BGP_Start); + } return 0; - + } /* * Set flag and configuration on all peer-group members, unless they are * explicitely overriding peer-group configuration. @@ -5321,6 +5326,12 @@ int peer_timers_connect_set(struct peer *peer, uint32_t connect) SET_FLAG(member->flags, PEER_FLAG_TIMER_CONNECT); member->connect = connect; member->v_connect = connect; + + if (member->status != Established) { + if (peer_active(member)) + BGP_EVENT_ADD(member, BGP_Stop); + BGP_EVENT_ADD(member, BGP_Start); + } } return 0; @@ -5348,9 +5359,14 @@ int peer_timers_connect_unset(struct peer *peer) peer->v_connect = peer->bgp->default_connect_retry; /* Skip peer-group mechanics for regular peers. */ - if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) + if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { + if (peer->status != Established) { + if (peer_active(peer)) + BGP_EVENT_ADD(peer, BGP_Stop); + BGP_EVENT_ADD(peer, BGP_Start); + } return 0; - + } /* * Remove flag and configuration from all peer-group members, unless * they are explicitely overriding peer-group configuration. @@ -5364,6 +5380,12 @@ int peer_timers_connect_unset(struct peer *peer) UNSET_FLAG(member->flags, PEER_FLAG_TIMER_CONNECT); member->connect = 0; member->v_connect = peer->bgp->default_connect_retry; + + if (member->status != Established) { + if (peer_active(member)) + BGP_EVENT_ADD(member, BGP_Stop); + BGP_EVENT_ADD(member, BGP_Start); + } } return 0; -- 2.39.5