diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2024-06-19 14:09:00 +0300 | 
|---|---|---|
| committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-06-24 19:41:59 +0000 | 
| commit | e56a5271eebbe0f8dbd52f4b03ebd8a7e788258d (patch) | |
| tree | d14223f0989c4975f7787cb5c1b602f6bc476b4a /bgpd | |
| parent | de0f0bd30779dd08a4896821053e8622be730826 (diff) | |
bgpd: Set last reset reason to admin shutdown if it was manually
Before this patch, we always printed the last reason "Waiting for OPEN", but
if it's a manual shutdown, then we technically are not waiting for OPEN.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit c25c7e929d550c2faca3af74a29593b8c0b75db3)
Diffstat (limited to 'bgpd')
| -rw-r--r-- | bgpd/bgpd.c | 14 | 
1 files changed, 13 insertions, 1 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index edb20aca58..492092bac4 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -4725,6 +4725,8 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg)  	/* iterate through peers of BGP instance */  	for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { +		peer->last_reset = PEER_DOWN_USER_SHUTDOWN; +  		/* continue, if peer is already in administrative shutdown. */  		if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))  			continue; @@ -4779,8 +4781,10 @@ void bgp_shutdown_disable(struct bgp *bgp)  	/* clear the BGP instances shutdown flag */  	UNSET_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN); -	for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) +	for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {  		bgp_timer_set(peer->connection); +		peer->last_reset = PEER_DOWN_WAITING_OPEN; +	}  }  /* Change specified peer flag. */ @@ -4852,6 +4856,10 @@ static int peer_flag_modify(struct peer *peer, uint64_t flag, int set)  				bgp_zebra_terminate_radv(peer->bgp, peer);  		} +		if (flag == PEER_FLAG_SHUTDOWN) +			peer->last_reset = set ? PEER_DOWN_USER_SHUTDOWN +					       : PEER_DOWN_WAITING_OPEN; +  		/* Execute flag action on peer. */  		if (action.type == peer_change_reset)  			peer_flag_modify_action(peer, flag); @@ -4887,6 +4895,10 @@ static int peer_flag_modify(struct peer *peer, uint64_t flag, int set)  			set ? bgp_zebra_initiate_radv(member->bgp, member)  			    : bgp_zebra_terminate_radv(member->bgp, member); +		if (flag == PEER_FLAG_SHUTDOWN) +			member->last_reset = set ? PEER_DOWN_USER_SHUTDOWN +						 : PEER_DOWN_WAITING_OPEN; +  		/* Execute flag action on peer-group member. */  		if (action.type == peer_change_reset)  			peer_flag_modify_action(member, flag);  | 
