Repository: napalm-automation/napalm

Issue:
get_bgp_neighbors() fails when there are Peers with same IP on different VRFs, works fine if they are unique.
### Description of Issue/Question

*Note*: Please check https://guides.github.com/features/mastering-markdown/
to see how to properly format your request.

### Did you follow the steps from https://github.com/napalm-automation/napalm#faq
(Place an ``x`` between the square brackets where applicable)

- [``x``] Yes
- [] No


### Setup

### napalm version
(Paste verbatim output from `pip freeze | grep napalm` between quotes below)

```
napalm==3.3.1
```

### Network operating system version
(Paste verbatim output from `show version` - or equivalent - between quotes below)

```
IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.6(2)T, RELEASE SOFTWARE (fc2)
```

### Steps to Reproduce the Issue
**get_bgp_neighbors() fails when there are Peers with same IP on different VRFs, works fine if they are unique**

Config :
            R-2#sh run | s r b
            router bgp 200
             bgp log-neighbor-changes
             neighbor 12.12.12.1 remote-as 100
             !
             address-family vpnv4
             exit-address-family
             !
             address-family ipv4 vrf **VRF-1**
             **_neighbor 20.20.20.1 remote-as 100_**
              neighbor 20.20.20.1 timers 10 30
              neighbor 20.20.20.1 activate
              neighbor 30.30.30.1 remote-as 100
              neighbor 30.30.30.1 timers 10 30
              neighbor 30.30.30.1 activate
             exit-address-family
             !
             address-family ipv4 vrf **VRF-2**
              **_neighbor 20.20.20.1 remote-as 100_**
              neighbor 20.20.20.1 timers 10 30
              neighbor 20.20.20.1 activate
             exit-address-family
            R-2#

CLI BGP O/P (shortened):
            R-2#sh ip bgp all summ
            For address family: IPv4 Unicast
            ==omitted==
            
            Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
            12.12.12.1      4        100      48      50        2    0    0 00:07:25        1
            
            For address family: VPNv4 Unicast
            ==omitted==
            
            Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
            20.20.20.1      4        100       0       0        1    0    0 never    Idle
            20.20.20.1      4        100      49      51        3    0    0 00:07:22        1
            30.30.30.1      4        100      50      51        3    0    0 00:07:23        1
            R-2#

### Error Traceback
(Paste the complete traceback of the exception between quotes below)

```
Traceback (most recent call last):
  File "c:\Users\User\Documents\Python\test2.py", line 10, in <module>
    BGP = device.get_bgp_neighbors()
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\napalm\ios\ios.py", line 1903, in get_bgp_neighbors
    assert afi not in existing["address_family"]
AssertionError
```



Discussion:

Resolving patch:
diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py
--- a/napalm/ios/ios.py
+++ b/napalm/ios/ios.py
@@ -1957,12 +1957,17 @@ def get_bgp_neighbors(self):
             # get neighbor_entry out of neighbor data
             neighbor_entry = None
             for neighbor in neighbor_data:
-                if (
-                    neighbor["afi"].lower() == afi
-                    and napalm.base.helpers.ip(neighbor["remote_addr"]) == remote_addr
-                ):
-                    neighbor_entry = neighbor
-                    break
+                current_neighbor = napalm.base.helpers.ip(neighbor["remote_addr"])
+                if neighbor["afi"].lower() == afi and current_neighbor == remote_addr:
+                    # Neighbor IPs in VRFs can overlap, so make sure
+                    # we haven't covered this VRF + IP already
+                    vrf = neighbor["vrf"] or "global"
+                    if (
+                        vrf == "global"
+                        or current_neighbor not in bgp_neighbor_data[vrf]["peers"]
+                    ):
+                        neighbor_entry = neighbor
+                        break
             # check for proper session data for the afi
             if neighbor_entry is None:
                 continue


Test patch: