Skip to content

Commit

Permalink
Merge pull request FRRouting#16275 from FRRouting/mergify/bp/stable/1…
Browse files Browse the repository at this point in the history
…0.0/pr-16242

bgpd: Set last reset reason to admin shutdown if it was manually (backport FRRouting#16242)
  • Loading branch information
Jafaral authored Jun 25, 2024
2 parents 15da768 + 95ceebd commit 812556c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 2 additions & 3 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -11439,10 +11439,9 @@ static void bgp_show_peer_reset(struct vty * vty, struct peer *peer,
BGP_NOTIFY_CEASE_HARD_RESET)
: "");
} else {
vty_out(vty, " %s (%s)\n",
vty_out(vty, " %s (%s)\n",
peer_down_str[(int)peer->last_reset],
peer->soft_version ? peer->soft_version
: "n/a");
peer->soft_version ? peer->soft_version : "n/a");
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4758,6 +4758,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;
Expand Down Expand Up @@ -4812,8 +4814,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. */
Expand Down Expand Up @@ -4885,6 +4889,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);
Expand Down Expand Up @@ -4920,6 +4928,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);
Expand Down

0 comments on commit 812556c

Please sign in to comment.