Skip to content

Commit c25c7e9

Browse files
committed
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 <[email protected]>
1 parent 64112ed commit c25c7e9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

bgpd/bgpd.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -4829,6 +4829,8 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg)
48294829

48304830
/* iterate through peers of BGP instance */
48314831
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
4832+
peer->last_reset = PEER_DOWN_USER_SHUTDOWN;
4833+
48324834
/* continue, if peer is already in administrative shutdown. */
48334835
if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))
48344836
continue;
@@ -4883,8 +4885,10 @@ void bgp_shutdown_disable(struct bgp *bgp)
48834885
/* clear the BGP instances shutdown flag */
48844886
UNSET_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN);
48854887

4886-
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer))
4888+
for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) {
48874889
bgp_timer_set(peer->connection);
4890+
peer->last_reset = PEER_DOWN_WAITING_OPEN;
4891+
}
48884892
}
48894893

48904894
/* Change specified peer flag. */
@@ -4956,6 +4960,10 @@ static int peer_flag_modify(struct peer *peer, uint64_t flag, int set)
49564960
bgp_zebra_terminate_radv(peer->bgp, peer);
49574961
}
49584962

4963+
if (flag == PEER_FLAG_SHUTDOWN)
4964+
peer->last_reset = set ? PEER_DOWN_USER_SHUTDOWN
4965+
: PEER_DOWN_WAITING_OPEN;
4966+
49594967
/* Execute flag action on peer. */
49604968
if (action.type == peer_change_reset)
49614969
peer_flag_modify_action(peer, flag);
@@ -4991,6 +4999,10 @@ static int peer_flag_modify(struct peer *peer, uint64_t flag, int set)
49914999
set ? bgp_zebra_initiate_radv(member->bgp, member)
49925000
: bgp_zebra_terminate_radv(member->bgp, member);
49935001

5002+
if (flag == PEER_FLAG_SHUTDOWN)
5003+
member->last_reset = set ? PEER_DOWN_USER_SHUTDOWN
5004+
: PEER_DOWN_WAITING_OPEN;
5005+
49945006
/* Execute flag action on peer-group member. */
49955007
if (action.type == peer_change_reset)
49965008
peer_flag_modify_action(member, flag);

0 commit comments

Comments
 (0)