Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cisco nxos bgp neighbor defect fix #505

Merged
merged 2 commits into from Oct 25, 2019
Merged

cisco nxos bgp neighbor defect fix #505

merged 2 commits into from Oct 25, 2019

Conversation

nnaukwal
Copy link
Contributor

@nnaukwal nnaukwal commented Oct 23, 2019

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT

cisco_nxos_show_ip_bgp_neighbors.template

SUMMARY

There is a bug in the current template due to which BGP neighbors in the downstate are NOT recorded/templated properly. Also, any neighbor entry following a BGP downstate neighbor entry gets wrongly templated.

Story:
There are 5 BGP neighbors in down state in "cisco_nxos_show_ip_bgp_neighbors.raw"

BGP neighbor is 202.77.85.157,  remote AS 64938, ibgp link,  Peer index 3
  No established BGP session with peer

BGP neighbor is 47.48.246.179,  remote AS 64938, ibgp link,  Peer index 4
  No established BGP session with peer

BGP neighbor is 178.51.35.168,  remote AS 64568, ebgp link,  Peer index 23
  No established BGP session with peer

BGP neighbor is 48.218.155.56,  remote AS 65271, ebgp link,  Peer index 34
  No established BGP session with peer

BGP neighbor is 32.180.174.240,  remote AS 65282, ebgp link,  Peer index 40
  No established BGP session with peer

However, the parsed file only has 4x of them in "cisco_nxos_show_ip_bgp_neighbors.parsed"

$ grep "neighbor:" cisco_nxos_show_ip_bgp_neighbors.parsed | egrep "202.77.85.157|47.48.246.179|178.51.35.168|48.218.155.56|32.180.174.240"
  neighbor: 202.77.85.157
  neighbor: 178.51.35.168
  neighbor: 48.218.155.56
  neighbor: 32.180.174.240
$ 

The neighbor which is missing is 47.48.246.179, and is primarily because of the current ruleset definitions in the "cisco_nxos_show_ip_bgp_neighbors.template".

The template currently sets recording at:

<snip>
  ^\s+Outbound\s+route-map\s+configured\s+is\s+$-OUTBOUND_ROUTEMAP},\s+handle\s+obtained
  ^\s+Last End-of-RIB received [\d:]+ after session start -> AddrFamState
  ^\s+Local host:\s+$-LOCALHOST_IP}, Local port:\s+$-LOCALHOST_PORT}
  ^\s+Foreign host:\s+$-REMOTE_IP}, Foreign port:\s+$-REMOTE_PORT} -> Record Start

Whereas, a neighbor in the downstate does NOT have "End of RIB" and neither does it have local/remote {IP/PORT} lines obviously.

A BGP neighbor in downstate ends at:

BGP neighbor is 202.77.85.157,  remote AS 64938, ibgp link,  Peer index 3
<snip>
  No established BGP session with peer   <<<<

From the list of all down neighbors, why only entry for "neighbor 47.48.246.179" is missing from the ".parsed" file?
It is because the entry for "47.48.246.179" immediately follows the BGP entry for another DOWN neighbor 202.77.85.157. This causes incorrect parsing/recording of the existing bgp neighbor .raw data. It further causes incorrect state transitions for "BGP neighbor 217.90.29.79" which immediately follows the 2x down neighbor entries.

Fix:
The explicit ruleset for catching "No established BGP session with peer" with Record Start entry has been added at the end.

After the change:

grep "neighbor':" /tmp/test | egrep "'202.77.85.157'|'47.48.246.179'|'178.51.35.168'|'48.218.155.56'|'32.180.174.240'"
  'neighbor': '202.77.85.157'
  'neighbor': '47.48.246.179'
  'neighbor': '178.51.35.168'
  'neighbor': '48.218.155.56'
  'neighbor': '32.180.174.240'

All of the down neighbor entries are now parsed OK, along with entries following the downed neighbors.

tox works OK and the parsed output now records Down neighbour state OK.

  py35: commands succeeded
  congratulations :)

@jmcgill298
Copy link
Contributor

I think the right approach will be to actually use Continue and Record on opening line of neighbor. The current method of recording at the end of the neighbor data is prone to improperly record the data as there are unknown last lines, and can always change. I will work on updating and send back to you

Copy link
Contributor

@jmcgill298 jmcgill298 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template should record on each neighbor's opening line, as that is the most consistent line that guarantees a neighbor's data has been completely collected.

Update start to:

 Start
+  ^BGP\s+neighbor\s+is -> Continue.Record
   ^BGP neighbor is ${NEIGHBOR},\s+remote AS\s+${ASN},.*

Update AddrFamCap:

 AddrFamCap
   ^\s+${ADDR_FAM_ADV} -> Start
+  ^BGP\s+neighbor\s+is -> Continue.Record
+  ^BGP\s+neighbor\s+is\s+${NEIGHBOR},\s+remote\s+AS\s+${ASN},.* -> Start

Update AddrFamState:

   ^\s+Local host:\s+${LOCALHOST_IP}, Local port:\s+${LOCALHOST_PORT}
-  ^\s+Foreign host:\s+${REMOTE_IP}, Foreign port:\s+${REMOTE_PORT} -> Record Start
-  ^\s+No\s+established\s+BGP\s+session\s+with\s+peer -> Record Start
-
-EOF
+  ^\s+Foreign host:\s+${REMOTE_IP}, Foreign port:\s+${REMOTE_PORT}
+  ^\s+No\s+established\s+BGP\s+session\s+with\s+peer
+  ^BGP\s+neighbor\s+is -> Continue.Record
+  ^BGP\s+neighbor\s+is\s+${NEIGHBOR},\s+remote\s+AS\s+${ASN},.* -> Start

@jmcgill298 jmcgill298 merged commit 633bc0d into networktocode:master Oct 25, 2019
@jmcgill298
Copy link
Contributor

Thanks @nnaukwal

thomasblass pushed a commit to thomasblass/ntc-templates that referenced this pull request Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants