summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Howell2023-12-16 22:41:22 +0000
committerRobert Marko2024-09-17 10:36:02 +0000
commitf79ab96312b04e4641031be2ffe4b82b9a281122 (patch)
tree330d7dbbb84c080b0a8673bafaa7397976fdcfbd
parentb0f991d03cc5fb6bdda412347acd5287968ab107 (diff)
downloadopenwrt-f79ab96312b04e4641031be2ffe4b82b9a281122.tar.gz
lldpd: LLDPD binds to only specified interfaces
Bind to the configured system interfaces only. Switchport interfaces are no longer ignored and uci interface values for LLDPD are honored. Signed-off-by: Stephen Howell <howels@allthatwemight.be> (cherry picked from commit 064b4999ad1f37f4c6ccf95a0404007b990ed0ef) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko <robimarko@gmail.com>
-rw-r--r--package/network/services/lldpd/files/lldpd.init21
1 files changed, 21 insertions, 0 deletions
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
index a52e6e0ec4..411fa0c652 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -33,6 +33,7 @@ get_config_restart_hash() {
config_get v 'config' 'lldp_class'; append _string "$v" ","
config_get v 'config' 'agentxsocket'; append _string "$v" ","
+ config_get v 'config' 'cid_interface'; append _string "$v" ","
config_get_bool v 'config' 'readonly_mode'; append _string "$v" ","
config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" ","
config_get_bool v 'config' 'enable_cdp'; append _string "$v" ","
@@ -44,6 +45,21 @@ get_config_restart_hash() {
export -n "$var=$_hash"
}
+get_config_cid_ifaces() {
+ local _ifaces
+ config_get _ifaces 'config' 'cid_interface'
+
+ local _iface _ifnames=""
+ for _iface in $_ifaces; do
+ local _ifname=""
+ if network_get_device _ifname "$_iface" || [ -e "/sys/class/net/$_iface" ]; then
+ append _ifnames "${_ifname:-$_iface}" ","
+ fi
+ done
+
+ export -n "${1}=$_ifnames"
+}
+
write_lldpd_conf()
{
local lldp_description
@@ -122,6 +138,11 @@ start_service() {
[ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class"
[ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket"
+ # ChassisID interfaces
+ local ifnames
+ get_config_cid_ifaces ifnames
+ [ -n "$ifnames" ] && procd_append_param command -C "$ifnames"
+
# Overwrite default configuration locations processed by lldpcli at start
procd_append_param command -O "$LLDPD_CONF"