mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Workaround bad lldp that supplies ifAlias instead of ifDescr for lldpRemPortDesc (#8666)
This commit is contained in:
committed by
Neil Lathwood
parent
9401e43eb9
commit
fea3c77916
@@ -1392,12 +1392,12 @@ function find_device_id($name = '', $ip = '', $mac_address = '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to find a port by ifDescr, ifName, or MAC
|
||||
* Try to find a port by ifDescr, ifName, ifAlias, or MAC
|
||||
*
|
||||
* @param string $description matched against ifDescr and ifName
|
||||
* @param string $identifier matched against ifDescr and ifName
|
||||
* @param string $description matched against ifDescr, ifName, and ifAlias
|
||||
* @param string $identifier matched against ifDescr, ifName, and ifAlias
|
||||
* @param int $device_id restrict search to ports on a specific device
|
||||
* @param string $mac_address check against ifPysAddress (should be in lowercase hexadecimal)
|
||||
* @param string $mac_address check against ifPhysAddress (should be in lowercase hexadecimal)
|
||||
* @return int
|
||||
*/
|
||||
function find_port_id($description, $identifier = '', $device_id = 0, $mac_address = null)
|
||||
@@ -1411,11 +1411,16 @@ function find_port_id($description, $identifier = '', $device_id = 0, $mac_addre
|
||||
|
||||
if ($device_id) {
|
||||
if ($description) {
|
||||
// order is important here, the standard says this is ifDescr, which some mfg confuse with ifName
|
||||
$statements[] = "SELECT `port_id` FROM `ports` WHERE `device_id`=? AND (`ifDescr`=? OR `ifName`=?)";
|
||||
|
||||
$params[] = $device_id;
|
||||
$params[] = $description;
|
||||
$params[] = $description;
|
||||
|
||||
// we check ifAlias last because this is a user editable field, but some bad LLDP implementations use it
|
||||
$statements[] = "SELECT `port_id` FROM `ports` WHERE `device_id`=? AND `ifAlias`=?";
|
||||
$params[] = $device_id;
|
||||
$params[] = $description;
|
||||
}
|
||||
|
||||
if ($identifier) {
|
||||
|
Reference in New Issue
Block a user