lldpd: add option to force SONMP enabled
authorStephen Howell <howels@allthatwemight.be>
Sun, 17 Dec 2023 00:28:43 +0000 (00:28 +0000)
committerStijn Tintel <stijn@linux-ipv6.be>
Thu, 8 Feb 2024 10:35:36 +0000 (12:35 +0200)
add option to force SONMP to be enabled even when no peer detected

Signed-off-by: Stephen Howell <howels@allthatwemight.be>
package/network/services/lldpd/Makefile
package/network/services/lldpd/files/lldpd.init

index 4dade4a14817cb7502a00f09f2d84dbdece0b4b9..02ef2d7520aa6607a8c5b0ec82313b48de31a2fd 100644 (file)
@@ -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
index bd90cea85b221713deada77720e6e8d40d1a6a8a..8e825e4f879ff9b44f29175feff4cf70de12e949 100644 (file)
@@ -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'