napalm-automation / napalm

Network Automation and Programmability Abstraction Layer with Multivendor support
Apache License 2.0
2.24k stars 552 forks source link

get_bgp_neighbors returns incorrect local-as for NXOS #1964

Open mkurjanski opened 1 year ago

mkurjanski commented 1 year ago

Description of Issue/Question

get_bgp_neighbors for NXOS returns global local-as setting rather than the per-session local-as

Looking at the internals of napalm it uses 'show bgp all summary vrf all' in the NXOS driver for gt_bgp_neighbors. This command only returns the global ASN for the BGP router. It does not return the actual local-as for each BGP peering session. You'd need to combine the data from 'show running-config bgp' output in order to return the correct local-as for each individual BGP session.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

(Place an x between the square brackets where applicable)

Setup

napalm version

(Paste verbatim output from pip freeze | grep napalm between quotes below)

$ pip freeze | grep napalm
napalm==3.4.1
napalm-ansible==1.1.0
napalm-base==1.0.1

Network operating system version

(Paste verbatim output from show version - or equivalent - between quotes below)

Software
 BIOS: version 5.6.0
 NXOS: version 9.3(10)

Steps to Reproduce the Issue

lab-nxos# show bgp all summary vrf all
BGP summary information for VRF default, address family IPv4 Unicast
BGP router identifier 172.26.156.34, local AS number 65115.7000
BGP table version is 499, IPv4 Unicast config peers 2, capable peers 1
3 network entries and 3 paths using 732 bytes of memory
BGP attribute entries [2/344], BGP AS path entries [1/10]
BGP community entries [1/36], BGP clusterlist entries [0/0]

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
11.11.11.1      4 65001    2932    2889      499    0    0 00:48:42 2 

lab-nxos# sh run bgp 

!Command: show running-config bgp
!Running configuration last done at: Tue Jun 13 16:50:39 2023
!Time: Wed Jun 14 09:25:54 2023

version 9.3(10) Bios:version 5.6.0 
feature bgp

router bgp 65115.7000
  router-id <redacted>
  address-family ipv4 unicast
  neighbor 11.11.11.1
    remote-as 65001
    local-as 12345
    description test_descr
    address-family ipv4 unicast
mkurjanski commented 1 year ago

Actually I just noticed that 'show ip bgp neighbors vrf all' returns local AS for eBGP neighbors so it could be used for more accurate information.

# show ip bgp neighbors vrf all
BGP neighbor is 11.11.11.1, remote AS 65001, local AS 12345, ebgp link, Peer index 5
  Description: test_descr
  BGP version 4, remote router ID 1.1.1.2
  Neighbor previous state = OpenConfirm
  BGP state = Established, up for 02:54:10
  Neighbor vrf: default
  ...