lldpd: add option to force FDP on

add option to force FDP when no peers detected

Signed-off-by: Stephen Howell <howels@allthatwemight.be>
This commit is contained in:
Stephen Howell 2023-12-17 00:26:21 +00:00 committed by Stijn Tintel
parent b67182008f
commit 1be2088a52
2 changed files with 24 additions and 6 deletions

View File

@ -72,7 +72,8 @@ ifneq ($(CONFIG_LLDPD_WITH_CDP),y)
sed -i -e '/cdp/d' $(1)/etc/config/lldpd sed -i -e '/cdp/d' $(1)/etc/config/lldpd
endif endif
ifneq ($(CONFIG_LLDPD_WITH_FDP),y) 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 endif
ifneq ($(CONFIG_LLDPD_WITH_EDP),y) ifneq ($(CONFIG_LLDPD_WITH_EDP),y)
sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd

View File

@ -5,6 +5,7 @@ START=90
STOP=01 STOP=01
CONFIG_LLDPD_WITH_CDP=y CONFIG_LLDPD_WITH_CDP=y
CONFIG_LLDPD_WITH_FDP=y
CONFIG_LLDPD_WITH_LLDPMED=y CONFIG_LLDPD_WITH_LLDPMED=y
USE_PROCD=1 USE_PROCD=1
@ -52,7 +53,10 @@ get_config_restart_hash() {
config_get_bool v 'config' 'force_cdpv2'; append _string "$v" "," config_get_bool v 'config' 'force_cdpv2'; append _string "$v" ","
fi fi
config_get_bool v 'config' 'enable_edp'; append _string "$v" "," config_get_bool v 'config' 'enable_edp'; 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' '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" "," config_get_bool v 'config' 'enable_sonmp'; append _string "$v" ","
_hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'` _hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'`
@ -60,8 +64,7 @@ get_config_restart_hash() {
} }
get_config_cid_ifaces() { get_config_cid_ifaces() {
local _ifaces local _ifacesCONFIG_LLDPD_WITH_FDP
config_get _ifaces 'config' 'cid_interface'
local _iface _ifnames="" local _iface _ifnames=""
for _iface in $_ifaces; do for _iface in $_ifaces; do
@ -145,6 +148,7 @@ start_service() {
local force_cdp local force_cdp
local force_cdpv2 local force_cdpv2
local enable_fdp local enable_fdp
local force_fdp
local enable_sonmp local enable_sonmp
local enable_edp local enable_edp
local lldp_class local lldp_class
@ -164,7 +168,10 @@ start_service() {
config_get_bool force_cdp 'config' 'force_cdp' 0 config_get_bool force_cdp 'config' 'force_cdp' 0
config_get_bool force_cdpv2 'config' 'force_cdpv2' 0 config_get_bool force_cdpv2 'config' 'force_cdpv2' 0
fi fi
if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then
config_get_bool enable_fdp 'config' 'enable_fdp' 0 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_sonmp 'config' 'enable_sonmp' 0
config_get_bool enable_edp 'config' 'enable_edp' 0 config_get_bool enable_edp 'config' 'enable_edp' 0
config_get lldp_class 'config' 'lldp_class' config_get lldp_class 'config' 'lldp_class'
@ -219,7 +226,16 @@ start_service() {
fi fi
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_sonmp -gt 0 ] && procd_append_param command '-s'
[ $enable_edp -gt 0 ] && procd_append_param command '-e' [ $enable_edp -gt 0 ] && procd_append_param command '-e'
[ $readonly_mode -gt 0 ] && procd_append_param command '-r' [ $readonly_mode -gt 0 ] && procd_append_param command '-r'
@ -278,6 +294,7 @@ reload_service() {
$LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF
unconfigure med fast-start unconfigure med fast-start
EOF EOF
fi fi
# Rewrite lldpd.conf # Rewrite lldpd.conf
# If something changed it should be included by the lldpcli call # If something changed it should be included by the lldpcli call