From 42d7fae9aa6311fa5b9afdd28f7dfaea5b8cf73e Mon Sep 17 00:00:00 2001 From: Adam Bishop Date: Mon, 15 Jun 2020 01:29:02 +0100 Subject: [PATCH] Make IPv6 discovery work on JunOS Although JunOS populates ipAddressIfIndex.ipv6, it does not add prefix lengths or other metadata. This means that IPv6 discovery fails. This change removes OIDs from the list when there is incomplete data. If the list is empty after IP-MIB is walked, it then tries IPv6 MIB. It's not a great fix, but I'm not confident I can fix the underlying issue without a complete re-write of this module. --- includes/discovery/ipv6-addresses.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/discovery/ipv6-addresses.inc.php b/includes/discovery/ipv6-addresses.inc.php index e561b3112a..da20d7cb9c 100644 --- a/includes/discovery/ipv6-addresses.inc.php +++ b/includes/discovery/ipv6-addresses.inc.php @@ -41,13 +41,18 @@ foreach ($vrfs_lite_cisco as $vrf) { $ipv6_prefixlen = explode('.', $ipv6_prefixlen); $ipv6_prefixlen = str_replace('"', '', end($ipv6_prefixlen)); + if (Str::contains($ipv6_prefixlen, 'SNMPv2-SMI::zeroDotZero')) { + d_echo('Incomplete IPv6 data in IF-MIB'); + $oids = trim(Str::replaceFirst($data, '', $oids)); + } + $ipv6_origin = snmp_get($device, ".1.3.6.1.2.1.4.34.1.6.2.16.$oid", '-Ovq', 'IP-MIB'); discover_process_ipv6($valid, $ifIndex, $ipv6_address, $ipv6_prefixlen, $ipv6_origin, $device['context_name']); } //end if } //end foreach - if (!$oids) { + if (empty($oids)) { $oids = snmp_walk($device, 'ipv6AddrPfxLength', ['-OsqnU', '-Ln'], 'IPV6-MIB'); $oids = str_replace('.1.3.6.1.2.1.55.1.8.1.2.', '', $oids); $oids = str_replace('"', '', $oids);