From 1201a69664061e5c349b9da5387f2c8d23797692 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:26:21 +0000 Subject: [PATCH] lldpd: add option to force FDP on add option to force FDP when no peers detected Signed-off-by: Stephen Howell (cherry picked from commit 1be2088a5247b2cfabe8be991c1e52ddaf780a16) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 3 ++- .../network/services/lldpd/files/lldpd.init | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index a83378bcba..4dade4a148 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -72,7 +72,8 @@ ifneq ($(CONFIG_LLDPD_WITH_CDP),y) sed -i -e '/cdp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_FDP),y) - sed -i -e '/fdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd + sed -i -e 's/CONFIG_LLDPD_WITH_FDP=y/CONFIG_LLDPD_WITH_FDP=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/fdp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_EDP),y) sed -i -e '/edp/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 faf100b198..bd90cea85b 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -5,6 +5,7 @@ START=90 STOP=01 CONFIG_LLDPD_WITH_CDP=y +CONFIG_LLDPD_WITH_FDP=y CONFIG_LLDPD_WITH_LLDPMED=y USE_PROCD=1 @@ -52,7 +53,10 @@ get_config_restart_hash() { config_get_bool v 'config' 'force_cdpv2'; append _string "$v" "," fi config_get_bool v 'config' 'enable_edp'; append _string "$v" "," - config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then + 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" "," _hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'` @@ -60,8 +64,7 @@ get_config_restart_hash() { } get_config_cid_ifaces() { - local _ifaces - config_get _ifaces 'config' 'cid_interface' + local _ifacesCONFIG_LLDPD_WITH_FDP local _iface _ifnames="" for _iface in $_ifaces; do @@ -145,6 +148,7 @@ start_service() { local force_cdp local force_cdpv2 local enable_fdp + local force_fdp local enable_sonmp local enable_edp local lldp_class @@ -164,7 +168,10 @@ start_service() { config_get_bool force_cdp 'config' 'force_cdp' 0 config_get_bool force_cdpv2 'config' 'force_cdpv2' 0 fi - config_get_bool enable_fdp 'config' 'enable_fdp' 0 + if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then + 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 config_get_bool enable_edp 'config' 'enable_edp' 0 config_get lldp_class 'config' 'lldp_class' @@ -219,7 +226,16 @@ start_service() { fi fi - [ $enable_fdp -gt 0 ] && procd_append_param command '-f' + if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ] && [ $enable_fdp -gt 0 ]; then + if [ $force_fdp -gt 0 ]; then + # FDP enbled and forced + procd_append_param command '-ff' + else + # FDP enabled + procd_append_param command '-f' + fi + fi + [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' [ $enable_edp -gt 0 ] && procd_append_param command '-e' [ $readonly_mode -gt 0 ] && procd_append_param command '-r' @@ -278,6 +294,7 @@ reload_service() { $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF unconfigure med fast-start EOF + fi # Rewrite lldpd.conf # If something changed it should be included by the lldpcli call -- 2.30.2