Bug in LLDP remote port lookup

Tags: #<Tag:0x00007f064b0864b8> #<Tag:0x00007f064b085d60> #<Tag:0x00007f064b085608>

Sometimes in the neighbours view of a device the remote port column appears to be linked incorrectly (i.e. to a completely different port to the one reported by the device CLI or indeed SNMP itself).

I figure this is because in discovery-protocols.inc.php you are using the lldpRemPortDesc as a key to look up the port in the database, as well as the lldpRemPortId. On most of the switches I have access for testing (Cisco, HP Comware) the lldpRemPortDesc will return the user-defined description/alias for a port if one is set, and the real port name if it is not. This means it has the potential to not be unique on the device or be set to something misleading depending on what the user has configured.

In functions.inc.php find_port_id() you seem to be using this (the description) as the primary first-choice way of looking up a port (rather than preferring the identifier) for some reason, so it is susceptible to returning incorrect port IDs depending on how people have configured their port descriptions, particularly if many ports on the switch have the same description.

If I comment out the if ($description) { ... } block in find_port_id everything starts to behave properly. Perhaps there’s a good reason for doing it the order you have but please have a look and potential revisit of this code.

I confirm bug:
On web

In the DB

xe-4/2/9 and xe10/2/9 have the same description