[openwrt/openwrt] lldpd: add option to force SONMP enabled
LEDE Commits
lede-commits at lists.infradead.org
Thu Feb 8 02:36:03 PST 2024
stintel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/4ac134aa78d2b4441b0afd485d1d26dbd53d7276
commit 4ac134aa78d2b4441b0afd485d1d26dbd53d7276
Author: Stephen Howell <howels at allthatwemight.be>
AuthorDate: Sun Dec 17 00:28:43 2023 +0000
lldpd: add option to force SONMP enabled
add option to force SONMP to be enabled even when no peer detected
Signed-off-by: Stephen Howell <howels at allthatwemight.be>
---
package/network/services/lldpd/Makefile | 3 ++-
package/network/services/lldpd/files/lldpd.init | 24 +++++++++++++++++++++---
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile
index 4dade4a148..02ef2d7520 100644
--- a/package/network/services/lldpd/Makefile
+++ b/package/network/services/lldpd/Makefile
@@ -79,7 +79,8 @@ ifneq ($(CONFIG_LLDPD_WITH_EDP),y)
sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
endif
ifneq ($(CONFIG_LLDPD_WITH_SONMP),y)
- sed -i -e '/sonmp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
+ sed -i -e 's/CONFIG_LLDPD_WITH_SONMP=y/CONFIG_LLDPD_WITH_SONMP=n/g' $(1)/etc/init.d/lldpd
+ sed -i -e '/sonmp/d' $(1)/etc/config/lldpd
endif
ifneq ($(CONFIG_LLDPD_WITH_SNMP),y)
sed -i -e '/agentxsocket/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
index bd90cea85b..8e825e4f87 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -7,6 +7,7 @@ STOP=01
CONFIG_LLDPD_WITH_CDP=y
CONFIG_LLDPD_WITH_FDP=y
CONFIG_LLDPD_WITH_LLDPMED=y
+CONFIG_LLDPD_WITH_SONMP=y
USE_PROCD=1
LLDPDBIN=/usr/sbin/lldpd
@@ -57,7 +58,10 @@ get_config_restart_hash() {
config_get_bool v 'config' 'enable_fdp'; append _string "$v" ","
config_get_bool v 'config' 'force_fdp'; append _string "$v" ","
fi
- config_get_bool v 'config' 'enable_sonmp'; append _string "$v" ","
+ if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ]; then
+ config_get_bool v 'config' 'enable_sonmp'; append _string "$v" ","
+ config_get_bool v 'config' 'force_sonmp'; append _string "$v" ","
+ fi
_hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'`
export -n "$var=$_hash"
@@ -150,6 +154,7 @@ start_service() {
local enable_fdp
local force_fdp
local enable_sonmp
+ local force_sonmp
local enable_edp
local lldp_class
local lldp_location
@@ -172,7 +177,10 @@ start_service() {
config_get_bool enable_fdp 'config' 'enable_fdp' 0
config_get_bool force_fdp 'config' 'force_fdp' 0
fi
- config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
+ if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ]; then
+ config_get_bool enable_sonmp 'config' 'enable_sonmp' 0
+ config_get_bool force_sonmp 'config' 'force_sonmp' 0
+ fi
config_get_bool enable_edp 'config' 'enable_edp' 0
config_get lldp_class 'config' 'lldp_class'
config_get lldp_location 'config' 'lldp_location'
@@ -236,8 +244,18 @@ start_service() {
fi
fi
- [ $enable_sonmp -gt 0 ] && procd_append_param command '-s'
+ if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ] && [ $enable_sonmp -gt 0 ]; then
+ if [ $force_sonmp -gt 0 ]; then
+ # SONMP enabled and forced
+ procd_append_param command '-ss'
+ else
+ # SONMP enabled
+ procd_append_param command '-s'
+ fi
+ fi
+
[ $enable_edp -gt 0 ] && procd_append_param command '-e'
+
[ $readonly_mode -gt 0 ] && procd_append_param command '-r'
[ $lldp_no_version -gt 0 ] && procd_append_param commanpackage/network/services/lldpd/Makefile package/network/services/lldpd/files/lldpd.initd '-k'
[ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i'
More information about the lede-commits
mailing list