From 6f32f76cd05fb8ecfd3371f1dbebc64635f6d0c2 Mon Sep 17 00:00:00 2001 From: Viktor G Date: Fri, 15 May 2020 18:14:14 +0300 Subject: [PATCH] LLDPd integrated switch workaround. Issue #9635 --- net-mgmt/pfSense-pkg-lldpd/Makefile | 2 +- .../files/usr/local/pkg/lldpd/lldpd.inc | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/net-mgmt/pfSense-pkg-lldpd/Makefile b/net-mgmt/pfSense-pkg-lldpd/Makefile index 4ec1eda3b3a0..8534849092cc 100644 --- a/net-mgmt/pfSense-pkg-lldpd/Makefile +++ b/net-mgmt/pfSense-pkg-lldpd/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ PORTNAME= pfSense-pkg-lldpd -PORTVERSION= 0.9.10 +PORTVERSION= 0.9.11 CATEGORIES= net-mgmt MASTER_SITES= # empty DISTFILES= # empty diff --git a/net-mgmt/pfSense-pkg-lldpd/files/usr/local/pkg/lldpd/lldpd.inc b/net-mgmt/pfSense-pkg-lldpd/files/usr/local/pkg/lldpd/lldpd.inc index 09d353e7ac78..6f9092251cb1 100644 --- a/net-mgmt/pfSense-pkg-lldpd/files/usr/local/pkg/lldpd/lldpd.inc +++ b/net-mgmt/pfSense-pkg-lldpd/files/usr/local/pkg/lldpd/lldpd.inc @@ -120,11 +120,24 @@ function lldpd_sync_config() { /* Interface list */ $interfaces = array(); + $int_switch = array(); + if (file_exists("/etc/inc/switch.inc")) { + require_once('switch.inc'); + if (!empty(switch_get_devices())) { + $int_switch = switch_get_uplink_ports(); + } + } foreach (explode(',', $lldpd_config['interfaces']) as $i) { foreach (get_parent_physical_interface($i) as $p) { - $interfaces[$p] = $p; + if (!empty($int_switch) && in_array($p, $int_switch)) { + $int = get_real_interface($i); + $interfaces[$int] = $int; + } else { + $interfaces[$p] = $p; + } } } + $interfaces = array_unique($interfaces); if (count($interfaces)) { $cmd .= ' -I ' . escapeshellarg(implode(',', $interfaces)); } @@ -134,7 +147,11 @@ function lldpd_sync_config() { $cmd .= ' -r'; } else { /* Chassis interface */ - $chassis = implode(',', get_parent_physical_interface($lldpd_config['chassis'])); + $chassis_int = get_parent_physical_interface($lldpd_config['chassis']); + if (!empty($int_switch) && empty(array_diff($int_switch, $chassis_int))) { + $chassis_int = array(get_real_interface($lldpd_config['chassis'])); + } + $chassis = implode(',', $chassis_int); if (isset($chassis)) { $cmd .= ' -C ' . escapeshellarg($chassis); }