Skip to content

Commit

Permalink
Merge pull request #5888 from ton31337/fix/do_not_show_failed_if_shut…
Browse files Browse the repository at this point in the history
…down_7.3

bgpd: [7.3] `show bgp summary failed` backports
  • Loading branch information
riw777 committed Mar 3, 2020
2 parents cf95bd4 + 5405288 commit 968d1b2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
9 changes: 8 additions & 1 deletion bgpd/bgp_fsm.c
Expand Up @@ -560,7 +560,10 @@ const char *const peer_down_str[] = {"",
"Waiting for NHT",
"Waiting for Peer IPv6 LLA",
"Waiting for VRF to be initialized",
"No AFI/SAFI activated for peer"};
"No AFI/SAFI activated for peer",
"AS Set config change",
"Waiting for peer OPEN",
"Reached received prefix count"};

static int bgp_graceful_restart_timer_expire(struct thread *thread)
{
Expand Down Expand Up @@ -1429,6 +1432,10 @@ int bgp_start(struct peer *peer)
"%s [FSM] Trying to start suppressed peer"
" - this is never supposed to happen!",
peer->host);
if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))
peer->last_reset = PEER_DOWN_USER_SHUTDOWN;
else if (CHECK_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
peer->last_reset = PEER_DOWN_PFX_COUNT;
return -1;
}

Expand Down
23 changes: 16 additions & 7 deletions bgpd/bgp_nht.c
Expand Up @@ -788,13 +788,22 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
bgp_process(bgp_path, rn, afi, safi);
}

if (peer && !CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED)) {
if (BGP_DEBUG(nht, NHT))
zlog_debug("%s: Updating peer (%s(%s)) status with NHT",
__FUNCTION__, peer->host,
peer->bgp->name_pretty);
bgp_fsm_event_update(peer, bgp_isvalid_nexthop(bnc));
SET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
if (peer) {
int valid_nexthops = bgp_isvalid_nexthop(bnc);

if (valid_nexthops)
peer->last_reset = PEER_DOWN_WAITING_OPEN;
else
peer->last_reset = PEER_DOWN_WAITING_NHT;

if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED)) {
if (BGP_DEBUG(nht, NHT))
zlog_debug("%s: Updating peer (%s(%s)) status with NHT",
__FUNCTION__, peer->host,
peer->bgp->name_pretty);
bgp_fsm_event_update(peer, valid_nexthops);
SET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED);
}
}

RESET_FLAG(bnc->change_flags);
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_vty.c
Expand Up @@ -8063,7 +8063,7 @@ static void bgp_show_peer_reset(struct vty * vty, struct peer *peer,
: "received",
code_str, subcode_str);
} else {
vty_out(vty, " %s\n",
vty_out(vty, " %s\n",
peer_down_str[(int)peer->last_reset]);
}
}
Expand Down Expand Up @@ -8119,7 +8119,7 @@ static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp,
if (len < max_neighbor_width)
vty_out(vty, "%*s", max_neighbor_width - len,
" ");
vty_out(vty, "%7d %7d %8s", peer->established,
vty_out(vty, "%7d %7d %9s", peer->established,
peer->dropped,
peer_uptime(peer->uptime, timebuf,
BGP_UPTIME_LEN, 0, NULL));
Expand Down
13 changes: 10 additions & 3 deletions bgpd/bgpd.h
Expand Up @@ -1185,10 +1185,10 @@ struct peer {
#define PEER_DOWN_REMOTE_AS_CHANGE 2 /* neighbor remote-as command */
#define PEER_DOWN_LOCAL_AS_CHANGE 3 /* neighbor local-as command */
#define PEER_DOWN_CLID_CHANGE 4 /* bgp cluster-id command */
#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation identifier command */
#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation id command */
#define PEER_DOWN_CONFED_PEER_CHANGE 6 /* bgp confederation peer command */
#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor route-reflector-client command */
#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor route-server-client command */
#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor rr-client command */
#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor rs-client command */
#define PEER_DOWN_UPDATE_SOURCE_CHANGE 9 /* neighbor update-source command */
#define PEER_DOWN_AF_ACTIVATE 10 /* neighbor activate command */
#define PEER_DOWN_USER_SHUTDOWN 11 /* neighbor shutdown command */
Expand All @@ -1212,6 +1212,13 @@ struct peer {
#define PEER_DOWN_VRF_UNINIT 29 /* Associated VRF is not init yet */
#define PEER_DOWN_NOAFI_ACTIVATED 30 /* No AFI/SAFI activated for peer */
#define PEER_DOWN_AS_SETS_REJECT 31 /* Reject routes with AS_SET */
#define PEER_DOWN_WAITING_OPEN 32 /* Waiting for open to succeed */
#define PEER_DOWN_PFX_COUNT 33 /* Reached received prefix count */
/*
* Remember to update peer_down_str in bgp_fsm.c when you add
* a new value to the last_reset reason
*/

size_t last_reset_cause_size;
uint8_t last_reset_cause[BGP_MAX_PACKET_SIZE];

Expand Down

0 comments on commit 968d1b2

Please sign in to comment.