You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

218 lines
8.1 KiB

From 2b5eda4c0539dcd30a06c975be36f879cc454e9f Mon Sep 17 00:00:00 2001
From: Donald Sharp <sharpd@cumulusnetworks.com>
Date: Mon, 10 Feb 2020 19:25:52 -0500
Subject: [PATCH 1/3] bgpd: Update failed reason to distinguish some NHT
scenarios
Current failed reasons for bgp when you have a peer that
is not online yet is `Waiting for NHT`, even if NHT has
succeeded. Add some code to differentiate this.
eva# show bgp ipv4 uni summ failed
BGP router identifier 192.168.201.135, local AS number 3923 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 2, using 43 KiB of memory
Neighbor EstdCnt DropCnt ResetTime Reason
192.168.44.1 0 0 never Waiting for NHT
192.168.201.139 0 0 never Waiting for Open to Succeed
Total number of neighbors 2
eva#
eva# show bgp nexthop
Current BGP nexthop cache:
192.168.44.1 invalid, peer 192.168.44.1
Must be Connected
Last update: Mon Feb 10 19:05:19 2020
192.168.201.139 valid [IGP metric 0], #paths 0, peer 192.168.201.139
So 192.168.201.139 is a peer for a connected route that has not been
created on .139, while 44.1 nexthop tracking has not succeeded yet.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
---
bgpd/bgp_fsm.c | 4 +++-
bgpd/bgp_nht.c | 23 ++++++++++++++++-------
bgpd/bgpd.h | 12 +++++++++---
3 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 3667dae83d..107e9fc892 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -560,7 +560,9 @@ 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"};
static int bgp_graceful_restart_timer_expire(struct thread *thread)
{
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index a50fc7d697..e9496e47a9 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -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);
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 7d81579009..66d7633553 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -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 */
@@ -1212,6 +1212,12 @@ 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 */
+ /*
+ * 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];
From 4098f79949dd0e1e4ed7b89df8dc9b2be81fa9d6 Mon Sep 17 00:00:00 2001
From: Donatas Abraitis <donatas.abraitis@gmail.com>
Date: Fri, 14 Feb 2020 23:21:55 +0200
Subject: [PATCH 2/3] bgpd: Show the real reason why the peer is failed
If the peer was shutdown locally, it doesn't show up as admin. shutdown.
Instead it's treated as "Waiting for peer OPEN".
The same applies to when the peer reaches maximum-prefix count.
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
---
bgpd/bgp_fsm.c | 7 ++++++-
bgpd/bgpd.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 107e9fc892..c920c4e501 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -562,7 +562,8 @@ const char *const peer_down_str[] = {"",
"Waiting for VRF to be initialized",
"No AFI/SAFI activated for peer",
"AS Set config change",
- "Waiting for peer OPEN"};
+ "Waiting for peer OPEN",
+ "Reached received prefix count"};
static int bgp_graceful_restart_timer_expire(struct thread *thread)
{
@@ -1431,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;
}
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 66d7633553..49e2a537fd 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1213,6 +1213,7 @@ struct peer {
#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
From 540528864d85a3b00e0794da769497ecfb8e0c27 Mon Sep 17 00:00:00 2001
From: Donatas Abraitis <donatas.abraitis@gmail.com>
Date: Tue, 11 Feb 2020 18:02:19 +0200
Subject: [PATCH 3/3] bgpd: Format properly `show bgp summary failed`
Before:
```
Neighbor EstdCnt DropCnt ResetTime Reason
192.168.0.1 0 0 never Waiting for peer OPEN
```
After:
```
Neighbor EstdCnt DropCnt ResetTime Reason
192.168.0.1 0 0 never Waiting for peer OPEN
```
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
---
bgpd/bgp_vty.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 53d9732956..243822206c 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -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]);
}
}
@@ -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));