diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 0f9741322f..a709c406c9 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -30,7 +30,18 @@ if (! empty($peers)) { } else { $peer_data_check = snmpwalk_cache_oid($device, 'bgpPeerRemoteAs', [], 'BGP4-MIB'); } - if (empty($peer_data_check)) { + // If a Cisco device has BGP peers in VRF(s), but no BGP peers in + // the default VRF: don't fall back to the default MIB, to avoid + // skipping IPv6 peers (CISCO-BGP4-MIB is required.) + // count(getVrfContexts) returns VRF's with a configured SNMP context + // e.g. snmp-server context context_name vrf vrf_name + // "> 0" because the default VRF is only included in the count, + // if it has a switch configured SNMP context. + // The issues occured on NX-OS (Nexus) and IOS-XR (ASR) devices. + // Using os_group 'cisco' breaks the 3560g snmpsim tests. + $vrf_contexts = DeviceCache::getPrimary()->getVrfContexts(); + $cisco_with_vrf = (($device['os'] == 'iosxr' || $device['os'] == 'nxos') && ! empty($vrf_contexts[0])); + if (empty($peer_data_check) && ! $cisco_with_vrf) { $peer_data_check = snmpwalk_cache_oid($device, 'bgpPeerRemoteAs', [], 'BGP4-MIB'); $generic = true; } @@ -53,7 +64,7 @@ if (! empty($peers)) { // cbgpPeer2RemoteAs, resulting in empty $peer_data_check. // Without the or clause, we won't see the VRF BGP peers. // ($peer_data_check isn't used in the Cisco code path,) - if (count($peer_data_check) > 0 || ($device['os_group'] == 'cisco' && count(DeviceCache::getPrimary()->getVrfContexts()) > 1)) { + if (count($peer_data_check) > 0 || $cisco_with_vrf) { if ($generic) { echo "\nfallback to default mib";