From 7dbb2e42b82d5d8ea42e69c73cf3ab7db19c0ea3 Mon Sep 17 00:00:00 2001 From: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com> Date: Fri, 26 Mar 2021 22:36:42 +0100 Subject: [PATCH] Huawei VRF BGP_Peers update (#12585) * Mib update * Fix update of peer + add PeerDescription * tests * force tests rerun --- includes/discovery/bgp-peers/vrp.inc.php | 30 ++- mibs/huawei/HUAWEI-BGP-VPN-MIB | 230 ++++++++++++++++++++-- tests/data/vrp_ce12804-withvrf.json | 4 +- tests/snmpsim/vrp_ce12804-withvrf.snmprec | 1 + 4 files changed, 242 insertions(+), 23 deletions(-) diff --git a/includes/discovery/bgp-peers/vrp.inc.php b/includes/discovery/bgp-peers/vrp.inc.php index d9056bd223..6d4f720bd7 100644 --- a/includes/discovery/bgp-peers/vrp.inc.php +++ b/includes/discovery/bgp-peers/vrp.inc.php @@ -27,7 +27,7 @@ use LibreNMS\Config; use LibreNMS\Util\IP; if (Config::get('enable_bgp')) { - $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeers', [], 'HUAWEI-BGP-VPN-MIB'); + $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerRemoteAs', [], 'HUAWEI-BGP-VPN-MIB'); if (count($bgpPeersCache) == 0) { //Either we have no BGP peer, or this VRP device does not support Huawei's own BGP MIB @@ -42,7 +42,14 @@ if (Config::get('enable_bgp')) { $map_vrf['byId'][$vrf['vrf_id']]['vrf_name'] = $vrf['vrf_name']; $map_vrf['byName'][$vrf['vrf_name']]['vrf_id'] = $vrf['vrf_id']; } - $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeers', [], 'HUAWEI-BGP-VPN-MIB'); + + $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerAddrFamilyTable', $bgpPeersCache, 'HUAWEI-BGP-VPN-MIB'); + $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerTable', $bgpPeersCache, 'HUAWEI-BGP-VPN-MIB'); + $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerRouteTable', $bgpPeersCache, 'HUAWEI-BGP-VPN-MIB'); + $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerSessionTable', $bgpPeersCache, 'HUAWEI-BGP-VPN-MIB'); + + $bgpPeersDesc = snmpwalk_cache_oid($device, 'hwBgpPeerSessionExtDescription', [], 'HUAWEI-BGP-VPN-MIB'); + foreach ($bgpPeersCache as $key => $value) { $oid = explode('.', $key); $vrfInstance = $value['hwBgpPeerVrfName']; @@ -50,10 +57,12 @@ if (Config::get('enable_bgp')) { $vrfInstance = ''; $value['hwBgpPeerVrfName'] = ''; } - $address = str_replace($oid[0] . '.' . $oid[1] . '.' . $oid[2] . '.' . $oid[3] . '.', '', $key); - if ($oid[3] == 'ipv6') { - $address = IP::fromHexString($address)->compressed(); - } elseif ($oid[3] != 'ipv4') { + $oid_address = str_replace($oid[0] . '.' . $oid[1] . '.' . $oid[2] . '.' . $oid[3] . '.', '', $key); + if ($oid[3] == 'ipv4') { + $address = $oid_address; + } elseif ($oid[3] == 'ipv6') { + $address = IP::fromHexString($oid_address)->compressed(); + } else { // we have a malformed OID reply, let's skip it continue; } @@ -63,6 +72,10 @@ if (Config::get('enable_bgp')) { $bgpPeers[$vrfInstance][$address]['afi'] = $oid[1]; $bgpPeers[$vrfInstance][$address]['safi'] = $oid[2]; $bgpPeers[$vrfInstance][$address]['typePeer'] = $oid[3]; + if (array_key_exists('0.' . $oid[3] . '.' . $oid_address, $bgpPeersDesc)) { + // We may have a description + $bgpPeers[$vrfInstance][$address]['bgpPeerDescr'] = $bgpPeersDesc['0.' . $oid[3] . '.' . $oid_address]['hwBgpPeerSessionExtDescription']; + } } foreach ($bgpPeers as $vrfName => $vrf) { @@ -90,6 +103,7 @@ if (Config::get('enable_bgp')) { 'bgpPeerOutTotalMessages' => 0, 'bgpPeerFsmEstablishedTime' => $value['hwBgpPeerFsmEstablishedTime'], 'bgpPeerInUpdateElapsedTime' => 0, + 'bgpPeerDescr' => $value['bgpPeerDescr'], 'astext' => $astext, ]; if (empty($vrfId)) { @@ -105,7 +119,7 @@ if (Config::get('enable_bgp')) { echo '+'; $vrp_bgp_peer_count++; } else { - dbUpdate(['bgpPeerRemoteAs' => $value['hwBgpPeerRemoteAs'], 'astext' => $astext], 'bgpPeers', 'device_id = ? AND bgpPeerIdentifier = ? AND vrf_id = ?', [$device['device_id'], $address, $vrfId]); + dbUpdate(['bgpPeerDescr' => $value['bgpPeerDescr'], 'bgpPeerRemoteAs' => $value['hwBgpPeerRemoteAs'], 'astext' => $astext], 'bgpPeers', 'device_id = ? AND bgpPeerIdentifier = ? ' . $checkVrf, [$device['device_id'], $address, $vrfId]); $seenPeer[$address] = 1; echo '.'; $vrp_bgp_peer_count++; @@ -162,7 +176,7 @@ if (Config::get('enable_bgp')) { unset($bgpPeersCache); unset($bgpPeers); if ($vrp_bgp_peer_count > 0) { - return; //Finish BGP discovery here, cause we collected data + return; //Finish BGP discovery here, cause we already collected data with Huawei MIBs } } // If not, we continue with standard BGP4 MIB diff --git a/mibs/huawei/HUAWEI-BGP-VPN-MIB b/mibs/huawei/HUAWEI-BGP-VPN-MIB index 8203742f7e..9598916bf4 100644 --- a/mibs/huawei/HUAWEI-BGP-VPN-MIB +++ b/mibs/huawei/HUAWEI-BGP-VPN-MIB @@ -1,10 +1,10 @@ -- ============================================================================ --- Copyright (C) 2018 by HUAWEI TECHNOLOGIES. All rights reserved. +-- Copyright (C) 2020 by HUAWEI TECHNOLOGIES. All rights reserved. -- -- Description: HUAWEI-BGP-VPN-MIB , this Mib module for management -- of BGP/VPN protocol. -- Reference: This MIB was extracted from RFC 4271 --- Version: V2.22 +-- Version: V2.28 -- History: -- , <2008-12-28>, -- , <2009-09-14>, @@ -33,7 +33,7 @@ -- Jan 19, 2015 at 15:02 GMT hwBgpMIB MODULE-IDENTITY - LAST-UPDATED "201805241100Z" -- May 24, 2018 at 1100 GMT + LAST-UPDATED "202007221200Z" -- Apr 13, 2020 at 1200 GMT ORGANIZATION "Huawei Technologies Co.,Ltd." CONTACT-INFO @@ -49,6 +49,30 @@ "The Mib module for management of BGP/VPN. Huawei Technologies co.,Ltd. Supplementary information may be available at: http://www.huawei.com" + + REVISION "202007221200Z" + DESCRIPTION + "Modify description of MIB nodes, include:hwOsNodeTable." + + REVISION "202004131200Z" + DESCRIPTION + "Modify description of MIB nodes, include: hwBgpPeerAddrFamilyPerRouteThresholdExceed, hwBgpPeerAddrFamilyPerRouteThresholdExceedClear, hwBgpPeerAddrFamilyPerRouteExceed, hwBgpPeerAddrFamilyPerRouteExceedClear, hwBgpRouteType." + + REVISION "201912251200Z" + DESCRIPTION + "Modify one MIB table for description, include: 'hwBgpProcessName'." + + REVISION "201912231200Z" + DESCRIPTION + "Modify description of MIB nodes, include: hwBgpPeerAddrFamilyRouteThresholdExceed, hwBgpPeerAddrFamilyRouteThresholdExceedClear, hwBgpPeerAddrFamilyRouteExceed, hwBgpPeerAddrFamilyRouteExceedClear." + + REVISION "201912201610Z" + DESCRIPTION + "Modify one MIB table for description, include: 'hwBgpVrfAddressFamily','hwBgpRouteMaxNum','hwBgpRouteThreshold'." + + REVISION "201903151025Z" + DESCRIPTION + "Modify one MIB table for description, include: 'hwBgpLabelLimitTable','hwVpnRouteLabelNumReachThresold','hwVpnRouteLabelNumReachMaximum'." REVISION "201805241100Z" DESCRIPTION @@ -1193,13 +1217,13 @@ STATUS current DESCRIPTION "The index of bgp route limit, including: - 1.ipv4(1): total ipv4 routes number. - 2.ipv6(2): total ipv6 routes number. - 3.ipv4vrf(3): ipv4 vrf routes number. - 4.ipv6vrf(4): ipv6 vrf routes number. - 5.ipv4public(5): ipv4 public routes number. - 6.ipv6public(6): ipv6 public routes number. - 7.l2ad(7): l2ad routes number." + 1. ipv4(1): total ipv4 routes number. + 2. ipv6(2): total ipv6 routes number. + 3. ipv4vrf(3): ipv4 vrf routes number. + 4. ipv6vrf(4): ipv6 vrf routes number. + 5. ipv4public(5): ipv4 public routes number. + 6. ipv6public(6): ipv6 public routes number. + 7. l2ad(7): l2ad routes number." ::= { hwBgpRouteLimitTable 1 } -- 1.3.6.1.4.1.2011.5.25.177.1.2.1.2 @@ -1228,7 +1252,15 @@ DESCRIPTION "The threshold number of bgp routes." ::= { hwBgpRouteLimitTable 4 } - + + -- 1.3.6.1.4.1.2011.5.25.177.1.2.1.5 + hwBgpRouteType OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (0..64)) + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Route type." + ::= { hwBgpRouteLimitTable 5 } -- 1.3.6.1.4.1.2011.5.25.177.1.2.2 hwBgpVrfRouteTable OBJECT-TYPE @@ -1375,6 +1407,45 @@ "Address family." ::= { hwEvpnRouteEntry 4 } + -- 1.3.6.1.4.1.2011.5.25.177.1.2.4 + hwBgpLabelLimitTable OBJECT IDENTIFIER ::= { hwBgpRoute 4 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.2.4.1 + hwBgpAddrFamilyAfi OBJECT-TYPE + SYNTAX HWBgpAfi + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "The address family of BGP." + ::= { hwBgpLabelLimitTable 1 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.2.4.2 + hwBgpAddrFamilySafi OBJECT-TYPE + SYNTAX HWBgpSafi + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "The sub-address family of BGP." + ::= { hwBgpLabelLimitTable 2 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.2.4.3 + hwBgpLabelMaxValue OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "The maximum number of BGP labels." + ::= { hwBgpLabelLimitTable 3 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.2.4.4 + hwBgpLabelLimitThreshold OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "The threshold number of BGP labels." + ::= { hwBgpLabelLimitTable 4 } + -- 1.3.6.1.4.1.2011.5.25.177.1.3 hwBgpTraps OBJECT IDENTIFIER ::= { hwBgpObjects 3 } @@ -1579,6 +1650,102 @@ "The number of routes fell below the clear alarm threshold." ::= { hwBgpTraps 24 } + -- 1.3.6.1.4.1.2011.5.25.177.1.3.25 + hwVpnRouteLabelNumReachThresold NOTIFICATION-TYPE + OBJECTS { hwBgpAddrFamilyAfi, hwBgpAddrFamilySafi, hwBgpLabelMaxValue, hwBgpLabelLimitThreshold } + STATUS current + DESCRIPTION + "The number of VPN route labels reached the alarm threshould." + ::= { hwBgpTraps 25 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.26 + hwVpnRouteLabelNumReachThresoldClear NOTIFICATION-TYPE + OBJECTS { hwBgpAddrFamilyAfi, hwBgpAddrFamilySafi, hwBgpLabelMaxValue, hwBgpLabelLimitThreshold } + STATUS current + DESCRIPTION + "The number of VPN route labels fell below the clear alarm threshold." + ::= { hwBgpTraps 26 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.27 + hwVpnRouteLabelNumReachMaximum NOTIFICATION-TYPE + OBJECTS { hwBgpAddrFamilyAfi, hwBgpAddrFamilySafi, hwBgpLabelMaxValue } + STATUS current + DESCRIPTION + "The number of VPN route labels reached the maximum value." + ::= { hwBgpTraps 27 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.28 + hwVpnRouteLabelNumReachMaximumClear NOTIFICATION-TYPE + OBJECTS { hwBgpAddrFamilyAfi, hwBgpAddrFamilySafi, hwBgpLabelMaxValue } + STATUS current + DESCRIPTION + "The number of VPN route labels fell below the maximum value." + ::= { hwBgpTraps 28 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.29 + hwBgpPeerAddrFamilyRouteThresholdExceed NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteMaxNum, hwBgpRouteThreshold, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of routes received from peers in a BGP address family reached the alarm threshold." + ::= { hwBgpTraps 29 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.30 + hwBgpPeerAddrFamilyRouteThresholdExceedClear NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteMaxNum, hwBgpRouteThreshold, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of routes received from peers in a BGP address family fell below the alarm threshold." + ::= { hwBgpTraps 30 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.31 + hwBgpPeerAddrFamilyRouteExceed NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteMaxNum, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of routes received from peers in a BGP address family reached the maximum value." + ::= { hwBgpTraps 31 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.32 + hwBgpPeerAddrFamilyRouteExceedClear NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteMaxNum, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of routes received from peers in a BGP address family fell below the maximum value." + ::= { hwBgpTraps 32 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.33 + hwBgpPeerAddrFamilyPerRouteThresholdExceed NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteType, hwBgpRouteMaxNum, hwBgpRouteThreshold, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of specified routes received from peers in a BGP address family reached the alarm threshold." + ::= { hwBgpTraps 33 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.34 + hwBgpPeerAddrFamilyPerRouteThresholdExceedClear NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteType, hwBgpRouteMaxNum, hwBgpRouteThreshold, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of specified routes received from peers in a BGP address family fell below the alarm threshold." + ::= { hwBgpTraps 34 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.35 + hwBgpPeerAddrFamilyPerRouteExceed NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteType, hwBgpRouteMaxNum, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of specified routes received from peers in a BGP address family reached the maximum value." + ::= { hwBgpTraps 35 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.3.36 + hwBgpPeerAddrFamilyPerRouteExceedClear NOTIFICATION-TYPE + OBJECTS { hwBgpVrfAddressFamily, hwBgpRouteType, hwBgpRouteMaxNum, hwBgpProcessName } + STATUS current + DESCRIPTION + "The number of specified routes received from peers in a BGP address family fell below the maximum value." + ::= { hwBgpTraps 36 } + -- 1.3.6.1.4.1.2011.5.25.177.1.4 hwBgpScalars OBJECT IDENTIFIER ::= { hwBgpObjects 4 } @@ -1663,6 +1830,43 @@ "The total number of Update packets sent to all the remote BGP peers." ::= { hwBgpScalars 9 } + -- 1.3.6.1.4.1.2011.5.25.177.1.5 + hwBgpProcess OBJECT IDENTIFIER ::= { hwBgpObjects 5 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.5.1 + hwBgpProcessCommTable OBJECT-TYPE + SYNTAX SEQUENCE OF HwBgpProcessCommEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "BGP process table." + ::= { hwBgpProcess 1 } + + -- 1.3.6.1.4.1.2011.5.25.177.1.5.1.1 + hwBgpProcessCommEntry OBJECT-TYPE + SYNTAX HwBgpProcessCommEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "BGP process entry." + INDEX { hwBgpProcessName } + ::= { hwBgpProcessCommTable 1 } + + HwBgpProcessCommEntry ::= + SEQUENCE { + hwBgpProcessName + OCTET STRING + } + + -- 1.3.6.1.4.1.2011.5.25.177.1.5.1.1.1 + hwBgpProcessName OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (1..31)) + MAX-ACCESS accessible-for-notify + STATUS current + DESCRIPTION + "Name of a BGP instance." + ::= { hwBgpProcessCommEntry 1 } + -- 1.3.6.1.4.1.2011.5.25.177.2 hwBgpVpnObjects OBJECT IDENTIFIER ::= { hwBgpMIB 2 } @@ -2216,7 +2420,7 @@ MAX-ACCESS not-accessible STATUS current DESCRIPTION - "Table contains some statistic information entries orgnized by os-node." + "Table contains some statistic information entries organized by os-node." ::= { hwPeerDistributeObjects 2 } hwOsNodeEntry OBJECT-TYPE @@ -2267,7 +2471,7 @@ MAX-ACCESS not-accessible STATUS current DESCRIPTION - "Table contains some information entries orgnized by distribute-instance." + "Table contains some information entries organized by distribute-instance." ::= { hwPeerDistributeObjects 3 } hwDistributeEntry OBJECT-TYPE diff --git a/tests/data/vrp_ce12804-withvrf.json b/tests/data/vrp_ce12804-withvrf.json index 4852a1de03..06a8c50e09 100644 --- a/tests/data/vrp_ce12804-withvrf.json +++ b/tests/data/vrp_ce12804-withvrf.json @@ -24882,7 +24882,7 @@ "bgpPeerLastErrorText": null, "bgpLocalAddr": "0.0.0.0", "bgpPeerRemoteAddr": "192.168.189.96", - "bgpPeerDescr": "", + "bgpPeerDescr" : "PeerDesc1", "bgpPeerInUpdates": 0, "bgpPeerOutUpdates": 0, "bgpPeerInTotalMessages": 0, @@ -24934,7 +24934,7 @@ "bgpPeerLastErrorText": null, "bgpLocalAddr": "0.0.0.0", "bgpPeerRemoteAddr": "192.168.189.96", - "bgpPeerDescr": "", + "bgpPeerDescr": "PeerDesc1", "bgpPeerInUpdates": 0, "bgpPeerOutUpdates": 0, "bgpPeerInTotalMessages": 0, diff --git a/tests/snmpsim/vrp_ce12804-withvrf.snmprec b/tests/snmpsim/vrp_ce12804-withvrf.snmprec index 7ca7a83b0e..7c17382a79 100644 --- a/tests/snmpsim/vrp_ce12804-withvrf.snmprec +++ b/tests/snmpsim/vrp_ce12804-withvrf.snmprec @@ -3705,4 +3705,5 @@ 1.3.6.1.4.1.2011.5.25.177.1.1.2.1.7.32.1.1.1.4.192.168.189.96|66|2078608 1.3.6.1.4.1.2011.5.25.177.1.1.2.1.9.32.1.1.1.4.192.168.189.96|4x|0202 1.3.6.1.4.1.2011.5.25.177.1.1.2.1.10.32.1.1.1.4.192.168.189.96|66|0 +1.3.6.1.4.1.2011.5.25.177.1.1.8.1.11.0.1.4.192.168.189.96|4|PeerDesc1 1.3.6.1.6.3.10.2.1.3.0|2|601981