Skip to content

Commit

Permalink
BUG FIX: cisco_ios_show_ip_bgp unable to parse routes (#340)
Browse files Browse the repository at this point in the history
OS Version 16.6.4 has an additional space after the route status codes. This fix allows for additional space character.

New test files were added with the additional output format
  • Loading branch information
paneu authored and jmcgill298 committed Jan 20, 2019
1 parent 6a47417 commit 31346af
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 3 deletions.
6 changes: 3 additions & 3 deletions templates/cisco_ios_show_ip_bgp.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Bgp_table
#
# Match if subnet is 17,18 characters long, creates two lines
# Example: *>i 10.104.192.208/29
^\s{0,1}${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s{0,1}(?=${NETWORK}).{17,18}$$ -> Next
^\s{0,1}${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s{0,2}(?=${NETWORK}).{17,18}$$ -> Next
#
#
# Compliment to previous, status, path_selection, route_source, network is filldown.
Expand All @@ -28,12 +28,12 @@ Bgp_table
#
# Match first when there is no network, since previous line had it already (compliment and filldown below)
# Example: * i172.16.1.0/24 172.16.1.2 0 100 0 i
^\s{0,1}${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s{0,1}\s{16}\s(?=${NEXT_HOP}).{19}\s(?=\s{0,6}${METRIC}).{6}\s(?=\s{0,6}${LOCAL_PREF}).{6}\s(?=\s{0,6}${WEIGHT}).{6}\s*${AS_PATH}\s*${ORIGIN}$$ -> Record
^\s{0,1}${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s{0,2}\s{16}\s(?=${NEXT_HOP}).{19}\s(?=\s{0,6}${METRIC}).{6}\s(?=\s{0,6}${LOCAL_PREF}).{6}\s(?=\s{0,6}${WEIGHT}).{6}\s*${AS_PATH}\s*${ORIGIN}$$ -> Record
#
#
# Full normal example. metric, and as_path might not exist, regex defaults to blank line.
# Example: *> 0.0.0.0 0 32768 i
^\s{0,1}${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s{0,1}(?=${NETWORK}).{16}\s(?=${NEXT_HOP}).{19}\s(?=\s{0,6}${METRIC}).{6}\s(?=\s{0,6}${LOCAL_PREF}).{6}\s(?=\s{0,6}${WEIGHT}).{6}\s*${AS_PATH}\s*${ORIGIN}$$ -> Record
^\s{0,1}${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s{0,2}(?=${NETWORK}).{16}\s(?=${NEXT_HOP}).{19}\s(?=\s{0,6}${METRIC}).{6}\s(?=\s{0,6}${LOCAL_PREF}).{6}\s(?=\s{0,6}${WEIGHT}).{6}\s*${AS_PATH}\s*${ORIGIN}$$ -> Record


EOF
82 changes: 82 additions & 0 deletions tests/cisco_ios/show_ip_bgp/cisco_ios_show_ip_bgp5.parsed
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
parsed_sample:
- as_path: ''
local_pref: ''
metric: '0'
network: 10.1.0.0/16
next_hop: 0.0.0.0
origin: 'i'
path_selection: '>'
route_source: ' '
status: '*'
weight: '32768'
- as_path: ''
local_pref: ''
metric: '0'
network: 10.2.0.0/16
next_hop: 0.0.0.0
origin: 'i'
path_selection: '>'
route_source: ' '
status: '*'
weight: '32768'
- as_path: ''
local_pref: ''
metric: '0'
network: 10.3.0.0/16
next_hop: 0.0.0.0
origin: 'i'
path_selection: '>'
route_source: ' '
status: '*'
weight: '32768'
- as_path: ''
local_pref: ''
metric: '0'
network: 10.4.0.0/16
next_hop: 0.0.0.0
origin: 'i'
path_selection: '>'
route_source: ' '
status: '*'
weight: '32768'
- as_path: ''
local_pref: '100'
metric: '0'
network: 10.11.0.0/16
next_hop: 10.0.0.1
origin: 'i'
path_selection: '>'
route_source: 'i'
status: '*'
weight: '0'
- as_path: ''
local_pref: '100'
metric: '0'
network: 10.12.0.0/16
next_hop: 10.0.0.1
origin: 'i'
path_selection: '>'
route_source: 'i'
status: '*'
weight: '0'
- as_path: ''
local_pref: '100'
metric: '0'
network: 10.13.0.0/16
next_hop: 10.0.0.1
origin: 'i'
path_selection: '>'
route_source: 'i'
status: '*'
weight: '0'
- as_path: ''
local_pref: '100'
metric: '0'
network: 10.14.0.0/16
next_hop: 10.0.0.1
origin: 'i'
path_selection: '>'
route_source: 'i'
status: '*'
weight: '0'
17 changes: 17 additions & 0 deletions tests/cisco_ios/show_ip_bgp/cisco_ios_show_ip_bgp5.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BGP table version is 17, local router ID is 10.0.0.0
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
t secondary path,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

Network Next Hop Metric LocPrf Weight Path
*> 10.1.0.0/16 0.0.0.0 0 32768 i
*> 10.2.0.0/16 0.0.0.0 0 32768 i
*> 10.3.0.0/16 0.0.0.0 0 32768 i
*> 10.4.0.0/16 0.0.0.0 0 32768 i
*>i 10.11.0.0/16 10.0.0.1 0 100 0 i
*>i 10.12.0.0/16 10.0.0.1 0 100 0 i
*>i 10.13.0.0/16 10.0.0.1 0 100 0 i
*>i 10.14.0.0/16 10.0.0.1 0 100 0 i

0 comments on commit 31346af

Please sign in to comment.